exec_outcome stringclasses 1
value | code_uid stringlengths 32 32 | file_name stringclasses 111
values | prob_desc_created_at stringlengths 10 10 | prob_desc_description stringlengths 63 3.8k | prob_desc_memory_limit stringclasses 18
values | source_code stringlengths 117 65.5k | lang_cluster stringclasses 1
value | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_time_limit stringclasses 27
values | prob_desc_sample_outputs stringlengths 2 796 | prob_desc_notes stringlengths 4 3k ⌀ | lang stringclasses 5
values | prob_desc_input_from stringclasses 3
values | tags listlengths 0 11 | src_uid stringlengths 32 32 | prob_desc_input_spec stringlengths 28 2.37k ⌀ | difficulty int64 -1 3.5k ⌀ | prob_desc_output_spec stringlengths 17 1.47k ⌀ | prob_desc_output_to stringclasses 3
values | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | 29b33ee5826538a8270215fe1ca95b4b | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes |
import java.util.Scanner;
public class divide {
public static void main(String[] args) {
Scanner ip=new Scanner(System.in);
int t=ip.nextInt();
long a[]=new long[t];
for(int i=0;i<t;i++)
{
a[i]=ip.nextLong();
}
for(int i=0;i<t;i++)
{ int count=0;
long num=a[i];
Boolean c=true;
while (nu... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 3168a3d22afa8b2848ec628edffadf2e | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class divideit{
static int steps(long k){
if(k%5!=0 && k%3!=0 && ((k&(k-1))!=0) &&k>1)
return Integer.MIN_VALUE;
if(k==1)
return 0;
if(k%5==0)
return 1+steps(4*(k/5));
else if(k%3==0)
return 1+steps(2*(k/3));
else if(... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | fa70950329d5e47232487d417e8de0f8 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class DivideIt {
private static int solve(long n) {
int moves = 0;
while (n > 1) {
if ((n % 2) == 0) {
n /= 2;
} else if ((n % 3) == 0) {
n = n / 3 * 2;
} else if ((n % 5) == 0) {
n = n / 5 * 4;
} else {
return -1;
}
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | df068810d0479ff1d9e3c543e337a074 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | // https://codeforces.com/problemset/problem/1176/A
import java.util.*;
public class DivideIt {
private static int solve(long n) {
int moves = 0;
while (n > 1) {
if ((n % 2) == 0) {
n /= 2;
} else if ((n % 3) == 0) {
n = n / 3 * 2;
} else if ((n % 5) == 0) {
n = n /... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 038ab592615f1069e2f45726f7685462 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
import static java.lang.Math.*;
public class Demo{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int q = in.nextInt();
while(q-->0){
int r=0;
long n = in.nextLong();
int a=0,b=0,c=0;
while (n!=1){
if (n%2==0){
n/=2;
a++;
} else ... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 1f8545041b6d2e362d0776c0963ed63a | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class Greedy_A_DivideIt {
public static void main(String[] args) throws Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
Long n=sc.nextLong();
solve(n);
}
sc.close();
}
public static void solve(Long n) {
int count=0;
while(n!... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 78ddc66339d680cebbfafcf1cc5706ef | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class _0166Divideit {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int cases=sc.nextInt();
while(cases>0) {
long n=sc.nextLong();
int moves=0;
while(n>1) {
if(n%5==0) {
n=4*n/5;
}
else if(n%3==0) {
n=2*n/3;
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | ff1c2d598e8bd391e73d0e263e852983 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | /*==============================================
Name : Shadman Shariar ||
Email : shadman.shariar@northsouth.edu ||
University : North South University (NSU) ||
Facebook : shadman.shahriar.007 ||
==============================================*/
import java.util.Scanner;
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | ff9dadf20220e482ad85c579ea59f0f7 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class java {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int tt = s.nextInt();
while(tt-- > 0) {
long n = s.nextLong();
int a = 0, b = 0, c = 0;
while(n%2 == 0) {
n /= 2;
a++;
}
while(n%3 == 0) {
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | f748172ead9396dc1645459981645427 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
//import java.util.Scanner;
/**
*
* @author DELL
*/
public class Main{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int track=1;
int t=sc.nextInt();
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | b58b6eee2655081886d5973b8c011eac | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class A1176 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int q = input.nextInt();
for (int i = 0; i < q; i++) {
int counter = 0;
long n = input.nextLong();
while(n%5 == 0){
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 02bf3e02d13a3178086d762108d0ba27 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Compa... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | be1827b560ca9968104cbe00f2d2accd | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class DivideIt{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t>0)
{
long n = sc.nextLong();
long count=0;
int flag=0;
while(n>1)
{
if(n%2==0)
{
count++;
n=n/2;
}
else if(n%3==0)
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 06f8411ff43145825c2c0dd6a035778d | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int q = input.nextInt();
while(q-->0) {
long n = input.nextLong();
int count = 0;
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | d78bf986c5153cb8abc2f4fd4e020646 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int o=sc.nextInt();
while(o-->0) {
long a=sc.nextLong();
int sum = 0;
while(a%5==0) {
a=a/5*4;
sum++;
}
while(a%3==0) {
a=a/3*2;
sum++;
}
while(a%2==0) {
a/=2;
sum++... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 137a71c834e9f2f2e77673d7f86d0c70 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner input ... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | a1a7f1433ffbde8270319dbe105222c2 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) {
FastReader sc=new FastReader();
int t=sc.nextInt();
StringBuilder sb=new StringBuilder();
while(t-->0) {
long n=sc.nextLong();
long k=n;
int c1=0,c2=0,c3=0;
while(k%5==0) {
c1++;
k=4*k/5;
}... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | ac43943980ff456f39aa5359c1ed0a8e | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class cf_1176_a {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tt = sc.nextInt();
while (tt-- > 0) {
long ans = 0;
long n = sc.nextLong();
while (true) {
if (n % 2 == 0)... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 5656a6047ebf10e3acade06c45bc63fc | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays;
import java.math.BigInteger;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | ca14aa807dbd338ca9242714b795d595 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class d {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int q,count=0;
q=input.nextInt();
for(int i=0;i<q;i++){
long n,a;
n=input.nextLong();
a=n;
while(a!=1){
if(a%2==0){
a=a/... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 6760dba8ed3046e371f03f41e87b1808 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
int t = s.nextInt();
while(t-->0){
long n = s.nextLong();
int count = 0;
while(n>1){
if(n%5 == 0)
n = 4*n/5;
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 6bd5d4ec887f2fa5cb3f418f660092e8 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A1176_DivideIt {
public static void main(String[] args) {
PrintWriter pw = new PrintWriter(System.out);
int q = nextInt();
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 16902952e324ae3ca7ba73f5f5452fe7 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.math.*;
public class Solution{
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int test = sc.nextInt();
while(test -->0){
long n = sc.nextLong();
int c1 = 0,c2 = 0, c3 =0;
whi... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 6a590057ce02465df73951042dd7750e | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class codeforces
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-->0){
long x = sc.nextLong();
int num = 0;
while(x%5==0... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 7afddddff8c261d335898f3a60b35579 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
import java.io.*;
// Compiler version JDK 11.0.2
public class Dcoder
{
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br = new BufferedReader(new InputStreamReader(System.in));
}
String next(){
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 6f3340c92bdcd83143c69fd8648775c4 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | //package com.company;
import java.io.*;
import java.util.*;
public class Divideit {
public static void main(String[] args) {
out = new PrintWriter(new BufferedOutputStream(System.out));
MyScanner sc = new MyScanner();//start
int n=sc.nextInt();
while (0<n--){
long x =... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 99df3f12bd706b36ceaa33f82ca1245f | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
import java.lang.Math;
public class Hello{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i = 0; i<t; i++){
long n = sc.nextLong(), five = 0, three = 0, two = 0;
while(n%5==0){
n = n/5;
five++;
}
while(n%3... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 8b6b6bcc32507c5e2c027c382b728188 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class DivideIt {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int q = sc.nextInt();
while (q > 0) {
long n = sc.nextLong();
int count = 0;
while (n > 1) {
if (n % 2 == 0) {
n /= 2;
} else if (n % 3 == 0) {
n = (n * 2... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 22810b2fd9ca63a0c9236053640c3000 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | /*
Author: Anthony Ngene
Created: 18/09/2020 - 05:38
*/
import java.io.*;
import java.util.*;
public class A {
// The only thing we have to fear is fear itself. - Franklin CodeForces.Div3.CF1385_656.P1.D. Roosevelt
void solver() throws IOException {
int cases = in.intNext();
for (int t = 1... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 2b25cba656c891f17cda507f96d98276 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes |
import java.util.Scanner;
public class code {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- != 0){
long n = sc.nextLong();
int count =0;
boolean br = false;
while(n != 1){
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | bd64cfc2296fe785538ea8ab7252c76f | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | // Coded by Vishal Mourya - The Legendary Coder
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = ... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 4f5b64599b978ec2cae92eb026aa7533 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class Bulbs
{
private static int counter = 0;
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
while(n > 0)
{
long a = scanner.nextLong();
int res = func(a)... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | a64d81fceb68064a06189600659f9218 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
/**
*
* @author mm887
*/
public class DivideIt {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int cases = input.nextInt();
while(cases-- > 0){
long num = input.nextLong();
long tmp = 0;
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 8ddebe06cc63b4dbbaccd077c1969eaa | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class Divideit
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc != 0)
{
long num = sc.nextLong();
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 410990140c3f08a95d0c2d3ba7e93c72 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.io.*;
import java.util.*;
public class A
{
static long n;
static int[] arr;
static String str;
public static void main(String[] args) throws IOException
{
Flash f = new Flash();
int T = f.ni();
for(int tc = 1; tc <= T; tc++){
n = f.nl();
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 22391dedbd56fc5a5f12dca2c7859049 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class App
{
public static void main( String[] args )
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
long n = sc.nextLong();
int c = 0;
while(n>1)
{
if(n%2==0)
n = n/2;
else if(n%3==0)
n = 2*n/3;
else if(n%5==0)
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 80d73052c43d11e6643a78734331a7fd | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
// System.out.println("Hello World");
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
while(t-->0){
long n=scan.nextLong();
int count=0;
while(n!=1){
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | c87890584adc117390c3161d6169bbb4 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.lang.*;
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t!=0)
{
long n=s.nextLong();
int c=0;
while(n>1)
{
if(n%2==0... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | a55dd0e0082364750efad80b22ae86cf | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes |
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
public static void process()throws IOException
{
long n=nl();
long res=0l;
while(n%3==0){
res+=2;
n/=3;
}
while(n%5==0){
res+=3;
n/=5;
}
... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | dcf34a4cce4d1a0b4ec4f005a204d036 | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int t=in.nextInt();
while(t-->0)
{
long n=in.nextLong();
int status=0;
long count=0;
while(n!=1)
{
if(n%2==0)
{
count++... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | 55e46dc51216b536c1904476684fa31e | train_000.jsonl | 1560090900 | You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$; Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$; Replace $$$n$$$ with... | 256 megabytes | import java.io.*;
import java.util.*;
public class cc{
public static void main(String args[])throws Exception{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
long n=sc.nextLong();
//int a[]=new int[n];
//int m=a[0];
//for(int i=0;i<n;i+... | Java | ["7\n1\n10\n25\n30\n14\n27\n1000000000000000000"] | 1 second | ["0\n4\n6\n6\n-1\n6\n72"] | null | Java 11 | standard input | [
"implementation",
"greedy",
"brute force"
] | ed5ea0e664aa986ab86e4e6746e8a1bf | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$). | 800 | Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it. | standard output | |
PASSED | e0ba7be44cfc0fad3f819a43a8276be2 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.ArrayList;
import java.util.Vector;
import java.util.StringTokenizer;
import ja... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | bd00f06c79570126b039bf1573fbae75 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class E {
static ArrayList<ArrayList<Integer>> graph;
static boolean[] vis... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 821ebaedde966812fa1b8be638614bf1 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
StringBuffer out = new StringBuffer();
int t=in.nextInt();
while(t--!=0) {
int n=in.nextInt(),
m=in.nextInt();
int arr[]=new int... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 3e29c313a0516b06b596548459fd1e27 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;
public class B {
public static int n, a, b, c, m;
public static ArrayList<Integer... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | a70e44d41cf70432c9a79aabb0fcdef2 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 07ddc8303dfa8bb14ab8224a0c6846ba | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | /**
* The author of the following code is - Dewansh Nigam
* Username - dewanshnigam
* Unstoppable Now.
*/
import java.util.*;
import java.io.*;
public class Codeforces_NewBie_ProblemE
{
static InputReader in=new InputReader(System.in);
static OutputWriter out=new OutputWriter(System.out);
sta... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | f9ddd9db0b18d5a9798960468e8ecb8b | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | /*package whatever //do not write package name here */
import java.io.*;
import java.util.*;
public class GFG {
static int n,m,a,b,c;
static ArrayList<ArrayList<Integer>> edges=new ArrayList<>();
static int[] solveUtil(int a)
{
Queue<Integer> queue=new LinkedList<>();
queue.add(a)... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 8a81484429c48d27a6fba2fc6d7e68ec | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution implements Runnable{
FastScanner sc;
PrintWriter pw;
final class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
try {
br = new BufferedReader(new InputStreamReader(S... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 304df5fb5ae0f5f1e3d76688ac46871a | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | // package Div3_636;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class ProblemE {
public static void main(String[] args)throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int test=... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 5b4c2350c9cd936298265d54216f3ee1 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class E {
@SuppressWarnings("unchecked")
public static void main(String[] ar... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 7be64991c898ab6fe0259cfdb8cf504f | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static class InputReader {
private InputStream stream;
... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 9f37ed6ea87b5ff80f5f17edb8fbd628 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public static class FastReader {
BufferedReader br;
StringTokenizer root;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (root == null || !root.hasMoreTokens()) {
try {
... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 14324fc6f9b9fc4cdfc7c4415c8481a1 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes |
import java.util.*;
public class ProblemE {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
long T=scn.nextLong();
for(int t=0;t<T;t++){
int N=scn.nextInt();
int M=scn.nextInt();
int a=scn.nextInt();
int b=scn.nex... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | c1ea5f0ddb38d47ebd8c4338a1431aac | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
public class C636E
{
static class Edge implements Comparator<Edge>
{
int i;
int d;
public Edge()
{
}
public Edge(int i,int d)
{
this.i=i;
this.d=d;
}
public int compare(Edge a,Edge b)
{
... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | bb521ba368dd49c3420da3642f90c872 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class E
{
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tok;
ArrayList<Long> inCosts, outCosts;
public void go() throw... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | a3c0e761e0217bb9a206c988a3234c4d | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | /**
* BaZ :D
*/
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class ACMIND
{
static FastReader scan;
static PrintWriter pw;
static long MOD = 1_000_000_007;
static long INF = 2_000_000_000_000_000_000L;
static long inf = 2_000_000_00... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 0befe6702492ea637039b08545c17893 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Contest {
public static class pair implements Comparable<pair> {
int u;
long val;
public pair(int a, long value) {
u = a;
val = value;
}
@Override
public i... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | a57fd684d43bd073d5927de50933de8e | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import java.awt.Point;
//ArrayList<Integer> ar=new ArrayList<Integer>();
//HashMap<Integer,Integer> h=new HashMap<Integer, Integer>();
//for(i=0;i<n;i++) a[i]=ni();
//int b[]=new int[m];
//int a[]=new int[n];
//int min=Integer.MAX_VALUE;
//in... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 59a907ca3cd9584eb0aea7e8cab7a0dc | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
// :)
public class E implements Runnable {
static int inf = Integer.MAX_VALUE;
public void run() {
InputReader sc = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 817c8ea1950b1cff136fab8d94519808 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class B {
static BufferedReader br;
static PrintWriter pw;
static int inf = (int) 1e9;
static long mod = (long) 1e9 + 7;
public static void main(String[] args) throw... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | df4d6e25bcec4b66072dbc9499f0df7e | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{ static ArrayList<Integer>[] adj;
static int[] da;
static int[] db;
static int[] dc;
public static void main (String[] args) throws java.lang.Exception
{Scanner sc=new Sca... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | a5da1be32b2ea974432475c286672f21 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class e {
static int n, m, a, b, c;
static Integer[] ws;
static long[] pre;
static ArrayDeque<Integer>[] edges;
static int[] da, db, dc;
public static void main(String[] args) {
FS sc = new FS();
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | b496daffb3e314178a9aac146ef0967c | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
static class Graph
{
HashMap<Integer,ArrayList<Integer>> graph;
int n;
public Graph(int n)
{
this.n=n;
graph=new HashMap<>();
for(int i=1;i<=n;i++)
{
graph.put(i,new ArrayList<Integer>());
... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 499b74c59ee734f444e5aeef6d8bf0d0 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class A implements Runnable {
boolean judge = false;
FastReader scn;
PrintWriter out;
String INPUT = "";
void solve() {
int t = scn.nextInt();
while (t-- > 0) {
int n = scn.nextInt(), m = scn.nextInt(), a = scn.nextInt() - 1, b = scn.nextInt() - 1,
c = scn... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 1f923a2a4f98f528406f55528fc04f7b | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | //package main;
import java.io.*;
import java.util.*;
public final class Main {
BufferedReader br;
StringTokenizer stk;
public static void main(String[] args) throws Exception {
new Main().run();
}
{
stk = null;
br = new BufferedReader(new InputStreamReader(System... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 5454493c9509597738cfb0a2d2be0caa | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | //package main;
import java.io.*;
import java.util.*;
public final class Main {
BufferedReader br;
StringTokenizer stk;
public static void main(String[] args) throws Exception {
new Main().run();
}
{
stk = null;
br = new BufferedReader(new InputStreamReader(System... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 0cc354fdf97f5929a7c40bbc110d61a1 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class E {
static int oo=(int)1e8;
public static void main(String[] args) {
FastScanner fs=... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 36e35f2d24ab1fdd1792fceb54757a25 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class R635D3E {
public static void main(String[] args) throws Exception{
int num = 998244353;
// TODO Auto-generated method stub
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(bf.readLine());
for(int i = 0;i<... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | acccec0660a6f9760d3991d8480f6cc1 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | /*
ID: tommatt1
LANG: JAVA
TASK:
*/
import java.util.*;
import java.io.*;
public class cf1343e{
static ArrayList<Integer>[] adj;
static int[] da;
static int[] db;
static int[] dc;
public static void main(String[] args)throws IOException {
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | b6deb3a5bbe7313b27e1a7f08186e280 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | //make sure to make new file!
import java.io.*;
import java.util.*;
public class E636{
public static void main(String[] args)throws IOException{
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int t = Integer.p... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 24469de5142e2355e5696346280b0956 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | /**
* Created by Aminul on 4/21/2020.
*/
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class E {
static ArrayDeque<Integer> g[];
public static void main(String[] args) throws Exception {
FastReader in = new FastReader(System.in);
PrintWriter pw = new PrintWri... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | c5c66f7757089ffdd27bcefcf283a692 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Sol{
public static List<Integer> adj[];
public static int n,m,a,b,c;
public static long p[];
public static int dist1[];
public static int dist2[];
public static int dist3[];
public static long psum[];
public static void main(String[] args) throws IOException... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 5410bf5367cce1d5831dd5e24fb47f52 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Task {
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(S... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | ee02618dda13935c48f64d7ca5fb8d4a | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Task {
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(S... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 191430198bd368eba441229cc1e65f65 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
private static BufferedReader br;
private static StreamTokenizer st;
private static PrintWriter pw;
static final int INF = 1000000007;
static final int MOD = 998244353;
static List<Integer> edges[];
static void bfs(int r, int... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | cd55ceb07c7422af74f88c6e0bfebea4 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import javax.rmi.ssl.SslRMIClientSocketFactory;
public class tr1 {
static PrintWriter out;
static StringBuilder sb;
static int n, k;
static long mod = 1000000007;
static int[][] memo;
static String s;
static HashSet<Integer> nodes;
static Arra... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 21fd1da649caad83a26b86841dcbea5b | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
public class Main {
final static int MAXN = 200000 + 5;
static int A;
static int B;
static int C;
static List<Integer>[] G = new List[MAXN];
static int N;
static int M;
static int T;
final static int MOD = 1000000007;
public... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 3fd16bdb379bf81e929fe18c0932c5fb | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class MainClass
{
public static void main(String[] args)throws IOException
{
Reader in = new Reader();
int t = in.nextInt();
StringBuilder stringBuilder = new StringBuilder();
while (t-- > 0)
{
int n = in.nextInt()... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 35cdf60b2ed3316fa37daa10a2bde1bb | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitS... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 117870fa511efac14b4fedb62afc8677 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class WeightsDistributing {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int T = Integer.parseInt(in.readLine());
for(int i = 0; ... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 44e4e101dd8679b6300b783e616ddc6f | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.util.*;
public class E {
static int n, m, a, b, c;
static List<List<Integer>> g;
static void bfs(int[] d, int src) {
Queue<Integer> q = new LinkedList<>();
q.offer(src);
int[] vis = new int[n+1];
vis[src] = 1;
while (q.isEmpty() == false) {
i... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 6b190ca05058405fdece91ef0522bd12 | train_000.jsonl | 1587479700 | You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges (which represents the map of Bertown) and the array of prices $$$p$$$ of length $$$m$$$. It is guaranteed that there is a path between each pair of vertices (districts).Mike has planned a trip from the vertex (district) $$$a$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class e636 {
static PrintWriter out;
static BufferedReader in;
static StringTokenizer st;
public static void main(String[] args) throws FileNotFoundException {
//out = new PrintWriter("test.out");
//in = new BufferedReader(new FileReader("te... | Java | ["2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7"] | 2 seconds | ["7\n12"] | NoteOne of the possible solution to the first test case of the example:One of the possible solution to the second test case of the example: | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"sortings",
"brute force"
] | 89be93cb82d9686ff099d156c309c146 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains five integers $$$n, m, a, b$$$ and $$$c$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$$$, $$$1... | 2,100 | For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally. | standard output | |
PASSED | 0f4a85d265f390229103e7a3413edefc | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.StringToken... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 70a086d68d3c61ff8852f53806772cfd | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Se... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 93fd3b76fb098fba018103a5eb9c1038 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class TaskC {
static Integer[][]dp;
static int n, m, ans;
static String s;
static TreeSet<Integer> primes;
static void generatePrimes()
{
primes = new TreeSet<>();
primes.add(2);
for (int i = ... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | ef00b04f0d4e945952317af44318e0da | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.util.*;
public class PrimeMatrix {
public static int prime[] = new int[1000000+100];
public static int state[]= new int[1000000+100];
public static int total=1;
public static void main(String[] args) {
int number=1000000;
sieve(number);
Scanner in = new Scanner(System... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | ced662943613c05f8afdf01b65c4e68d | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.util.Scanner;
public class PrimeMatrix
{
static int [] primes;
static int [] bs;
static final int SIZE = 9593;
static final int INF = (int) 1e9;
static void sieve(int n)
{
bs = new int[n+1];
primes = new int[SIZE];
bs[0] = bs[1] = 1;
int idx = 0;
for (int i = 2; i < bs.length; i++)
{
... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 0035836b379058c007f8bcb69e132f4b | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 91df1b280e316dedab5210ed36620095 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 5ab1ba9c97d4309380193656697034a7 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
boolean [] prime = new boolean[250000];
for(int i=0;i<250000;i++)
prime[i] = true;
prime[0]=prime[1]=false;
for(int... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 662cb258e44d81643f73bb8093b37556 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes |
import java.io.*;
import java.util.*;
public class CF {
public static void main(String[] args) throws IOException {
//FastScanner in = new FastScanner(new FileInputStream(new File("input.txt")));
//PrintWriter out = new PrintWriter(new File("output.txt"));
FastScanner in = new FastScanner... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 06df0ce0192e5cc82ba7b10e2963f9a4 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes |
/*
*
* Date: 07 September 2019
* Time: 01:03:00
*/
import java.io.*;
import java.util.*;
public class pm
{
static int p[]=new int[10454];
static void seive(){
int n=110005;
boolean prime[]=new boolean[n+1];
Arrays.fill(prime,true);
prime[0]=false;
prime[1]=false;
... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 21a839df67072a11a02bb5057f9d9282 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.util.*;
public class CodeForces
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int m = input.nextInt();
int[][] array = new int[n][m];
int[] next = new int[100100];
boolean[] primes = sieveOfEratosthenes(1000100);
int min = Intege... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 2b3157f59a91880b71d76dccc877612f | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.util.*;
import java.util.Scanner;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import javax.lang.model.util.ElementScanner6;
public class B271
{
static class FastReader
... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 51f262a555f1a2c124785812f842e0e6 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.awt.*;
import java.io.*;
import java.util.*;
public class AA implements Runnable {
public void run() {
InputReader sc = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int i=0,j=0,k=0;
int t=0;
//t=sc.nextInt();
while (t-->0)
... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | fb1b60b3bd86c635e9ffac8e134f25a7 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
static ArrayList<Integer> prime;
public static void sieve()
{
boolean[] isPrime = new bool... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 0d931d94a8ab923de5d52d22aaeb5cd8 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
static ArrayList<Integer> prime;
public static void sieve()
{
boolean[] isPrime = new bool... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | c2aef36d5c7d542e0094681361114732 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.util.*;
public class main {
public static ArrayList<Integer> sieve(int n){
boolean[] primeBoolArray = new boolean[n+1];
Arrays.fill(primeBoolArray, true);
ArrayList<Integer> myPrimes = new ArrayList<Integer>(n+1);
primeBoolArray[0] = false;
primeBoolArray[1] = false;
for(int currNumber = ... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output | |
PASSED | 910326ed8ac1806b4bc2a096bc1bc607 | train_000.jsonl | 1360596600 | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p... | 256 megabytes | import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class P271B {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
int[][] arr = new int[n][m];
for (int r = 0; r < n; r++) {
for (int c = 0; c < m; c+... | Java | ["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"] | 2 seconds | ["1", "3", "0"] | NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a... | Java 8 | standard input | [
"binary search",
"number theory",
"brute force",
"math"
] | d549f70d028a884f0313743c09c685f1 | The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are... | 1,300 | Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.