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
79296c2573ffd170ab1aded0ff1f49fd
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer token = new StringTokenizer(br.readLine()); int n = Integer.parseInt(token.nextToken()); int k =...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
8b7fce711ef0fbd0563f3385c8253f8a
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Mario { public static void main(String[] args) { Scanner cin=new Scanner(System.in); int n=cin.nextInt(); long c=cin.nextLong(); long arr[]=new long[26]; String s=cin.next(); for (int i = 0; i < s.length(); i++) { arr[s.charAt(i)-'A']++; ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
1822fd4247b183735692c644f7bb2018
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Solve { void sieveOfEratosthenes(int n) { bool...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
385f54806439ff953c7135e4908dfa1b
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.math.BigInteger; import java.util.Collections; import java.util.Scanner; public class B_462 { public static long[] merge_sort(long[] input,int start,int end) { int mid=(start+end)/2; if(start>end) return new long[0]; if(start==end) { long[] ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
12c7279bd87fc6fec20d911c299a548c
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.*; public class ForceCode { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); long k = (long) scanner.nextInt(); String str = scanner.next(); long[] count = new long[26]; for (int i = 0; i < n; i++){ count...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
94628fd009f0086aa13ef0351b1d1ecb
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import static java.util.Arrays.fill; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; /** * * @author nirmit */ public class Main1 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
c0fe83e81aeb133b2b97e170fb503d3b
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Scanner; import java.util.List; import java.util.ArrayList; import java.util.LinkedList; import java.util.Map; import java.util.HashMap; import java.util.Set; import java.util.HashSet; import java.util.Arrays; import java.util.TreeSet; import java.util.Collections; import java.util.Comparator; import j...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
e9d29f4a2f3910ca2953ed0fe3b4c8a8
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.*; public class MA { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n =scan.nextInt(); long k = scan.nextInt(); String s = scan.next(); int arr [] = new int[26]; for(int i=0;i<s.length();i++) { char a = s.charAt(i); int val = a-'A'; arr[val]++; } lon...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
bb8f33af1ec119e9c3e5bdb98e883dc7
train_003.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.L...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is: Β Β Β Β  for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 11
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$ Β β€” road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$ Β β€” the points where the safety islands are located....
2,400
Output a single integer Β β€” the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
fa8e4f5145b48d5e6967dfd812791a9d
train_003.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public void solve() { int n = reader.nextInt(); int m = reader.nextInt(); int[] d = new int[m]; for (int i = 0; i < m; i++) d[i] = reader.nextInt(); int g = reader.nextInt(); int r = reader.nextInt(); ...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is: Β Β Β Β  for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 11
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$ Β β€” road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$ Β β€” the points where the safety islands are located....
2,400
Output a single integer Β β€” the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
c0a07266004dd929379999cf846cedd4
train_003.jsonl
1337182200
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers:...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); Ta...
Java
["3\npair pair int int int", "1\npair int"]
2 seconds
["pair&lt;pair&lt;int,int&gt;,int&gt;", "Error occurred"]
null
Java 8
standard input
[ "dfs and similar" ]
6587be85c64a0d5fb66eec0c5957cb62
The first line contains a single integer n (1 ≀ n ≀ 105), showing how many numbers the type dictated by Gena contains. The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes). It is guaranteed that the total number of words does not exceed 105 and that a...
1,500
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters. It is guaranteed that ...
standard output
PASSED
fc042dc5f6dde0a7f9be3d27e083c7b0
train_003.jsonl
1337182200
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers:...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class C190 { public static int mod = 1000000007; public static long INF = (1L << 60); static FastS...
Java
["3\npair pair int int int", "1\npair int"]
2 seconds
["pair&lt;pair&lt;int,int&gt;,int&gt;", "Error occurred"]
null
Java 8
standard input
[ "dfs and similar" ]
6587be85c64a0d5fb66eec0c5957cb62
The first line contains a single integer n (1 ≀ n ≀ 105), showing how many numbers the type dictated by Gena contains. The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes). It is guaranteed that the total number of words does not exceed 105 and that a...
1,500
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters. It is guaranteed that ...
standard output
PASSED
2c624f8aff267fcc7dd153d17f71b906
train_003.jsonl
1337182200
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers:...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class C190 { public static int mod = 1000000007; public static long INF = (1L << 60); static FastS...
Java
["3\npair pair int int int", "1\npair int"]
2 seconds
["pair&lt;pair&lt;int,int&gt;,int&gt;", "Error occurred"]
null
Java 8
standard input
[ "dfs and similar" ]
6587be85c64a0d5fb66eec0c5957cb62
The first line contains a single integer n (1 ≀ n ≀ 105), showing how many numbers the type dictated by Gena contains. The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes). It is guaranteed that the total number of words does not exceed 105 and that a...
1,500
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters. It is guaranteed that ...
standard output
PASSED
a1b3fb0fce6ab860a6690b8f28d6aa53
train_003.jsonl
1337182200
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers:...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static String[] words; static StringBuilder sb = new StringBuilder(); static int found; static boolean error; ...
Java
["3\npair pair int int int", "1\npair int"]
2 seconds
["pair&lt;pair&lt;int,int&gt;,int&gt;", "Error occurred"]
null
Java 8
standard input
[ "dfs and similar" ]
6587be85c64a0d5fb66eec0c5957cb62
The first line contains a single integer n (1 ≀ n ≀ 105), showing how many numbers the type dictated by Gena contains. The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes). It is guaranteed that the total number of words does not exceed 105 and that a...
1,500
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters. It is guaranteed that ...
standard output
PASSED
2e80f80a36e0cdb24c42349fbc0229b4
train_003.jsonl
1337182200
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers:...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P190C { StringBuilder ans = new StringBuilder(); Deque<String> inp = new ArrayDeque(); boolean parse() { if (inp.size() == 0) { return false; } if (inp.pollFirst()...
Java
["3\npair pair int int int", "1\npair int"]
2 seconds
["pair&lt;pair&lt;int,int&gt;,int&gt;", "Error occurred"]
null
Java 8
standard input
[ "dfs and similar" ]
6587be85c64a0d5fb66eec0c5957cb62
The first line contains a single integer n (1 ≀ n ≀ 105), showing how many numbers the type dictated by Gena contains. The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes). It is guaranteed that the total number of words does not exceed 105 and that a...
1,500
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters. It is guaranteed that ...
standard output
PASSED
bc1285250d06c29b1963cff61745836a
train_003.jsonl
1337182200
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers:...
256 megabytes
import java.util.Scanner; public class Main { static Scanner scan; static String s; static StringBuilder res = new StringBuilder(""); static boolean fail = false; public static void main(String[] args) { scan = new Scanner(System.in); String n = scan.nextLine(); recur(); ...
Java
["3\npair pair int int int", "1\npair int"]
2 seconds
["pair&lt;pair&lt;int,int&gt;,int&gt;", "Error occurred"]
null
Java 8
standard input
[ "dfs and similar" ]
6587be85c64a0d5fb66eec0c5957cb62
The first line contains a single integer n (1 ≀ n ≀ 105), showing how many numbers the type dictated by Gena contains. The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes). It is guaranteed that the total number of words does not exceed 105 and that a...
1,500
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters. It is guaranteed that ...
standard output
PASSED
a78b3c75cd434654bd7657b8fdfbb4e8
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner; public class Test { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int d=sc.nextInt(); int marks=a+b+c+d; int ran...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
fa631bdac2bd206d6fbd867ba758d1b3
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
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
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
39cfbf3c3093cf302361dbb5a3bb1319
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner; public class A1017_Rank { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int rank = 1; int Thomas = scan.nextInt() + scan.nextInt() + scan.nextInt() + scan.nextInt(); for (int i = 1; i < n; i...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
e405964de4e87a789df400efc4c59327
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String args[]) { FastScanner in=new FastScanner(); // int t=in.nextInt(); // L: while(--t>=0) { int n=in.nextInt(); ArrayList<int []> arr=new ArrayList<>(); for(int i=0;i<n;i++) { arr.add(new int[] {i, in.nextInt(), in.next...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
cdc42d4381cc0a3e2e22807ac135967b
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.*; public class mohammad{ public static void main(String args[]){ Scanner U = new Scanner(System.in); int t = U.nextInt(); int[] b= new int[t]; for(int i=0 ; i<t ; i++){ int[] a= new int[4]; for(int j=0 ; j<4 ; j++) a[j]= U.nex...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
913503cd4979d9cccc88ab42f2a5faec
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner; public class Lo { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int sum=0; int c=1; int max=0; int E = s.nextInt(); int G = s.nextInt(); int M = s.nextInt(); int ...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
40edb6e952d2214b315b74ac86f8da17
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import static java.util.Arrays.sort; import java.util.Scanner; public class Domilson { public static void main(String[] args) { Scanner ler=new Scanner(System.in); int i,j,a,s=0; int n=ler.nextInt(); int lugar[]=new int [n]; for(i=1;i<=n;i++){ for(j=0;j<4;j++){ ...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
369e4ff66c4478b0238b18f73d3da537
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner; import java.util.stream.Stream; public class TheRank { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); sc.nextLine(); int rank=1; int [] num=new int[n]; for (int i = 0; i < n; i++) { ...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
521d7ff39bbd5e9ab60fbf4bdc88ea32
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n,a,b,c,d; int pos =1; n = sc.nextInt(); a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt(); int ...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
4d5940b21d056a7f20b8db73d89b8294
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[][] a=new int[n+1][2]; for(int i=1;i<=n;i++) { a[i][0]=i; for(int j=0;j<4;j++) { ...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
102b134534d77860701819b0eafedf7b
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Codeforces3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); long b,k=0, c = 0, a = input.nextLong(); long[] e= new long[1000]; if (a > 1) { for (int i = 0; i < a; i++) { ...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
56c121db87453cdce0e57209bf492cef
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.ut...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
69540458eb2f5196be775012059c0b2f
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner; public class TheRank { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r = sc.nextInt() + 1; int c = 5; int[][] m = new int[r][c]; int othersSum = 0; int tomasSum = 0; int tomasRank = r; for (int i = 1; i < r; i++) { for (int j = 1;...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
94669cbb0d80b1fc49c506e88620c74c
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
/* Problem Name: The Rank URL: http://codeforces.com/problemset/problem/1017/A */ import java.util.*; public class The_Rank{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] sum = new int[n-1]; int johnSum = 0; for(int i = 0;i<n;i++){ for(...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
21262618a0cdd5d7ef62815d2120a65e
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner; public class DONEMestoVTablice { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a, b, c, d; int[] arr = new int[n]; int index = 0; int Tomsum = 0; int Tomindex = -1; for (int i = 0; i < n; i++) { a = sc.next...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
045253bf064fad87b850722482182dba
train_003.jsonl
1533737100
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's i...
256 megabytes
import java.util.Scanner;import java.util.Arrays; public class ranking { public static void main (String [] args) { Scanner scanner = new Scanner (System.in); int n=scanner.nextInt(); int [] a;a=new int [n]; int [] b;b=new int [n]; for (int i=0;i<n;i++) { for (int j=0;j<4;j++) { int x=scanner.nextInt(); a[i]+=x;...
Java
["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"]
1 second
["2", "1"]
NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $...
Java 8
standard input
[ "implementation" ]
3c984366bba580993d1694d27982a773
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$)Β β€” the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\leq a_i, b_i, c_i, d_i\leq 100$$$)Β β€” the grades of the $$$i$$$-th student on English, German, Math, and History. ...
800
Print the rank of Thomas Smith. Thomas's id is $$$1$$$.
standard output
PASSED
8e4cc7d128f050504f5295ab133acb8e
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.Scanner; import java.util.Map; import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.HashSet; import java.util.LinkedList; public class B129 { static int[] neg; static Set<Integer> curr; static int grp; private static void get1(int n) { for (int i = 1; i <= n; ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
2f127dfde4093a57780249c353a07329
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.*; public class Main{ /* . . . . . . . some constants . */ static int i=0,j=0,k=0,l=0; /* . . . if any . . */ public static void main(String[] args) throws IOException{ /* . . . . . . */ int n=ni(); int m=ni(); bool...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
dc23cc8c238ca30d3f5b1bbdb797f29a
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.Scanner; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import jav...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
1b52b58dd10f0b329f6dfa04c3bd7a72
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
//package main; import java.awt.Point; 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 Input...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
6e82e8e97e751dfc523d3fda118b3bd4
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner in =new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int from[] = new int[m]; int to[] = new int[m]; boolean ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
91b492b6154389ec4490d5fbf5c0cac7
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; public class StudentsAndShoeLaces { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), ans = 0, m = in.nextInt(), a[][] = new int [n][n], st[] = new int[n]; for (int i = 0; i < m; i++) { int x = in.nextInt(), y = in.nextInt(); a[x - 1][y...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
3c91ba272825167af9a09dc0657f654a
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class StudentsAndShoelaces { public static void main(String[] args) throws IOException { BufferedRea...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
c91c78329ce9bae9846293a6d4602a18
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { private static FastReader fr = new FastReader(); private static Helper hp = new Helper(); private static StringBuilder result = new StringBuilder(); public static void main(String[] args) { Task solver = new Task();...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
5b2c5a6dc38e0af186951ef7cdfe9d5d
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); HashMap<Integer, ArrayList<Integer>> A = new HashMap<>(); for (int i=0; i<m; i++) { in...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
b20e391bc9564ba8e557cb4c8d534d98
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class TaskB { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[][] adjMat = new int[n][n]; for (int i = 0 ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
b74fab4ff8265b9bee23fe77090e6604
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.sql.Array; import java.util.*; public class TaskC { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); Array...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
da10542d6ee0696ae25aa3c4712bba0e
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.StringTokenizer; public class TaskB { public static void main(String[] args) throws IOException { ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
452272227b5fa8ade77cd6b176966f40
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.*; import java.util.*; public class tr0 { static PrintWriter out; static StringBuilder sb; static final double EPS = 1e-9; static long mod = 998244353; static int inf = (int) 1e9 + 2; static long[] fac; static int[] si; static ArrayList<Integer> primes; static TreeSet<Integer>[] ad; static Arr...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
169b34f59bdac8128f1d4e6f428ad195
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import j...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
e98ed2b99d5e776f0ad83d90c33259a0
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author dipankar12 */ import java.io.*; import java.math.*; import java.util.*; public class r129b { public static void...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
a5567f8e7430902240d262a161f6cb2c
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author dipankar12 */ import java.io.*; import java.math.*; import java.util.*; public class r129b { public static void...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
a5b76258c3a0ef0bd113fe74fbe96562
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import javax.print.DocFlavor; import java.io.*; import java.math.BigInteger; import java.nio.Buffer; import java.sql.BatchUpdateException; import java.util.*; import java.util.stream.Stream; import java.util.Vector; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import static java.l...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
34a8c717b17d231d7232c01d437ea4a2
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class StudentsAndShoelaces implements Closeable { ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
05dfd8305dc6d216feaccd30ecae9eb2
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args){ FastScanner scanner = new FastScanner(); int n = scanner.nextInt(); int m = scanner.nextInt(); int[] a = new int[m]; int[] b = new int[m]; for(int i = 0; i < m; i++){ a[i] = scanner.nextInt()-1; b[i] =...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
de840049030f9601733879d7d4c354fb
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
/* * * Date: 07 September 2019 * Time: 01:03:00 */ import java.io.*; import java.util.*; public class sh { public static void main(String[] args) throws NumberFormatException, IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.next...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
b8b5db9b1e62d5f8946e6e910fe75d2a
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); int a, b; int[][] nodes = new int[n][n]; for (int i = 0; i < m; i++) { ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
971c25a81462e5931122e949998168c2
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; public class fourteen { public static void main(String[] args) { Scanner scn= new Scanner(System.in); int n= scn.nextInt(); int m= scn.nextInt(); Map<Integer,List<Integer>> mymap = new HashMap<Integer,List<Integer>>(); Map<Integer,List<Integer>> cpmap = new HashMap<Integer,List<Integer...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
365ec56cac5ced4d8c047a5981852437
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; /** * Created by Tejas on 01-07-2018. */ public class Main { static HashSet<Integer>[] adjList; public static void main(String[] args) throws IOException { BufferedReader bufferedReader =...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
8467f632c21f99564356cc15cd9bcb95
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; /** * Created by Tejas on 01-07-2018. */ public class Main { static HashSet<Integer>[] adjList; public static void main(String[] args) throws IOException { BufferedReader bufferedReader =...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
1b0a6ec8e76a7cdb355f45619565e2af
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.*; //267630EY public class Main129B2 { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); Vector<Integer>[] graph=(Vector...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
56244fefc29011b77cafe508effae263
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.*; public class Main129B { static class Graph { Vector<Integer>[] G; public Graph(int n) { G=(Vector<Integer>[]) new Vector[n]; for(int i=0;i<n;i++) G[i]=new Vector<Integer>(); } public void add(int v,int w) { G[v].add(w); G...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
9e74edfd442b4edeb834d7dbf566a0e4
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; public class Solution { public static void main(String args[]) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int m = input.nextInt(); int count = 0; LinkedList<Integer>[] graph = new LinkedList[n]; for(int i=0; i<n; i++) graph[i] = new LinkedList<Integer>(); ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
fb4ea7daf93fe6a9b5cac312143891f1
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; public class B129 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int M = in.nextInt(); Node[] nodes = ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
5fb68d25540b85fafdec123ba98b5688
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main{ static Node[] node; static int vis[],nb[]; static int bfs(int start,int n){ for(int i=1;i<=n;i++){ if(vis[i]==-1) continue; vis[i]=0; } int sid=0; vis[start]=1; Arra...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
6022929d6de3f8929fc958503daf4f3c
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Shoe { private int v; private LinkedList<Integer> adj[]; public Shoe(int v) { this.v=v; adj=new LinkedList[v+1]; for(int i=0;i<v+1;i++) { adj[i]=new LinkedList<>(); } } public void ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
c33ba73daf0c952a58988a0c48288bfe
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Test2 { static class pair{ int f; int s; protected pair(int f,int s){ this.f=f;this.s=s; } } public static void main(String[] args)throws Exception { reader in = new reader(System.in); int n=in.nextInt();...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
8a4d9dc8ad059f439f23b9c546d795be
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class dfs { // better solution for less steps public static int gcdFast(int x, int y...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
05b123a471efb9f497edf318e6efdb9d
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class CF129_D2_B { private static ArrayList<ArrayList<Integer>> graph = new ArrayList<>(); public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
ce2550642a3e0530a815cba9f1c3297a
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; public class Bshoo { private static final Scanner in = new Scanner(System.in); private static int N,M,l,k,X[],O[],V,sum; private static List<Integer> gr[]; private static boolean B []; public static void main(String[] args) { N=in.nextInt();M=in.nextInt(); X=new int...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
38b160e5ccd04948338d08b93d877220
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner leer = new Scanner(System.in); int n= leer.nextInt(); int m= leer.nextInt(); Lista A []= new Lista[n+1]; int N [] = new int [n+1]; for (int i = 1; i <=n; ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
30aae169ea8c993231efd3a46ac600ac
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
// δ½œθ€…οΌšζ¨ζˆη‘žε…ˆη”Ÿ // try FastScanner when done import java.util.*; public class student { static ArrayList<Integer>[] adj; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); adj = new ArrayList[n]; for(int i=0;i<n;i++) { ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
53a25de37a474e7393c85907f9534de4
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.*; import java.util.*; public class student { static class FastScanner { static final int DEFAULT_BUFF = 1024, EOF = -1, INT_MIN = 48, INT_MAX = 57; static final byte NEG = 45; static final int[] ints = new int[58]; static { int value = 0; for (int i = 48; i < ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
7c5fd91e06d128b86cc6e0f25dbee0e6
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
//import java.util.ArrayList; import java.util.ArrayList; import java.util.Scanner; import javax.xml.transform.Templates; //import java.util.Collection; //import java.util.Collections; public class test { static public void main(String phone[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
5cd1894b28be3cfbb9e9fe2a91d4945c
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class test { static public void main(String phone[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] arr = new int[110]; int[][] grid = new int[10005][2]; for (int i = 0; i < m; i++) { int x = sc.n...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
d2de1fdfdaa0918d34fb55a68c1e2ac3
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; /** * */ /** * @author mohanad * */ public class Div2_129B { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOExcepti...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
e42b7a4b77b9d23990b33de6a995d5f3
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; /** * * @author mohanad elmaghrby */ public class Div2_129B { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner scan= new Scanner (System.in); int n =scan.nextInt(); int m=scan.nextInt(); int count[...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
2b6d270044e4e050d9a5716a2e62afef
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.*; import java.io.*; public class StudentsandShoelaces { InputStream is; PrintWriter out; String INPUT = ""; void solve() throws IOException { int n= ni(), m= ni(); ArrayList<ArrayList<Integer>> arrayLists = new ArrayList<>(); for(int i=0;i<=n;i++) ...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
7da4c261ca17fdd73076b7982c97ab3c
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String [] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); i...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
63e4f02ecb1e2e4aa1200acb84f914f2
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException{ Scanner sc=new Scanner(System.in); int t=1;//sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int m=sc.nextInt(); HashSet<Integer>[] set=new HashSet[n]; for(int i=0;i<n;i++) { set[i]=n...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
02676d374c665755dae02dd9bf23dada
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
import java.io.*; import java.util.*; public class B_StudentsShoelaces { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStre...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
9d9ebd4c90e7fdb3bb47ec5d22104a7f
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
//package competitive; import java.util.*; import java.io.*; public class B129 { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s=br.readLine(); String str[]= s.trim().split(" "); int n=Integer.parseInt(str[0]),i...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
93ae9f0f010321e006214d7b4098ede6
train_003.jsonl
1321337400
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
256 megabytes
//package competitive; import java.util.*; import java.io.*; public class B129 { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s=br.readLine(); String str[]= s.trim().split(" "); int n=Integer.parseInt(str[0]),i...
Java
["3 3\n1 2\n2 3\n3 1", "6 3\n1 2\n2 3\n3 4", "6 5\n1 4\n2 4\n3 4\n5 4\n6 4"]
2 seconds
["0", "2", "1"]
NoteIn the first sample Anna and Maria won't kick out any group of students β€” in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the tw...
Java 8
standard input
[ "implementation", "dfs and similar", "brute force", "graphs" ]
f8315dc903b0542c453cab4577bcb20d
The first line contains two integers n and m β€” the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b β€” the numbers of students tied by the i-th lace (1 ≀ a, b ≀ n, a ≠ b). It is guaranteed that no two st...
1,200
Print the single number β€” the number of groups of students that will be kicked out from the club.
standard output
PASSED
4d3bf9c928423b1eb23445ebd754400f
train_003.jsonl
1462633500
Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities.Bear Limak was once in a city a and he wanted to go to a city b. There was no direct connection so he decided to take a long walk, visiting each...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class B { static StringTokenizer st; static BufferedReader ...
Java
["7 11\n2 4 7 3", "1000 999\n10 20 30 40"]
2 seconds
["2 7 1 3 6 5 4\n7 1 5 4 6 2 3", "-1"]
NoteIn the first sample test, there should be 7 cities and at most 11 roads. The provided sample solution generates 10 roads, as in the drawing. You can also see a simple path of length n between 2 and 4, and a path between 7 and 3.
Java 7
standard input
[ "constructive algorithms", "graphs" ]
6b398790adbd26dd9af64e9086e38f7f
The first line of the input contains two integers n and k (4 ≀ n ≀ 1000, n - 1 ≀ k ≀ 2n - 2)Β β€” the number of cities and the maximum allowed number of roads, respectively. The second line contains four distinct integers a, b, c and d (1 ≀ a, b, c, d ≀ n).
1,600
Print -1 if it's impossible to satisfy all the given conditions. Otherwise, print two lines with paths descriptions. The first of these two lines should contain n distinct integers v1, v2, ..., vn where v1 = a and vn = b. The second line should contain n distinct integers u1, u2, ..., un where u1 = c and un = d. Two pa...
standard output
PASSED
338af97d6e5f1073b71bcd1436f78cc7
train_003.jsonl
1462633500
Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities.Bear Limak was once in a city a and he wanted to go to a city b. There was no direct connection so he decided to take a long walk, visiting each...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Codeforces674B { public static void main(String[] args) { try { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken()); int ...
Java
["7 11\n2 4 7 3", "1000 999\n10 20 30 40"]
2 seconds
["2 7 1 3 6 5 4\n7 1 5 4 6 2 3", "-1"]
NoteIn the first sample test, there should be 7 cities and at most 11 roads. The provided sample solution generates 10 roads, as in the drawing. You can also see a simple path of length n between 2 and 4, and a path between 7 and 3.
Java 7
standard input
[ "constructive algorithms", "graphs" ]
6b398790adbd26dd9af64e9086e38f7f
The first line of the input contains two integers n and k (4 ≀ n ≀ 1000, n - 1 ≀ k ≀ 2n - 2)Β β€” the number of cities and the maximum allowed number of roads, respectively. The second line contains four distinct integers a, b, c and d (1 ≀ a, b, c, d ≀ n).
1,600
Print -1 if it's impossible to satisfy all the given conditions. Otherwise, print two lines with paths descriptions. The first of these two lines should contain n distinct integers v1, v2, ..., vn where v1 = a and vn = b. The second line should contain n distinct integers u1, u2, ..., un where u1 = c and un = d. Two pa...
standard output
PASSED
f29f650115b950fbfca483bb4f7029a2
train_003.jsonl
1462633500
Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities.Bear Limak was once in a city a and he wanted to go to a city b. There was no direct connection so he decided to take a long walk, visiting each...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection...
Java
["7 11\n2 4 7 3", "1000 999\n10 20 30 40"]
2 seconds
["2 7 1 3 6 5 4\n7 1 5 4 6 2 3", "-1"]
NoteIn the first sample test, there should be 7 cities and at most 11 roads. The provided sample solution generates 10 roads, as in the drawing. You can also see a simple path of length n between 2 and 4, and a path between 7 and 3.
Java 7
standard input
[ "constructive algorithms", "graphs" ]
6b398790adbd26dd9af64e9086e38f7f
The first line of the input contains two integers n and k (4 ≀ n ≀ 1000, n - 1 ≀ k ≀ 2n - 2)Β β€” the number of cities and the maximum allowed number of roads, respectively. The second line contains four distinct integers a, b, c and d (1 ≀ a, b, c, d ≀ n).
1,600
Print -1 if it's impossible to satisfy all the given conditions. Otherwise, print two lines with paths descriptions. The first of these two lines should contain n distinct integers v1, v2, ..., vn where v1 = a and vn = b. The second line should contain n distinct integers u1, u2, ..., un where u1 = c and un = d. Two pa...
standard output
PASSED
9bb0ffc87be4be1faca9f67366727ec0
train_003.jsonl
1566135900
You are given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. With a cost of one coin you can perform the following operation:Choose one of these numbers and add or subtract $$$1$$$ from it.In particular, we can apply this operation to the same number several times.We want to make the product of all these numbers equal to ...
256 megabytes
import java.math.*; import java.util.*; public class BruteForce { public static Scanner in =new Scanner(System.in); public static void main(String[] args){ ArrayList<Integer> neg=new ArrayList<Integer>(); ArrayList<Integer> pos=new ArrayList<Integer>(); int n=in.next...
Java
["2\n-1 1", "4\n0 0 0 0", "5\n-5 -3 5 3 0"]
1 second
["2", "4", "13"]
NoteIn the first example, you can change $$$1$$$ to $$$-1$$$ or $$$-1$$$ to $$$1$$$ in $$$2$$$ coins.In the second example, you have to apply at least $$$4$$$ operations for the product not to be $$$0$$$.In the third example, you can change $$$-5$$$ to $$$-1$$$ in $$$4$$$ coins, $$$-3$$$ to $$$-1$$$ in $$$2$$$ coins, $...
Java 8
standard input
[ "dp", "implementation" ]
3b3b2408609082fa5c3a0d55bb65d29a
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$)Β β€” the number of numbers. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$)Β β€” the numbers.
900
Output a single numberΒ β€” the minimal number of coins you need to pay to make the product equal to $$$1$$$.
standard output
PASSED
af518b5230409e779a080b879bd34a60
train_003.jsonl
1566135900
You are given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. With a cost of one coin you can perform the following operation:Choose one of these numbers and add or subtract $$$1$$$ from it.In particular, we can apply this operation to the same number several times.We want to make the product of all these numbers equal to ...
256 megabytes
import java.util.*; public class MakeProductEqualOne { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long arr[] = new long[n]; for(int i=0;i<n;i++) { arr[i] = sc.nextLong(); } long a = 0; for(int i=0;i<n;i++) { if(arr[i]==0) { a++; } }...
Java
["2\n-1 1", "4\n0 0 0 0", "5\n-5 -3 5 3 0"]
1 second
["2", "4", "13"]
NoteIn the first example, you can change $$$1$$$ to $$$-1$$$ or $$$-1$$$ to $$$1$$$ in $$$2$$$ coins.In the second example, you have to apply at least $$$4$$$ operations for the product not to be $$$0$$$.In the third example, you can change $$$-5$$$ to $$$-1$$$ in $$$4$$$ coins, $$$-3$$$ to $$$-1$$$ in $$$2$$$ coins, $...
Java 8
standard input
[ "dp", "implementation" ]
3b3b2408609082fa5c3a0d55bb65d29a
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$)Β β€” the number of numbers. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$)Β β€” the numbers.
900
Output a single numberΒ β€” the minimal number of coins you need to pay to make the product equal to $$$1$$$.
standard output
PASSED
fd67f498f7812b1538ec038d8571fe52
train_003.jsonl
1566135900
You are given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. With a cost of one coin you can perform the following operation:Choose one of these numbers and add or subtract $$$1$$$ from it.In particular, we can apply this operation to the same number several times.We want to make the product of all these numbers equal to ...
256 megabytes
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; public class GFG { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int[n]; for(int i = 0;i <...
Java
["2\n-1 1", "4\n0 0 0 0", "5\n-5 -3 5 3 0"]
1 second
["2", "4", "13"]
NoteIn the first example, you can change $$$1$$$ to $$$-1$$$ or $$$-1$$$ to $$$1$$$ in $$$2$$$ coins.In the second example, you have to apply at least $$$4$$$ operations for the product not to be $$$0$$$.In the third example, you can change $$$-5$$$ to $$$-1$$$ in $$$4$$$ coins, $$$-3$$$ to $$$-1$$$ in $$$2$$$ coins, $...
Java 8
standard input
[ "dp", "implementation" ]
3b3b2408609082fa5c3a0d55bb65d29a
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$)Β β€” the number of numbers. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$)Β β€” the numbers.
900
Output a single numberΒ β€” the minimal number of coins you need to pay to make the product equal to $$$1$$$.
standard output
PASSED
5162cd903fd4c83765adcf40ee3de5ff
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Tmbao */ public class Main ...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
cadf13c11d6ff5721ef7c31d6c69d4ac
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.*; public class Main { static int[][] min, max; public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int s = scanner.nextInt(); int l = scanner.nextInt(); int mp = (int) Math.ce...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
2375a6e4c1308d1f24d011897139944e
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.io.*; import java.util.*; public class Task { public static void main(String[] args) throws IOException { new Task().solve(); } PrintWriter out; int cnt = 0; int n; boolean[] used; int[] use; ArrayList<Integer>[] rg; ArrayList<Integer> tsort = new ArrayList<Integer>(); int[] comp; int[] c...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
c166935f93205c211b87833ae435aabd
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author about@manhquynh.net */ public class Main { public static void main(String[] args) { InputStream i...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
a35236753a63da9b2ad83e721dd8b724
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.awt.print.Book; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.Thread.State; import java.math.BigInteger; import java.nio.file.attribute.AclEntry.Builder; import java.util.Arrays; import java.util.StringTokenizer; imp...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
9d58558433f2c1512e48b585c387836d
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.*; import java.io.*; public class B { public static PrintStream out = System.out; public static InputReader in = new InputReader(System.in); public static void main(String args[]) { int N, S, L; N = in.nextInt(); S = in.nextInt(); L = in.nextInt(); in...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
045f09429b802b9de450efdcd09be2b7
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.Scanner; import java.util.Deque; import java.util.ArrayDeque; public class B { final int oo = (int)1e9; class IT { int[] low, high; int[] min, max; IT(int N) { low = new int[4*N+4]; high = new int[4*N+4]; min = new int[4*N+4]; max = new int[4*N+4]; init(1, 0, N-1); } privat...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
2eff1fd112d18bca37e8ba4b902fe89c
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.NavigableSet; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.IOException; import java.util.TreeSet; import java.i...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
2ee60b6492d7efd092508bba480bcee5
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.*; import java.io.*; public class B { public static final int INF = 100000000; public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(System.in); int n = in.nextInt(); int s = in.nextInt(); int l = in.nextInt(); IntervalTree it = new IntervalTree...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
d9310f06dc24121ed3258319e8167433
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.io.*; import java.util.*; public class BMain { String noResultMessage = "NoResult"; Parser in = new Parser(); PrintWriter out; int n = in.nextInteger(); int s = in.nextInteger(); int l = in.nextInteger(); int[] as = in.nextIntegers(n); public void solve() { if(l >...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
3101bb3e16656bb6273ea98120583c7c
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
// package Div2; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Random; import java.util.Scanner; import java.util.Stack; public class Sketch { private static class Segtree { public int[] nodes; private void build(int[] nums, int pos,...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
720f35f35e1a4fd319db696d5cab2e1c
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.*; public class Main { static int[][] min, max; public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int s = scanner.nextInt(); int l = scanner.nextInt(); int mp = (int) Math.ce...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
1bb0c0b1b3296aab43b9af5b1dd9ce1b
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.SortedSet...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
3be8b77903238bca50d582e11beafd2f
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collecti...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output
PASSED
e0540a4b6a8df07eddac854c586fd0e1
train_003.jsonl
1416590400
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: Each piece should contain at least l numbers. The difference between the maximal and the minimal number on the piece should be ...
256 megabytes
import java.util.*; public class Main { static int[][] min, max; public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int s = scanner.nextInt(); int l = scanner.nextInt(); int mp = (int) Math.ce...
Java
["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1"]
1 second
["3", "-1"]
NoteFor the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Java 7
standard input
[ "dp", "two pointers", "binary search", "data structures" ]
3d670528c82a7d8dcd187b7304d36f96
The first line contains three space-separated integers n, s, l (1 ≀ n ≀ 105, 0 ≀ s ≀ 109, 1 ≀ l ≀ 105). The second line contains n integers ai separated by spaces ( - 109 ≀ ai ≀ 109).
2,000
Output the minimal number of strip pieces. If there are no ways to split the strip, output -1.
standard output