diff --git "a/languages/c/validation.jsonl" "b/languages/c/validation.jsonl" new file mode 100644--- /dev/null +++ "b/languages/c/validation.jsonl" @@ -0,0 +1,1000 @@ +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s622951782", "group_id": "codeNet:p00005", "input_text": "#include\nint main(){\n int a,b,ans1=0,ans2=0,i;\n scanf(\"%d %d\",&a,&b);\n if(a0;i--){\n if((a%i==0) && (b%i==0)){\n ans1=i;\n break;\n }\n }\n i=a;\n while(1){\n if((i%a==0) && (i%b==0)){\n ans2=i;\n break;\n }\n i++;\n }\n printf(\"%d %d\\n\",ans1,ans2);\n return(0);\n}", "language": "C", "metadata": {"date": 1431335491, "filename_ext": "c", "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/s622951782.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s622951782", "user_id": "u522516700"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "#include\nint main(){\n int a,b,ans1=0,ans2=0,i;\n scanf(\"%d %d\",&a,&b);\n if(a0;i--){\n if((a%i==0) && (b%i==0)){\n ans1=i;\n break;\n }\n }\n i=a;\n while(1){\n if((i%a==0) && (i%b==0)){\n ans2=i;\n break;\n }\n i++;\n }\n printf(\"%d %d\\n\",ans1,ans2);\n return(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 10, "memory_kb": 592}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s913424688", "group_id": "codeNet:p00005", "input_text": "#include \n\nint main(void)\n{\n\tlong long int a, b, i, GCD, LCM;\n\twhile (scanf(\"%d %d\", &a, &b) != -1){\n\t\tLCM = b;\n\t\twhile (LCM % a != 0){\n\t\t\tLCM = LCM + b;\n\t\t}\n\t\ti = 2;\n\t\twhile ((a % GCD != 0)||(b % GCD != 0)){\n\t\t\tGCD = a / i;\n\t\t\ti++;\n\t\t}\n\tprintf(\"%ld %ld\\n\", GCD, LCM);\n\t}\n\treturn 0;\n}", "language": "C", "metadata": {"date": 1447650136, "filename_ext": "c", "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/s913424688.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s913424688", "user_id": "u851803750"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "#include \n\nint main(void)\n{\n\tlong long int a, b, i, GCD, LCM;\n\twhile (scanf(\"%d %d\", &a, &b) != -1){\n\t\tLCM = b;\n\t\twhile (LCM % a != 0){\n\t\t\tLCM = LCM + b;\n\t\t}\n\t\ti = 2;\n\t\twhile ((a % GCD != 0)||(b % GCD != 0)){\n\t\t\tGCD = a / i;\n\t\t\ti++;\n\t\t}\n\tprintf(\"%ld %ld\\n\", GCD, LCM);\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 293, "cpu_time_ms": 20000, "memory_kb": 548}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s076661803", "group_id": "codeNet:p00005", "input_text": "#include \n\nint main(void){\n long a,b,i=2;\n while(scanf(\"%ld %ld \",&a,&b)!=EOF){\n i=a;\n while(1){\n if(a%i==0&&b%i==0) break;\n i--;\n }\n printf(\"%ld %ld\\n\",i,a*b/i);\n }\n return 0;\n}", "language": "C", "metadata": {"date": 1353044682, "filename_ext": "c", "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/s076661803.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s076661803", "user_id": "u955423223"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "#include \n\nint main(void){\n long a,b,i=2;\n while(scanf(\"%ld %ld \",&a,&b)!=EOF){\n i=a;\n while(1){\n if(a%i==0&&b%i==0) break;\n i--;\n }\n printf(\"%ld %ld\\n\",i,a*b/i);\n }\n return 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 5130, "memory_kb": 600}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s169826088", "group_id": "codeNet:p00009", "input_text": "#include\n\nint Isprime(int n);\n\nint main(){\nint n,i,cnt,times;\ntimes=0;\nwhile((scanf(\"\\n%d\",&n)!=EOF)||(times<30)){\n cnt=0;\n for(i=1;i<=n;i++){\n cnt+=Isprime(i);\n }\n printf(\"%d\\n\",cnt);\n times++;\n}\nreturn 0;\n}\n\n\nint Isprime(int n){\nint i,isp;\nisp=1;\nif(n==1){\n isp=0;\n}\nfor(i=2;i\n\nint Isprime(int n);\n\nint main(){\nint n,i,cnt,times;\ntimes=0;\nwhile((scanf(\"\\n%d\",&n)!=EOF)||(times<30)){\n cnt=0;\n for(i=1;i<=n;i++){\n cnt+=Isprime(i);\n }\n printf(\"%d\\n\",cnt);\n times++;\n}\nreturn 0;\n}\n\n\nint Isprime(int n){\nint i,isp;\nisp=1;\nif(n==1){\n isp=0;\n}\nfor(i=2;i\n\n#define NUM 30\n\nint main()\n{ \n int i,j;\n int fig[NUM];\n int pnum = 0;\n int countv = 0;\n int countpn = 0;\n char str[100000];\n \n while(fgets(str,sizeof(str),stdin) != NULL){\n \n if(countv > NUM){\n break;\n }\n\n sscanf(str,\"%d\",&pnum);\n \n for(i=2;i<=pnum;i++){\n for(j=2;j<=i;j++){\n if(i%j==0){\n break;\n }\n }\n if(i==j){\n countpn++;\n }\n }\n fig[countv++] = countpn;\n countpn = 0;\n }\n \n for(i=0;i\n\n#define NUM 30\n\nint main()\n{ \n int i,j;\n int fig[NUM];\n int pnum = 0;\n int countv = 0;\n int countpn = 0;\n char str[100000];\n \n while(fgets(str,sizeof(str),stdin) != NULL){\n \n if(countv > NUM){\n break;\n }\n\n sscanf(str,\"%d\",&pnum);\n \n for(i=2;i<=pnum;i++){\n for(j=2;j<=i;j++){\n if(i%j==0){\n break;\n }\n }\n if(i==j){\n countpn++;\n }\n }\n fig[countv++] = countpn;\n countpn = 0;\n }\n \n for(i=0;i\nmain(){\n int n,i,j;\n while(scanf(\"%d\",&n) !=EOF){\n int c=0,jud;\n if(n>=2) c++;\n for(i=3;i<=n;i+=2){\n jud=1;\n if(i!=3&&i%3==0) continue;\n if(i!=5&&i%5==0) continue;\n if(i!=7&&i%7==0) continue;\n if(i!=11&&i%11==0) continue;\n if(i!=13&&i%13==0) continue;\n if(i!=17&&i%17==0) continue;\n if(i!=19&&i%19==0) continue;\n for(j=2;j*j<=i;j++){\n\tif(i%j==0){\n\t jud=0;\n\t break;\n\t}\n }\n if(jud==1) c++;\n }\n printf(\"%d\\n\",c);\n }\n return 0; \n}", "language": "C", "metadata": {"date": 1274341118, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00009/input.txt", "sample_output_relpath": "derived/input_output/data/p00009/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00009/C/s078605411.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s078605411", "user_id": "u915493477"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "#include \nmain(){\n int n,i,j;\n while(scanf(\"%d\",&n) !=EOF){\n int c=0,jud;\n if(n>=2) c++;\n for(i=3;i<=n;i+=2){\n jud=1;\n if(i!=3&&i%3==0) continue;\n if(i!=5&&i%5==0) continue;\n if(i!=7&&i%7==0) continue;\n if(i!=11&&i%11==0) continue;\n if(i!=13&&i%13==0) continue;\n if(i!=17&&i%17==0) continue;\n if(i!=19&&i%19==0) continue;\n for(j=2;j*j<=i;j++){\n\tif(i%j==0){\n\t jud=0;\n\t break;\n\t}\n }\n if(jud==1) c++;\n }\n printf(\"%d\\n\",c);\n }\n return 0; \n}", "problem_context": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "sample_input": "10\n3\n11\n"}, "reference_outputs": ["4\n2\n5\n"], "source_document_id": "p00009", "source_text": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 521, "cpu_time_ms": 3290, "memory_kb": 408}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s191679778", "group_id": "codeNet:p00009", "input_text": "#include \n#include \n\n\nint n,i,j,sqrtn,sum,flag;\nchar number[1000000];\n\nint hantei(int x){\n\tif (number[x]==1){\n\t\treturn 0;\n\t}\n\tsqrtn=(int)sqrt(x);\n\tflag=0;\n\tfor(j=1;j*6-1=3){\n\t\t\tsum=2;\n\t\t}else if (n==2){\n\t\t\tsum=1;\n\t\t}else{\n\t\t\tsum=0;\n\t\t}\n\t\tfor(i=6;i-1<=n;i+=6){\n\t\t\thantei(i-1);\n\t\t\tif(i+1<=n)hantei(i+1);\n\t\t}\n\t\tprintf(\"%d\\n\",sum);\n\t\t\n\t}\n\treturn 0;\n}", "language": "C", "metadata": {"date": 1301564644, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00009/input.txt", "sample_output_relpath": "derived/input_output/data/p00009/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00009/C/s191679778.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s191679778", "user_id": "u775414834"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "#include \n#include \n\n\nint n,i,j,sqrtn,sum,flag;\nchar number[1000000];\n\nint hantei(int x){\n\tif (number[x]==1){\n\t\treturn 0;\n\t}\n\tsqrtn=(int)sqrt(x);\n\tflag=0;\n\tfor(j=1;j*6-1=3){\n\t\t\tsum=2;\n\t\t}else if (n==2){\n\t\t\tsum=1;\n\t\t}else{\n\t\t\tsum=0;\n\t\t}\n\t\tfor(i=6;i-1<=n;i+=6){\n\t\t\thantei(i-1);\n\t\t\tif(i+1<=n)hantei(i+1);\n\t\t}\n\t\tprintf(\"%d\\n\",sum);\n\t\t\n\t}\n\treturn 0;\n}", "problem_context": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "sample_input": "10\n3\n11\n"}, "reference_outputs": ["4\n2\n5\n"], "source_document_id": "p00009", "source_text": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 741, "cpu_time_ms": 890, "memory_kb": 1380}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s093829133", "group_id": "codeNet:p00009", "input_text": "#include \n#define N 1000000\n \nint main(void){\n int p[N];\n int i,j,n;\n \n p[0]=0; p[1]=0; p[2]=1;\n for( i=3;i\n#define N 1000000\n \nint main(void){\n int p[N];\n int i,j,n;\n \n p[0]=0; p[1]=0; p[2]=1;\n for( i=3;i\n#include \n\nint main() {\n\tint n, i, alen, blen, carry, out[80];\n\tchar a[80], b[80];\n\t\n\tscanf(\"%d\", &n);\n\twhile (n--) {\n\t\tscanf(\"%s\", a);\n\t\tscanf(\"%s\", b);\n\t\talen = strlen(a);\n\t\tblen = strlen(b);\n\t\tif (alen > 80 || blen > 80){\n\t\t\tprintf(\"overflow\\n\");\n\t\t\tcontinue;\n\t\t}\n\t\ti = carry = 0;\n\t\twhile (alen || blen) {\n\t\t\tout[i] = carry;\n\t\t\tif (alen) out[i] += a[--alen] - '0';\n\t\t\tif (blen) out[i] += b[--blen] - '0';\n\t\t\tcarry = out[i] / 10;\n\t\t\tout[i++] %= 10;\n\t\t}\n\t\tif (carry) out[i] = 1;\n\t\telse i--;\n\t\tif (i >= 80) {\n\t\t\tprintf(\"overflow\\n\");\n\t\t\tcontinue;\n\t\t}\n\t\tfor (; i >= 0; i--)\n\t\t\tprintf(\"%d\", out[i]);\n\t\tprintf(\"\\n\");\n\t}\n\treturn 0;\n}", "language": "C", "metadata": {"date": 1406035985, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00015.html", "problem_id": "p00015", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00015/input.txt", "sample_output_relpath": "derived/input_output/data/p00015/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00015/C/s207668488.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s207668488", "user_id": "u464852834"}, "prompt_components": {"gold_output": "1800\n10000000000000000000000000000000000000000\noverflow\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\noverflow\noverflow\n", "input_to_evaluate": "#include \n#include \n\nint main() {\n\tint n, i, alen, blen, carry, out[80];\n\tchar a[80], b[80];\n\t\n\tscanf(\"%d\", &n);\n\twhile (n--) {\n\t\tscanf(\"%s\", a);\n\t\tscanf(\"%s\", b);\n\t\talen = strlen(a);\n\t\tblen = strlen(b);\n\t\tif (alen > 80 || blen > 80){\n\t\t\tprintf(\"overflow\\n\");\n\t\t\tcontinue;\n\t\t}\n\t\ti = carry = 0;\n\t\twhile (alen || blen) {\n\t\t\tout[i] = carry;\n\t\t\tif (alen) out[i] += a[--alen] - '0';\n\t\t\tif (blen) out[i] += b[--blen] - '0';\n\t\t\tcarry = out[i] / 10;\n\t\t\tout[i++] %= 10;\n\t\t}\n\t\tif (carry) out[i] = 1;\n\t\telse i--;\n\t\tif (i >= 80) {\n\t\t\tprintf(\"overflow\\n\");\n\t\t\tcontinue;\n\t\t}\n\t\tfor (; i >= 0; i--)\n\t\t\tprintf(\"%d\", out[i]);\n\t\tprintf(\"\\n\");\n\t}\n\treturn 0;\n}", "problem_context": "National Budget\n\nA country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.\n\nYour task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.\n\nIf given integers or the sum have more than 80 digits, print \"overflow\".\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets N (1 ≤ N ≤ 50) is given. Each dataset consists of 2 lines:\n\nThe first integer\nThe second integer\n\nThe integer has at most 100 digits.\n\nOutput\n\nFor each dataset, print the sum of given integers in a line.\n\nSample Input\n\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n\nOutput for the Sample Input\n\n1800\n10000000000000000000000000000000000000000\noverflow\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\noverflow\noverflow", "sample_input": "6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n"}, "reference_outputs": ["1800\n10000000000000000000000000000000000000000\noverflow\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\noverflow\noverflow\n"], "source_document_id": "p00015", "source_text": "National Budget\n\nA country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.\n\nYour task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.\n\nIf given integers or the sum have more than 80 digits, print \"overflow\".\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets N (1 ≤ N ≤ 50) is given. Each dataset consists of 2 lines:\n\nThe first integer\nThe second integer\n\nThe integer has at most 100 digits.\n\nOutput\n\nFor each dataset, print the sum of given integers in a line.\n\nSample Input\n\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n\nOutput for the Sample Input\n\n1800\n10000000000000000000000000000000000000000\noverflow\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\noverflow\noverflow", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 658, "cpu_time_ms": 20000, "memory_kb": 608}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s892939901", "group_id": "codeNet:p00098", "input_text": "/*\n Aizu Vol-0 0098: Maximum Sum Sequence II \n 2017.8.15 bal4u@uu\n ????????????????????§???\n*/\n\n#include \n\n#define MAX 100\n\nint a[MAX + 5][MAX + 5], N;\nint s[MAX + 5][MAX + 5];\n\nint main()\n{\n\tint r, c, r2, c2, k, max;\n\n\tscanf(\"%d\", &N);\n\tfor (r = 1; r <= N; r++) for (c = 1; c <= N; c++) scanf(\"%d\", a[r] + c);\n\tfor (r = 1; r <= N; r++)\n\t\tfor (s[r][1] = a[r][1], c = 2; c <= N; c++) s[r][c] += s[r][c-1] + a[r][c];\n\tmax = a[1][1];\n\tfor (r = 1; r <= N; r++) for (c = 1; c <= N; c++) {\n\t\tfor (c2 = c; c2 <= N; c2++) {\n\t\t\tk = s[r][c2] - s[r][c - 1];\tif (k > max) max = k;\n\t\t\tfor (r2 = r + 1; r2 <= N; r2++) { k += s[r2][c2] - s[r2][c - 1]; if (k > max) max = k; }\n\t\t}\n\t}\n\tprintf(\"%d\\n\", max);\n\treturn 0;\n}", "language": "C", "metadata": {"date": 1502745398, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00098.html", "problem_id": "p00098", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00098/input.txt", "sample_output_relpath": "derived/input_output/data/p00098/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00098/C/s892939901.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s892939901", "user_id": "u847467233"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "/*\n Aizu Vol-0 0098: Maximum Sum Sequence II \n 2017.8.15 bal4u@uu\n ????????????????????§???\n*/\n\n#include \n\n#define MAX 100\n\nint a[MAX + 5][MAX + 5], N;\nint s[MAX + 5][MAX + 5];\n\nint main()\n{\n\tint r, c, r2, c2, k, max;\n\n\tscanf(\"%d\", &N);\n\tfor (r = 1; r <= N; r++) for (c = 1; c <= N; c++) scanf(\"%d\", a[r] + c);\n\tfor (r = 1; r <= N; r++)\n\t\tfor (s[r][1] = a[r][1], c = 2; c <= N; c++) s[r][c] += s[r][c-1] + a[r][c];\n\tmax = a[1][1];\n\tfor (r = 1; r <= N; r++) for (c = 1; c <= N; c++) {\n\t\tfor (c2 = c; c2 <= N; c2++) {\n\t\t\tk = s[r][c2] - s[r][c - 1];\tif (k > max) max = k;\n\t\t\tfor (r2 = r + 1; r2 <= N; r2++) { k += s[r2][c2] - s[r2][c - 1]; if (k > max) max = k; }\n\t\t}\n\t}\n\tprintf(\"%d\\n\", max);\n\treturn 0;\n}", "problem_context": "Maximum Sum Sequence II\n\n与えられた整数の行列\n\na1,1 a1,2 ... a1,n\na2,1 a2,2 ... a2,n\n:\nan,1 an,2 ... an, n\n\nで、縦・横方向に1つ以上連続した項(部分行列)の和の最大値を出力して終了するプログラムを作成して下さい。\n\nInput\n\n入力データは以下の形式で与えられます。\n\nn\na1,1 a1,2 ... a1,n\na2,1 a2,2 ... a2,n\n:\nan,1 an,2 ... an, n\n\nn は 1 以上 100 以下、ai,j は -10000 以上 10000 以下です。\n\nOutput\n\n最大値を 1 行に出力して下さい。\n\nSample Input 1\n\n3\n1 -2 3\n-4 5 6\n7 8 -9\n\nOutput for the Sample Input 1\n\n16\n\nこの入力の場合、以下の部分行列の項の和が最大となります。\n\n-4 5\n7 8\n\nSample Input 2\n\n4\n1 3 -9 2\n2 7 -1 5\n-8 3 2 -1\n5 0 -3 1\n\nOutput for the Sample Input 2\n\n15\n\nこの入力の場合、以下の部分行列の項の和が最大となります。\n\n7 -1 5\n3 2 -1", "sample_input": "3\n1 -2 3\n-4 5 6\n7 8 -9\n"}, "reference_outputs": ["16\n"], "source_document_id": "p00098", "source_text": "Maximum Sum Sequence II\n\n与えられた整数の行列\n\na1,1 a1,2 ... a1,n\na2,1 a2,2 ... a2,n\n:\nan,1 an,2 ... an, n\n\nで、縦・横方向に1つ以上連続した項(部分行列)の和の最大値を出力して終了するプログラムを作成して下さい。\n\nInput\n\n入力データは以下の形式で与えられます。\n\nn\na1,1 a1,2 ... a1,n\na2,1 a2,2 ... a2,n\n:\nan,1 an,2 ... an, n\n\nn は 1 以上 100 以下、ai,j は -10000 以上 10000 以下です。\n\nOutput\n\n最大値を 1 行に出力して下さい。\n\nSample Input 1\n\n3\n1 -2 3\n-4 5 6\n7 8 -9\n\nOutput for the Sample Input 1\n\n16\n\nこの入力の場合、以下の部分行列の項の和が最大となります。\n\n-4 5\n7 8\n\nSample Input 2\n\n4\n1 3 -9 2\n2 7 -1 5\n-8 3 2 -1\n5 0 -3 1\n\nOutput for the Sample Input 2\n\n15\n\nこの入力の場合、以下の部分行列の項の和が最大となります。\n\n7 -1 5\n3 2 -1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 715, "cpu_time_ms": 50, "memory_kb": 684}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s900889371", "group_id": "codeNet:p00098", "input_text": "/*\n AOJ 0098\n Title:Maximum sum of sequence\n @kankichi573\n*/\n#include \n#include \n#define max(x,y) (((x)>(y))?(x):(y))\nint N;\nint array[100][100];\nint row_sum[100][100][100];\nvoid calc_row_sum()\n{\n int i,j,k,s;\n for(i=0;i\n#include \n#define max(x,y) (((x)>(y))?(x):(y))\nint N;\nint array[100][100];\nint row_sum[100][100][100];\nvoid calc_row_sum()\n{\n int i,j,k,s;\n for(i=0;i(y)?(x):(y))\n#define min(x,y)((x)<(y)?(x):(y))\nchar map[501*500];\nDH[501];\nmain(){\n\tint H,W,i,x,y,w,h,S;\n\tfor(;scanf(\"%d%d\\n\",&H,&W),H;){\n\t\tfor(i=0;i<(W+1)*H;i++)\n\t\t\tmap[i]=getchar();\n\t\tmemset(DH,0,sizeof(DH));\n\t\tS=0;\n\t\tfor(y=1;y<=H;y++){\n\t\t\tfor(x=1;x<=W;x++){\n\t\t\t\tif(map[(y-1)*(W+1)+(x-1)]=='.'){\n\t\t\t\t\tDH[x]++;\n\t\t\t\t\th=H;\n\t\t\t\t\tfor(w=1;h;w++){\n\t\t\t\t\t\th=min(h,DH[x-w+1]);\n\t\t\t\t\t\tS=max(S,w*h);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tDH[x]=0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\",S);\n\t}\n\texit(0);\n}", "language": "C", "metadata": {"date": 1288776630, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00116.html", "problem_id": "p00116", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00116/input.txt", "sample_output_relpath": "derived/input_output/data/p00116/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00116/C/s984613650.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s984613650", "user_id": "u399107199"}, "prompt_components": {"gold_output": "28\n12\n6\n", "input_to_evaluate": "#define max(x,y)((x)>(y)?(x):(y))\n#define min(x,y)((x)<(y)?(x):(y))\nchar map[501*500];\nDH[501];\nmain(){\n\tint H,W,i,x,y,w,h,S;\n\tfor(;scanf(\"%d%d\\n\",&H,&W),H;){\n\t\tfor(i=0;i<(W+1)*H;i++)\n\t\t\tmap[i]=getchar();\n\t\tmemset(DH,0,sizeof(DH));\n\t\tS=0;\n\t\tfor(y=1;y<=H;y++){\n\t\t\tfor(x=1;x<=W;x++){\n\t\t\t\tif(map[(y-1)*(W+1)+(x-1)]=='.'){\n\t\t\t\t\tDH[x]++;\n\t\t\t\t\th=H;\n\t\t\t\t\tfor(w=1;h;w++){\n\t\t\t\t\t\th=min(h,DH[x-w+1]);\n\t\t\t\t\t\tS=max(S,w*h);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tDH[x]=0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\",S);\n\t}\n\texit(0);\n}", "problem_context": "長方形探索\n\n縦に H 行、横に W 列並べられた、合計 W × H のマス目があります。いくつかのマス目には印がついています。各マス目の印の状態を読み込み、印のついていないマス目だけからなる最大の長方形の面積を出力するプログラムを作成してください。\n\n入力データは 1 行 W 文字から構成され、H 行が与えられます。たとえば以下のようなデータが与えられます。\n\n..*....**.\n..........\n**....***.\n....*.....\n..*.......\n...**.....\n.*.*......\n..........\n..**......\n.*..*.....\n\n入力データの一行が、一行のマス目を表現します。入力データの文字列のうち、. (ピリオド) は印のついていないマス目、* (アスタリスク) は印のついているマス目を示しています。入力データの文字列には、ピリオド、アスタリスク、改行以外の文字は含まれません。\n\n上記の例では、下図の 0 で示される長方形が最大となります。\n\n..*....**.\n..........\n**....***.\n....*00000\n..*..00000\n...**00000\n.*.*.00000\n.....00000\n..**.00000\n.*..*00000\n\nよって、35 と出力すれば正解になります。なお、すべてのマス目に印がついている場合には、0 を出力してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットはスペースで区切られた H と W からなる行から始まり、つづいて H × W の長方形が与えられます。H, W はともに 500 以下とします。\n\n入力は2つの 0 を含む行で終わります。データセットの数は 20 を超えません。\n\nOutput\n\n各データセットごとに、最大の長方形の面積を1行に出力してください。\n\nSample Input\n\n10 10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n**........\n.*........\n..........\n....*..***\n.*....*...\n10 10\n..*....*..\n.*.*...*..\n*****..*..\n*...*..*..\n*...*..*..\n..........\n****.*...*\n..*..*...*\n.*...*...*\n****..***.\n2 3\n...\n...\n0 0\n\nOutput for the Sample Input\n\n28\n12\n6", "sample_input": "10 10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n**........\n.*........\n..........\n....*..***\n.*....*...\n10 10\n..*....*..\n.*.*...*..\n*****..*..\n*...*..*..\n*...*..*..\n..........\n****.*...*\n..*..*...*\n.*...*...*\n****..***.\n2 3\n...\n...\n0 0\n"}, "reference_outputs": ["28\n12\n6\n"], "source_document_id": "p00116", "source_text": "長方形探索\n\n縦に H 行、横に W 列並べられた、合計 W × H のマス目があります。いくつかのマス目には印がついています。各マス目の印の状態を読み込み、印のついていないマス目だけからなる最大の���方形の面積を出力するプログラムを作成してください。\n\n入力データは 1 行 W 文字から構成され、H 行が与えられます。たとえば以下のようなデータが与えられます。\n\n..*....**.\n..........\n**....***.\n....*.....\n..*.......\n...**.....\n.*.*......\n..........\n..**......\n.*..*.....\n\n入力データの一行が、一行のマス目を表現します。入力データの文字列のうち、. (ピリオド) は印のついていないマス目、* (アスタリスク) は印のついているマス目を示しています。入力データの文字列には、ピリオド、アスタリスク、改行以外の文字は含まれません。\n\n上記の例では、下図の 0 で示される長方形が最大となります。\n\n..*....**.\n..........\n**....***.\n....*00000\n..*..00000\n...**00000\n.*.*.00000\n.....00000\n..**.00000\n.*..*00000\n\nよって、35 と出力すれば正解になります。なお、すべてのマス目に印がついている場合には、0 を出力してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットはスペースで区切られた H と W からなる行から始まり、つづいて H × W の長方形が与えられます。H, W はともに 500 以下とします。\n\n入力は2つの 0 を含む行で終わります。データセットの数は 20 を超えません。\n\nOutput\n\n各データセットごとに、最大の長方形の面積を1行に出力してください。\n\nSample Input\n\n10 10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n**........\n.*........\n..........\n....*..***\n.*....*...\n10 10\n..*....*..\n.*.*...*..\n*****..*..\n*...*..*..\n*...*..*..\n..........\n****.*...*\n..*..*...*\n.*...*...*\n****..***.\n2 3\n...\n...\n0 0\n\nOutput for the Sample Input\n\n28\n12\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 491, "cpu_time_ms": 60, "memory_kb": 652}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s282246294", "group_id": "codeNet:p00151", "input_text": "#include\nint main(){\n char s[258];\n int n,i,j,l,k,x,y,max;\n int X[]={1,1,0,-1};\n int Y[]={0,1,1, 1};\n while(1){\n scanf(\"%d\",&n);\n if(n==0)break;\n scanf(\"\\n\");\n int m[257][257]={0};\n max=0;\n for(i=0;i\nint main(){\n char s[258];\n int n,i,j,l,k,x,y,max;\n int X[]={1,1,0,-1};\n int Y[]={0,1,1, 1};\n while(1){\n scanf(\"%d\",&n);\n if(n==0)break;\n scanf(\"\\n\");\n int m[257][257]={0};\n max=0;\n for(i=0;i\n#include \n\n#define MAX 100000\n#define sqrtMAX 317\n\nint main(void)\n{\n int n;\n int *b;\n b = malloc((MAX+1)*sizeof(int));\n int *p;\n p = malloc((MAX+1)*sizeof(int));\n int *c;\n c = malloc((MAX+1)*sizeof(int));\n\n int i, j;\n int count;\n\n b[0] = 1;\n b[1] = 1;\n for(i=4; i<=MAX; i+=2)\n b[i] = 1;\n for(i=3; i MAX)\n break;\n c[p[i]+p[j]]++;\n }\n }\n\n while(scanf(\"%d\", &n)!=EOF) {\n if(n==0)\n break;\n printf(\"%d\\n\", c[n]);\n }\n\n free(b);\n free(p);\n free(c);\n\n return 0;\n}", "language": "C", "metadata": {"date": 1303015278, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00185.html", "problem_id": "p00185", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00185/input.txt", "sample_output_relpath": "derived/input_output/data/p00185/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00185/C/s378073291.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s378073291", "user_id": "u392015442"}, "prompt_components": {"gold_output": "6\n72\n274\n607\n", "input_to_evaluate": "#include\n#include \n\n#define MAX 100000\n#define sqrtMAX 317\n\nint main(void)\n{\n int n;\n int *b;\n b = malloc((MAX+1)*sizeof(int));\n int *p;\n p = malloc((MAX+1)*sizeof(int));\n int *c;\n c = malloc((MAX+1)*sizeof(int));\n\n int i, j;\n int count;\n\n b[0] = 1;\n b[1] = 1;\n for(i=4; i<=MAX; i+=2)\n b[i] = 1;\n for(i=3; i MAX)\n break;\n c[p[i]+p[j]]++;\n }\n }\n\n while(scanf(\"%d\", &n)!=EOF) {\n if(n==0)\n break;\n printf(\"%d\\n\", c[n]);\n }\n\n free(b);\n free(p);\n free(c);\n\n return 0;\n}", "problem_context": "ゴールドバッハ予想\n\nゴールドバッハ予想とは「6 以上のどんな偶数も、2 つの素数 (*1) の和として表わすことができる」というものです。\n\nたとえば、偶数の 12 は 12 = 5 + 7 、18 は 18 = 5 + 13 = 7 + 11 などと表すことができます。\n\n和が 134 となる 2 つの素数の組み合せをすべて書き出すと、以下の通りとなります。\n\n134 = 3+131 = 7+127 = 31+103 = 37+97 = 61+73 = 67+67\n\n= 131+3 = 127+7 = 103+31 = 97+37 = 73+61\n\n与えられた数が大きくなると、いくらでも素数の組み合せが見つかるよ��な気がします。しかし、現代数学をもってしてもこの予想を証明することも、反例を作ることもできません(*2)。ちょっと不思議な感じがしますね。\n\nそこで、ゴールドバッハ予想を鑑賞するために、偶数 n を入力とし、和が n となる 2 つの素数の組み合せの数を求めるプログラムを作成してください。\n\n和が n となる素数の組み合せの数とは n = p + q かつ p ≤ q であるような正の素数 p, q の組み合せの数です。上の例からわかるように和が 134 となる素数の組み合せは6 個です。\n\n(*1) 素数とは、1 または自分自身以外に約数を持たない整数のことである。なお、1 は素数ではない。\n\n(*2) 2007 年 2 月現在、5×1017 までの全ての偶数について成り立つことが確かめられている。(Wikipedia)\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。 各データセットとして、1つの偶数 n (6 ≤ n ≤ 1000000) が1行に与えられます。\n\nデータセットの数は 500 を超えません。\n\nOutput\n\nデータセット毎に素数の組み合せの数を1行に出力します。\n\nSample Input\n\n134\n4330\n34808\n98792\n0\n\nOutput for the Sample Input\n\n6\n72\n274\n607", "sample_input": "134\n4330\n34808\n98792\n0\n"}, "reference_outputs": ["6\n72\n274\n607\n"], "source_document_id": "p00185", "source_text": "ゴールドバッハ予想\n\nゴールドバッハ予想とは「6 以上のどんな偶数も、2 つの素数 (*1) の和として表わすことができる」というものです。\n\nたとえば、偶数の 12 は 12 = 5 + 7 、18 は 18 = 5 + 13 = 7 + 11 などと表すことができます。\n\n和が 134 となる 2 つの素数の組み合せをすべて書き出すと、以下の通りとなります。\n\n134 = 3+131 = 7+127 = 31+103 = 37+97 = 61+73 = 67+67\n\n= 131+3 = 127+7 = 103+31 = 97+37 = 73+61\n\n与えられた数が大きくなると、いくらでも素数の組み合せが見つかるような気がします。しかし、現代数学をもってしてもこの予想を証明することも、反例を作ることもできません(*2)。ちょっと不思議な感じがしますね。\n\nそこで、ゴールドバッハ予想を鑑賞するために、偶数 n を入力とし、和が n となる 2 つの素数の組み合せの数を求めるプログラムを作成してください。\n\n和が n となる素数の組み合せの数とは n = p + q かつ p ≤ q であるような正の素数 p, q の組み合せの数です。上の例からわかるように和が 134 となる素数の組み合せは6 個です。\n\n(*1) 素数とは、1 または自分自身以外に約数を持たない整数のことである。なお、1 は素数ではない。\n\n(*2) 2007 年 2 月現在、5×1017 までの全ての偶数について成り立つことが確かめられている。(Wikipedia)\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。 各データセットとして、1つの偶数 n (6 ≤ n ≤ 1000000) が1行に与えられます。\n\nデータセットの数は 500 を超えません。\n\nOutput\n\nデータセット毎に素数の組み合せの数を1行に出力します。\n\nSample Input\n\n134\n4330\n34808\n98792\n0\n\nOutput for the Sample Input\n\n6\n72\n274\n607", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 50, "memory_kb": 1144}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s478633975", "group_id": "codeNet:p00185", "input_text": "#include \n#include \n#include \n\nint i,j,n,prime[2000000],ans,list[1000000];\n\nint main(){\n\tfor(i=2;i<=1000000;i++)prime[i]=1;\n\tfor(i=2,n=0;i<=1000000;i++){\n\t\tif(prime[i]==1){\n\t\t\tlist[n]=i;n++;\n\t\t\tif(i<=1000)for(j=i*i;j<=1000000;j+=i)prime[j]=0;\n\t\t}\n\t}\n\twhile(scanf(\"%d\",&n)*n){\n\t\tans=0;\n\t\tfor(i=1;list[i]<=n/2;i++){\n\t\t\tif(prime[n-list[i]]==1)ans++;\n\t\t}\n\t\tprintf(\"%d\\n\",ans);\n\t}\n\treturn 0;\n}", "language": "C", "metadata": {"date": 1375702648, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00185.html", "problem_id": "p00185", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00185/input.txt", "sample_output_relpath": "derived/input_output/data/p00185/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00185/C/s478633975.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s478633975", "user_id": "u263489624"}, "prompt_components": {"gold_output": "6\n72\n274\n607\n", "input_to_evaluate": "#include \n#include \n#include \n\nint i,j,n,prime[2000000],ans,list[1000000];\n\nint main(){\n\tfor(i=2;i<=1000000;i++)prime[i]=1;\n\tfor(i=2,n=0;i<=1000000;i++){\n\t\tif(prime[i]==1){\n\t\t\tlist[n]=i;n++;\n\t\t\tif(i<=1000)for(j=i*i;j<=1000000;j+=i)prime[j]=0;\n\t\t}\n\t}\n\twhile(scanf(\"%d\",&n)*n){\n\t\tans=0;\n\t\tfor(i=1;list[i]<=n/2;i++){\n\t\t\tif(prime[n-list[i]]==1)ans++;\n\t\t}\n\t\tprintf(\"%d\\n\",ans);\n\t}\n\treturn 0;\n}", "problem_context": "ゴールドバッハ予想\n\nゴールドバッハ予想とは「6 以上のどんな偶数も、2 つの素数 (*1) の和として表わすことができる」というものです。\n\nたとえば、偶数の 12 は 12 = 5 + 7 、18 は 18 = 5 + 13 = 7 + 11 などと表すことができます。\n\n和が 134 となる 2 つの素数の組み合せをすべて書き出すと、以下の通りとなります。\n\n134 = 3+131 = 7+127 = 31+103 = 37+97 = 61+73 = 67+67\n\n= 131+3 = 127+7 = 103+31 = 97+37 = 73+61\n\n与えられた数が大きくなると、いくらでも素数の組み合せが見つかるような気がします。しかし、現代数学をもってしてもこの予想を証明することも、反例を作ることもできません(*2)。ちょっと不思議な感じがしますね。\n\nそこで、ゴールドバッハ予想を鑑賞するために、偶数 n を入力とし、和が n となる 2 つの素数の組み合せの数を求めるプログラムを作成してください。\n\n和が n となる素数の組み合せの数とは n = p + q かつ p ≤ q であるような正の素数 p, q の組み合せの数です。上の例からわかるように和が 134 となる素数の組み合せは6 個です。\n\n(*1) 素数とは、1 または自分自身以外に約数を持たない整数のことである。なお、1 は素数ではない。\n\n(*2) 2007 年 2 月現在、5×1017 までの全ての偶数について成り立つことが確かめられている。(Wikipedia)\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。 各データセットとして、1つの偶数 n (6 ≤ n ≤ 1000000) が1行に与えられます。\n\nデータセットの数は 500 を超えません。\n\nOutput\n\nデータセット毎に素数の組み合せの数を1行に出力します。\n\nSample Input\n\n134\n4330\n34808\n98792\n0\n\nOutput for the Sample Input\n\n6\n72\n274\n607", "sample_input": "134\n4330\n34808\n98792\n0\n"}, "reference_outputs": ["6\n72\n274\n607\n"], "source_document_id": "p00185", "source_text": "ゴールドバッハ予想\n\nゴールドバッハ予想とは「6 以上のどんな偶数も、2 つの素数 (*1) の和として表わすことができる」というものです。\n\nたとえば、偶数の 12 は 12 = 5 + 7 、18 は 18 = 5 + 13 = 7 + 11 などと表すことができます。\n\n和が 134 となる 2 つの素数の組み合せをすべて書き出すと、以下の通りとなります。\n\n134 = 3+131 = 7+127 = 31+103 = 37+97 = 61+73 = 67+67\n\n= 131+3 = 127+7 = 103+31 = 97+37 = 73+61\n\n与えられた数が大きくなると、いくらでも素数の組み合せが見つかるような気がします。しかし、現代数学をもってしてもこの予想を証明することも、反例を作ることもできません(*2)。ちょっと不思議な感じがしますね。\n\nそこで、ゴールドバッハ予想を鑑賞するために、偶数 n を入力とし、和が n となる 2 つの素数の組み合せの数を求めるプログラムを作成してください。\n\n和が n となる素数の組み合せの数とは n = p + q かつ p ≤ q であるような正の素数 p, q の組み合せの数です。上の例からわかるように和が 134 となる素数の組み合せは6 個です。\n\n(*1) 素数とは、1 または自分自身以外に約数を持たない整数のことである。なお、1 は素数ではない。\n\n(*2) 2007 年 2 月現在、5×1017 までの全ての偶数について成り立つことが確かめられている。(Wikipedia)\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。 各データセットとして、1つの偶数 n (6 ≤ n ≤ 1000000) が1行に与えられます。\n\nデータセットの数は 500 を超えません。\n\nOutput\n\nデータセット毎に素数の組み合せの数を1行に出力します。\n\nSample Input\n\n134\n4330\n34808\n98792\n0\n\nOutput for the Sample Input\n\n6\n72\n274\n607", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 7052}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s356421205", "group_id": "codeNet:p00188", "input_text": "#include \n\nint main(void)\n{\n\tint i, n;\n\tint array[128];\n\tint t;\n\t\n\tint l, r, m, num;\n\t\n\twhile (scanf(\"%d\", &n), n){\n\t\tfor (i = 0; i < n; i++){\n\t\t\tscanf(\"%d\", &array[i]);\n\t\t}\n\t\t\n\t\tscanf(\"%d\", &t);\n\t\t\n\t\tl = 0;\n\t\tr = n - 1;\n\t\tnum = 0;\n\t\twhile (1){\n\t\t\tm = (l + r) / 2;\n\t\t\t\n//\t\t\tprintf(\"%d %d %d\\n\", l, m, r);\n//\t\t\tprintf(\"%d %d %d\\n\", array[m], t);\n\t\t\tnum++;\n\t\t\t\n\t\t\tif (t == array[m] || l == r){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (t > array[m]){\n\t\t\t\tl = m + 1;\n\t\t\t}\n\t\t\telse if (t < array[m]){\n\t\t\t\tr = m - 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprintf(\"%d\\n\", num);\n\t}\n\t\n\treturn (0);\n}", "language": "C", "metadata": {"date": 1412149147, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00188.html", "problem_id": "p00188", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00188/input.txt", "sample_output_relpath": "derived/input_output/data/p00188/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00188/C/s356421205.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s356421205", "user_id": "u334031393"}, "prompt_components": {"gold_output": "3\n3\n", "input_to_evaluate": "#include \n\nint main(void)\n{\n\tint i, n;\n\tint array[128];\n\tint t;\n\t\n\tint l, r, m, num;\n\t\n\twhile (scanf(\"%d\", &n), n){\n\t\tfor (i = 0; i < n; i++){\n\t\t\tscanf(\"%d\", &array[i]);\n\t\t}\n\t\t\n\t\tscanf(\"%d\", &t);\n\t\t\n\t\tl = 0;\n\t\tr = n - 1;\n\t\tnum = 0;\n\t\twhile (1){\n\t\t\tm = (l + r) / 2;\n\t\t\t\n//\t\t\tprintf(\"%d %d %d\\n\", l, m, r);\n//\t\t\tprintf(\"%d %d %d\\n\", array[m], t);\n\t\t\tnum++;\n\t\t\t\n\t\t\tif (t == array[m] || l == r){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (t > array[m]){\n\t\t\t\tl = m + 1;\n\t\t\t}\n\t\t\telse if (t < array[m]){\n\t\t\t\tr = m - 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprintf(\"%d\\n\", num);\n\t}\n\t\n\treturn (0);\n}", "problem_context": "探索\n\n「探索」とは、たくさんの情報の中から望みの情報を得る操作のことです。身近な例では、合格発表の時の「たくさんの受験番号から自分の受験番号を見つける」ことや、電話帳から「会津太郎さんの電話番号を見つける」ときなどがあります。この探索という操作はコンピュータの分野でも広く用いられています。\n\n探索の方法は沢山あります。探索の対象となるデータが、小さい順(または大きい順)に並べられている場合に使うことができる探索の方法を考えます。\n\n小さい順(または大きい順)に並べられているデータ列の中央に位置する値と目的の値との大小関係を用いて、中央に位置する値から前半部分を探索範囲にするか後半部分を探索範囲にするかを決めることで、探索の範囲を絞っていく方法があります。手順は以下のようになります。\n\nデータの列の全体を探索の範囲とします。\n\n探索の範囲の中央に位置する値を調べます。\n\n目的の値と中央に位置する値が一致すれば探索を終了します。\n\n目的の値と中央に位置する値よりも小さければ前半部分を探索の範囲とし、大きければ後半部分を探索の範囲として2.へ戻ります。\n\n以下は上述した探索の方法の例です。この例での目的の値は51です。それぞれのデータには番号\n(index)が振られており、この番号は0から始まっています。\n\nステップ1: 最初は番号0~6全体を探索の範囲とします。\n\nステップ2: 探索の範囲の中央に位置する値を調べます。ただし、「中央に位置する値」とは、(左側の番号+右側の番号)を2で割った番号の位置にある値とします。つまり、この場合、(0 + 6) ÷ 2 を計算し、番号3にある値(36)が中央に位置する値となります。\n\nステップ3:目的の値(51)と中央に位置する値(36)を比較します。\n\nステップ4:ステップ3の結果から、目的の値は中央に位置する値より大きいので、後半部分にあたる番号4 (中央に位置する値の隣)以降を探索の範囲とします。同様の手順で探索の範囲の中央に位置する値を調べ、目的の値が中央に位置する値より小さければ前半部分を探索の範囲とし、大きければ後半部分���探索の範囲として、探索の範囲を小さくしていきます。(ステップ2~ステップ4の繰り返し)目的の値が中央に位置する値と一致するか、探索の範囲がつきてしまった時に探索を終了します。\n\nn 個の数値の配列を入力とし、目的の値と中央に位置する値を比較した回数を出力するプログラムを作成してください。ただし、中央に位置する値の番号を計算したとき、割り切れない場合は、小数点以下を切り捨てた値をその番号とすることとします。\n与えられるデータ列は小さい順に整列されているものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。 各データセットは以下の形式で与えられます。\n\nn\na1\na2\n:\nan\nk\n\n1 行目に数値の数 n (1 ≤ n ≤ 100) 、続く n 行に i 個目の数値 ai (1 ≤ ai ≤ 100000, 整数) が与えられます。\n\n続く行に探索する値 k (1 ≤ k ≤ 100000) が与えられます。\n\nOutput\n\nデータセット毎に探索が終わるまでの比較回数を1行に出力します。\n\nSample Input\n\n7\n11\n15\n23\n36\n51\n61\n86\n51\n4\n1\n2\n3\n5\n4\n0\n\nOutput for the Sample Input\n\n3\n3", "sample_input": "7\n11\n15\n23\n36\n51\n61\n86\n51\n4\n1\n2\n3\n5\n4\n0\n"}, "reference_outputs": ["3\n3\n"], "source_document_id": "p00188", "source_text": "探索\n\n「探索」とは、たくさんの情報の中から望みの情報を得る操作のことです。身近な例では、合格発表の時の「たくさんの受験番号から自分の受験番号を見つける」ことや、電話帳から「会津太郎さんの電話番号を見つける」ときなどがあります。この探索という操作はコンピュータの分野でも広く用いられています。\n\n探索の方法は沢山あります。探索の対象となるデータが、小さい順(または大きい順)に並べられている場合に使うことができる探索の方法を考えます。\n\n小さい順(または大きい順)に並べられているデータ列の中央に位置する値と目的の値との大小関係を用いて、中央に位置する値から前半部分を探索範囲にするか後半部分を探索範囲にするかを決めることで、探索の範囲を絞っていく方法があります。手順は以下のようになります。\n\nデータの列の全体を探索の範囲とします。\n\n探索の範囲の中央に位置する値を調べます。\n\n目的の値と中央に位置する値が一致すれば探索を終了します。\n\n目的の値と中央に位置する値よりも小さければ前半部分を探索の範囲とし、大きければ後半部分を探索の範囲として2.へ戻ります。\n\n以下は上述した探索の方法の例です。この例での目的の値は51です。それぞれのデータには番号\n(index)が振られており、この番号は0から始まっています。\n\nステップ1: 最初は番号0~6全体を探索の範囲とします。\n\nステップ2: 探索の範囲の中央に位置する値を調べます。ただし、「中央に位置する値」とは、(左側の番号+右側の番号)を2で割った番号の位置にある値とします。つまり、この場合、(0 + 6) ÷ 2 を計算し、番号3にある値(36)が中央に位置する値となります。\n\nステップ3:目的の値(51)と中央に位置する値(36)を比較します。\n\nステップ4:ステップ3の結果から、目的の値は中央に位置する値より大きいので、後半部分にあたる番号4 (中央に位置する値の隣)以降を探索の範囲とします。同様の手順で探索の範囲の中央に位置する値を調べ、目的の値が中央に位置する値より小さければ前半部分を探索の範囲とし、大きければ後半部分を探索の範囲として、探索の範囲を小さくしていきます。(ステップ2~ステップ4の繰り返し)目的の値が中央に位置する値と一致するか、探索の範囲がつきてしまった時に探索を終了します。\n\nn 個の数値の配列を入力とし、目的の値と中央に位置する値を比較した回数を出力するプログラムを作成してください。ただし、中央に位置する値の番号を計算したとき、割り切れない場合は、小数点以下を切り捨てた値をその番号とすることとします。\n与えられるデータ列は小さい順に整列されているものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。 各データセットは以下の形式で与えられます。\n\nn\na1\na2\n:\nan\nk\n\n1 行目に数値の数 n (1 ≤ n ≤ 100) 、続く n 行に i 個目の数値 ai (1 ≤ ai ≤ 100000, 整数) ��与えられます。\n\n続く行に探索する値 k (1 ≤ k ≤ 100000) が与えられます。\n\nOutput\n\nデータセット毎に探索が終わるまでの比較回数を1行に出力します。\n\nSample Input\n\n7\n11\n15\n23\n36\n51\n61\n86\n51\n4\n1\n2\n3\n5\n4\n0\n\nOutput for the Sample Input\n\n3\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 560, "cpu_time_ms": 20000, "memory_kb": 584}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s233720568", "group_id": "codeNet:p00217", "input_text": "#include \n\nint main(void) {\n\tint a,b,c,n,max=0,p,g;\n\t\n\t\n\tscanf(\"%d\",&n);\n\twhile(n!=0){\n\t\twhile(n>0){\n\t\t\tscanf(\"%d %d %d\",&a,&b,&c);\n\t\t\tg=b+c;\n\t\t\tif(max\n\nint main(void) {\n\tint a,b,c,n,max=0,p,g;\n\t\n\t\n\tscanf(\"%d\",&n);\n\twhile(n!=0){\n\t\twhile(n>0){\n\t\t\tscanf(\"%d %d %d\",&a,&b,&c);\n\t\t\tg=b+c;\n\t\t\tif(max\n#include \n#include \n\nint main(){\n int p[10000],i,m,n,ps,pc,j,s;\n char say[101]; \n\n while(1){\n scanf(\"%d %d\",&m,&n);\n if(m==0 && n==0) break;\n pc=m;\n for(i=0;i\n#include \n#include \n\nint main(){\n int p[10000],i,m,n,ps,pc,j,s;\n char say[101]; \n\n while(1){\n scanf(\"%d %d\",&m,&n);\n if(m==0 && n==0) break;\n pc=m;\n for(i=0;i\n\nint main()\n{\n int a[1000],n,m,sum,i,j,t;\n\n while(1){\n scanf(\"%d%d\",&n,&m);\n if(n==0&&m==0)break;\n sum=0;\n for(i=0;ia[j+1]){\n\t t=a[j];\n\t a[j]=a[j+1];\n\t a[j+1]=t;\n\t}\n }\n }\n sum=0;\n if(n>m){\n if(m==1){\n for(i=0;i\n\nint main()\n{\n int a[1000],n,m,sum,i,j,t;\n\n while(1){\n scanf(\"%d%d\",&n,&m);\n if(n==0&&m==0)break;\n sum=0;\n for(i=0;ia[j+1]){\n\t t=a[j];\n\t a[j]=a[j+1];\n\t a[j+1]=t;\n\t}\n }\n }\n sum=0;\n if(n>m){\n if(m==1){\n for(i=0;i\n int main(){\n\t int n,j,i;\n\t int p,q,r,c;\n\t while(scanf(\"%d\",&n) != 0){\n int x[1001][4];\n int sum=0;\n for(j=0;j\n int main(){\n\t int n,j,i;\n\t int p,q,r,c;\n\t while(scanf(\"%d\",&n) != 0){\n int x[1001][4];\n int sum=0;\n for(j=0;j\nint main(){\n int n,k,i,j,a,b,c,e,h,mi,min;\n while(scanf(\"%d %d\",&n,&k),n||k){\n int m[100][100]={0};\n while(k--){\n if(scanf(\"%d\",&a),a){\n\tscanf(\"%d %d %d\",&b,&c,&e);\n\tb--;\n\tc--;\n\tif(m[b][c]>e||m[b][c]==0)m[b][c]=m[c][b]=e;\n }\n else{\n\tscanf(\"%d %d\",&b,&c);\n\tb--;\n\tc--;\n\tlong long d[100]={0};\n\tchar f[100]={0};\n\tmi=b;\n\t//d[mi]=0;\n\tfor(i=0;id[mi]+m[mi][j]){\n\t d[j]=d[mi]+m[mi][j];\n\t h=1;\n\t }\n\t }\n\t if(!h)break;\n\t min=2100000000;\n\t for(j=0;jd[j]){\n\t min=d[j];\n\t mi=j;\n\t }\n\t }\n\t}\n\tif(d[c])printf(\"%lld\\n\",d[c]);\n\telse printf(\"-1\\n\");\n }\n }\n }\n return 0;\n}", "language": "C", "metadata": {"date": 1432880419, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00449.html", "problem_id": "p00449", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00449/input.txt", "sample_output_relpath": "derived/input_output/data/p00449/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00449/C/s196095245.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s196095245", "user_id": "u744420470"}, "prompt_components": {"gold_output": "-1\n15\n12\n5955\n21431\n9298\n16392\n24774\n8840\n", "input_to_evaluate": "#include\nint main(){\n int n,k,i,j,a,b,c,e,h,mi,min;\n while(scanf(\"%d %d\",&n,&k),n||k){\n int m[100][100]={0};\n while(k--){\n if(scanf(\"%d\",&a),a){\n\tscanf(\"%d %d %d\",&b,&c,&e);\n\tb--;\n\tc--;\n\tif(m[b][c]>e||m[b][c]==0)m[b][c]=m[c][b]=e;\n }\n else{\n\tscanf(\"%d %d\",&b,&c);\n\tb--;\n\tc--;\n\tlong long d[100]={0};\n\tchar f[100]={0};\n\tmi=b;\n\t//d[mi]=0;\n\tfor(i=0;id[mi]+m[mi][j]){\n\t d[j]=d[mi]+m[mi][j];\n\t h=1;\n\t }\n\t }\n\t if(!h)break;\n\t min=2100000000;\n\t for(j=0;jd[j]){\n\t min=d[j];\n\t mi=j;\n\t }\n\t }\n\t}\n\tif(d[c])printf(\"%lld\\n\",d[c]);\n\telse printf(\"-1\\n\");\n }\n }\n }\n return 0;\n}", "problem_context": "船旅\n\n問題\n\nJOI国には,n 島の島があり,各島には 1 から n までの番号が付けられている.現在,JOI国では各島の間を結ぶ航路網の整備が進んでいる.\n\nあなたは,船舶の切符を扱っているチケットセンターに勤務している.JOI国には船舶を使って,できる限り安価に,島と島の間を旅行したいと考えている人が沢山おり,彼らは,出発地と目的地を注文票に記入して,あなたのところに送ってくる.\n\nあなたの仕事は,客から注文票を受け取ったらすぐに,いくつかの船舶を乗り継いで,出発地と目的地を結ぶ航路の中で,もっとも安価な運賃を計算し,客に伝えることである.\nただし,旅程によっては,船舶を使って旅行することが出来ない場合もある.そのときは『船舶を使って旅行することが出来ない』と客に伝える必要がある.また,JOI国では,島と島の間を結ぶ新しい船舶が,次々と運航を開始しており,あなたには,その情報が随時伝えられる.客に返事をする際には,最新の情報に留意しなければならない.\n\n入力として,客の注文票や新たに運航を開始した船舶の運航情報が与えられたときに,客への返事を求めるプログラムを作成せよ.\n\nなお,入力例1と出力例1に対する実行状況を,図1として図示している.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力の 1 行目には2つの整数 n, k (1 ≤ n ≤ 100, 1 ≤ k ≤ 5000) が書かれている.これは,島の数が n 島で,入力が k + 1 行からなることを表す.\ni + 1 行目 (1 ≤ i ≤ k) には, 3 個または 4 個の整数が空白を区切りとして書かれている.\n\n最初の数字が 0 のとき,この行は客の注文票を表す.\n\nこの行には3個の整数 0, a, b (1 ≤ a ≤ n, 1 ≤ b ≤ n, a ≠ b) が空白を区切りとして書かれている.\nこれは,客が,島 a を出発地とし島 b を目的地とするような注文票を送ってきたことを表す.\n\n最初の数字が 1 のとき,この行は新たに運航を開始した船舶の運航情報を表す.\n\nこの行には 4 個の整数 1, c, d, e (1 ≤ c ≤ n, 1 ≤ d ≤ n, c ≠ d, 1 ≤ e ≤ 1000000) が書かれている.\n\nこれは島 c と島 d を往復する船舶が新たに運航を開始し,この船舶の島 c から島 d への運賃と,島 d から島 c への運賃が,共に e であることを表す.\n\nこの行以降の注文票に対しては,この船舶も考慮して返事をしなければならない.\n\n最初の段階では,船舶は一隻も運航していないものとする.入力のうち,船舶の運航情報を表す行は 1000 行以下である.また,島と島の間に,複数の船舶が運航することがあることに注意せよ.\n\nn, k がともに 0 のとき入力の終了を示す. データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに以下の形式で出力する.\n\n入力のうち,注文票を表す行の数を m とおく.\n各データセットの出力は m 行からなり, i 行目(1 ≤ i ≤ m)には, i 番目の注文票に対する返事を表す整数を書く.\nすなわち, i 番目の注文票の出発地と目的地の間を,いくつかの船舶を乗り継いで旅行することが可能ならば,その運賃の合計の最小値を書く.旅行することが不可能ならば,-1 を出力する.\n\n入出力例\n\n入力例\n\n3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 2 343750\n1 1 3 3343\n1 1 4 347392\n1 1 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 15934\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0\n\n出力例\n\n-1\n15\n12\n5955\n21431\n9298\n16392\n24774\n8840\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 2 343750\n1 1 3 3343\n1 1 4 347392\n1 1 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 15934\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0\n"}, "reference_outputs": ["-1\n15\n12\n5955\n21431\n9298\n16392\n24774\n8840\n"], "source_document_id": "p00449", "source_text": "船旅\n\n問題\n\nJOI国には,n 島の島があり,各島には 1 から n までの番号が付���られている.現在,JOI国では各島の間を結ぶ航路網の整備が進んでいる.\n\nあなたは,船舶の切符を扱っているチケットセンターに勤務している.JOI国には船舶を使って,できる限り安価に,島と島の間を旅行したいと考えている人が沢山おり,彼らは,出発地と目的地を注文票に記入して,あなたのところに送ってくる.\n\nあなたの仕事は,客から注文票を受け取ったらすぐに,いくつかの船舶を乗り継いで,出発地と目的地を結ぶ航路の中で,もっとも安価な運賃を計算し,客に伝えることである.\nただし,旅程によっては,船舶を使って旅行することが出来ない場合もある.そのときは『船舶を使って旅行することが出来ない』と客に伝える必要がある.また,JOI国では,島と島の間を結ぶ新しい船舶が,次々と運航を開始しており,あなたには,その情報が随時伝えられる.客に返事をする際には,最新の情報に留意しなければならない.\n\n入力として,客の注文票や新たに運航を開始した船舶の運航情報が与えられたときに,客への返事を求めるプログラムを作成せよ.\n\nなお,入力例1と出力例1に対する実行状況を,図1として図示している.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力の 1 行目には2つの整数 n, k (1 ≤ n ≤ 100, 1 ≤ k ≤ 5000) が書かれている.これは,島の数が n 島で,入力が k + 1 行からなることを表す.\ni + 1 行目 (1 ≤ i ≤ k) には, 3 個または 4 個の整数が空白を区切りとして書かれている.\n\n最初の数字が 0 のとき,この行は客の注文票を表す.\n\nこの行には3個の整数 0, a, b (1 ≤ a ≤ n, 1 ≤ b ≤ n, a ≠ b) が空白を区切りとして書かれている.\nこれは,客が,島 a を出発地とし島 b を目的地とするような注文票を送ってきたことを表す.\n\n最初の数字が 1 のとき,この行は新たに運航を開始した船舶の運航情報を表す.\n\nこの行には 4 個の整数 1, c, d, e (1 ≤ c ≤ n, 1 ≤ d ≤ n, c ≠ d, 1 ≤ e ≤ 1000000) が書かれている.\n\nこれは島 c と島 d を往復する船舶が新たに運航を開始し,この船舶の島 c から島 d への運賃と,島 d から島 c への運賃が,共に e であることを表す.\n\nこの行以降の注文票に対しては,この船舶も考慮して返事をしなければならない.\n\n最初の段階では,船舶は一隻も運航していないものとする.入力のうち,船舶の運航情報を表す行は 1000 行以下である.また,島と島の間に,複数の船舶が運航することがあることに注意せよ.\n\nn, k がともに 0 のとき入力の終了を示す. データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに以下の形式で出力する.\n\n入力のうち,注文票を表す行の数を m とおく.\n各データセットの出力は m 行からなり, i 行目(1 ≤ i ≤ m)には, i 番目の注文票に対する返事を表す整数を書く.\nすなわち, i 番目の注文票の出発地と目的地の間を,いくつかの船舶を乗り継いで旅行することが可能ならば,その運賃の合計の最小値を書く.旅行することが不可能ならば,-1 を出力する.\n\n入出力例\n\n入力例\n\n3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 2 343750\n1 1 3 3343\n1 1 4 347392\n1 1 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 15934\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0\n\n出力例\n\n-1\n15\n12\n5955\n21431\n9298\n16392\n24774\n8840\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 779, "cpu_time_ms": 40, "memory_kb": 660}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s515690953", "group_id": "codeNet:p00461", "input_text": "main(n,s,c,t){for(;scanf(\"%d%*d \",&n)*n;printf(\"%d\\n\",s))for(s=c=0;t=getchar()%5;s+=c&c/2>=n)c=c&1^t&1?c+1:t&1;}", "language": "C", "metadata": {"date": 1377355950, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00461.html", "problem_id": "p00461", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00461/input.txt", "sample_output_relpath": "derived/input_output/data/p00461/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00461/C/s515690953.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s515690953", "user_id": "u340315059"}, "prompt_components": {"gold_output": "4\n2\n", "input_to_evaluate": "main(n,s,c,t){for(;scanf(\"%d%*d \",&n)*n;printf(\"%d\\n\",s))for(s=c=0;t=getchar()%5;s+=c&c/2>=n)c=c&1^t&1?c+1:t&1;}", "problem_context": "IOIOI\n\n問題\n\n整数 n (1 ≤ n) に対し, n + 1 個の I と n 個の O を I から始めて交互に並べてできる文字列を Pn とする.ここで I と O はそれぞれ英大文字のアイとオーである.\n\nP1\n\nIOI\n\nP2\n\nIOIOI\n\nP3\n\nIOIOIOI\n\n.\n\n.\n\n.\n\nPn\n\nIOIOIO ... OI (O が n 個)\n\n図 1-1 本問で考える文字列 Pn\n\n整数 n と, I と O のみからなる文字列 s が与えられた時, s の中に Pn が何ヶ所含まれているかを出力するプログラムを作成せよ.\n\n例\n\nn が 1, s が OOIOIOIOIIOII の場合, P1 は IOI であり,下図 1-2 に示した 4ヶ所に含まれている.よって,出力は 4 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-2 n が 1, s が OOIOIOIOIIOII の場合の例\n\nn が 2, s が OOIOIOIOIIOII の場合, P2 は IOIOI であり,下図 1-3 に示した 2ヶ所に含まれている.よって,出力は 2 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-3 n が 2, s が OOIOIOIOIIOII の場合の例\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n1 行目には整数 n (1 ≤ n ≤ 1000000) が書かれている.\n\n2 行目には整数 m (1 ≤ m ≤ 1000000) が書かれている. m は s の文字数を表す.\n\n3 行目には文字列 s が書かれている. s は I と O のみからなる.\n\n全ての採点用データで, 2n + 1 ≤ m である.採点用データのうち, 配点の 50% 分については, n ≤ 100, m ≤ 10000 を満たす.\n\nn が 0 のとき入力の終了を示す. データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに,文字列 s に文字列 Pn が何ヶ所含まれるかを表す 1 つの整数を1 行に出力する. s に Pn が含まれていない場合は,整数として 0 を出力せよ.\n\n入出力例\n\n入力例\n\n1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n\n出力例\n\n4\n2\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n"}, "reference_outputs": ["4\n2\n"], "source_document_id": "p00461", "source_text": "IOIOI\n\n問題\n\n整数 n (1 ≤ n) に対し, n + 1 個の I と n 個の O を I から始めて交互に並べてできる文字列を Pn とする.ここで I と O はそれぞれ英大文字のアイとオーである.\n\nP1\n\nIOI\n\nP2\n\nIOIOI\n\nP3\n\nIOIOIOI\n\n.\n\n.\n\n.\n\nPn\n\nIOIOIO ... OI (O が n 個)\n\n図 1-1 本問で考える文字列 Pn\n\n整数 n と, I と O のみからなる文字列 s が与えられた時, s の中に Pn が何ヶ所含まれているかを出力するプログラムを作成せよ.\n\n例\n\nn が 1, s が OOIOIOIOIIOII の場合, P1 は IOI であり,下図 1-2 に示した 4ヶ所に含まれている.よって,出力は 4 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-2 n が 1, s が OOIOIOIOIIOII の場合の例\n\nn が 2, s が OOIOIOIOIIOII の場合, P2 は IOIOI であり,下図 1-3 に示した 2ヶ所に含まれている.よって,出力は 2 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-3 n が 2, s が OOIOIOIOIIOII の場合の例\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n1 行目には整数 n (1 ≤ n ≤ 1000000) が書かれている.\n\n2 行目には整数 m (1 ≤ m ≤ 1000000) が書かれている. m は s の文字数を表す.\n\n3 行目には文字列 s が書かれている. s は I と O のみからなる.\n\n全ての採点用データで, 2n + 1 ≤ m である.採点用データのうち, 配点の 50% 分については, n ≤ 100, m ≤ 10000 を満たす.\n\nn が 0 のとき入力の終了を示す. データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに,文字列 s に文字列 Pn が何ヶ所含まれるかを表す 1 つの整数を1 行に出力する. s に Pn が含まれていない場合は,整数として 0 を出力せよ.\n\n入出力例\n\n入力例\n\n1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n\n出力例\n\n4\n2\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 112, "cpu_time_ms": 10, "memory_kb": 604}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s378023515", "group_id": "codeNet:p00469", "input_text": "// AOJ 0546\n//\n// Lining up the cards\n\n#include \n#include \nint a[10];\nchar kekka[5040][9];\nint len; // n\nint r; // k\nint pcnt;\n \nvoid print()\n{\n if(r==2)\n sprintf(kekka[pcnt],\"%d%d\\0\",a[0],a[1]);\n else if(r==3)\n sprintf(kekka[pcnt],\"%d%d%d\\0\",a[0],a[1],a[2]);\n else if(r==4)\n sprintf(kekka[pcnt],\"%d%d%d%d\\0\",a[0],a[1],a[2],a[3]); \n\n pcnt++;\n}\n\nvoid recursive(int j)\n{ \n int i,t,k;\n\n if(j==r){\n print();\n return; \n } \n for(i=j;ij;k--) \n\t a[k]=a[k-1]; \n\t a[j]=t; \n\t recursive(j+1); \n // j~iを循環左ローテート \n\t for(k=j;k\n#include \nint a[10];\nchar kekka[5040][9];\nint len; // n\nint r; // k\nint pcnt;\n \nvoid print()\n{\n if(r==2)\n sprintf(kekka[pcnt],\"%d%d\\0\",a[0],a[1]);\n else if(r==3)\n sprintf(kekka[pcnt],\"%d%d%d\\0\",a[0],a[1],a[2]);\n else if(r==4)\n sprintf(kekka[pcnt],\"%d%d%d%d\\0\",a[0],a[1],a[2],a[3]); \n\n pcnt++;\n}\n\nvoid recursive(int j)\n{ \n int i,t,k;\n\n if(j==r){\n print();\n return; \n } \n for(i=j;ij;k--) \n\t a[k]=a[k-1]; \n\t a[j]=t; \n\t recursive(j+1); \n // j~iを循環左ローテート \n\t for(k=j;k\n#include\nint main( void )\n{\n\tshort n ;\n\tchar name[ 26 ] ;\n\tchar moji[ 101 ] ,nm[26][ 2 ] ;\n\tshort len ,lename ,lenc ;\n\tshort cnt = 0 ;\n\tshort i ,j ,k ,t ,u ;\n\tscanf( \"%d\", &n ) ;\n\tscanf( \"%s\", name ) ;\n\tlename = strlen( name ) ;\n\tfor( i = 0 ; i < lename ; i++ )\n\t{\n\t\tstrncpy( nm[ i ] ,name + i ,1 ) ;\n\t}\n\tfor( i = 0 ; i < n ; i++ )\n\t{\n\t\tscanf( \"%s\", moji ) ;\n\t\tlen = strlen( moji ) ;\n\t\tfor( j = 0 ; j < len ; j++ )\n\t\t{\n\t\t\tif( strstr( moji ,name ) != NULL )\n\t\t\t{\n\t\t\t\tcnt++ ;\n\t\t\t\tbreak ;\n\t\t\t}\n\t\t\tk = u = 0 ;\n\t\t\n\t\tONEMORE :\n\t\t\tfor( ; moji[ u ] != nm[ 0 ][ 0 ] ; u++ ) ;\n\t\t\tfor( ; ( ( k / 2) + 1 ) * lename < len ; k++ )\n\t\t\t{\n\t\t\t\tu++ ;\n\t\t\t\tif( nm[ 1 ][ 0 ] == moji[ k + u ] )\n\t\t\t\t{\n\t\t\t\t\tfor( t = 1 ; t < lename ; t++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tif( nm[ t ][ 0 ] != moji[ ( k + u ) * t ] )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgoto ZOKA ;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcnt++ ;\n\t\t\t\t\t\tgoto INPUT ;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tZOKA : ;\n\t\t\t}\n\t\t\tif( u < len )\n\t\t\t{\n\t\t\t\tgoto ONEMORE ;\n\t\t\t}\n\t\t}\n\t\tINPUT : ;\n\t}\n\tprintf( \"%d\\n\", cnt ) ;\n\treturn 0;\n}", "language": "C", "metadata": {"date": 1477582045, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00501.html", "problem_id": "p00501", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00501/input.txt", "sample_output_relpath": "derived/input_output/data/p00501/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00501/C/s338538331.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s338538331", "user_id": "u302788563"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\n#include\nint main( void )\n{\n\tshort n ;\n\tchar name[ 26 ] ;\n\tchar moji[ 101 ] ,nm[26][ 2 ] ;\n\tshort len ,lename ,lenc ;\n\tshort cnt = 0 ;\n\tshort i ,j ,k ,t ,u ;\n\tscanf( \"%d\", &n ) ;\n\tscanf( \"%s\", name ) ;\n\tlename = strlen( name ) ;\n\tfor( i = 0 ; i < lename ; i++ )\n\t{\n\t\tstrncpy( nm[ i ] ,name + i ,1 ) ;\n\t}\n\tfor( i = 0 ; i < n ; i++ )\n\t{\n\t\tscanf( \"%s\", moji ) ;\n\t\tlen = strlen( moji ) ;\n\t\tfor( j = 0 ; j < len ; j++ )\n\t\t{\n\t\t\tif( strstr( moji ,name ) != NULL )\n\t\t\t{\n\t\t\t\tcnt++ ;\n\t\t\t\tbreak ;\n\t\t\t}\n\t\t\tk = u = 0 ;\n\t\t\n\t\tONEMORE :\n\t\t\tfor( ; moji[ u ] != nm[ 0 ][ 0 ] ; u++ ) ;\n\t\t\tfor( ; ( ( k / 2) + 1 ) * lename < len ; k++ )\n\t\t\t{\n\t\t\t\tu++ ;\n\t\t\t\tif( nm[ 1 ][ 0 ] == moji[ k + u ] )\n\t\t\t\t{\n\t\t\t\t\tfor( t = 1 ; t < lename ; t++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tif( nm[ t ][ 0 ] != moji[ ( k + u ) * t ] )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgoto ZOKA ;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcnt++ ;\n\t\t\t\t\t\tgoto INPUT ;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tZOKA : ;\n\t\t\t}\n\t\t\tif( u < len )\n\t\t\t{\n\t\t\t\tgoto ONEMORE ;\n\t\t\t}\n\t\t}\n\t\tINPUT : ;\n\t}\n\tprintf( \"%d\\n\", cnt ) ;\n\treturn 0;\n}", "problem_context": "看板 (Signboard)\n\n問題\n\nJOI 君はお店の看板を作ることにした.\n\n文字が等間隔に書かれた古い看板が N 枚ある.JOI 君は古い看板からいくつかの文字を消すことで看板を作る.残った文字列がお店の名前になっていて,しかも残った文字が等間隔に並んでいるようにしたい.看板は 1 枚の古い看板から作らなければならず,古い看板を切ったりつなげたりしてはならない.\n\nお店の名前と N 枚の古い看板の情報が与えられた時,JOI 君が作ることができる看板の枚数を求めるプログラムを作成せよ.ただし, 1 枚の古い看板から作ることができる看板が複数考えられる場合も,作ることができる看板は 1 枚であると考える.\n\n入力\n\n入力は 2 + N 行からなる.\n\n1 行目には,整数 N (1 ≦ N ≦ 100) が書かれており,古い看板の枚数を表す.\n\n2 行目には,3 文字以上 25 文字以下のアルファベット小文字からなる文字列が書かれており,お店の名前を表す.\n\n続く N 行のうちの i 行目 (1 ≦ i ≦ N) には 1 文字以上 100 文字以下のアルファベット小文字からなる文字列が書かれており,i 枚目の古い看板に書かれている文字列を表す.\n\n出力\n\nJOI 君が作ることができる看板の枚数を表す整数を 1 行で出力せよ.\n\n入出力例\n\n入力例\n\n4\nbar\nabracadabra\nbear\nbar\nbaraxbara\n\n出力例\n\n3\n\nお店の名前は bar である.\n\n1 枚目の古い看板には文字列 abracadabra が書かれている.\nこの古い看板から 2 文字目,6 文字目,10 文字目以外を消すことで看板を作ることができる.\n\n2 枚目は,2 文字目を消すと bar という文字列を作ることができるが,これは残った文字が等間隔に並んでいない.\n\n3 枚目は,文字を何も消さなくても看板になっている.\n\n4 枚目の古い看板から看板を作る方法は 2 通りある.\n1 つの方法は,1 文字目,2 文字目,3 文字目以外を消すことである.\nもう 1 つの方法は,6 文字目,7 文字目,8 文字目以外を消すことである.\n\nよって,JOI 君は 1 枚目,3 枚目,4 枚目の古い看板から看板を作ることができるので,3 を出力する.\n\n問題文と自動審判に使われ��データは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "4\nbar\nabracadabra\nbear\nbar\nbaraxbara\n"}, "reference_outputs": ["3\n"], "source_document_id": "p00501", "source_text": "看板 (Signboard)\n\n問題\n\nJOI 君はお店の看板を作ることにした.\n\n文字が等間隔に書かれた古い看板が N 枚ある.JOI 君は古い看板からいくつかの文字を消すことで看板を作る.残った文字列がお店の名前になっていて,しかも残った文字が等間隔に並んでいるようにしたい.看板は 1 枚の古い看板から作らなければならず,古い看板を切ったりつなげたりしてはならない.\n\nお店の名前と N 枚の古い看板の情報が与えられた時,JOI 君が作ることができる看板の枚数を求めるプログラムを作成せよ.ただし, 1 枚の古い看板から作ることができる看板が複数考えられる場合も,作ることができる看板は 1 枚であると考える.\n\n入力\n\n入力は 2 + N 行からなる.\n\n1 行目には,整数 N (1 ≦ N ≦ 100) が書かれており,古い看板の枚数を表す.\n\n2 行目には,3 文字以上 25 文字以下のアルファベット小文字からなる文字列が書かれており,お店の名前を表す.\n\n続く N 行のうちの i 行目 (1 ≦ i ≦ N) には 1 文字以上 100 文字以下のアルファベット小文字からなる文字列が書かれており,i 枚目の古い看板に書かれている文字列を表す.\n\n出力\n\nJOI 君が作ることができる看板の枚数を表す整数を 1 行で出力せよ.\n\n入出力例\n\n入力例\n\n4\nbar\nabracadabra\nbear\nbar\nbaraxbara\n\n出力例\n\n3\n\nお店の名前は bar である.\n\n1 枚目の古い看板には文字列 abracadabra が書かれている.\nこの古い看板から 2 文字目,6 文字目,10 文字目以外を消すことで看板を作ることができる.\n\n2 枚目は,2 文字目を消すと bar という文字列を作ることができるが,これは残った文字が等間隔に並んでいない.\n\n3 枚目は,文字を何も消さなくても看板になっている.\n\n4 枚目の古い看板から看板を作る方法は 2 通りある.\n1 つの方法は,1 文字目,2 文字目,3 文字目以外を消すことである.\nもう 1 つの方法は,6 文字目,7 文字目,8 文字目以外を消すことである.\n\nよって,JOI 君は 1 枚目,3 枚目,4 枚目の古い看板から看板を作ることができるので,3 を出力する.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1001, "cpu_time_ms": 20000, "memory_kb": 572}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s062388656", "group_id": "codeNet:p00605", "input_text": "#include\nint main(){\n while(1){\n int N,K;\n int flg=0,i,j,S[100],B;\n scanf(\"%d %d\",&N,&K);\n if( N==0 && K==0 ) break;\n\n for(i=0 ; i\nint main(){\n while(1){\n int N,K;\n int flg=0,i,j,S[100],B;\n scanf(\"%d %d\",&N,&K);\n if( N==0 && K==0 ) break;\n\n for(i=0 ; i\n\nstatic inline int getint(){\n int ret = 0;\n int g;\n while((g = getchar() - '0'), g<0);\n ret = g;\n while((g = getchar() - '0'), g>=0){\n ret *= 10;\n ret += g;\n }\n return ret;\n}\n\nstatic inline int cnt(unsigned int bits) {\n bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);\n bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);\n bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);\n bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);\n return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);\n}\n\nint memo[1<<20];\n\nint main(){\n int c[20],k,r[20];\n int n,u;\n register unsigned int i,j,l;\n for(i=0; i<(1<<20); i++) memo[i] = cnt(i);\n while(n=getint(), u=getint(), n+u){\n int ans = n;\n\n for(i=0; i= ans) continue;\n\n for(j=0; ok & j-n; j++){\n\tif(i & (1<= u & ok)\n\tans = cc;\n }\n printf(\"%d\\n\",ans);\n }\n}", "language": "C", "metadata": {"date": 1283439150, "filename_ext": "c", "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/s670900056.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s670900056", "user_id": "u609255173"}, "prompt_components": {"gold_output": "2\n3\n", "input_to_evaluate": "#include\n\nstatic inline int getint(){\n int ret = 0;\n int g;\n while((g = getchar() - '0'), g<0);\n ret = g;\n while((g = getchar() - '0'), g>=0){\n ret *= 10;\n ret += g;\n }\n return ret;\n}\n\nstatic inline int cnt(unsigned int bits) {\n bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);\n bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);\n bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);\n bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);\n return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);\n}\n\nint memo[1<<20];\n\nint main(){\n int c[20],k,r[20];\n int n,u;\n register unsigned int i,j,l;\n for(i=0; i<(1<<20); i++) memo[i] = cnt(i);\n while(n=getint(), u=getint(), n+u){\n int ans = n;\n\n for(i=0; i= ans) continue;\n\n for(j=0; ok & j-n; j++){\n\tif(i & (1<= u & ok)\n\tans = cc;\n }\n printf(\"%d\\n\",ans);\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1211, "cpu_time_ms": 1030, "memory_kb": 4464}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s637683235", "group_id": "codeNet:p00719", "input_text": "// AOJ 1138: Traveling by Stagecoach\n// 2017.11.18 bal4u@uu\n\n#include \n//#include \n#include \n\n#define QMAX 1000000\ntypedef struct { double t; int node, c; } QUE;\nQUE que[QMAX]; int qsize;\n\n#define PARENT(i) ((i)>>1)\n#define LEFT(i) ((i)<<1)\n#define RIGHT(i) (((i)<<1)+1)\n\nvoid min_heapify(int i)\n{\n\tint l, r, min;\n\tQUE qt;\n\n\tl = LEFT(i), r = RIGHT(i);\n\tif (l < qsize && que[l].t < que[i].t) min = l; else min = i;\n\tif (r < qsize && que[r].t < que[min].t) min = r;\n\tif (min != i) {\n\t\tqt = que[i], que[i] = que[min], que[min] = qt;\n\t\tmin_heapify(min);\n\t}\n}\n\nvoid deq()\n{\n//\tif (qsize == 0) return 0;\n//\t*n = que[0].node, *t = que[0].t, *c = que[0].c;\n\tque[0] = que[--qsize];\n\tmin_heapify(0);\n//\treturn 1;\n}\n\nint qmax;\nvoid enq(int n, double t, int c)\n{\n\tint i, min;\n\tQUE qt;\n\n\ti = qsize++;\t//if (qsize > qmax) qmax = qsize;\n\tque[i].t = t, que[i].node = n, que[i].c = c;\n\twhile (i > 0 && que[min = PARENT(i)].t > que[i].t) {\n\t\tqt = que[i], que[i] = que[min], que[min] = qt;\n\t\ti = min;\n\t}\n}\n\n#define INF 1e10\n#define MAX 31\ntypedef struct { int to[MAX], d[MAX]; } TBL;\nTBL tbl[MAX];\nint len[MAX];\nint t[8];\ndouble node[MAX][256];\nchar visited[MAX][256];\n\n\nvoid dijkstra(int start, int goal, int N)\n{\n\tint i, j, jj, s, e, c, lim;\n\tdouble tm;\n\n\tqsize = 0;\n\tmemset(visited, 0, sizeof(visited));\n\tfor (lim = 1<= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);\n\treturn n;\n}\n\nint main()\n{\n\tint N, M, P, A, B, i, k, x, y, z, lim;\n\tdouble ans;\n\n\twhile (fgets(bp=buf, 40, stdin) && *bp != '0') {\n\t\tN = getint(), bp++, M = getint(), bp++;\n\t\tP = getint(), bp++, A = getint()-1, bp++, B = getint()-1;\n\t\tmemset(len, 0, sizeof(len));\n\t\tfgets(bp=buf, 40, stdin);\n\t\tfor (i = 0; i < N; i++) t[i] = getint(), bp++;\n\t\tfor (i = 0; i < P; i++) {\n\t\t\tfgets(bp=buf, 40, stdin);\n\t\t\tx = getint()-1, bp++, y = getint()-1, bp++, z = getint();\n\t\t\tk = len[x], tbl[x].to[k] = y, tbl[x].d[k] = z, len[x]++;\n\t\t\tk = len[y], tbl[y].to[k] = x, tbl[y].d[k] = z, len[y]++;\n\t\t}\n\t\tdijkstra(A, B, N);\n\t\tfor (ans = INF, lim = 1<\n//#include \n#include \n\n#define QMAX 1000000\ntypedef struct { double t; int node, c; } QUE;\nQUE que[QMAX]; int qsize;\n\n#define PARENT(i) ((i)>>1)\n#define LEFT(i) ((i)<<1)\n#define RIGHT(i) (((i)<<1)+1)\n\nvoid min_heapify(int i)\n{\n\tint l, r, min;\n\tQUE qt;\n\n\tl = LEFT(i), r = RIGHT(i);\n\tif (l < qsize && que[l].t < que[i].t) min = l; else min = i;\n\tif (r < qsize && que[r].t < que[min].t) min = r;\n\tif (min != i) {\n\t\tqt = que[i], que[i] = que[min], que[min] = qt;\n\t\tmin_heapify(min);\n\t}\n}\n\nvoid deq()\n{\n//\tif (qsize == 0) return 0;\n//\t*n = que[0].node, *t = que[0].t, *c = que[0].c;\n\tque[0] = que[--qsize];\n\tmin_heapify(0);\n//\treturn 1;\n}\n\nint qmax;\nvoid enq(int n, double t, int c)\n{\n\tint i, min;\n\tQUE qt;\n\n\ti = qsize++;\t//if (qsize > qmax) qmax = qsize;\n\tque[i].t = t, que[i].node = n, que[i].c = c;\n\twhile (i > 0 && que[min = PARENT(i)].t > que[i].t) {\n\t\tqt = que[i], que[i] = que[min], que[min] = qt;\n\t\ti = min;\n\t}\n}\n\n#define INF 1e10\n#define MAX 31\ntypedef struct { int to[MAX], d[MAX]; } TBL;\nTBL tbl[MAX];\nint len[MAX];\nint t[8];\ndouble node[MAX][256];\nchar visited[MAX][256];\n\n\nvoid dijkstra(int start, int goal, int N)\n{\n\tint i, j, jj, s, e, c, lim;\n\tdouble tm;\n\n\tqsize = 0;\n\tmemset(visited, 0, sizeof(visited));\n\tfor (lim = 1<= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);\n\treturn n;\n}\n\nint main()\n{\n\tint N, M, P, A, B, i, k, x, y, z, lim;\n\tdouble ans;\n\n\twhile (fgets(bp=buf, 40, stdin) && *bp != '0') {\n\t\tN = getint(), bp++, M = getint(), bp++;\n\t\tP = getint(), bp++, A = getint()-1, bp++, B = getint()-1;\n\t\tmemset(len, 0, sizeof(len));\n\t\tfgets(bp=buf, 40, stdin);\n\t\tfor (i = 0; i < N; i++) t[i] = getint(), bp++;\n\t\tfor (i = 0; i < P; i++) {\n\t\t\tfgets(bp=buf, 40, stdin);\n\t\t\tx = getint()-1, bp++, y = getint()-1, bp++, z = getint();\n\t\t\tk = len[x], tbl[x].to[k] = y, tbl[x].d[k] = z, len[x]++;\n\t\t\tk = len[y], tbl[y].to[k] = x, tbl[y].d[k] = z, len[y]++;\n\t\t}\n\t\tdijkstra(A, B, N);\n\t\tfor (ans = INF, lim = 1<\n\nint main() {\n long a, d, n;\n long i, j;\n\n while(1) {\n scanf(\"%ld %ld %ld\", &a, &d, &n);\n if(a > 9307 || d > 346 || n > 210)\n scanf(\"%ld %ld %ld\", &a, &d, &n);\n else if(a == 0 && d == 0 && n == 0)\n break;\n i = 1;\n\n if((a % 2) == 0) {\n i++;\n if(i <= n)\n a = a + d;\n }\n\n do {\n for(j = 3; j < a; j+=2) {\n if((a % j) == 0)\n break;\n if(a < (j + 2))\n i+=1;\n }\n if(i <= n)\n a = a + d;\n } while(i <= n);\n\n printf(\"%ld\\n\", a);\n }\n\n return 0;\n}", "language": "C", "metadata": {"date": 1502549669, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00722.html", "problem_id": "p00722", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00722/input.txt", "sample_output_relpath": "derived/input_output/data/p00722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00722/C/s664156017.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s664156017", "user_id": "u036867520"}, "prompt_components": {"gold_output": "92809\n6709\n12037\n103\n93523\n14503\n2\n899429\n5107\n412717\n22699\n25673\n", "input_to_evaluate": "#include \n\nint main() {\n long a, d, n;\n long i, j;\n\n while(1) {\n scanf(\"%ld %ld %ld\", &a, &d, &n);\n if(a > 9307 || d > 346 || n > 210)\n scanf(\"%ld %ld %ld\", &a, &d, &n);\n else if(a == 0 && d == 0 && n == 0)\n break;\n i = 1;\n\n if((a % 2) == 0) {\n i++;\n if(i <= n)\n a = a + d;\n }\n\n do {\n for(j = 3; j < a; j+=2) {\n if((a % j) == 0)\n break;\n if(a < (j + 2))\n i+=1;\n }\n if(i <= n)\n a = a + d;\n } while(i <= n);\n\n printf(\"%ld\\n\", a);\n }\n\n return 0;\n}", "problem_context": "Problem A: Dirichlet's Theorem on Arithmetic Progressions\n\nGood evening, contestants.\n\nIf a and d are relatively prime positive integers,\nthe arithmetic sequence beginning with a\nand increasing by d, i.e.,\na,\na + d,\na + 2d,\na + 3d,\na + 4d,\n...,\ncontains infinitely many prime numbers.\nThis fact is known as Dirichlet's Theorem on Arithmetic Progressions,\nwhich had been conjectured by Johann Carl Friedrich Gauss (1777 - 1855)\nand was proved by Johann Peter Gustav Lejeune Dirichlet (1805 - 1859)\nin 1837.\n\nFor example,\nthe arithmetic sequence beginning with 2 and increasing by 3,\ni.e.,\n\n2,\n5,\n8,\n11,\n14,\n17,\n20,\n23,\n26,\n29,\n32,\n35,\n38,\n41,\n44,\n47,\n50,\n53,\n56,\n59,\n62,\n65,\n68,\n71,\n74,\n77,\n80,\n83,\n86,\n89,\n92,\n95,\n98,\n...\n,\n\ncontains infinitely many prime numbers\n\n2,\n5,\n11,\n17,\n23,\n29,\n41,\n47,\n53,\n59,\n71,\n83,\n89,\n...\n\n.\n\nYour mission, should you decide to accept it,\nis to write a program to find\nthe nth prime number in this arithmetic sequence\nfor given positive integers a, d, and n.\n\nAs always, should you or any of your team be tired or confused,\nthe secretary disavow any knowledge of your actions.\nThis judge system will self-terminate in three hours.\nGood luck!\n\nInput\n\nThe input is a sequence of datasets.\nA dataset is a line containing three positive integers\na, d, and n separated by a space.\na and d are relatively prime.\nYou may assume a <= 9307, d <= 346,\nand n <= 210.\n\nThe end of the input is indicated by a line\ncontaining three zeros separated by a space.\nIt is not a dataset.\n\nOutput\n\nThe output should be composed of\nas many lines as the number of the input datasets.\nEach line should contain a single integer\nand should never contain extra characters.\n\nThe output integer corresponding to\na dataset a, d, n should be\nthe nth\nprime number among those contained\nin the arithmetic sequence beginning with a\nand increasing by d.\n\nFYI, it is known that the result is always less than\n106 (one million)\nunder this input condition.\n\nSample Input\n\n367 186 151\n179 10 203\n271 37 39\n103 230 1\n27 104 185\n253 50 85\n1 1 1\n9075 337 210\n307 24 79\n331 221 177\n259 170 40\n269 58 102\n0 0 0\n\nOutput for the Sample Input\n\n92809\n6709\n12037\n103\n93523\n14503\n2\n899429\n5107\n412717\n22699\n25673", "sample_input": "367 186 151\n179 10 203\n271 37 39\n103 230 1\n27 104 185\n253 50 85\n1 1 1\n9075 337 210\n307 24 79\n331 221 177\n259 170 40\n269 58 102\n0 0 0\n"}, "reference_outputs": ["92809\n6709\n12037\n103\n93523\n14503\n2\n899429\n5107\n412717\n22699\n25673\n"], "source_document_id": "p00722", "source_text": "Problem A: Dirichlet's Theorem on Arithmetic Progressions\n\nGood evening, contestants.\n\nIf a and d are relatively prime positive integers,\nthe arithmetic sequence beginning with a\nand increasing by d, i.e.,\na,\na + d,\na + 2d,\na + 3d,\na + 4d,\n...,\ncontains infinitely many prime numbers.\nThis fact is known as Dirichlet's Theorem on Arithmetic Progressions,\nwhich had been conjectured by Johann Carl Friedrich Gauss (1777 - 1855)\nand was proved by Johann Peter Gustav Lejeune Dirichlet (1805 - 1859)\nin 1837.\n\nFor example,\nthe arithmetic sequence beginning with 2 and increasing by 3,\ni.e.,\n\n2,\n5,\n8,\n11,\n14,\n17,\n20,\n23,\n26,\n29,\n32,\n35,\n38,\n41,\n44,\n47,\n50,\n53,\n56,\n59,\n62,\n65,\n68,\n71,\n74,\n77,\n80,\n83,\n86,\n89,\n92,\n95,\n98,\n...\n,\n\ncontains infinitely many prime numbers\n\n2,\n5,\n11,\n17,\n23,\n29,\n41,\n47,\n53,\n59,\n71,\n83,\n89,\n...\n\n.\n\nYour mission, should you decide to accept it,\nis to write a program to find\nthe nth prime number in this arithmetic sequence\nfor given positive integers a, d, and n.\n\nAs always, should you or any of your team be tired or confused,\nthe secretary disavow any knowledge of your actions.\nThis judge system will self-terminate in three hours.\nGood luck!\n\nInput\n\nThe input is a sequence of datasets.\nA dataset is a line containing three positive integers\na, d, and n separated by a space.\na and d are relatively prime.\nYou may assume a <= 9307, d <= 346,\nand n <= 210.\n\nThe end of the input is indicated by a line\ncontaining three zeros separated by a space.\nIt is not a dataset.\n\nOutput\n\nThe output should be composed of\nas many lines as the number of the input datasets.\nEach line should contain a single integer\nand should never contain extra characters.\n\nThe output integer corresponding to\na dataset a, d, n should be\nthe nth\nprime number among those contained\nin the arithmetic sequence beginning with a\nand increasing by d.\n\nFYI, it is known that the result is always less than\n106 (one million)\nunder this input condition.\n\nSample Input\n\n367 186 151\n179 10 203\n271 37 39\n103 230 1\n27 104 185\n253 50 85\n1 1 1\n9075 337 210\n307 24 79\n331 221 177\n259 170 40\n269 58 102\n0 0 0\n\nOutput for the Sample Input\n\n92809\n6709\n12037\n103\n93523\n14503\n2\n899429\n5107\n412717\n22699\n25673", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 566, "cpu_time_ms": 20000, "memory_kb": 552}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s220298018", "group_id": "codeNet:p00740", "input_text": "//Number 1159\n#include \n\nint main(void)\n{\n int i, n, p, stone = 0;\n int human[50] = {0};\n\n while(1)\n {\n scanf(\"%d %d\", &n, &p);\n\n stone = p;\n if(n == 0 && p == 0)\n\tbreak;\n\n for(i=0; i\n\nint main(void)\n{\n int i, n, p, stone = 0;\n int human[50] = {0};\n\n while(1)\n {\n scanf(\"%d %d\", &n, &p);\n\n stone = p;\n if(n == 0 && p == 0)\n\tbreak;\n\n for(i=0; i\n#include \n#include \n#include \n\n#define N 13\n#define L 9\n#define DIG 10\n#define VCMAX 12\n#define CMAX 128\n#define TRUE 1\n#define FALSE 0\n\nint n;\nint cnum;\nchar m[N][L];\nchar f[CMAX];\nint non_zero[CMAX];\nchar vc[VCMAX];\nchar onenum[VCMAX];\nint used[DIG];\nint mlen[N];\nint onum;\nint g_cnt;\n\nvoid ResetGlobal(){\n int i,j;\n n = onum = cnum = 0;\n for(i = 0; i < CMAX;++i){\n f[i]=0;\n non_zero[i]=FALSE;\n }\n for(i = 0; i < DIG; ++i){\n used[i] = FALSE;\n }\n for(i = 0; i < VCMAX; ++i){\n vc[i]=0;\n onenum[i]=0;\n }\n for(i = 0; i < N; ++i){\n mlen[i]=0;\n for(j = 0; j < L; ++j){\n m[i][j] = 0;\n }\n }\n}\n\nint dfs(int depth){\n int i,j;\n int ret = 0;\n\n int t=0;\n int cnt=0;\n\n for(i = 0; i < onum; ++i){\n if(f[onenum[i]]>='0'){++cnt;}\n }\n\n if(cnt==onum){\n for(i=0;i=0&&t%10!=ld) || (ld<0&&used[t%10]) ){\n return 0;\n }\n /*\n if(mlen[n-1]==1&&t>=10)return 0;\n if(mlen[n-1]>1){\n int c=f[m[n-1][mlen[n-1]-2]];\n if(c>='0'&&t>=10&&){\n\tfor(i = 0; i < n; ++i){\n\t for(j=0;j= 0; --j){\n\tm[i][j] = buf[j];\n\tint bFound=FALSE;\n\tif(j==len-1){\n\t for(k=0;k1)non_zero[buf[j]]=TRUE;\n }\n }\n\n /*\n for(i=0;i\n#include \n#include \n#include \n\n#define N 13\n#define L 9\n#define DIG 10\n#define VCMAX 12\n#define CMAX 128\n#define TRUE 1\n#define FALSE 0\n\nint n;\nint cnum;\nchar m[N][L];\nchar f[CMAX];\nint non_zero[CMAX];\nchar vc[VCMAX];\nchar onenum[VCMAX];\nint used[DIG];\nint mlen[N];\nint onum;\nint g_cnt;\n\nvoid ResetGlobal(){\n int i,j;\n n = onum = cnum = 0;\n for(i = 0; i < CMAX;++i){\n f[i]=0;\n non_zero[i]=FALSE;\n }\n for(i = 0; i < DIG; ++i){\n used[i] = FALSE;\n }\n for(i = 0; i < VCMAX; ++i){\n vc[i]=0;\n onenum[i]=0;\n }\n for(i = 0; i < N; ++i){\n mlen[i]=0;\n for(j = 0; j < L; ++j){\n m[i][j] = 0;\n }\n }\n}\n\nint dfs(int depth){\n int i,j;\n int ret = 0;\n\n int t=0;\n int cnt=0;\n\n for(i = 0; i < onum; ++i){\n if(f[onenum[i]]>='0'){++cnt;}\n }\n\n if(cnt==onum){\n for(i=0;i=0&&t%10!=ld) || (ld<0&&used[t%10]) ){\n return 0;\n }\n /*\n if(mlen[n-1]==1&&t>=10)return 0;\n if(mlen[n-1]>1){\n int c=f[m[n-1][mlen[n-1]-2]];\n if(c>='0'&&t>=10&&){\n\tfor(i = 0; i < n; ++i){\n\t for(j=0;j= 0; --j){\n\tm[i][j] = buf[j];\n\tint bFound=FALSE;\n\tif(j==len-1){\n\t for(k=0;k1)non_zero[buf[j]]=TRUE;\n }\n }\n\n /*\n for(i=0;i\n#include \n\n#define MAX_DATA 201\n\nstruct data {\n int mom;\n int hou;\n};\n\nint board[MAX_DATA][MAX_DATA];\nint mimasita[MAX_DATA][MAX_DATA];\nstruct data dataset[MAX_DATA];\nint n, l, ans_x1, ans_y1, ans_x2, ans_y2;\n\nvoid cl_array(void);\nvoid tansaku(int num, int x, int y);\nvoid make_board(void);\nvoid search_ans(int x, int y);\n\nint main(void) {\n int i, j, ans;\n scanf(\"%d\",&n);\n while(n != 0) {\n cl_array();\n for(i = 1; i < n; i++) {\n scanf(\"%d %d\",&dataset[i].mom, &dataset[i].hou);\n }\n make_board();\n //puts(\"探索終了\");\n search_ans(100, 100);\n printf(\"%d %d\\n\",ans_x2-ans_x1+1, ans_y2-ans_y1+1);\n scanf(\"%d\",&n);\n }\n return 0;\n}\n\nvoid make_board(void) {\n int i;\n board[100][100] = 0;\n for(i = 1; i < n; i++) {\n tansaku(i, 100, 100);\n }\n}\n\nvoid tansaku(int num, int x, int y) {\n if(board[x][y] == -1 || x < 0 || y < 0\n || x >= MAX_DATA || y >= MAX_DATA || mimasita[x][y] == num) {\n return;\n }\n mimasita[x][y] = num;\n if(board[x][y] != dataset[num].mom) {\n tansaku(num, x-1, y);\n tansaku(num, x, y-1);\n tansaku(num, x+1, y);\n tansaku(num, x, y+1);\n } else {\n if(dataset[num].hou == 0) {\n board[x-1][y] = num;\n } else if(dataset[num].hou == 1) {\n board[x][y+1] = num;\n } else if(dataset[num].hou == 2) {\n board[x+1][y] = num;\n } else if(dataset[num].hou == 3) {\n board[x][y-1] = num;\n }\n return;\n }\n}\n\nvoid cl_array(void) {\n int i, j;\n ans_x1 = 201;\n ans_x2 = -1;\n ans_y1 = 201;\n ans_y2 = -1;\n for(i = 0; i < MAX_DATA; i++) {\n for(j = 0; j < MAX_DATA; j++) {\n mimasita[i][j] = 0;\n board[i][j] = -1;\n }\n }\n}\n\nvoid search_ans(int x, int y) {\n int i, j;\n for(i = 0; i < MAX_DATA; i++) {\n for(j = 0; j < MAX_DATA; j++) {\n if(board[i][j] != -1) {\n if(i < ans_x1) {\n ans_x1 = i;\n }\n if(i > ans_x2) {\n ans_x2 = i;\n }\n if(j < ans_y1) {\n ans_y1 = j;\n }\n if(j > ans_y2) {\n ans_y2 = j;\n }\n }\n }\n }\n}", "language": "C", "metadata": {"date": 1451783351, "filename_ext": "c", "original_language": "C", "problem_description_relpath": "problem_descriptions/p00746.html", "problem_id": "p00746", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00746/input.txt", "sample_output_relpath": "derived/input_output/data/p00746/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00746/C/s468423713.c", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s468423713", "user_id": "u648717067"}, "prompt_components": {"gold_output": "1 1\n3 3\n4 4\n5 6\n", "input_to_evaluate": "#include \n#include \n\n#define MAX_DATA 201\n\nstruct data {\n int mom;\n int hou;\n};\n\nint board[MAX_DATA][MAX_DATA];\nint mimasita[MAX_DATA][MAX_DATA];\nstruct data dataset[MAX_DATA];\nint n, l, ans_x1, ans_y1, ans_x2, ans_y2;\n\nvoid cl_array(void);\nvoid tansaku(int num, int x, int y);\nvoid make_board(void);\nvoid search_ans(int x, int y);\n\nint main(void) {\n int i, j, ans;\n scanf(\"%d\",&n);\n while(n != 0) {\n cl_array();\n for(i = 1; i < n; i++) {\n scanf(\"%d %d\",&dataset[i].mom, &dataset[i].hou);\n }\n make_board();\n //puts(\"探索終了\");\n search_ans(100, 100);\n printf(\"%d %d\\n\",ans_x2-ans_x1+1, ans_y2-ans_y1+1);\n scanf(\"%d\",&n);\n }\n return 0;\n}\n\nvoid make_board(void) {\n int i;\n board[100][100] = 0;\n for(i = 1; i < n; i++) {\n tansaku(i, 100, 100);\n }\n}\n\nvoid tansaku(int num, int x, int y) {\n if(board[x][y] == -1 || x < 0 || y < 0\n || x >= MAX_DATA || y >= MAX_DATA || mimasita[x][y] == num) {\n return;\n }\n mimasita[x][y] = num;\n if(board[x][y] != dataset[num].mom) {\n tansaku(num, x-1, y);\n tansaku(num, x, y-1);\n tansaku(num, x+1, y);\n tansaku(num, x, y+1);\n } else {\n if(dataset[num].hou == 0) {\n board[x-1][y] = num;\n } else if(dataset[num].hou == 1) {\n board[x][y+1] = num;\n } else if(dataset[num].hou == 2) {\n board[x+1][y] = num;\n } else if(dataset[num].hou == 3) {\n board[x][y-1] = num;\n }\n return;\n }\n}\n\nvoid cl_array(void) {\n int i, j;\n ans_x1 = 201;\n ans_x2 = -1;\n ans_y1 = 201;\n ans_y2 = -1;\n for(i = 0; i < MAX_DATA; i++) {\n for(j = 0; j < MAX_DATA; j++) {\n mimasita[i][j] = 0;\n board[i][j] = -1;\n }\n }\n}\n\nvoid search_ans(int x, int y) {\n int i, j;\n for(i = 0; i < MAX_DATA; i++) {\n for(j = 0; j < MAX_DATA; j++) {\n if(board[i][j] != -1) {\n if(i < ans_x1) {\n ans_x1 = i;\n }\n if(i > ans_x2) {\n ans_x2 = i;\n }\n if(j < ans_y1) {\n ans_y1 = j;\n }\n if(j > ans_y2) {\n ans_y2 = j;\n }\n }\n }\n }\n}", "problem_context": "Problem A: Pablo Squarson's Headache\n\nPablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is \"Squares\". Today we are visiting his studio to see how his masterpieces are given birth.\n\nAt the center of his studio, there is a huuuuuge table and beside it are many, many squares of the same size. Pablo Squarson puts one of the squares on the table. Then he places some other squares on the table in sequence. It seems his methodical nature forces him to place each square side by side to the one that he already placed on, with machine-like precision.\n\nOh! The first piece of artwork is done. Pablo Squarson seems satisfied with it. Look at his happy face.\n\nOh, what's wrong with Pablo? He is tearing his hair! Oh, I see. He wants to find a box that fits the new piece of work but he has trouble figuring out its size. Let's help him!\n\nYour mission is to write a program that takes instructions that record how Pablo made a piece of his artwork and computes its width and height. It is known that the size of each square is 1. You may assume that Pablo does not put a square on another.\n\nI hear someone murmured \"A smaller box will do\". No, poor Pablo, shaking his head, is grumbling \"My square style does not seem to be understood by illiterates\".\n\nInput\n\nThe input consists of a number of datasets. Each dataset represents the way Pablo made a piece of his artwork. The format of a dataset is as follows.\n\nN\n\nn1 d1\n\nn2 d2\n\n...\n\nnN-1 dN-1\n\nThe first line contains the number of squares (= N) used to make the piece of artwork. The number is a positive integer and is smaller than 200.\n\nThe remaining (N-1) lines in the dataset are square placement instructions. The line “ni di” indicates placement of the square numbered i (≤ N-1). The rules of numbering squares are as follows. The first square is numbered \"zero\". Subsequently placed squares are numbered 1, 2, ..., (N-1). Note that the input does not give any placement instruction to the first square, which is numbered zero.\n\nA square placement instruction for the square numbered i, namely “ni di”, directs it to be placed next to the one that is numbered ni, towards the direction given by di, which denotes leftward (= 0), downward (= 1), rightward (= 2), and upward (= 3).\n\nFor example, pieces of artwork corresponding to the four datasets shown in Sample Input are depicted below. Squares are labeled by their numbers.\n\nThe end of the input is indicated by a line that contains a single zero.\n\nOutput\n\nFor each dataset, output a line that contains the width and the height of the piece of artwork as decimal numbers, separated by a space. Each line should not contain any other characters.\n\nSample Input\n\n1\n5\n0 0\n0 1\n0 2\n0 3\n12\n0 0\n1 0\n2 0\n3 1\n4 1\n5 1\n6 2\n7 2\n8 2\n9 3\n10 3\n10\n0 2\n1 2\n2 2\n3 2\n2 1\n5 1\n6 1\n7 1\n8 1\n0\n\nOutput for the Sample Input\n\n1 1\n3 3\n4 4\n5 6", "sample_input": "1\n5\n0 0\n0 1\n0 2\n0 3\n12\n0 0\n1 0\n2 0\n3 1\n4 1\n5 1\n6 2\n7 2\n8 2\n9 3\n10 3\n10\n0 2\n1 2\n2 2\n3 2\n2 1\n5 1\n6 1\n7 1\n8 1\n0\n"}, "reference_outputs": ["1 1\n3 3\n4 4\n5 6\n"], "source_document_id": "p00746", "source_text": "Problem A: Pablo Squarson's Headache\n\nPablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is \"Squares\". Today we are visiting his studio to see how his masterpieces are given birth.\n\nAt the center of his studio, there is a huuuuuge table and beside it are many, many squares of the same size. Pablo Squarson puts one of the squares on the table. Then he places some other squares on the table in sequence. It seems his methodical nature forces him to place each square side by side to the one that he already placed on, with machine-like precision.\n\nOh! The first piece of artwork is done. Pablo Squarson seems satisfied with it. Look at his happy face.\n\nOh, what's wrong with Pablo? He is tearing his hair! Oh, I see. He wants to find a box that fits the new piece of work but he has trouble figuring out its size. Let's help him!\n\nYour mission is to write a program that takes instructions that record how Pablo made a piece of his artwork and computes its width and height. It is known that the size of each square is 1. You may assume that Pablo does not put a square on another.\n\nI hear someone murmured \"A smaller box will do\". No, poor Pablo, shaking his head, is grumbling \"My square style does not seem to be understood by illiterates\".\n\nInput\n\nThe input consists of a number of datasets. Each dataset represents the way Pablo made a piece of his artwork. The format of a dataset is as follows.\n\nN\n\nn1 d1\n\nn2 d2\n\n...\n\nnN-1 dN-1\n\nThe first line contains the number of squares (= N) used to make the piece of artwork. The number is a positive integer and is smaller than 200.\n\nThe remaining (N-1) lines in the dataset are square placement instructions. The line “ni di” indicates placement of the square numbered i (≤ N-1). The rules of numbering squares are as follows. The first square is numbered \"zero\". Subsequently placed squares are numbered 1, 2, ..., (N-1). Note that the input does not give any placement instruction to the first square, which is numbered zero.\n\nA square placement instruction for the square numbered i, namely “ni di”, directs it to be placed next to the one that is numbered ni, towards the direction given by di, which denotes leftward (= 0), downward (= 1), rightward (= 2), and upward (= 3).\n\nFor example, pieces of artwork corresponding to the four datasets shown in Sample Input are depicted below. Squares are labeled by their numbers.\n\nThe end of the input is indicated by a line that contains a single zero.\n\nOutput\n\nFor each dataset, output a line that contains the width and the height of the piece of artwork as decimal numbers, separated by a space. Each line should not contain any other characters.\n\nSample Input\n\n1\n5\n0 0\n0 1\n0 2\n0 3\n12\n0 0\n1 0\n2 0\n3 1\n4 1\n5 1\n6 2\n7 2\n8 2\n9 3\n10 3\n10\n0 2\n1 2\n2 2\n3 2\n2 1\n5 1\n6 1\n7 1\n8 1\n0\n\nOutput for the Sample Input\n\n1 1\n3 3\n4 4\n5 6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2371, "cpu_time_ms": 10, "memory_kb": 928}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C:s612886413", "group_id": "codeNet:p00770", "input_text": "#include \n#include \n#include \n#include \ntypedef long long int ll;\nlong long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}\nlong long LCM(long long a, long long b) {return a/GCD(a,b)*b;}\n#define mmax(x,y)(x>y?x:y)\n#define mmin(x,y)(xd)return;\n\tif(dmax[x][y]!=0&&dmax[x][y]==d)return;\n\tchmax(dmax[x][y],d);\n\n\tint i=0;\n\tfor(i=-1;i<=1;i++){\n\t\tint nx=x+1,ny=y+i;\n\t\tif(nx>=0&&nx<3000&&ny>=0&&ny<3000){\n\t\t\tif(G[nx][ny]!=-1){\n\t\t\t\tif(color[nx][ny]==0){\n\t\t\t\t\tcolor[nx][ny]=1;\n\t\t\t\t\tif(Prime[G[nx][ny]]==0){\n\t\t\t\t\t\td++;\n\t\t\t\t\t\tif(ans0&&m>0){\n\t\tans=0;pans=0;\n\t\tfor(i=0;i<3000;i++){\n\t\t\tfor(j=0;j<3000;j++){\n\t\t\t\tG[i][j]=-1;\n\t\t\t}\n\t\t}\n\t\tmemset(color,0,sizeof(color));\n\t\tmemset(dmax,0,sizeof(dmax));\n\t\ti=1500;j=1500;\n\t\tint now=1;int turn =0;int len=1;\n\t\tint cnt=0;\n\t\twhile(m){\n\t\t\t//G[i][j]=now++;\n\t\t\tfor(k=0;k\n#include \n#include \n#include \ntypedef long long int ll;\nlong long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}\nlong long LCM(long long a, long long b) {return a/GCD(a,b)*b;}\n#define mmax(x,y)(x>y?x:y)\n#define mmin(x,y)(xd)return;\n\tif(dmax[x][y]!=0&&dmax[x][y]==d)return;\n\tchmax(dmax[x][y],d);\n\n\tint i=0;\n\tfor(i=-1;i<=1;i++){\n\t\tint nx=x+1,ny=y+i;\n\t\tif(nx>=0&&nx<3000&&ny>=0&&ny<3000){\n\t\t\tif(G[nx][ny]!=-1){\n\t\t\t\tif(color[nx][ny]==0){\n\t\t\t\t\tcolor[nx][ny]=1;\n\t\t\t\t\tif(Prime[G[nx][ny]]==0){\n\t\t\t\t\t\td++;\n\t\t\t\t\t\tif(ans0&&m>0){\n\t\tans=0;pans=0;\n\t\tfor(i=0;i<3000;i++){\n\t\t\tfor(j=0;j<3000;j++){\n\t\t\t\tG[i][j]=-1;\n\t\t\t}\n\t\t}\n\t\tmemset(color,0,sizeof(color));\n\t\tmemset(dmax,0,sizeof(dmax));\n\t\ti=1500;j=1500;\n\t\tint now=1;int turn =0;int len=1;\n\t\tint cnt=0;\n\t\twhile(m){\n\t\t\t//G[i][j]=now++;\n\t\t\tfor(k=0;k