sample_inputs
stringlengths
5
384
input_specification
stringlengths
48
911
src_uid
stringlengths
32
32
source_code
stringlengths
29
6.77k
sample_outputs
stringlengths
5
393
lang_cluster
stringclasses
4 values
notes
stringlengths
30
1.52k
βŒ€
output_specification
stringlengths
25
681
description
stringlengths
140
2.49k
human_testcases
stringlengths
243
50.8k
human_pass_rate
float64
100
100
human_line_coverage
float64
100
100
human_branch_coverage
float64
100
100
human_sample_testcases_1
stringlengths
190
3.11k
human_sample_testcases_2
stringlengths
190
3.11k
human_sample_testcases_3
stringlengths
190
3.11k
human_sample_testcases_4
stringlengths
190
3.11k
human_sample_testcases_5
stringlengths
190
3.11k
human_sample_pass_rate_1
float64
100
100
human_sample_pass_rate_2
float64
100
100
human_sample_pass_rate_3
float64
100
100
human_sample_pass_rate_4
float64
100
100
human_sample_pass_rate_5
float64
100
100
human_sample_line_coverage_1
float64
52.2
100
human_sample_line_coverage_2
float64
60
100
human_sample_line_coverage_3
float64
50
100
human_sample_line_coverage_4
float64
43.5
100
human_sample_line_coverage_5
float64
21.7
100
human_sample_branch_coverage_1
float64
45.5
100
human_sample_branch_coverage_2
float64
45.8
100
human_sample_branch_coverage_3
float64
16.7
100
human_sample_branch_coverage_4
float64
36.4
100
human_sample_branch_coverage_5
float64
18.2
100
id
int64
1
400
human_sample_pass_rate
float64
100
100
human_sample_line_coverage
float64
47
100
human_sample_branch_coverage
float64
41.8
100
["5 2\nNYNNY", "6 1\n????NN"]
The first line contains two integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ n) β€” the number of episodes in the series and the dissatisfaction which should be checked. The second line contains the sequence which consists of n symbols "Y", "N" and "?". If the i-th symbol equals "Y", Stepan remembers that he has watched the episo...
5bd578d3da5837c259b222336a194d12
import java.util.Scanner; public class project{ public static void main(String[]args){ Scanner s = new Scanner(System.in); int n = s.nextInt(), k = s.nextInt(); String str = s.nextLine(); str = s.nextLine(); int ans = 0; for (int i = 0; i < n; ++i) { if (i == 0 || str.charAt(i - 1) != 'N') { int...
["YES", "NO"]
Java
NoteIn the first test Stepan remembers about all the episodes whether he has watched them or not. His dissatisfaction is 2, because he hasn't watch two episodes in a row β€” the episode number 3 and the episode number 4. The answer is "YES", because k = 2.In the second test k = 1, Stepan's dissatisfaction is greater than...
If Stepan's dissatisfaction can be exactly equal to k, then print "YES" (without qoutes). Otherwise print "NO" (without qoutes).
Well, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched it, or he is unsure, has he watched this episode or not. Stepan's dissatisfaction is the maximum numbe...
[{"input": "5 2\r\nNYNNY\r\n", "output": ["YES"]}, {"input": "6 1\r\n????NN\r\n", "output": ["NO"]}, {"input": "100 8\r\nNYNNY?YNNNNNN?NNNNNYNY?YYNYNN?NNNY??NNYNYNNNYNNNYNNNNNNNNY?NNNYNYN?NNNY?YY?NNYNN?NNNYNNYNNYN?NNYNYNN\r\n", "output": ["YES"]}, {"input": "10 1\r\nNY???NY?Y?\r\n", "output": ["YES"]}, {"input": "20 7\...
100
100
100
[{'input': '1 0\r\nN\r\n', 'output': ['NO']}, {'input': '51 1\r\nYYYNYNYNNYYNNY?YNYYYYYYNNYNYN??NYNYYNYYYYYYNNYNNNYY\r\n', 'output': ['NO']}, {'input': '100 10\r\nN?NNYYYNNNNNNYYNNYYNNNNNNNNYYNNNYYNNYNYNY?NNNNNNNNNYYNNNNYNNNNYNNNYNNYNNN?NNY?NNNNNNNNN?NYNYNNNNNNNN\r\n', 'output': ['YES']}, {'input': '100 34\r\n?NNNN??N?...
[{'input': '100 6\r\n????????????????????????????????????????????????????????????????????????????????????????????????????\r\n', 'output': ['YES']}, {'input': '100 26\r\nNNYNNNNNNNNNNNNN?NNNNNNNNNNNNNYNNNNYNNNNNNNNNNNNYNNNNNN?NNNYNNNNNNNNNNYYNNNNNNNNYNNNNNNNNYYYNNNNYYNY\r\n', 'output': ['NO']}, {'input': '100 1\r\nYYYYY...
[{'input': '20 7\r\nN?N??NNN?NNN?Y???Y??\r\n', 'output': ['YES']}, {'input': '100 8\r\nNYNNY?YNNNNNN?NNNNNYNY?YYNYNN?NNNY??NNYNYNNNYNNNYNNNNNNNNY?NNNYNYN?NNNY?YY?NNYNN?NNNYNNYNNYN?NNYNYNN\r\n', 'output': ['YES']}, {'input': '100 34\r\n?NNNN??N???NNNN?NNN?N???N?N????NNNNNNN?N??N???NNNN???N?N?NN?NNNNN?NNN???N??NN??Y??NNN...
[{'input': '100 10\r\nNNNNYNNNYNNNNNNNNYNYNYNNNNNYNNNNNYNNNNNNNNNNNYNYYNNNNNNNYYNNYNYNNYYNNNNYNNNNNYNNNNYNNNNYNNY??YNNNNYY\r\n', 'output': ['NO']}, {'input': '51 5\r\nY??N????????Y??N?????N???N???YN?N?Y?N??Y?Y??Y???NN?\r\n', 'output': ['YES']}, {'input': '7 3\r\nN?YY???\r\n', 'output': ['YES']}, {'input': '1 0\r\n?\r\n...
[{'input': '51 1\r\nYYYNYNYNNYYNNY?YNYYYYYYNNYNYN??NYNYYNYYYYYYNNYNNNYY\r\n', 'output': ['NO']}, {'input': '100 21\r\n?NNNNNYNN??NNN?N????N?NN?N??NN?NNNY?NN?NY?NN?NNN?NN?N?NNNNNNY?NYNN??N??NYNN?NN?NNNN?N???NN?NN?Y?NYNY\r\n', 'output': ['YES']}, {'input': '100 2\r\nYYYYYYYYYYYNYYYYYYYYYYYYYYYYYYYYYYYYYNYY?YYYYYYYYYYYYYY...
100
100
100
100
100
100
91.3
100
100
95.65
96.43
89.29
96.43
96.43
85.71
201
100
97.39
92.858
["1 10 1 10 1", "1 5 6 10 1"]
First string contains five integer numbers l, r, x, y, k (1 ≀ l ≀ r ≀ 107, 1 ≀ x ≀ y ≀ 107, 1 ≀ k ≀ 107).
1110d3671e9f77fd8d66dca6e74d2048
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner scan=new Scanner(System.in); int l=scan.nextInt(); int r=sc...
["YES", "NO"]
Java
null
Print "YES" without quotes if a potion with efficiency exactly k can be bought in the store and "NO" without quotes otherwise. You can output each of the letters in any register.
Kirill plays a new computer game. He came to the potion store where he can buy any potion. Each potion is characterized by two integersΒ β€” amount of experience and cost. The efficiency of a potion is the ratio of the amount of experience to the cost. Efficiency may be a non-integer number.For each two integer numbers a ...
[{"input": "1 10 1 10 1\r\n", "output": ["YES"]}, {"input": "1 5 6 10 1\r\n", "output": ["NO"]}, {"input": "1 1 1 1 1\r\n", "output": ["YES"]}, {"input": "1 1 1 1 2\r\n", "output": ["NO"]}, {"input": "1 100000 1 100000 100000\r\n", "output": ["YES"]}, {"input": "1 100000 1 100000 100001\r\n", "output": ["NO"]}, {"input...
100
100
100
[{'input': '5000000 10000000 1 4999999 1\r\n', 'output': ['NO']}, {'input': '2 3 1 2 2\r\n', 'output': ['YES']}, {'input': '99 100 1 100 50\r\n', 'output': ['YES']}, {'input': '10 10 2 5 4\r\n', 'output': ['NO']}, {'input': '9222174 9829060 9418763 9955619 9092468\r\n', 'output': ['NO']}]
[{'input': '5440 46549 61481 99500 10\r\n', 'output': ['NO']}, {'input': '200 300 4000381 4000382 4000381\r\n', 'output': ['NO']}, {'input': '10000000 10000000 10 10000000 100000\r\n', 'output': ['YES']}, {'input': '60 60 2 3 25\r\n', 'output': ['NO']}, {'input': '91939 94921 10197 89487 1\r\n', 'output': ['NO']}]
[{'input': '10 10 100000 10000000 10000000\r\n', 'output': ['NO']}, {'input': '2 4 1 3 1\r\n', 'output': ['YES']}, {'input': '1 1 1 1 2\r\n', 'output': ['NO']}, {'input': '5426234 6375745 2636512 8492816 4409404\r\n', 'output': ['NO']}, {'input': '79446 95675 93934 96272 3\r\n', 'output': ['NO']}]
[{'input': '7 7 3 6 2\r\n', 'output': ['NO']}, {'input': '15 21 2 4 7\r\n', 'output': ['YES']}, {'input': '3 6 1 2 2\r\n', 'output': ['YES']}, {'input': '99 100 1 100 50\r\n', 'output': ['YES']}, {'input': '1 100000 1 100000 100001\r\n', 'output': ['NO']}]
[{'input': '10000000 10000000 1 100000 10000000\r\n', 'output': ['YES']}, {'input': '4 4 1 100 2\r\n', 'output': ['YES']}, {'input': '30518 58228 74071 77671 1\r\n', 'output': ['NO']}, {'input': '1 1 1 1 1\r\n', 'output': ['YES']}, {'input': '11 17 2 5 2\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
202
100
100
100
["4\nVKVK", "5\nBVVKV", "7\nVVKEVKK", "20\nVKVKVVVKVOVKVQKKKVVK", "5\nLIMAK"]
The first line of the input contains an integer n (1 ≀ n ≀ 75)Β β€” the length of the string. The second line contains a string s, consisting of uppercase English letters. The length of the string is equal to n.
08444f9ab1718270b5ade46852b155d7
import java.util.*; public class C_Bear_And_Company_3 { static int cv, ck , cs; static int[][] freq; static ArrayList<Integer>[] pos; static int[][][][] dp; public static void main(String[] agrs) { Scanner in = new Scanner(System.in); int n = in.nextInt(); char[] c = in.ne...
["3", "2", "3", "8", "0"]
Java
NoteIn the first sample, the initial string is "VKVK". The minimum possible number of moves is 3. One optimal sequence of moves is: Swap two last letters. The string becomes "VKKV". Swap first two letters. The string becomes "KVKV". Swap the second and the third letter. The string becomes "KKVV". Indeed, this string do...
Print one integer, denoting the minimum possible number of moves Limak can do, in order to obtain a string without a substring "VK".
Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.Limak has a string s tha...
[{"input": "4\r\nVKVK\r\n", "output": ["3"]}, {"input": "5\r\nBVVKV\r\n", "output": ["2"]}, {"input": "7\r\nVVKEVKK\r\n", "output": ["3"]}, {"input": "20\r\nVKVKVVVKVOVKVQKKKVVK\r\n", "output": ["8"]}, {"input": "5\r\nLIMAK\r\n", "output": ["0"]}, {"input": "1\r\nV\r\n", "output": ["0"]}, {"input": "1\r\nK\r\n", "outpu...
100
100
100
[{'input': '10\r\nKKZKKVKZKV\r\n', 'output': ['1']}, {'input': '1\r\nK\r\n', 'output': ['0']}, {'input': '57\r\nVVVVKKKKKKAAVVVVVVVVKKKKKKKVVVVVVVVVKKKKKKKKKKKKKKKKKKKKO\r\n', 'output': ['34']}, {'input': '71\r\nZKKKVVVVVVVKKKKKEVVKKVVVKKKVVVVKKKKVVVVVVVVKKKKKKKKKKKVVVVVVVVVVKKKKKKK\r\n', 'output': ['153']}, {'input': ...
[{'input': '75\r\nZXPZMAKZZZZZZAZXAZAAPOAFAZUZZAZABQZZAZZBZAAAZZFANYAAZZZZAZHZARACAAZAZDPCAVZ\r\n', 'output': ['0']}, {'input': '10\r\nVVKAVZVAAZ\r\n', 'output': ['1']}, {'input': '65\r\nVVVVKKAVVKVKKVVVVKKAVVKVKKVVVVKKAVVKVKKVVVVKKAVVKVKKVVVVKKAVVKVKK\r\n', 'output': ['50']}, {'input': '75\r\nVVVVVVVVVVVVVVVVVVVVVVVVV...
[{'input': '50\r\nKKAKVVNAVVVVKKVKKZVKKKKVKFTVVKKVVVVVZVLKKKKKKVKVVV\r\n', 'output': ['11']}, {'input': '17\r\nQZVRZKDKMZZAKKZVA\r\n', 'output': ['0']}, {'input': '75\r\nAJAKVZASUKAYZFSZRPAAVAGZKFZZHZZZKKKVLQAAVAHQHAZCVEZAAZZAAZIAAAZKKAAUKROVKAK\r\n', 'output': ['1']}, {'input': '74\r\nVJVKVUKVVVVVVKVLVKKVVKZVNZVKKVVVA...
[{'input': '75\r\nVVVVVKVKVVKKEVVVVVAKVKKZKVVPKKZKAVKVAKVMZKZVUVKKIVVZVVVKVKZVVVVKKVKVZZVOVKV\r\n', 'output': ['23']}, {'input': '2\r\nKV\r\n', 'output': ['0']}, {'input': '5\r\nLIMAK\r\n', 'output': ['0']}, {'input': '75\r\nKVVKCVKVVVVKVVVKVKVAVVMVVVVVKKVVVKVVVVVKKVVVVVKVVKVVVKKKKKVKKVKAVVVVVVVVVVK\r\n', 'output': ['7...
[{'input': '75\r\nVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKV\r\n', 'output': ['703']}, {'input': '64\r\nVVKKVAVBVCVDVEVFVGVHVIVJVKVLVMVNVOVPVQVRVSVTVUVVVWVXVYVZVVVKKKKK\r\n', 'output': ['7']}, {'input': '51\r\nAVVVVVVVVVVKKKKKKKKKKVVVVVVVVVVVVVVVKKKKKKKKKKKKKKK\r\n', 'output': ['135']},...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
203
100
100
100
["mew", "wuffuw", "qqqqqqqq"]
The first line contains a non-empty string $$$s$$$ with length at most $$$50$$$ characters, containing lowercase English letters only.
6c85175d334f811617e7030e0403f706
import java.util.HashSet; import java.util.Scanner; public class Nafis { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); int sz = str.length(); HashSet<Character> freq = new HashSet<>(); for (int i = 0; i <= sz / 2; i++...
["3", "5", "0"]
Java
Note"mew" is not a palindrome, so the longest substring of it that is not a palindrome, is the string "mew" itself. Thus, the answer for the first example is $$$3$$$.The string "uffuw" is one of the longest non-palindrome substrings (of length $$$5$$$) of the string "wuffuw", so the answer for the second example is $$$...
If there is such a substring in $$$s$$$ that is not a palindrome, print the maximum length of such a substring. Otherwise print $$$0$$$. Note that there can be multiple longest substrings that are not palindromes, but their length is unique.
A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.A substring $$$s[l \ldots r]$$$ ($$$1 \leq l \leq r \leq |s|$$$) of a string $$$s = s_{1}s_{2}...
[{"input": "mew\r\n", "output": ["3"]}, {"input": "wuffuw\r\n", "output": ["5"]}, {"input": "qqqqqqqq\r\n", "output": ["0"]}, {"input": "ijvji\r\n", "output": ["4"]}, {"input": "iiiiiii\r\n", "output": ["0"]}, {"input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow\r\n", "output": ["49"]}, {"input": "wwwwwwwwwwww...
100
100
100
[{'input': 'aaabcda\r\n', 'output': ['7']}, {'input': 'abbaaaaaabba\r\n', 'output': ['11']}, {'input': 'oftmhcmclgyqaojljoaqyglcmchmtfo\r\n', 'output': ['30']}, {'input': 'aabca\r\n', 'output': ['5']}, {'input': 'abcda\r\n', 'output': ['5']}]
[{'input': 'abcdefgaaaa\r\n', 'output': ['11']}, {'input': 'abcaa\r\n', 'output': ['5']}, {'input': 'aabbbbbaaaaaa\r\n', 'output': ['13']}, {'input': 'aabaa\r\n', 'output': ['4']}, {'input': 'yyyyyyyyyyyyyyyyyyyyyyyyy\r\n', 'output': ['0']}]
[{'input': 'ababa\r\n', 'output': ['4']}, {'input': 'cabc\r\n', 'output': ['4']}, {'input': 'abbbaaa\r\n', 'output': ['7']}, {'input': 'sssssspssssss\r\n', 'output': ['12']}, {'input': 'abbaaaaaabba\r\n', 'output': ['11']}]
[{'input': 'abaaaaaaaa\r\n', 'output': ['10']}, {'input': 'abba\r\n', 'output': ['3']}, {'input': 'aabcd\r\n', 'output': ['5']}, {'input': 'abbbaaa\r\n', 'output': ['7']}, {'input': 'aacbca\r\n', 'output': ['6']}]
[{'input': 'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr\r\n', 'output': ['0']}, {'input': 'yyyyyyyyyyyyyyyyyyyyyyyyy\r\n', 'output': ['0']}, {'input': 'aba\r\n', 'output': ['2']}, {'input': 'cabc\r\n', 'output': ['4']}, {'input': 'aaaaabababaaaaa\r\n', 'output': ['14']}]
100
100
100
100
100
100
100
100
100
100
83.33
100
83.33
83.33
100
204
100
100
89.998
["1f", "2d", "4a", "5e"]
The only line of input contains a description of Vasya's seat in the format ns, where n (1 ≀ n ≀ 1018) is the index of the row and s is the seat in this row, denoted as letter from 'a' to 'f'. The index of the row and the seat are not separated by a space.
069d0cb9b7c798a81007fb5b63fa0f45
import java.util.*; import java.math.*; import java.io.*; public class FoodOnThePlane { public static void main(String args[]) throws Exception { BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader s = new BufferedReader(new FileReader("*.in")); //PrintWriter out = new Print...
["1", "10", "11", "18"]
Java
NoteIn the first sample, the first flight attendant serves Vasya first, so Vasya gets his lunch after 1 second.In the second sample, the flight attendants will spend 6 seconds to serve everyone in the rows 1 and 3, then they will move one row forward in 1 second. As they first serve seats located to the right of the ai...
Print one integerΒ β€” the number of seconds Vasya has to wait until he gets his lunch.
A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the left of an aisle (if one looks in the direction of the cockpit), while seats...
[{"input": "1f\r\n", "output": ["1"]}, {"input": "2d\r\n", "output": ["10"]}, {"input": "4a\r\n", "output": ["11"]}, {"input": "5e\r\n", "output": ["18"]}, {"input": "2c\r\n", "output": ["13"]}, {"input": "1b\r\n", "output": ["5"]}, {"input": "1000000000000000000d\r\n", "output": ["3999999999999999994"]}, {"input": "99...
100
100
100
[{'input': '999999999e\r\n', 'output': ['3999999986']}, {'input': '100001d\r\n', 'output': ['400003']}, {'input': '999999999999999994d\r\n', 'output': ['3999999999999999978']}, {'input': '11f\r\n', 'output': ['33']}, {'input': '999999999999999997a\r\n', 'output': ['3999999999999999988']}]
[{'input': '999999999a\r\n', 'output': ['3999999988']}, {'input': '999999999999999993e\r\n', 'output': ['3999999999999999970']}, {'input': '3c\r\n', 'output': ['6']}, {'input': '8f\r\n', 'output': ['24']}, {'input': '4c\r\n', 'output': ['13']}]
[{'input': '999999999999999993e\r\n', 'output': ['3999999999999999970']}, {'input': '2c\r\n', 'output': ['13']}, {'input': '3d\r\n', 'output': ['3']}, {'input': '999999999999999994a\r\n', 'output': ['3999999999999999979']}, {'input': '999999999999999999a\r\n', 'output': ['3999999999999999988']}]
[{'input': '999999997d\r\n', 'output': ['3999999987']}, {'input': '999999999999999999c\r\n', 'output': ['3999999999999999990']}, {'input': '4b\r\n', 'output': ['12']}, {'input': '1e\r\n', 'output': ['2']}, {'input': '2f\r\n', 'output': ['8']}]
[{'input': '8f\r\n', 'output': ['24']}, {'input': '1a\r\n', 'output': ['4']}, {'input': '999999999b\r\n', 'output': ['3999999989']}, {'input': '999999999999999999d\r\n', 'output': ['3999999999999999987']}, {'input': '999999888888777777a\r\n', 'output': ['3999999555555111108']}]
100
100
100
100
100
89.29
89.29
89.29
92.86
89.29
75
75
80
90
80
205
100
90.004
80
["2 2 1 0 0 1", "2 2 10 11 0 1", "2 4 3 -1 3 7"]
The only line contains integers a, b, x1, y1, x2 and y2 β€” the parameters of the bad squares, the coordinates of the initial and the final squares correspondingly (2 ≀ a, b ≀ 109 and |x1|,|y1|,|x2|,|y2| ≀ 109). It is guaranteed that the initial and the final square aren't bad.
7219d1837c83b5920992aee5a60dc0d9
import java.io.*; import java.util.*; public class Main { void solve(Scanner in, PrintWriter out) { int a = in.nextInt(); int b = in.nextInt(); int x1 = in.nextInt(); int y1 = in.nextInt(); int x2 = in.nextInt(); int y2 = in.nextInt(); int n1 = Math.floorD...
["1", "5", "2"]
Java
NoteIn the third sample one of the possible paths in (3;-1)-&gt;(3;0)-&gt;(3;1)-&gt;(3;2)-&gt;(4;2)-&gt;(4;3)-&gt;(4;4)-&gt;(4;5)-&gt;(4;6)-&gt;(4;7)-&gt;(3;7). Squares (3;1) and (4;4) are bad.
Print a single number β€” the minimum number of bad cells that one will have to visit in order to travel from square (x1; y1) to square (x2; y2).
You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you can move to any other side-neighboring one. A square (x; y) is consid...
[{"input": "2 2 1 0 0 1\r\n", "output": ["1"]}, {"input": "2 2 10 11 0 1\r\n", "output": ["5"]}, {"input": "2 4 3 -1 3 7\r\n", "output": ["2"]}, {"input": "2 2 9 10 -10 -11\r\n", "output": ["10"]}, {"input": "3 2 -11 -10 10 11\r\n", "output": ["7"]}, {"input": "3 2 11 -12 -12 11\r\n", "output": ["11"]}, {"input": "3 3 ...
100
100
100
[{'input': '55 22 189761193 -192020216 -153412991 188486816\r\n', 'output': ['16447301']}, {'input': '53 50 -120558789 -138770904 4229051 102239338\r\n', 'output': ['3450925']}, {'input': '664 408 -151206136 -299481355 -385233545 310492602\r\n', 'output': ['1034315']}, {'input': '18 116 231579605 226020224 -214399491 -...
[{'input': '42 45 13921918 62207801 80023961 -85820354\r\n', 'output': ['2379224']}, {'input': '2571 2243 474188235 -306739018 48936920 -83297677\r\n', 'output': ['144603']}, {'input': '2033 1908 -480144210 482795119 496763189 -594064604\r\n', 'output': ['538199']}, {'input': '3 2 -8 -9 -14 -1\r\n', 'output': ['4']}, {...
[{'input': '4 4 0 -3 11 -4\r\n', 'output': ['1']}, {'input': '20967 19929 821529452 892087465 -867106029 -836044344\r\n', 'output': ['81480']}, {'input': '1425 1444 516172942 520776621 -319341286 -488388923\r\n', 'output': ['647256']}, {'input': '72 75 182000846 -19533501 -166922752 -142084479\r\n', 'output': ['3274129...
[{'input': '4 4 3 2 10 -1\r\n', 'output': ['1']}, {'input': '125 204 91089644 83192699 -300075653 54365352\r\n', 'output': ['1679971']}, {'input': '3 4 -8 5 6 -3\r\n', 'output': ['3']}, {'input': '101304499 148554333 -590787464 -890180401 -117457421 997140710\r\n', 'output': ['12']}, {'input': '3 5 -20 19 21 16\r\n', '...
[{'input': '783 827 -98613981 316213558 -275430891 455234090\r\n', 'output': ['190954']}, {'input': '10005 10008 -234169778 -592210597 -126329886 -812018105\r\n', 'output': ['16370']}, {'input': '1425 1444 516172942 520776621 -319341286 -488388923\r\n', 'output': ['647256']}, {'input': '3 2 8 -25 0 25\r\n', 'output': [...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
206
100
100
100
["12"]
The only line of the input contains one integer n (1 ≀ n ≀ 1018) β€” the prediction on the number of people who will buy the game.
e392be5411ffccc1df50e65ec1f5c589
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long res = (n / 2) + (n / 3) - (n / 6) + (n / 42) +(n / 5) + (n / 7) + (n/ 30) + (n / 70) + (n / 105) -(n /...
["2"]
Java
null
Output one integer showing how many numbers from 1 to n are not divisible by any number from 2 to 10.
IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is not divisible ...
[{"input": "12\r\n", "output": ["2"]}, {"input": "2519\r\n", "output": ["576"]}, {"input": "2521\r\n", "output": ["577"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "314159265\r\n", "output": ["71807832"]}, {"input": "718281828459045235\r\n", "output": ["164178703647781768"]}, {"input": "1000000000000000000\r\n", ...
100
100
100
[{'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '12\r\n', 'output': ['2']}, {'input': '3628800\r\n', 'output': ['829440']}, {'input': '2519\r\n', 'output': ['576']}, {'input': '718281828459045235\r\n', 'output': ['164178703647781768']}]
[{'input': '314159265\r\n', 'output': ['71807832']}, {'input': '3628800\r\n', 'output': ['829440']}, {'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '1\r\n', 'output': ['1']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}]
[{'input': '2521\r\n', 'output': ['577']}, {'input': '12\r\n', 'output': ['2']}, {'input': '3628800\r\n', 'output': ['829440']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}]
[{'input': '3628800\r\n', 'output': ['829440']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '314159265\r\n', 'output': ['71807832']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '12\r\n', 'output': ['2']}]
[{'input': '12\r\n', 'output': ['2']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '2519\r\n', 'output': ['576']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
207
100
100
100
["1 1 2", "3 4 5", "4 1 1"]
The single line of the input contains three space-separated integers a, b and c (1 ≀ a, b, c ≀ 106) β€” the valence numbers of the given atoms.
b3b986fddc3770fed64b878fa42ab1bc
import java.util.Scanner; public class SimpleMoecules { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int a = input.nextInt(); int b = input.nextInt(); int c = input.nextInt(); if((c+b-a)%2==0){ int z = (c+b-a)/2; if(z<0){ ...
["0 1 1", "1 3 2", "Impossible"]
Java
NoteThe first sample corresponds to the first figure. There are no bonds between atoms 1 and 2 in this case.The second sample corresponds to the second figure. There is one or more bonds between each pair of atoms.The third sample corresponds to the third figure. There is no solution, because an atom cannot form bonds ...
If such a molecule can be built, print three space-separated integers β€” the number of bonds between the 1-st and the 2-nd, the 2-nd and the 3-rd, the 3-rd and the 1-st atoms, correspondingly. If there are multiple solutions, output any of them. If there is no solution, print "Impossible" (without the quotes).
Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number β€” the number of bonds the atom must form with other atoms. An atom can form one o...
[{"input": "1 1 2\r\n", "output": ["0 1 1"]}, {"input": "3 4 5\r\n", "output": ["1 3 2"]}, {"input": "4 1 1\r\n", "output": ["Impossible"]}, {"input": "1 1 1\r\n", "output": ["Impossible"]}, {"input": "1000000 1000000 1000000\r\n", "output": ["500000 500000 500000"]}, {"input": "3 11 8\r\n", "output": ["3 8 0"]}, {"inp...
100
100
100
[{'input': '3 11 8\r\n', 'output': ['3 8 0']}, {'input': '8 5 12\r\n', 'output': ['Impossible']}, {'input': '10 5 15\r\n', 'output': ['0 5 10']}, {'input': '9 95 90\r\n', 'output': ['7 88 2']}, {'input': '2 2 2\r\n', 'output': ['1 1 1']}]
[{'input': '59 54 56\r\n', 'output': ['Impossible']}, {'input': '10 4 16\r\n', 'output': ['Impossible']}, {'input': '9 95 90\r\n', 'output': ['7 88 2']}, {'input': '8 5 12\r\n', 'output': ['Impossible']}, {'input': '1 1 3\r\n', 'output': ['Impossible']}]
[{'input': '7357 3578 9123\r\n', 'output': ['906 2672 6451']}, {'input': '3 5 8\r\n', 'output': ['0 5 3']}, {'input': '5 8 13\r\n', 'output': ['0 8 5']}, {'input': '1000000 500000 2\r\n', 'output': ['Impossible']}, {'input': '741349 48244 642678\r\n', 'output': ['Impossible']}]
[{'input': '2 4 2\r\n', 'output': ['2 2 0']}, {'input': '1000000 1000000 1000000\r\n', 'output': ['500000 500000 500000']}, {'input': '1 1 3\r\n', 'output': ['Impossible']}, {'input': '4 4 4\r\n', 'output': ['2 2 2']}, {'input': '3 3 6\r\n', 'output': ['0 3 3']}]
[{'input': '5 8 13\r\n', 'output': ['0 8 5']}, {'input': '8 5 12\r\n', 'output': ['Impossible']}, {'input': '688348 726472 442198\r\n', 'output': ['486311 240161 202037']}, {'input': '246 137 940\r\n', 'output': ['Impossible']}, {'input': '1 1 1\r\n', 'output': ['Impossible']}]
100
100
100
100
100
71.43
80.95
80.95
71.43
71.43
62.5
75
75
62.5
62.5
208
100
75.238
67.5
["4"]
The only line contains an integer n (2 ≀ n ≀ 1012), the number of vertices in the graph.
a98f0d924ea52cafe0048f213f075891
// http://codeforces.com/contest/959/problem/E import java.io.*; import java.util.InputMismatchException; public class CF959E { public static void main(String[] args) throws IOException { InputReader in = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); final ...
["4"]
Java
NoteIn the first sample: The weight of the minimum spanning tree is 1+2+1=4.
The only line contains an integer x, the weight of the graph's minimum spanning tree.
Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≀ u &lt; v &lt; n, vertex u and vertex v are connected with an undirected edge that has weight (where is the bitwi...
[{"input": "4\r\n", "output": ["4"]}, {"input": "10\r\n", "output": ["21"]}, {"input": "2\r\n", "output": ["1"]}, {"input": "1000000000000\r\n", "output": ["20140978692096"]}, {"input": "999999999999\r\n", "output": ["20140978692095"]}, {"input": "23131234\r\n", "output": ["293058929"]}, {"input": "100000\r\n", "output...
100
100
100
[{'input': '1048576\r\n', 'output': ['10485760']}, {'input': '999999999999\r\n', 'output': ['20140978692095']}, {'input': '23131234\r\n', 'output': ['293058929']}, {'input': '200\r\n', 'output': ['844']}, {'input': '7\r\n', 'output': ['11']}]
[{'input': '10\r\n', 'output': ['21']}, {'input': '123456789\r\n', 'output': ['1680249144']}, {'input': '536870912\r\n', 'output': ['7784628224']}, {'input': '6\r\n', 'output': ['9']}, {'input': '1048576\r\n', 'output': ['10485760']}]
[{'input': '200\r\n', 'output': ['844']}, {'input': '4\r\n', 'output': ['4']}, {'input': '6\r\n', 'output': ['9']}, {'input': '7\r\n', 'output': ['11']}, {'input': '1048576\r\n', 'output': ['10485760']}]
[{'input': '10\r\n', 'output': ['21']}, {'input': '1000000000000\r\n', 'output': ['20140978692096']}, {'input': '2\r\n', 'output': ['1']}, {'input': '999999999999\r\n', 'output': ['20140978692095']}, {'input': '549755813889\r\n', 'output': ['11269994184704']}]
[{'input': '549755813888\r\n', 'output': ['10720238370816']}, {'input': '4\r\n', 'output': ['4']}, {'input': '536870912\r\n', 'output': ['7784628224']}, {'input': '7\r\n', 'output': ['11']}, {'input': '3\r\n', 'output': ['3']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
209
100
100
100
["5", "3"]
The first and only line of the input contains a single integer n (3 ≀ n ≀ 54321) - the number of vertices of the regular polygon drawn by Ari.
efa8e7901a3084d34cfb1a6b18067f2b
import java.util.Scanner; public class cls_div2_328_B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long n = scan.nextInt(); scan.close(); long result = (n - 2) + ((n - 3) * (n - 2)); System.out.pr...
["9", "1"]
Java
NoteOne of the possible solutions for the first sample is shown on the picture above.
Print the minimum number of jumps Ada should make to collect all the walnuts. Note, that she doesn't need to leave the polygon after.
Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.Ari draws a regular convex polygon on the floor and numbers it's vertices 1, 2, ..., n in clockwise order. Then starting from the vertex 1 she draws a ray in the direction of each other vertex. ...
[{"input": "5\r\n", "output": ["9"]}, {"input": "3\r\n", "output": ["1"]}, {"input": "54321\r\n", "output": ["2950553761"]}, {"input": "4\r\n", "output": ["4"]}, {"input": "6\r\n", "output": ["16"]}, {"input": "7\r\n", "output": ["25"]}, {"input": "8\r\n", "output": ["36"]}, {"input": "9\r\n", "output": ["49"]}, {"inpu...
100
100
100
[{'input': '4\r\n', 'output': ['4']}, {'input': '54314\r\n', 'output': ['2949793344']}, {'input': '8\r\n', 'output': ['36']}, {'input': '54320\r\n', 'output': ['2950445124']}, {'input': '8153\r\n', 'output': ['66438801']}]
[{'input': '20380\r\n', 'output': ['415262884']}, {'input': '16659\r\n', 'output': ['277455649']}, {'input': '23481\r\n', 'output': ['551263441']}, {'input': '54320\r\n', 'output': ['2950445124']}, {'input': '5\r\n', 'output': ['9']}]
[{'input': '54318\r\n', 'output': ['2950227856']}, {'input': '7\r\n', 'output': ['25']}, {'input': '10\r\n', 'output': ['64']}, {'input': '4\r\n', 'output': ['4']}, {'input': '54316\r\n', 'output': ['2950010596']}]
[{'input': '10\r\n', 'output': ['64']}, {'input': '4\r\n', 'output': ['4']}, {'input': '7\r\n', 'output': ['25']}, {'input': '20380\r\n', 'output': ['415262884']}, {'input': '3\r\n', 'output': ['1']}]
[{'input': '54317\r\n', 'output': ['2950119225']}, {'input': '5\r\n', 'output': ['9']}, {'input': '54315\r\n', 'output': ['2949901969']}, {'input': '6\r\n', 'output': ['16']}, {'input': '314\r\n', 'output': ['97344']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
210
100
100
100
["7\nABACABA", "5\nZZZAA"]
The first line of the input contains integer number $$$n$$$ ($$$2 \le n \le 100$$$) β€” the length of string $$$s$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ capital Latin letters.
e78005d4be93dbaa518f3b40cca84ab1
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String s=sc.next(); char c[]=s.toCharArray(); char aa='1',bb='1'; int max=-1; for(int i=0;i<c.length-1;i++){ char a=c[i],b=c[i+1]; int con=1; for(int j=i+1;j<c...
["AB", "ZZ"]
Java
NoteIn the first example "BA" is also valid answer.In the second example the only two-gram "ZZ" can be printed because it contained in the string "ZZZAA" two times.
Print the only line containing exactly two capital Latin letters β€” any two-gram contained in the given string $$$s$$$ as a substring (i.e. two consecutive characters of the string) maximal number of times.
Two-gram is an ordered pair (i.e. string of length two) of capital Latin letters. For example, "AZ", "AA", "ZA" β€” three distinct two-grams.You are given a string $$$s$$$ consisting of $$$n$$$ capital Latin letters. Your task is to find any two-gram contained in the given string as a substring (i.e. two consecutive char...
[{"input": "7\r\nABACABA\r\n", "output": ["BA", "AB"]}, {"input": "5\r\nZZZAA\r\n", "output": ["ZZ"]}, {"input": "26\r\nQWERTYUIOPASDFGHJKLZXCVBNM\r\n", "output": ["KL", "QW", "WE", "AS"]}, {"input": "2\r\nQA\r\n", "output": ["QA"]}, {"input": "2\r\nWW\r\n", "output": ["WW"]}, {"input": "11\r\nGGRRAATTZZZ\r\n", "output...
100
100
100
[{'input': '100\r\nURXCAIZFIBNJTPCZHBQIBCILLPXZCFGMKKZMNPLCYGAVJVIBMCZEBSJWPSCPQDYCTTKPOKIJRSKIZPDGCHVOUTMPNECYORSFZFNC\r\n', 'output': ['IB']}, {'input': '9\r\nAAAAAAAAA\r\n', 'output': ['AA']}, {'input': '23\r\nAABBBAAACCCCCAAADDDDDDD\r\n', 'output': ['DD']}, {'input': '7\r\nABACABA\r\n', 'output': ['BA', 'AB']}, {'i...
[{'input': '3\r\nLOL\r\n', 'output': ['OL', 'LO']}, {'input': '9\r\nMIKEPIDOR\r\n', 'output': ['EP', 'MI', 'DO', 'IK']}, {'input': '2\r\nWW\r\n', 'output': ['WW']}, {'input': '11\r\nGGRRAATTZZZ\r\n', 'output': ['ZZ']}, {'input': '100\r\nURXCAIZFIBNJTPCZHBQIBCILLPXZCFGMKKZMNPLCYGAVJVIBMCZEBSJWPSCPQDYCTTKPOKIJRSKIZPDGCHV...
[{'input': '7\r\nKADUROV\r\n', 'output': ['KA', 'AD']}, {'input': '9\r\nEGORLETOV\r\n', 'output': ['GO', 'EG', 'TO']}, {'input': '50\r\nNYQAHBYYOXLTRYQDMVENEMAQNBAKGLGQOLXNAIFNQTOCLNNQIA\r\n', 'output': ['NQ', 'YQ']}, {'input': '5\r\nAZAZA\r\n', 'output': ['ZA', 'AZ']}, {'input': '15\r\nMIRZOYANOVECLOX\r\n', 'output': ...
[{'input': '11\r\nGGRRAATTZZZ\r\n', 'output': ['ZZ']}, {'input': '9\r\nAAAAAAAAA\r\n', 'output': ['AA']}, {'input': '2\r\nQA\r\n', 'output': ['QA']}, {'input': '9\r\nMIKEPIDOR\r\n', 'output': ['EP', 'MI', 'DO', 'IK']}, {'input': '5\r\nFUFEL\r\n', 'output': ['UF', 'EL', 'FU']}]
[{'input': '2\r\nWW\r\n', 'output': ['WW']}, {'input': '50\r\nNYQAHBYYOXLTRYQDMVENEMAQNBAKGLGQOLXNAIFNQTOCLNNQIA\r\n', 'output': ['NQ', 'YQ']}, {'input': '10\r\nSQSQSQSQTG\r\n', 'output': ['SQ']}, {'input': '5\r\nAZAZA\r\n', 'output': ['ZA', 'AZ']}, {'input': '5\r\nFUFEL\r\n', 'output': ['UF', 'EL', 'FU']}]
100
100
100
100
100
100
100
100
100
100
94.44
94.44
94.44
100
94.44
211
100
100
95.552
["10 2\n3 5\n11 13", "10 3\n3 5\n9 10\n11 13", "20 1\n3 19"]
The first line contains two integers n and k (1 ≀ n ≀ 100 000, 1 ≀ k ≀ 100)Β β€” the number of seconds the cutlet should be cooked on each side and number of periods of time in which Arkady can flip it. The next k lines contain descriptions of these intervals. Each line contains two integers li and ri (0 ≀ li ≀ ri ≀ 2Β·n),...
2e0d1b1f1a7b8df2d2598c3cb2c869d5
import java.io.*; import java.util.*; public class CF939_D2_F { public static void main(String[] args)throws Throwable { MyScanner sc=new MyScanner(); PrintWriter pw=new PrintWriter(System.out); int n=sc.nextInt()*2; int k=sc.nextInt(); int [] l=new int [k+1]; int [] r=new int [k+1]; SparseTable [][] ...
["Full\n2", "Full\n1", "Hungry"]
Java
NoteIn the first example Arkady should flip the cutlet in time moment 3 seconds after he starts cooking and in time moment 13 seconds after he starts cooking.In the second example, Arkady can flip the cutlet at 10 seconds after he starts cooking.
Output "Hungry" if Arkady won't be able to fry the cutlet for exactly n seconds on one side and exactly n seconds on the other side. Otherwise, output "Full" in the first line, and the minimum number of times he should flip the cutlet in the second line.
Arkady wants to have a dinner. He has just returned from a shop where he has bought a semifinished cutlet. He only needs to fry it. The cutlet should be fried for 2n seconds, in particular, it should be fried for n seconds on one side and n seconds on the other side. Arkady has already got a frying pan and turn on fire...
[{"input": "10 2\r\n3 5\r\n11 13\r\n", "output": ["Full\r\n2"]}, {"input": "10 3\r\n3 5\r\n9 10\r\n11 13\r\n", "output": ["Full\r\n1"]}, {"input": "20 1\r\n3 19\r\n", "output": ["Hungry"]}, {"input": "10 1\r\n0 20\r\n", "output": ["Full\r\n1"]}, {"input": "10 1\r\n0 1\r\n", "output": ["Hungry"]}, {"input": "10 1\r\n10 ...
100
100
100
[{'input': '100000 3\r\n54962 59962\r\n98273 103273\r\n174042 179042\r\n', 'output': ['Full\r\n1']}, {'input': '100000 1\r\n100000 100000\r\n', 'output': ['Full\r\n1']}, {'input': '1000 5\r\n123 174\r\n716 789\r\n1284 1360\r\n1415 1443\r\n1623 1648\r\n', 'output': ['Full\r\n3']}, {'input': '10 2\r\n4 4\r\n14 14\r\n', '...
[{'input': '100000 2\r\n0 99999\r\n100001 200000\r\n', 'output': ['Full\r\n2']}, {'input': '100000 20\r\n5000 9999\r\n14999 19998\r\n24998 29997\r\n34997 39996\r\n44996 49995\r\n54995 59994\r\n64994 69993\r\n74993 79992\r\n84992 89991\r\n94991 99990\r\n104990 109989\r\n114989 119988\r\n124988 129987\r\n134987 139986\r\...
[{'input': '100000 17\r\n7247 18957\r\n56758 64403\r\n79823 83648\r\n83649 83715\r\n83732 84946\r\n84947 84963\r\n84964 84968\r\n84970 84978\r\n84982 84991\r\n84992 87130\r\n172421 176513\r\n176514 176596\r\n176629 176689\r\n176692 177213\r\n197692 199830\r\n199831 199993\r\n199997 200000\r\n', 'output': ['Full\r\n3']}...
[{'input': '100000 6\r\n397 1397\r\n15892 16892\r\n35746 36746\r\n94193 95193\r\n166848 167848\r\n185228 186228\r\n', 'output': ['Full\r\n5']}, {'input': '20 1\r\n3 19\r\n', 'output': ['Hungry']}, {'input': '1000 5\r\n123 174\r\n716 789\r\n1284 1360\r\n1415 1443\r\n1623 1648\r\n', 'output': ['Full\r\n3']}, {'input': '1...
[{'input': '1000 6\r\n292 304\r\n1135 1147\r\n1338 1350\r\n1472 1491\r\n1720 1732\r\n1773 1790\r\n', 'output': ['Full\r\n4']}, {'input': '100000 12\r\n589 2312\r\n2349 12326\r\n12499 12759\r\n12796 21228\r\n70394 77570\r\n77571 86238\r\n133314 135096\r\n135104 135113\r\n135118 135128\r\n135135 137324\r\n190272 199989\r...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
212
100
100
100
["4 2", "3 2"]
The input contains a single line consisting of $$$2$$$ integers $$$N$$$ and $$$M$$$ ($$$1 \le N \le 10^{18}$$$, $$$2 \le M \le 100$$$).
e7b9eec21d950f5d963ff50619c6f119
import java.util.*; public class issam{ static class consecutive{ long mod; long[][] matrix; long nbWays(long n,int m,long mod){ this.mod = mod; if(n<(long)m) return 1; if(n==(long)m) return 2; if(m==1) return nbPow(2,n); matrix = n...
["5", "3"]
Java
NoteIn the first example each magic gem can split into $$$2$$$ normal gems, and we know that the total amount of gems are $$$4$$$.Let $$$1$$$ denote a magic gem, and $$$0$$$ denote a normal gem.The total configurations you can have is: $$$1 1 1 1$$$ (None of the gems split); $$$0 0 1 1$$$ (First magic gem splits int...
Print one integer, the total number of configurations of the resulting set of gems, given that the total amount of space taken is $$$N$$$ units. Print the answer modulo $$$1000000007$$$ ($$$10^9+7$$$).
Reziba has many magic gems. Each magic gem can be split into $$$M$$$ normal gems. The amount of space each magic (and normal) gem takes is $$$1$$$ unit. A normal gem cannot be split.Reziba wants to choose a set of magic gems and split some of them, so the total space occupied by the resulting set of gems is $$$N$$$ uni...
[{"input": "4 2\r\n", "output": ["5"]}, {"input": "3 2\r\n", "output": ["3"]}, {"input": "1000000000000000000 2\r\n", "output": ["680057396"]}, {"input": "1000000000000000000 3\r\n", "output": ["615472476"]}, {"input": "1000000000000000000 5\r\n", "output": ["285726867"]}, {"input": "1000000000000000000 42\r\n", "outpu...
100
100
100
[{'input': '1000000000000000000 69\r\n', 'output': ['864131130']}, {'input': '1000000000000000000 99\r\n', 'output': ['847914677']}, {'input': '5 4\r\n', 'output': ['3']}, {'input': '69 2\r\n', 'output': ['489376391']}, {'input': '99 99\r\n', 'output': ['2']}]
[{'input': '5 5\r\n', 'output': ['2']}, {'input': '2 4\r\n', 'output': ['1']}, {'input': '25 2\r\n', 'output': ['121393']}, {'input': '1000000000000000000 2\r\n', 'output': ['680057396']}, {'input': '6 5\r\n', 'output': ['3']}]
[{'input': '2 5\r\n', 'output': ['1']}, {'input': '1000000000000000000 5\r\n', 'output': ['285726867']}, {'input': '1000000000000000000 69\r\n', 'output': ['864131130']}, {'input': '4 2\r\n', 'output': ['5']}, {'input': '7 2\r\n', 'output': ['21']}]
[{'input': '1000000000000000000 5\r\n', 'output': ['285726867']}, {'input': '1000000000000000000 3\r\n', 'output': ['615472476']}, {'input': '576460752303423487 100\r\n', 'output': ['163029191']}, {'input': '1000000000000000000 100\r\n', 'output': ['161502719']}, {'input': '5 5\r\n', 'output': ['2']}]
[{'input': '5 5\r\n', 'output': ['2']}, {'input': '2 5\r\n', 'output': ['1']}, {'input': '1000000000000000000 99\r\n', 'output': ['847914677']}, {'input': '5 3\r\n', 'output': ['4']}, {'input': '2 2\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
213
100
100
100
["3", "6", "100"]
The single line contains a single integer n (1 ≀ n ≀ 105).
63262317ba572d78163c91b853c05506
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plu...
["2", "-1", "8"]
Java
null
If Serozha wins, print k, which represents the minimal number of piles into which he can split the initial one during the first move in order to win the game. If Gena wins, print "-1" (without the quotes).
Two best friends Serozha and Gena play a game.Initially there is one pile consisting of n stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of a1 &gt; a2 &gt; ... &gt; ak &gt; 0 stones. The piles should meet the condition a1 - a2 = a2 - a3 = ... = ak ...
[{"input": "3\r\n", "output": ["2"]}, {"input": "6\r\n", "output": ["-1"]}, {"input": "100\r\n", "output": ["8"]}, {"input": "33\r\n", "output": ["2"]}, {"input": "23\r\n", "output": ["-1"]}, {"input": "35\r\n", "output": ["-1"]}, {"input": "15\r\n", "output": ["2"]}, {"input": "99\r\n", "output": ["2"]}, {"input": "46...
100
100
100
[{'input': '41385\r\n', 'output': ['15']}, {'input': '6\r\n', 'output': ['-1']}, {'input': '573\r\n', 'output': ['3']}, {'input': '3\r\n', 'output': ['2']}, {'input': '38798\r\n', 'output': ['76']}]
[{'input': '42602\r\n', 'output': ['17']}, {'input': '66873\r\n', 'output': ['2']}, {'input': '684\r\n', 'output': ['-1']}, {'input': '35\r\n', 'output': ['-1']}, {'input': '42863\r\n', 'output': ['-1']}]
[{'input': '100000\r\n', 'output': ['-1']}, {'input': '9564\r\n', 'output': ['3']}, {'input': '35708\r\n', 'output': ['-1']}, {'input': '56\r\n', 'output': ['-1']}, {'input': '100\r\n', 'output': ['8']}]
[{'input': '45899\r\n', 'output': ['-1']}, {'input': '56\r\n', 'output': ['-1']}, {'input': '1515\r\n', 'output': ['2']}, {'input': '36655\r\n', 'output': ['-1']}, {'input': '63478\r\n', 'output': ['-1']}]
[{'input': '100000\r\n', 'output': ['-1']}, {'input': '39509\r\n', 'output': ['-1']}, {'input': '46\r\n', 'output': ['4']}, {'input': '63478\r\n', 'output': ['-1']}, {'input': '8149\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
214
100
100
100
["2 0 3 3 5 21", "2 4 3 0 6 17"]
The only line contains six integers a1, b1, a2, b2, L, R (0 &lt; a1, a2 ≀ 2Β·109,  - 2Β·109 ≀ b1, b2, L, R ≀ 2Β·109, L ≀ R).
b08ee0cd6f5cb574086fa02f07d457a4
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.math.BigInteger; import java.util.Random; import java.util.StringTokenizer; public class D { public static void main(String[] args) { FastScanner sc = new FastScanner(); ...
["3", "2"]
Java
null
Print the desired number of integers x.
You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≀ x ≀ R and x = a1k' + b1 = a2l' + b2, for some integers k', l' β‰₯ 0.
[{"input": "2 0 3 3 5 21\r\n", "output": ["3"]}, {"input": "2 4 3 0 6 17\r\n", "output": ["2"]}, {"input": "2 0 4 2 -39 -37\r\n", "output": ["0"]}, {"input": "1 9 3 11 49 109\r\n", "output": ["20"]}, {"input": "3 81 5 72 -1761 501\r\n", "output": ["28"]}, {"input": "8 -89 20 67 8771 35222\r\n", "output": ["661"]}, {"in...
100
100
100
[{'input': '1 1 1 1 -2000000000 2000000000\r\n', 'output': ['2000000000']}, {'input': '1 10497 19135 2995296 -301164547 -180830773\r\n', 'output': ['0']}, {'input': '1689390799 501112014 13 -1621132473 398367938 709483101\r\n', 'output': ['0']}, {'input': '1228969457 -1826233120 11 -1063855654 -819177202 1039858319\r\n...
[{'input': '16 -16 5 20 -9 7\r\n', 'output': ['0']}, {'input': '66 90 48 84 -1709970247 1229724777\r\n', 'output': ['2329024']}, {'input': '1446642133 -7 9 -1719422944 -916435667 36154654\r\n', 'output': ['1']}, {'input': '2 -1500000000 4 -1499999999 1600000000 1700000000\r\n', 'output': ['0']}, {'input': '18 -11234731...
[{'input': '989432982 2 9 366779468 -1427636085 985664909\r\n', 'output': ['0']}, {'input': '1480269313 -1048624081 1314841531 -8 295288505 358226461\r\n', 'output': ['0']}, {'input': '13 0 1419591662 -1360930956 343359607 1283114457\r\n', 'output': ['0']}, {'input': '70 -835526513 23 687193329 -1461506792 1969698938\r...
[{'input': '1 1 1 1 -2000000000 2000000000\r\n', 'output': ['2000000000']}, {'input': '8 40306 2753 1809818 254464419 340812028\r\n', 'output': ['3921']}, {'input': '66 90 48 84 -1709970247 1229724777\r\n', 'output': ['2329024']}, {'input': '2 -1000000000 2 -999999999 -1000000000 1000000000\r\n', 'output': ['0']}, {'in...
[{'input': '4 -9 1 -2 -13 -1\r\n', 'output': ['1']}, {'input': '1 -9 2 -10 -10 -9\r\n', 'output': ['0']}, {'input': '12 -696575903 571708420 236073275 2 14\r\n', 'output': ['0']}, {'input': '8 40306 2753 1809818 254464419 340812028\r\n', 'output': ['3921']}, {'input': '9 -1 8 -1 -711474975 237571596\r\n', 'output': ['3...
100
100
100
100
100
96.15
100
96.15
98.08
100
83.33
100
83.33
91.67
100
215
100
98.076
91.666
["3 2\n1 3\n2 1", "5 5\n3 3\n3 3", "4 2\n2 3\n1 2"]
The first line contains two space-separated numbers a1 and b1 β€” the sides of the board. Next two lines contain numbers a2, b2, a3 and b3 β€” the sides of the paintings. All numbers ai, bi in the input are integers and fit into the range from 1 to 1000.
2ff30d9c4288390fd7b5b37715638ad9
import java.util.*; public class CF560BGetaldIntoArts { public static void main(String[] args) { Scanner s = new Scanner(System.in); boolean b = true; int a1 = s.nextInt(); int b1 = s.nextInt(); int a2 = s.nextInt(); int b2 = s.nextInt(); int a3 = s.nextInt...
["YES", "NO", "YES"]
Java
NoteThat's how we can place the pictures in the first test:And that's how we can do it in the third one.
If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO" (without the quotes).
Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a1 × b1 rectangle, the paintings have shape of a a2 × b2 and a3 × b3 rectangles.Since the ...
[{"input": "3 2\r\n1 3\r\n2 1\r\n", "output": ["YES"]}, {"input": "5 5\r\n3 3\r\n3 3\r\n", "output": ["NO"]}, {"input": "4 2\r\n2 3\r\n1 2\r\n", "output": ["YES"]}, {"input": "3 3\r\n1 1\r\n1 1\r\n", "output": ["YES"]}, {"input": "1000 1000\r\n999 999\r\n1 1000\r\n", "output": ["YES"]}, {"input": "7 7\r\n5 5\r\n2 4\r\n...
100
100
100
[{'input': '9 10\r\n4 8\r\n5 6\r\n', 'output': ['YES']}, {'input': '3 3\r\n3 4\r\n3 6\r\n', 'output': ['NO']}, {'input': '7 10\r\n7 5\r\n1 7\r\n', 'output': ['YES']}, {'input': '78 86\r\n63 8\r\n9 4\r\n', 'output': ['YES']}, {'input': '9 7\r\n5 2\r\n4 1\r\n', 'output': ['YES']}]
[{'input': '7 3\r\n7 8\r\n1 5\r\n', 'output': ['NO']}, {'input': '993 1000\r\n201 307\r\n692 758\r\n', 'output': ['YES']}, {'input': '663 287\r\n193 212\r\n615 787\r\n', 'output': ['NO']}, {'input': '8 7\r\n1 7\r\n3 2\r\n', 'output': ['YES']}, {'input': '954 576\r\n324 433\r\n247 911\r\n', 'output': ['YES']}]
[{'input': '965 1000\r\n606 895\r\n533 394\r\n', 'output': ['YES']}, {'input': '32 891\r\n573 351\r\n648 892\r\n', 'output': ['NO']}, {'input': '9 7\r\n5 2\r\n4 1\r\n', 'output': ['YES']}, {'input': '91 100\r\n61 40\r\n60 88\r\n', 'output': ['YES']}, {'input': '162 742\r\n465 429\r\n571 29\r\n', 'output': ['NO']}]
[{'input': '8 7\r\n1 7\r\n3 2\r\n', 'output': ['YES']}, {'input': '95 72\r\n65 31\r\n89 50\r\n', 'output': ['NO']}, {'input': '99 100\r\n99 72\r\n68 1\r\n', 'output': ['YES']}, {'input': '32 891\r\n573 351\r\n648 892\r\n', 'output': ['NO']}, {'input': '58 64\r\n98 30\r\n61 52\r\n', 'output': ['NO']}]
[{'input': '97 100\r\n95 40\r\n70 60\r\n', 'output': ['YES']}, {'input': '868 535\r\n409 690\r\n761 104\r\n', 'output': ['YES']}, {'input': '100 100\r\n6 45\r\n97 54\r\n', 'output': ['YES']}, {'input': '10 10\r\n10 5\r\n4 3\r\n', 'output': ['YES']}, {'input': '501 932\r\n463 636\r\n363 918\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
76.47
76.47
73.53
88.24
70.59
216
100
100
77.06
["14 34", "50 34", "387420489 225159023", "5 5"]
The first line contains two integers a and c (0 ≀ a, c ≀ 109). Both numbers are written in decimal notation.
5fb635d52ddccf6a4d5103805da02a88
// ~/BAU/ACM-ICPC/Teams/A++/BlackBurn95 // ~/sudo apt-get Accpeted import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; ...
["50", "14", "1000000001", "0"]
Java
null
Print the single integer b, such that a tor b = c. If there are several possible numbers b, print the smallest one. You should print the number in decimal notation.
Little Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Ternatron IV" operates with ternary and not binary logic. Petya immediately wondered how the xor operation is performed on this computer (and whether there is anything like it...
[{"input": "14 34\r\n", "output": ["50"]}, {"input": "50 34\r\n", "output": ["14"]}, {"input": "387420489 225159023\r\n", "output": ["1000000001"]}, {"input": "5 5\r\n", "output": ["0"]}, {"input": "23476 23875625\r\n", "output": ["23860906"]}, {"input": "11111 10101010\r\n", "output": ["10116146"]}, {"input": "1 23865...
100
100
100
[{'input': '9925 9952\r\n', 'output': ['27']}, {'input': '2376234 0\r\n', 'output': ['4732515']}, {'input': '345157805 719310676\r\n', 'output': ['504894191']}, {'input': '69272798 718909239\r\n', 'output': ['668771236']}, {'input': '561666539 29904379\r\n', 'output': ['1152454076']}]
[{'input': '387420489 225159023\r\n', 'output': ['1000000001']}, {'input': '111174087 482024380\r\n', 'output': ['430083082']}, {'input': '294567098 631452590\r\n', 'output': ['745235571']}, {'input': '702754885 762686553\r\n', 'output': ['81198815']}, {'input': '50 34\r\n', 'output': ['14']}]
[{'input': '455705795 757666961\r\n', 'output': ['303798597']}, {'input': '987310001 827978268\r\n', 'output': ['275919178']}, {'input': '5341 813849430\r\n', 'output': ['813850920']}, {'input': '4232 755480607\r\n', 'output': ['755485882']}, {'input': '1000000000 100000000\r\n', 'output': ['650219958']}]
[{'input': '44788825 4485\r\n', 'output': ['89397617']}, {'input': '5341 813849430\r\n', 'output': ['813850920']}, {'input': '268520356 1999\r\n', 'output': ['135088146']}, {'input': '523162963 922976263\r\n', 'output': ['414184806']}, {'input': '154618752 504073566\r\n', 'output': ['753527130']}]
[{'input': '5440 6647\r\n', 'output': ['10711']}, {'input': '229485033 8860\r\n', 'output': ['308580772']}, {'input': '948688087 38251290\r\n', 'output': ['768385433']}, {'input': '657244587 28654748\r\n', 'output': ['921153434']}, {'input': '285938679 907528096\r\n', 'output': ['1068058915']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
90
217
100
100
98
["4 4\n5 2 4 1", "3 20\n199 41 299"]
The first line contains two integers n and m (1 ≀ n ≀ 35, 1 ≀ m ≀ 109). The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 109).
d3a8a3e69a55936ee33aedd66e5b7f4a
import java.util.Arrays; import java.util.Scanner; public class Main{ static int[] p = new int[(1<<18) + 10]; static int[] q = new int[(1<<18) + 10]; static int lenp = 0, lenq = 0; static int M = 0; public static void main(String[] args){ Scanner c = new Scanner(System.in); int n ...
["3", "19"]
Java
NoteIn the first example you can choose a sequence b = {1, 2}, so the sum is equal to 7 (and that's 3 after taking it modulo 4).In the second example you can choose a sequence b = {3}.
Print the maximum possible value of .
You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, ..., bk (1 ≀ b1 &lt; b2 &lt; ... &lt; bk ≀ n) in such a way that the value of is maximized. Chosen sequence can be empty.Print the maximum possible value of .
[{"input": "4 4\r\n5 2 4 1\r\n", "output": ["3"]}, {"input": "3 20\r\n199 41 299\r\n", "output": ["19"]}, {"input": "5 10\r\n47 100 49 2 56\r\n", "output": ["9"]}, {"input": "5 1000\r\n38361 75847 14913 11499 8297\r\n", "output": ["917"]}, {"input": "10 10\r\n48 33 96 77 67 59 35 15 14 86\r\n", "output": ["9"]}, {"inpu...
100
100
100
[{'input': '4 4\r\n5 2 4 1\r\n', 'output': ['3']}, {'input': '35 1000000000\r\n513 9778 5859 8149 297 7965 7152 917 243 4353 7248 4913 9403 6199 2930 7461 3888 1898 3222 9424 3960 1902 2933 5268 2650 1687 5319 5065 8450 141 4219 2586 2176 1118 9635\r\n', 'output': ['158921']}, {'input': '35 346194136\r\n89792 283104 58...
[{'input': '30 1000\r\n81021 18939 94456 90340 76840 78808 27921 71826 99382 1237 93435 35153 71691 25508 96732 23778 49073 60025 95231 88719 61650 50925 34416 73600 7295 14654 78340 72871 17324 77484\r\n', 'output': ['999']}, {'input': '35 106920170\r\n36941450 53002950 90488020 66086895 77577045 16147985 26130825 849...
[{'input': '6 7\r\n1 1 1 1 1 6\r\n', 'output': ['6']}, {'input': '35 982451653\r\n5253 7912 3641 7428 6138 9613 9059 6352 9070 89 9030 1686 3098 7852 3316 8158 7497 5804 130 6201 235 64 3451 6104 4148 3446 6059 6802 7466 8781 1636 8291 8874 8924 5997\r\n', 'output': ['197605']}, {'input': '2 8\r\n2 7\r\n', 'output': ['...
[{'input': '15 982451653\r\n384052103 7482105 882228352 582828798 992251028 892163214 687253903 951043841 277531875 402248542 499362766 919046434 350763964 288775999 982610665\r\n', 'output': ['982368704']}, {'input': '4 4\r\n5 2 4 1\r\n', 'output': ['3']}, {'input': '35 106920170\r\n36941450 53002950 90488020 66086895...
[{'input': '5 10\r\n47 100 49 2 56\r\n', 'output': ['9']}, {'input': '15 982451653\r\n7975 7526 1213 2318 209 7815 4153 1853 6651 2880 4535 587 8022 3365 5491\r\n', 'output': ['64593']}, {'input': '30 1000\r\n81021 18939 94456 90340 76840 78808 27921 71826 99382 1237 93435 35153 71691 25508 96732 23778 49073 60025 9523...
100
100
100
100
100
82.69
90.38
90.38
86.54
82.69
72.22
83.33
83.33
77.78
72.22
218
100
86.536
77.776
["40047", "7747774", "1000000000000000000"]
The only line contains an integer n (1 ≀ n ≀ 1018). Please do not use the %lld specificator to read or write 64-bit numbers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
33b73fd9e7f19894ea08e98b790d07f1
import java.util.Scanner; public class test3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); long n = input.nextLong(); if(check(n) == 7 || check(n) == 4) System.out.println("YES"); else System.out.println("NO"); } ...
["NO", "YES", "NO"]
Java
NoteIn the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".In the third sample there are no lucky digits, so the answer is "NO".
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky dig...
[{"input": "40047\r\n", "output": ["NO"]}, {"input": "7747774\r\n", "output": ["YES"]}, {"input": "1000000000000000000\r\n", "output": ["NO"]}, {"input": "7\r\n", "output": ["NO"]}, {"input": "4\r\n", "output": ["NO"]}, {"input": "474404774\r\n", "output": ["NO"]}, {"input": "4744000695826\r\n", "output": ["YES"]}, {"i...
100
100
100
[{'input': '999999999999994744\r\n', 'output': ['YES']}, {'input': '474447447774444774\r\n', 'output': ['NO']}, {'input': '1\r\n', 'output': ['NO']}, {'input': '777777777444444444\r\n', 'output': ['NO']}, {'input': '444444444444444444\r\n', 'output': ['NO']}]
[{'input': '777777777444444444\r\n', 'output': ['NO']}, {'input': '40047\r\n', 'output': ['NO']}, {'input': '9847745885202111\r\n', 'output': ['YES']}, {'input': '4\r\n', 'output': ['NO']}, {'input': '1\r\n', 'output': ['NO']}]
[{'input': '7747774\r\n', 'output': ['YES']}, {'input': '400000000474\r\n', 'output': ['YES']}, {'input': '9847745885202111\r\n', 'output': ['YES']}, {'input': '999999999999994744\r\n', 'output': ['YES']}, {'input': '963\r\n', 'output': ['NO']}]
[{'input': '123456789123456789\r\n', 'output': ['YES']}, {'input': '474447447774444774\r\n', 'output': ['NO']}, {'input': '87414417444\r\n', 'output': ['NO']}, {'input': '4700\r\n', 'output': ['NO']}, {'input': '855474448854788540\r\n', 'output': ['NO']}]
[{'input': '9847745885202111\r\n', 'output': ['YES']}, {'input': '999999999\r\n', 'output': ['NO']}, {'input': '400000000474\r\n', 'output': ['YES']}, {'input': '474447447774444774\r\n', 'output': ['NO']}, {'input': '87414417444\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
90
90
100
90
90
219
100
100
92
["10\nrocesfedoc", "16\nplmaetwoxesisiht", "1\nz"]
The first line of input consists of a single integer $$$n$$$ ($$$1 \le n \le 100$$$) β€” the length of the string $$$t$$$. The second line of input consists of the string $$$t$$$. The length of $$$t$$$ is $$$n$$$, and it consists only of lowercase Latin letters.
1b0b2ee44c63cb0634cb63f2ad65cdd3
import java.util.Scanner; public class RevEncrypt { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), i, j; String t = in.next(), s = ""; in.close(); for (i = 2; i <= n; i++) if (n % i == 0) { for (j = i - 1; j >= 0; j--) s += t.charAt(j); ...
["codeforces", "thisisexampletwo", "z"]
Java
NoteThe first example is described in the problem statement.
Print a string $$$s$$$ such that the above algorithm results in $$$t$$$.
A string $$$s$$$ of length $$$n$$$ can be encrypted by the following algorithm: iterate over all divisors of $$$n$$$ in decreasing order (i.e. from $$$n$$$ to $$$1$$$), for each divisor $$$d$$$, reverse the substring $$$s[1 \dots d]$$$ (i.e. the substring which starts at position $$$1$$$ and ends at position $$$d$$$)...
[{"input": "10\r\nrocesfedoc\r\n", "output": ["codeforces"]}, {"input": "16\r\nplmaetwoxesisiht\r\n", "output": ["thisisexampletwo"]}, {"input": "1\r\nz\r\n", "output": ["z"]}, {"input": "2\r\nir\r\n", "output": ["ri"]}, {"input": "3\r\nilj\r\n", "output": ["jli"]}, {"input": "4\r\njfyy\r\n", "output": ["yyjf"]}, {"inp...
100
100
100
[{'input': '16\r\nplmaetwoxesisiht\r\n', 'output': ['thisisexampletwo']}, {'input': '90\r\ncccchccccccccccccccccccccccccccwcccccccccgcccccchccccccccccccccccccccccxccccccncccccccuccc\r\n', 'output': ['cccucccccccnccccccxcccccccccccccccccccccchccccccccccccccccccccccchccccccccccwcccccccccgccc']}, {'input': '89\r\nwwwwwwww...
[{'input': '4\r\njfyy\r\n', 'output': ['yyjf']}, {'input': '16\r\nplmaetwoxesisiht\r\n', 'output': ['thisisexampletwo']}, {'input': '90\r\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm\r\n', 'output': ['mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm...
[{'input': '64\r\nhnlzzhrvqnldswxfsrowfhmyzbxtyoxhogudasgywxycyhzgiseerbislcncvnwy\r\n', 'output': ['ywnvcnclsibreesigzhycyxwygsadugofxwsdlnqzlhnzhrvsrowfhmyzbxtyoxh']}, {'input': '99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\r\n', 'output': ['qqqqqqqqqqqqqqq...
[{'input': '100\r\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\r\n', 'output': ['oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo']}, {'input': '100\r\ndjjjjjjjjjjgjjjjjjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjjjjajjjjjj...
[{'input': '89\r\nwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\r\n', 'output': ['wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww']}, {'input': '99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
220
100
100
100
["0 0 0 0 9\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n7 0 0 0 0", "0 43 21 18 2\n3 0 21 11 65\n5 2 0 1 4\n54 62 12 0 99\n87 64 81 33 0"]
The input consists of five lines, each line contains five space-separated integers: the j-th number in the i-th line shows gij (0 ≀ gij ≀ 105). It is guaranteed that gii = 0 for all i. Assume that the students are numbered from 1 to 5.
be6d4df20e9a48d183dd8f34531df246
import java.io.*; import java.math.BigInteger; import java.util.*; public class Temp3 { public static void main(String[] args) throws Throwable { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[][] arr = new int[5][5]; for (int i = 0; i < arr.length; i++) { StringTokenizer st = n...
["32", "620"]
Java
NoteIn the first sample, the optimal arrangement of the line is 23154. In this case, the total happiness equals:(g23 + g32 + g15 + g51) + (g13 + g31 + g54 + g45) + (g15 + g51) + (g54 + g45) = 32.
Print a single integer β€” the maximum possible total happiness of the students.
Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks. There is only one shower and there are multiple students who wish to have a shower in the morning. That's why every morning there is a line of five people in front of the dormitory s...
[{"input": "0 0 0 0 9\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n7 0 0 0 0\r\n", "output": ["32"]}, {"input": "0 43 21 18 2\r\n3 0 21 11 65\r\n5 2 0 1 4\r\n54 62 12 0 99\r\n87 64 81 33 0\r\n", "output": ["620"]}, {"input": "0 4 2 4 9\r\n6 0 2 5 0\r\n2 5 0 6 3\r\n6 3 3 0 10\r\n0 3 1 3 0\r\n", "output": ["63"]}, {"input":...
100
100
100
[{'input': '0 70 10 0 0\r\n70 0 50 90 0\r\n10 50 0 80 0\r\n0 90 80 0 100\r\n0 0 0 100 0\r\n', 'output': ['960']}, {'input': '0 43 21 18 2\r\n3 0 21 11 65\r\n5 2 0 1 4\r\n54 62 12 0 99\r\n87 64 81 33 0\r\n', 'output': ['620']}, {'input': '0 5271 65319 64976 13673\r\n80352 0 41169 66004 47397\r\n33603 44407 0 55079 36122...
[{'input': '0 1 1 1 0\r\n1 0 0 1 0\r\n0 1 0 0 1\r\n1 1 0 0 0\r\n1 0 0 1 0\r\n', 'output': ['10']}, {'input': '0 27677 88187 87515 82582\r\n98177 0 22852 28214 99977\r\n52662 14066 0 79760 68188\r\n56883 30561 91843 0 79777\r\n12461 14821 29284 54372 0\r\n', 'output': ['878207']}, {'input': '0 28287 52158 19163 10096\r\...
[{'input': '0 3 0 0 0\r\n3 0 2 0 0\r\n0 2 0 1 0\r\n0 0 1 0 1\r\n0 0 0 1 0\r\n', 'output': ['24']}, {'input': '0 9699 6962 6645 7790\r\n9280 0 6215 8661 6241\r\n2295 7817 0 7373 9681\r\n693 6298 1381 0 4633\r\n7626 3761 694 4073 0\r\n', 'output': ['93667']}, {'input': '0 1 1 1 0\r\n1 0 0 1 0\r\n0 1 0 0 1\r\n1 1 0 0 0\r\...
[{'input': '0 42865 18485 37168 43099\r\n41476 0 58754 73410 51163\r\n76093 44493 0 51611 93773\r\n87223 80979 58422 0 63327\r\n51215 63346 84797 52809 0\r\n', 'output': ['864938']}, {'input': '0 3 6 9 8\r\n2 0 8 7 7\r\n4 6 0 6 1\r\n9 0 3 0 6\r\n6 5 0 2 0\r\n', 'output': ['90']}, {'input': '0 28287 52158 19163 10096\r\...
[{'input': '0 3 0 0 0\r\n3 0 2 0 0\r\n0 2 0 1 0\r\n0 0 1 0 1\r\n0 0 0 1 0\r\n', 'output': ['24']}, {'input': '0 9994 14841 63916 37926\r\n80090 0 90258 96988 18217\r\n674 69024 0 17641 54436\r\n35046 21380 14213 0 67188\r\n49360 19086 68337 70856 0\r\n', 'output': ['801116']}, {'input': '0 39037 87960 13497 38526\r\n55...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
221
100
100
100
["8.549e2", "8.549e3", "0.33e0"]
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 ≀ a ≀ 9, 0 ≀ d &lt; 10100, 0 ≀ b ≀ 100)Β β€” the scientific notation of the desired distance value. a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0)...
a79358099f08f3ec50c013d47d910eef
import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; /** * Created by kaaveh on 7/29/16. */ public class _697B_ { public static void main(String[] args) throws IOException { char tmp; int num; int zero; ArrayList<Character> data = new ArrayList<>(); ...
["854.9", "8549", "0.33"]
Java
null
Print the only real number x (the desired distance value) in the only line in its decimal notation. Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes. Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be ...
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance ...
[{"input": "8.549e2\r\n", "output": ["854.9"]}, {"input": "8.549e3\r\n", "output": ["8549"]}, {"input": "0.33e0\r\n", "output": ["0.33"]}, {"input": "1.31e1\r\n", "output": ["13.1"]}, {"input": "1.038e0\r\n", "output": ["1.038"]}, {"input": "8.25983e5\r\n", "output": ["825983"]}, {"input": "8.77056e6\r\n", "output": ["...
100
100
100
[{'input': '1.31e1\r\n', 'output': ['13.1']}, {'input': '3.0e0\r\n', 'output': ['3']}, {'input': '0.75e0\r\n', 'output': ['0.75']}, {'input': '5.8743505652112692964508303637002e64\r\n', 'output': ['58743505652112692964508303637002000000000000000000000000000000000']}, {'input': '7.706020096764828403530824236911875259477...
[{'input': '1.91641639840522198229453882518758458881136053577016034847369545687354908120008812644841021662133251e89\r\n', 'output': ['191641639840522198229453882518758458881136053577016034847369545687354908120008812644841021.662133251']}, {'input': '8.549e2\r\n', 'output': ['854.9']}, {'input': '0.0e0\r\n', 'output': [...
[{'input': '0.0e0\r\n', 'output': ['0']}, {'input': '9.0e0\r\n', 'output': ['9']}, {'input': '0.7e0\r\n', 'output': ['0.7']}, {'input': '1.0e0\r\n', 'output': ['1']}, {'input': '2.0629094807595491132306264747042243928486303384791951220362096240931158821630792563855724946791054152e85\r\n', 'output': ['206290948075954911...
[{'input': '4.0e0\r\n', 'output': ['4']}, {'input': '1.91641639840522198229453882518758458881136053577016034847369545687354908120008812644841021662133251e89\r\n', 'output': ['191641639840522198229453882518758458881136053577016034847369545687354908120008812644841021.662133251']}, {'input': '1.038e0\r\n', 'output': ['1.0...
[{'input': '3.2371070627618799335840070613481911588919091676203766004638236894609230433739617153911544972468224113e50\r\n', 'output': ['323710706276187993358400706134819115889190916762037.66004638236894609230433739617153911544972468224113']}, {'input': '2.806303180541991592302230754797823269634e39\r\n', 'output': ['280...
100
100
100
100
100
100
86.96
86.96
86.96
100
90
75
85
75
90
222
100
92.176
83
["11\n00000000008", "22\n0011223344556677889988", "11\n31415926535"]
The first line contains an integer $$$n$$$Β β€” the number of cards with digits that you have ($$$1 \leq n \leq 100$$$). The second line contains a string of $$$n$$$ digits (characters "0", "1", ..., "9") $$$s_1, s_2, \ldots, s_n$$$. The string will not contain any other characters, such as leading or trailing spaces.
259d01b81bef5536b969247ff2c2d776
import java.io.PrintWriter; import java.util.Scanner; public class PhoneNumbers { void solve(Scanner s, PrintWriter out) { s.next(); int e = 0, o = 0; for (char c : s.next().toCharArray()) if (c == '8') e++; else o++; out.println(Math.min(e, (o + e) / 11)); } public static void main(String[]...
["1", "2", "0"]
Java
NoteIn the first example, one phone number, "8000000000", can be made from these cards.In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789".In the third example you can't make any phone number from the given cards.
If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0.
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.You have $$$n$$$ cards with digits, and you want to use them to make as many phone...
[{"input": "11\r\n00000000008\r\n", "output": ["1"]}, {"input": "22\r\n0011223344556677889988\r\n", "output": ["2"]}, {"input": "11\r\n31415926535\r\n", "output": ["0"]}, {"input": "99\r\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\r\n", "output": ["9"]}, {"input"...
100
100
100
[{'input': '82\r\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\r\n', 'output': ['7']}, {'input': '1\r\n8\r\n', 'output': ['0']}, {'input': '52\r\n8878588869084488848898838898788838337877898817818888\r\n', 'output': ['4']}, {'input': '65\r\n445421213628307196771752035604388582608788...
[{'input': '66\r\n157941266854773786962397310504192100434183957442977444078457168272\r\n', 'output': ['5']}, {'input': '50\r\n88888888888888888888888888888888888888888888888888\r\n', 'output': ['4']}, {'input': '92\r\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\r\n', 'ou...
[{'input': '10\r\n8000000000\r\n', 'output': ['0']}, {'input': '41\r\n78888884888874788841882882888088888588888\r\n', 'output': ['3']}, {'input': '65\r\n44542121362830719677175203560438858260878894083124543850593761845\r\n', 'output': ['5']}, {'input': '33\r\n429980628264468835720540136177288\r\n', 'output': ['3']}, {'...
[{'input': '70\r\n8888888888888888888888888888888888888888888888888888888888888888888888\r\n', 'output': ['6']}, {'input': '54\r\n438283821340622774637957966575424773837418828888614203\r\n', 'output': ['4']}, {'input': '76\r\n7900795570936733366353829649382870728119825830883973668601071678041634916557\r\n', 'output': [...
[{'input': '63\r\n728385948188688801288285888788852829888898565895847689806684688\r\n', 'output': ['5']}, {'input': '8\r\n12345678\r\n', 'output': ['0']}, {'input': '51\r\n882889888888689888850888388887688788888888888858888\r\n', 'output': ['4']}, {'input': '75\r\n8789097598928888461836086892578068133769509588637984878...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
223
100
100
100
["7 3\n5 10\n2 5\n3 6", "3 3\n1 3\n2 2\n3 1"]
The first line of the input contains integer n (1 ≀ n ≀ 2Β·108) and integer m (1 ≀ m ≀ 20). The i + 1-th line contains a pair of numbers ai and bi (1 ≀ ai ≀ 108, 1 ≀ bi ≀ 10). All the input numbers are integer.
c052d85e402691b05e494b5283d62679
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import static java.util.Collections.reverseOrder; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entr...
["62", "7"]
Java
null
Output the only number β€” answer to the problem.
A burglar got into a matches warehouse and wants to steal as many matches as possible. In the warehouse there are m containers, in the i-th container there are ai matchboxes, and each matchbox contains bi matches. All the matchboxes are of the same size. The burglar's rucksack can hold n matchboxes exactly. Your task i...
[{"input": "7 3\r\n5 10\r\n2 5\r\n3 6\r\n", "output": ["62"]}, {"input": "3 3\r\n1 3\r\n2 2\r\n3 1\r\n", "output": ["7"]}, {"input": "1 1\r\n1 2\r\n", "output": ["2"]}, {"input": "1 2\r\n1 9\r\n1 6\r\n", "output": ["9"]}, {"input": "1 10\r\n1 1\r\n1 9\r\n1 3\r\n1 9\r\n1 7\r\n1 10\r\n1 4\r\n1 7\r\n1 3\r\n1 1\r\n", "outp...
100
100
100
[{'input': '2 2\r\n2 4\r\n1 4\r\n', 'output': ['8']}, {'input': '2 1\r\n2 1\r\n', 'output': ['2']}, {'input': '200000000 6\r\n7465600 6\r\n8453505 10\r\n4572014 8\r\n8899499 3\r\n86805622 10\r\n64439238 6\r\n', 'output': ['1447294907']}, {'input': '4 1\r\n2 2\r\n', 'output': ['4']}, {'input': '200000000 10\r\n27953106 ...
[{'input': '200000000 9\r\n17463897 9\r\n79520463 1\r\n162407 4\r\n41017993 8\r\n71054118 4\r\n9447587 2\r\n5298038 9\r\n3674560 7\r\n20539314 5\r\n', 'output': ['996523209']}, {'input': '200000000 6\r\n7465600 6\r\n8453505 10\r\n4572014 8\r\n8899499 3\r\n86805622 10\r\n64439238 6\r\n', 'output': ['1447294907']}, {'inp...
[{'input': '10 10\r\n1 8\r\n2 10\r\n1 9\r\n1 1\r\n1 9\r\n1 6\r\n1 4\r\n2 5\r\n1 2\r\n1 4\r\n', 'output': ['70']}, {'input': '1 2\r\n1 9\r\n1 6\r\n', 'output': ['9']}, {'input': '5 2\r\n3 9\r\n2 2\r\n', 'output': ['31']}, {'input': '10 4\r\n1 5\r\n5 2\r\n1 9\r\n3 3\r\n', 'output': ['33']}, {'input': '200000000 10\r\n556...
[{'input': '200000000 10\r\n55649 8\r\n10980981 9\r\n3192542 8\r\n94994808 4\r\n3626106 1\r\n100000000 6\r\n5260110 9\r\n4121453 2\r\n15125061 4\r\n669569 6\r\n', 'output': ['1095537357']}, {'input': '200000000 2\r\n11823018 6\r\n100000000 9\r\n', 'output': ['970938108']}, {'input': '200000000 20\r\n983125 2\r\n7453215...
[{'input': '1 10\r\n1 1\r\n1 9\r\n1 3\r\n1 9\r\n1 7\r\n1 10\r\n1 4\r\n1 7\r\n1 3\r\n1 1\r\n', 'output': ['10']}, {'input': '10 10\r\n1 8\r\n2 10\r\n1 9\r\n1 1\r\n1 9\r\n1 6\r\n1 4\r\n2 5\r\n1 2\r\n1 4\r\n', 'output': ['70']}, {'input': '200000000 2\r\n11823018 6\r\n100000000 9\r\n', 'output': ['970938108']}, {'input': ...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
224
100
100
100
["5 5 2", "6 7 4"]
A single line contains three space-separated integers a, b, r (1 ≀ a, b, r ≀ 100) β€” the table sides and the plates' radius, correspondingly.
90b9ef939a13cf29715bc5bce26c9896
//package com.example.hackerranksolutions; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; 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.Compara...
["First", "Second"]
Java
NoteIn the first sample the table has place for only one plate. The first player puts a plate on the table, the second player can't do that and loses. In the second sample the table is so small that it doesn't have enough place even for one plate. So the first player loses without making a single move.
If wins the player who moves first, print "First" (without the quotes). Otherwise print "Second" (without the quotes).
You've got a rectangular table with length a and width b and the infinite number of plates of radius r. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but they can touch each other), and so that any point on any plate is located within the...
[{"input": "5 5 2\r\n", "output": ["First"]}, {"input": "6 7 4\r\n", "output": ["Second"]}, {"input": "100 100 1\r\n", "output": ["First"]}, {"input": "1 1 100\r\n", "output": ["Second"]}, {"input": "13 7 3\r\n", "output": ["First"]}, {"input": "23 7 3\r\n", "output": ["First"]}, {"input": "9 9 2\r\n", "output": ["Firs...
100
100
100
[{'input': '100 100 51\r\n', 'output': ['Second']}, {'input': '44 58 5\r\n', 'output': ['First']}, {'input': '24 70 13\r\n', 'output': ['Second']}, {'input': '10 2 4\r\n', 'output': ['Second']}, {'input': '19 20 10\r\n', 'output': ['Second']}]
[{'input': '16 17 3\r\n', 'output': ['First']}, {'input': '4 4 6\r\n', 'output': ['Second']}, {'input': '2 100 1\r\n', 'output': ['First']}, {'input': '100 100 50\r\n', 'output': ['First']}, {'input': '1 100 3\r\n', 'output': ['Second']}]
[{'input': '61 2 3\r\n', 'output': ['Second']}, {'input': '100 1 2\r\n', 'output': ['Second']}, {'input': '30 40 14\r\n', 'output': ['First']}, {'input': '17 16 3\r\n', 'output': ['First']}, {'input': '15 16 1\r\n', 'output': ['First']}]
[{'input': '74 1 1\r\n', 'output': ['Second']}, {'input': '2 100 1\r\n', 'output': ['First']}, {'input': '15 16 1\r\n', 'output': ['First']}, {'input': '100 99 50\r\n', 'output': ['Second']}, {'input': '100 20 12\r\n', 'output': ['Second']}]
[{'input': '10 10 1\r\n', 'output': ['First']}, {'input': '20 5 6\r\n', 'output': ['Second']}, {'input': '17 17 3\r\n', 'output': ['First']}, {'input': '100 100 49\r\n', 'output': ['First']}, {'input': '15 17 3\r\n', 'output': ['First']}]
100
100
100
100
100
100
100
100
100
100
100
75
75
75
75
225
100
100
80
["3", "4"]
A single line contains one non-negative integer $$$n$$$ ($$$0 \le n \leq 10^{18}$$$)Β β€” the number of Shiro's friends. The circular pizza has to be sliced into $$$n + 1$$$ pieces.
236177ff30dafe68295b5d33dc501828
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); //inputs long n = input.nextLong(); if(n == 0) System.out.println(0); else if((n + 1) % 2 == 0) System.o...
["2", "5"]
Java
NoteTo cut the round pizza into quarters one has to make two cuts through the center with angle $$$90^{\circ}$$$ between them.To cut the round pizza into five equal parts one has to make five cuts.
A single integerΒ β€” the number of straight cuts Shiro needs.
Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.Today is Shiro's birthday. She really loves pizza so she wants to invite her friends to the pizza restaurant near her house to celebr...
[{"input": "3\r\n", "output": ["2"]}, {"input": "4\r\n", "output": ["5"]}, {"input": "10\r\n", "output": ["11"]}, {"input": "10000000000\r\n", "output": ["10000000001"]}, {"input": "1234567891\r\n", "output": ["617283946"]}, {"input": "7509213957\r\n", "output": ["3754606979"]}, {"input": "99999999999999999\r\n", "outp...
100
100
100
[{'input': '712394453192\r\n', 'output': ['712394453193']}, {'input': '760713016476190622\r\n', 'output': ['760713016476190623']}, {'input': '2\r\n', 'output': ['3']}, {'input': '269587449430302150\r\n', 'output': ['269587449430302151']}, {'input': '335408917861648766\r\n', 'output': ['335408917861648767']}]
[{'input': '711066337317063338\r\n', 'output': ['711066337317063339']}, {'input': '520974001910286909\r\n', 'output': ['260487000955143455']}, {'input': '1000000000000000000\r\n', 'output': ['1000000000000000001']}, {'input': '3\r\n', 'output': ['2']}, {'input': '760713016476190622\r\n', 'output': ['760713016476190623'...
[{'input': '99999999999999999\r\n', 'output': ['50000000000000000']}, {'input': '779547116602436424\r\n', 'output': ['779547116602436425']}, {'input': '354979173822804781\r\n', 'output': ['177489586911402391']}, {'input': '269587449430302150\r\n', 'output': ['269587449430302151']}, {'input': '349993004923078531\r\n', '...
[{'input': '2\r\n', 'output': ['3']}, {'input': '578223540024979436\r\n', 'output': ['578223540024979437']}, {'input': '856674611404539671\r\n', 'output': ['428337305702269836']}, {'input': '520974001910286909\r\n', 'output': ['260487000955143455']}, {'input': '99999999999999999\r\n', 'output': ['50000000000000000']}]
[{'input': '10\r\n', 'output': ['11']}, {'input': '28316250877914571\r\n', 'output': ['14158125438957286']}, {'input': '919845426262703496\r\n', 'output': ['919845426262703497']}, {'input': '4\r\n', 'output': ['5']}, {'input': '578223540024979436\r\n', 'output': ['578223540024979437']}]
100
100
100
100
100
75
87.5
87.5
87.5
87.5
50
75
75
75
75
226
100
85
70
["^ &gt;\n1", "&lt; ^\n3", "^ v\n6"]
There are two characters in the first string – the starting and the ending position of a spinner. The position is encoded with one of the following characters: v (ASCII code 118, lowercase v), &lt; (ASCII code 60), ^ (ASCII code 94) or &gt; (ASCII code 62) (see the picture above for reference). Characters are separated...
fb99ef80fd21f98674fe85d80a2e5298
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author pigsoft */ public class Main { public static void main(String[] args) { InputStream i...
["cw", "ccw", "undefined"]
Java
null
Output cw, if the direction is clockwise, ccw – if counter-clockwise, and undefined otherwise.
Walking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays – caramel spinner! Wanting to join the craze, she has immediately bought the strange contraption.Spinners in Sweetland have the form of V-shaped pieces of caramel. Each s...
[{"input": "^ >\r\n1\r\n", "output": ["cw"]}, {"input": "< ^\r\n3\r\n", "output": ["ccw"]}, {"input": "^ v\r\n6\r\n", "output": ["undefined"]}, {"input": "^ >\r\n999999999\r\n", "output": ["ccw"]}, {"input": "> v\r\n1\r\n", "output": ["cw"]}, {"input": "v <\r\n1\r\n", "output": ["cw"]}, {"input": "< ^\r\n1\r\n", "outpu...
100
100
100
[{'input': '^ >\r\n822875521\r\n', 'output': ['cw']}, {'input': 'v >\r\n3\r\n', 'output': ['cw']}, {'input': '^ v\r\n6\r\n', 'output': ['undefined']}, {'input': '> ^\r\n1\r\n', 'output': ['ccw']}, {'input': '< ^\r\n3\r\n', 'output': ['ccw']}]
[{'input': '^ ^\r\n0\r\n', 'output': ['undefined']}, {'input': 'v <\r\n1\r\n', 'output': ['cw']}, {'input': '^ <\r\n3\r\n', 'output': ['cw']}, {'input': 'v <\r\n3\r\n', 'output': ['ccw']}, {'input': '< ^\r\n1\r\n', 'output': ['cw']}]
[{'input': '^ <\r\n3\r\n', 'output': ['cw']}, {'input': '^ v\r\n6\r\n', 'output': ['undefined']}, {'input': '^ >\r\n822875521\r\n', 'output': ['cw']}, {'input': '^ >\r\n999999999\r\n', 'output': ['ccw']}, {'input': '> >\r\n12\r\n', 'output': ['undefined']}]
[{'input': '^ >\r\n861895563\r\n', 'output': ['ccw']}, {'input': '^ <\r\n11\r\n', 'output': ['cw']}, {'input': '< >\r\n6\r\n', 'output': ['undefined']}, {'input': 'v >\r\n139018901\r\n', 'output': ['ccw']}, {'input': 'v <\r\n422435957\r\n', 'output': ['cw']}]
[{'input': 'v v\r\n4\r\n', 'output': ['undefined']}, {'input': '< v\r\n1\r\n', 'output': ['ccw']}, {'input': '^ >\r\n999999999\r\n', 'output': ['ccw']}, {'input': '^ <\r\n11\r\n', 'output': ['cw']}, {'input': 'v <\r\n3\r\n', 'output': ['ccw']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
227
100
100
100
["4\n1001", "1\n1"]
The first line contains integer number n (1 ≀ n ≀ 100) β€” the length of string s. The second line contains the string s consisting of characters "0" and "1". It is guaranteed that the string s is correct.
ac244791f8b648d672ed3de32ce0074d
//package codeforces; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int len = sc.nextInt(); String str = sc.next(); if (len < 2) { System.out.println(str); } else { String[] str_char = s...
["100", "1"]
Java
NoteIn the first example you can obtain the answer by the following sequence of operations: "1001" "1010" "1100" "100".In the second example you can't obtain smaller answer no matter what operations you use.
Print one string β€” the minimum correct string that you can obtain from the given one.
String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".You are given a correct string s.You can perform two different operations on this string: swap any pair of adjacent characters (for example, "101" "110"); replac...
[{"input": "4\r\n1001\r\n", "output": ["100"]}, {"input": "1\r\n1\r\n", "output": ["1"]}, {"input": "100\r\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\r\n", "output": ["1000000000000000000000000000000000000000"]}, {"input": "100\r\n100000000000000000000000000000...
100
100
100
[{'input': '8\r\n10101010\r\n', 'output': ['10000']}, {'input': '5\r\n11100\r\n', 'output': ['100']}, {'input': '100\r\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n', 'output': ['1']}, {'input': '2\r\n11\r\n', 'output': ['1']}, {'input': '1\r\n0\r\n', 'output'...
[{'input': '5\r\n11100\r\n', 'output': ['100']}, {'input': '100\r\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n', 'output': ['1']}, {'input': '100\r\n1111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111\r\n', 'ou...
[{'input': '5\r\n11100\r\n', 'output': ['100']}, {'input': '100\r\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n', 'output': ['1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000']}, {'input': '100\r\n11101111000...
[{'input': '8\r\n10101010\r\n', 'output': ['10000']}, {'input': '100\r\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\r\n', 'output': ['1000000000000000000000000000000000000000']}, {'input': '100\r\n100000000000000000000000000000000000000000000000000000000000000000...
[{'input': '100\r\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\r\n', 'output': ['1000000000000000000000000000000000000000']}, {'input': '1\r\n1\r\n', 'output': ['1']}, {'input': '4\r\n1001\r\n', 'output': ['100']}, {'input': '100\r\n111111111111111111111111111111...
100
100
100
100
100
100
91.67
100
91.67
100
100
83.33
100
83.33
100
228
100
96.668
93.332
["3000"]
The only line of the input contains one integer n (1 ≀ n ≀ 1018) β€” the prediction on the number of people who will buy the game.
8551308e5ff435e0fc507b89a912408a
import java.util.Scanner; public class Divisibility { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double a = sc.nextDouble(); double ans = Math.floor(a/2520); System.out.printf("%.0f",ans); } }
["1"]
Java
null
Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10.
IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer ...
[{"input": "3000\r\n", "output": ["1"]}, {"input": "2520\r\n", "output": ["1"]}, {"input": "2519\r\n", "output": ["0"]}, {"input": "2521\r\n", "output": ["1"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "314159265\r\n", "output": ["124666"]}, {"input": "718281828459045235\r\n", "output": ["285032471610732"]}, {"in...
100
100
100
[{'input': '314159265\r\n', 'output': ['124666']}, {'input': '2521\r\n', 'output': ['1']}, {'input': '987654321234567890\r\n', 'output': ['391926317950225']}, {'input': '1\r\n', 'output': ['0']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}]
[{'input': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '2521\r\n', 'output': ['1']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}]
[{'input': '1\r\n', 'output': ['0']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '718281828459045235\r\n', 'output': ['285032471610732']}]
[{'input': '314159265\r\n', 'output': ['124666']}, {'input': '1\r\n', 'output': ['0']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '504000000000000000\r\n', 'output': ['200000000000000']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}]
[{'input': '3000\r\n', 'output': ['1']}, {'input': '2521\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '2520\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
229
100
100
100
["5\nabaca", "8\nabcddcba"]
The first line contains one integer $$$n$$$ ($$$1 \le n \le 500$$$) β€” the length of string $$$s$$$. The second line contains the string $$$s$$$ ($$$|s| = n$$$) consisting of lowercase Latin letters.
516a89f4d1ae867fc1151becd92471e6
import java.util.*; import java.io.*; public class code{ public static void main(String[] args)throws IOException{ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] c = sc.next().toCharArray(); int[] d = new int[n]; for(int i=0;i<n;i++) d[i] = (int)c[i]; ...
["3", "4"]
Java
null
Output a single integer β€” the minimal number of operation to delete string $$$s$$$.
You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase Latin letters. You may apply some operations to this string: in one operation you can delete some contiguous substring of this string, if all letters in the substring you delete are equal. For example, after deleting substring bbbb from string abb...
[{"input": "5\r\nabaca\r\n", "output": ["3"]}, {"input": "8\r\nabcddcba\r\n", "output": ["4"]}, {"input": "1\r\nx\r\n", "output": ["1"]}, {"input": "500\r\nbbababaabaabaabbbbbbaabbabbabbaabababababbbbabaaabbbbaaabbbbbbbabababaaaaabbbbabaababbababbaaaaaabbaaabbaabaaababbbbbabbaabaabaabbbaaabaabbaaabbaabababbaaabaaabaaaa...
100
100
100
[{'input': '500\r\nedfeaaaaddffdbfbcebefebdfdadbdadcbbdbdcabfdbdeccaeebcdebdddfedcacbbefeabdbbdeceeacadbbbebffcebbaffdcabcedccddeeccdfbdedfeddcbebdadffbaacbbedbdbfdbcaecccbbcfefdbddabdeadeeeecffdbcfcbeabcdeeaaddeeddeadccdefbeaabfabadaddbfaddbecaaeccbdefececdbebbddffbbfcfdddcadbccedcecabdcfceeefcdbbfcaeccbcdcddbfabcbedf...
[{'input': '500\r\nacdccbcdabcabdeaceeacabdebeccabcabcaeaadeaaaaecdeecbaecdeebcaccdacddeabedbddcbbdbabbddaeeddebebdecceeebbcaecadbedbaaccadcacbbcbebceabbddbbccdcdcddebbdbbdebbcbbdadbedebacaecabbbedccebcaecbceadaeabbaeecceacaacbeaebdbaeedabbebbaaadeceabeccccbadcebbeccdeadddedcdeebcaeedddbdcccddbaeabeeacddbdcdbaebeedbdea...
[{'input': '500\r\nebeeeeabaebabbacacccbcddbdadabdaedbecadecacdcdeccabdbbddbccabeccbdebdebedbaedeeaecccdadbcabbcdacadaddacbbbdaaeceaaeabbacdecacbebebbbbededccbdbbeddabcbebdabcccedabdbcccbbeebaecabcacbcdadcbebbadcbeadebccedaceebcebceeaacbbdcdacdcdedaddeedaddedadbccccdddcddccceaabcadecbebdeeeebcbcadedbdddaadcdceceaadeead...
[{'input': '500\r\ncdbdadbdcabdcbdbaadacaacbbbbcdaccddbdbbdabccacbaacdbbdcbddadabaaccbabccabadddbdcdcdddbbcbadddcabcddcdbabacacbdbcaadacbbbdccbcabacdbcccbdccbaacddaaaabdacbdccbbbbcaabbbdabadadacabdbbaaacadcbaacadadbbdbcdabcdabccacbdcaadaccdbdcaccaaddacddccdadddddddbacaccdbbbbcbbabbdcacbcaacaabdddbdccdaddcddbbaabaabdbcc...
[{'input': '500\r\nabccacbaabaabaaccaaaacacbbcbccaababacbbbccbbcbcccabbccacbacbbacabbcbccccbcbbaccbcaacbacbbaaababccaccbcacaccccabbcbcbaacccbccabccaacccccccccbcabaacaaabccaaaabcccbcbbaabccabbbaaccbbcccbcccbabacbcabbbbccaaacaabcbabbbacacacbcaabbbacaaaaaaacbcabbcaccbcbaabacccacccabbbcbcbacccabcabbaabaacbcbaacbbccccbbbcca...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
230
100
100
100
["0 0 6 0 6 6 0 6\n1 3 3 5 5 3 3 1", "0 0 6 0 6 6 0 6\n7 3 9 5 11 3 9 1", "6 0 6 6 0 6 0 0\n7 4 4 7 7 10 10 7"]
The input data consists of two lines, one for each square, both containing 4 pairs of integers. Each pair represents coordinates of one vertex of the square. Coordinates within each line are either in clockwise or counterclockwise order. The first line contains the coordinates of the square with sides parallel to the c...
f6a3dd8b3bab58ff66055c61ddfdf06a
import java.awt.Polygon; import java.awt.geom.Line2D; import java.util.Scanner; public class Squares { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); int x1[]=new int[4]; int x2[]=new int[4]; int y1[]=new int[4]; int y2[]=new int[4];boolean t=false; f...
["YES", "NO", "YES"]
Java
NoteIn the first example the second square lies entirely within the first square, so they do intersect.In the second sample squares do not have any points in common.Here are images corresponding to the samples:
Print "Yes" if squares intersect, otherwise print "No". You can print each letter in any case (upper or lower).
You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the tw...
[{"input": "0 0 6 0 6 6 0 6\r\n1 3 3 5 5 3 3 1\r\n", "output": ["yes", "YES"]}, {"input": "0 0 6 0 6 6 0 6\r\n7 3 9 5 11 3 9 1\r\n", "output": ["NO", "no"]}, {"input": "6 0 6 6 0 6 0 0\r\n7 4 4 7 7 10 10 7\r\n", "output": ["yes", "YES"]}, {"input": "0 0 6 0 6 6 0 6\r\n8 4 4 8 8 12 12 8\r\n", "output": ["yes", "YES"]}, ...
100
100
100
[{'input': '79 -19 79 15 45 15 45 -19\r\n-1 24 -29 52 -1 80 27 52\r\n', 'output': ['NO', 'no']}, {'input': '1 1 1 6 6 6 6 1\r\n5 8 8 11 11 8 8 5\r\n', 'output': ['NO', 'no']}, {'input': '-16 -10 -16 9 3 9 3 -10\r\n-8 -1 2 9 12 -1 2 -11\r\n', 'output': ['yes', 'YES']}, {'input': '-47 3 -37 3 -37 -7 -47 -7\r\n-37 3 -33 -...
[{'input': '13 1 15 1 15 3 13 3\r\n13 19 21 11 13 3 5 11\r\n', 'output': ['yes', 'YES']}, {'input': '-38 -26 32 -26 32 44 -38 44\r\n2 -27 -44 19 2 65 48 19\r\n', 'output': ['yes', 'YES']}, {'input': '-44 -17 -64 -17 -64 3 -44 3\r\n-56 15 -44 27 -32 15 -44 3\r\n', 'output': ['yes', 'YES']}, {'input': '-7 16 43 16 43 66 ...
[{'input': '-93 -86 -85 -86 -85 -78 -93 -78\r\n-13 61 0 48 -13 35 -26 48\r\n', 'output': ['NO', 'no']}, {'input': '-4 -8 -4 -15 3 -15 3 -8\r\n-10 5 -27 -12 -10 -29 7 -12\r\n', 'output': ['yes', 'YES']}, {'input': '52 -47 52 -30 35 -30 35 -47\r\n49 -22 64 -37 49 -52 34 -37\r\n', 'output': ['yes', 'YES']}, {'input': '-5 ...
[{'input': '-27 -73 72 -73 72 26 -27 26\r\n58 11 100 -31 58 -73 16 -31\r\n', 'output': ['yes', 'YES']}, {'input': '15 -18 3 -18 3 -6 15 -6\r\n29 -1 16 -14 3 -1 16 12\r\n', 'output': ['yes', 'YES']}, {'input': '-29 13 -39 13 -39 3 -29 3\r\n-36 -4 -50 -18 -36 -32 -22 -18\r\n', 'output': ['NO', 'no']}, {'input': '17 3 2 3...
[{'input': '2 2 4 2 4 4 2 4\r\n0 3 3 6 6 3 3 0\r\n', 'output': ['yes', 'YES']}, {'input': '99 99 99 100 100 100 100 99\r\n-100 0 0 100 100 0 0 -100\r\n', 'output': ['NO', 'no']}, {'input': '-35 3 -21 3 -21 -11 -35 -11\r\n-8 -10 3 -21 -8 -32 -19 -21\r\n', 'output': ['NO', 'no']}, {'input': '-90 2 0 2 0 92 -90 92\r\n-66 ...
100
100
100
100
100
94.29
91.43
94.29
94.29
100
91.67
79.17
91.67
91.67
100
231
100
94.86
90.836
["5 2\n#G#T#", "6 1\nT....G", "7 3\nT..#..G", "6 2\n..GT.."]
The first line of the input contains two integers n and k (2 ≀ n ≀ 100, 1 ≀ k ≀ n - 1)Β β€” the number of cells in the line and the length of one grasshopper's jump. The second line contains a string of length n consisting of characters '.', '#', 'G' and 'T'. Character '.' means that the corresponding cell is empty, chara...
189a9b5ce669bdb04b9d371d74a5dd41
import java.io.*; import java.util.*; public class Problem2A { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] in = br.readLine().split(" "); int n = Integer.parseInt(in[0]); int k = Integer.parseInt(in[1]); char[]...
["YES", "YES", "NO", "NO"]
Java
NoteIn the first sample, the grasshopper can make one jump to the right in order to get from cell 2 to cell 4.In the second sample, the grasshopper is only able to jump to neighboring cells but the way to the insect is freeΒ β€” he can get there by jumping left 5 times.In the third sample, the grasshopper can't make a sin...
If there exists a sequence of jumps (each jump of length k), such that the grasshopper can get from his initial position to the cell with the insect, print "YES" (without quotes) in the only line of the input. Otherwise, print "NO" (without quotes).
On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in another empty cell. The gras...
[{"input": "5 2\r\n#G#T#\r\n", "output": ["YES", "Yes"]}, {"input": "6 1\r\nT....G\r\n", "output": ["YES", "Yes"]}, {"input": "7 3\r\nT..#..G\r\n", "output": ["No", "NO"]}, {"input": "6 2\r\n..GT..\r\n", "output": ["No", "NO"]}, {"input": "2 1\r\nGT\r\n", "output": ["YES", "Yes"]}, {"input": "100 5\r\nG####.####.####.#...
100
100
100
[{'input': '6 2\r\nG#T###\r\n', 'output': ['YES', 'Yes']}, {'input': '100 17\r\nG################.#################################.################T###############################\r\n', 'output': ['No', 'NO']}, {'input': '100 99\r\nT.#...............................#............#..............................##..........
[{'input': '100 20\r\n.....G................................................................................T.............\r\n', 'output': ['No', 'NO']}, {'input': '100 9\r\nT................................................................................................G..\r\n', 'output': ['No', 'NO']}, {'input': '100...
[{'input': '100 1\r\nT.#................................................................................................G\r\n', 'output': ['No', 'NO']}, {'input': '100 2\r\n..#####.#.#.......#.#.#...##..####..###..#.#######GT####.#.#...##...##.#..###....##.#.#..#.###....#.\r\n', 'output': ['No', 'NO']}, {'input': '100 ...
[{'input': '100 5\r\nG####.####.####.####.####.####.####.####.####.####.####.####.####.#########.####.####.####.####T####\r\n', 'output': ['No', 'NO']}, {'input': '100 17\r\n.########.G##.####.#.######.###############..#.###########.##.#####.##.#####.#T.###..###.########.##\r\n', 'output': ['YES', 'Yes']}, {'input': '1...
[{'input': '5 1\r\nG.T##\r\n', 'output': ['YES', 'Yes']}, {'input': '14 3\r\n...G.....#..T.\r\n', 'output': ['No', 'NO']}, {'input': '48 1\r\nT..............................................G\r\n', 'output': ['YES', 'Yes']}, {'input': '100 3\r\nG..................................#......#......#.......#.#..........#........
100
100
100
100
100
96.15
100
100
100
100
94.44
100
100
100
100
232
100
99.23
98.888
["5\n10 5 0 -5 -10", "4\n1 1 1 1", "3\n5 1 -5", "2\n900 1000"]
The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of days for which the average air temperature is known. The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 ≀ ti ≀ 1000)Β β€” where ti is the average temperature in the i-th day.
d04fa4322a1b300bdf4a56f09681b17f
import java.util.*; import java.io.*; public class Main { int solve(Scanner in, PrintWriter out) { int n = in.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++) arr[i] = in.nextInt(); if(n == 2) out.print(arr[1] + (arr[1] - arr[0])); else{ int ans = 0; int step = arr[0] - arr...
["-15", "1", "-5", "1100"]
Java
NoteIn the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is  - 10 - 5 =  - 15.In the second example the sequence of the average temperatures is an arithmetic p...
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the f...
[{"input": "5\r\n10 5 0 -5 -10\r\n", "output": ["-15"]}, {"input": "4\r\n1 1 1 1\r\n", "output": ["1"]}, {"input": "3\r\n5 1 -5\r\n", "output": ["-5"]}, {"input": "2\r\n900 1000\r\n", "output": ["1100"]}, {"input": "2\r\n1 2\r\n", "output": ["3"]}, {"input": "3\r\n2 5 8\r\n", "output": ["11"]}, {"input": "4\r\n4 1 -2 -...
100
100
100
[{'input': '2\r\n-1000 -1000\r\n', 'output': ['-1000']}, {'input': '3\r\n5 1 -5\r\n', 'output': ['-5']}, {'input': '10\r\n-1000 -995 -990 -984 -980 -975 -970 -965 -960 -955\r\n', 'output': ['-955']}, {'input': '3\r\n2 5 8\r\n', 'output': ['11']}, {'input': '11\r\n-999 -800 -600 -400 -200 0 200 400 600 800 1000\r\n', 'o...
[{'input': '4\r\n1 2 4 5\r\n', 'output': ['5']}, {'input': '3\r\n2 4 8\r\n', 'output': ['8']}, {'input': '5\r\n1000 544 88 -368 -824\r\n', 'output': ['-1280']}, {'input': '33\r\n456 411 366 321 276 231 186 141 96 51 6 -39 -84 -129 -174 -219 -264 -309 -354 -399 -444 -489 -534 -579 -624 -669 -714 -759 -804 -849 -894 -939...
[{'input': '11\r\n-999 -800 -600 -400 -200 0 200 400 600 800 1000\r\n', 'output': ['1000']}, {'input': '10\r\n-1000 -995 -990 -984 -980 -975 -970 -965 -960 -955\r\n', 'output': ['-955']}, {'input': '4\r\n4 1 -2 -5\r\n', 'output': ['-8']}, {'input': '33\r\n456 411 366 321 276 231 186 141 96 51 6 -39 -84 -129 -174 -219 -...
[{'input': '11\r\n-1000 -800 -600 -400 -200 0 200 400 600 800 1000\r\n', 'output': ['1200']}, {'input': '77\r\n-765 -742 -719 -696 -673 -650 -627 -604 -581 -558 -535 -512 -489 -466 -443 -420 -397 -374 -351 -328 -305 -282 -259 -236 -213 -190 -167 -144 -121 -98 -75 -52 -29 -6 17 40 63 86 109 132 155 178 201 224 247 270 2...
[{'input': '100\r\n-85 -80 -76 -72 -68 -64 -60 -56 -52 -48 -44 -40 -36 -32 -28 -24 -20 -16 -12 -8 -4 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244...
100
100
100
100
100
100
95.24
95.24
100
100
100
87.5
87.5
100
100
233
100
98.096
95
["5\n3 4 5 6 7", "7\n12 13 14 15 14 13 12", "1\n8"]
The first line of the input contains a single integer n (1 ≀ n ≀ 92)Β β€” the number of consecutive days Vitya was watching the size of the visible part of the moon. The second line contains n integers ai (0 ≀ ai ≀ 15)Β β€” Vitya's records. It's guaranteed that the input data is consistent.
8330d9fea8d50a79741507b878da0a75
import java.util.Scanner; public class Vitya { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] t = new int[n]; for (int i=0;i<n;i++) { t[i]=scanner.nextInt(); } if (n==1) {if(t[0]==15) {System.out.println("DOWN");}else if(t[0]==0) {Sy...
["UP", "DOWN", "-1"]
Java
NoteIn the first sample, the size of the moon on the next day will be equal to 8, thus the answer is "UP".In the second sample, the size of the moon on the next day will be 11, thus the answer is "DOWN".In the third sample, there is no way to determine whether the size of the moon on the next day will be 7 or 9, thus t...
If Vitya can be sure that the size of visible part of the moon on day n + 1 will be less than the size of the visible part on day n, then print "DOWN" at the only line of the output. If he might be sure that the size of the visible part will increase, then print "UP". If it's impossible to determine what exactly will h...
Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down.Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units) ...
[{"input": "5\r\n3 4 5 6 7\r\n", "output": ["UP"]}, {"input": "7\r\n12 13 14 15 14 13 12\r\n", "output": ["DOWN"]}, {"input": "1\r\n8\r\n", "output": ["-1"]}, {"input": "44\r\n7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10\r\n", "output": ["DOWN"]}, {"input...
100
100
100
[{'input': '92\r\n1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0\r\n', 'output': ['UP']}, {'input': '1\r\n14\r\n', 'output': ['-1']}, {'input': '1\r\n...
[{'input': '2\r\n8 9\r\n', 'output': ['UP']}, {'input': '27\r\n11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\r\n', 'output': ['DOWN']}, {'input': '3\r\n2 1 0\r\n', 'output': ['UP']}, {'input': '1\r\n13\r\n', 'output': ['-1']}, {'input': '2\r\n1 2\r\n', 'output': ['UP']}]
[{'input': '92\r\n10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11\r\n', 'output': ['UP']}, {'input': '3\r\n10 11 12\r\n', 'output': ['UP']}, {'input'...
[{'input': '3\r\n2 1 0\r\n', 'output': ['UP']}, {'input': '2\r\n14 15\r\n', 'output': ['DOWN']}, {'input': '2\r\n10 9\r\n', 'output': ['DOWN']}, {'input': '13\r\n10 9 8 7 6 5 4 3 2 1 0 1 2\r\n', 'output': ['UP']}, {'input': '21\r\n3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7\r\n', 'output': ['DOWN']}]
[{'input': '44\r\n7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10\r\n', 'output': ['DOWN']}, {'input': '1\r\n13\r\n', 'output': ['-1']}, {'input': '6\r\n10 11 12 13 14 15\r\n', 'output': ['DOWN']}, {'input': '6\r\n8 7 6 5 4 3\r\n', 'output': ['DOWN']}, {'inp...
100
100
100
100
100
88.89
100
100
100
100
64.29
85.71
71.43
64.29
71.43
234
100
97.778
71.43
["4\nZCTH", "5\nZDATG", "6\nAFBAKC"]
The first line contains a single integer $$$n$$$ ($$$4 \leq n \leq 50$$$)Β β€” the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of exactly $$$n$$$ uppercase letters of the Latin alphabet.
ee4f88abe4c9fa776abd15c5f3a94543
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import java.util.Scanner; /** * * @author Lalo */ public class ContestSandbox { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner...
["2", "5", "16"]
Java
NoteIn the first example, you should replace the letter "Z" with "A" for one operation, the letter "H"Β β€” with the letter "G" for one operation. You will get the string "ACTG", in which the genome is present as a substring.In the second example, we replace the letter "A" with "C" for two operations, the letter "D"Β β€” wit...
Output the minimum number of operations that need to be applied to the string $$$s$$$ so that the genome appears as a substring in it.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".Maxim was very boring to sit in class, so the teacher came up with a task for him: on a given string $$$s$$$ consisting of uppercase letters and length ...
[{"input": "4\r\nZCTH\r\n", "output": ["2"]}, {"input": "5\r\nZDATG\r\n", "output": ["5"]}, {"input": "6\r\nAFBAKC\r\n", "output": ["16"]}, {"input": "9\r\nAAABBBCCC\r\n", "output": ["14"]}, {"input": "8\r\nABCDABCD\r\n", "output": ["13"]}, {"input": "4\r\nNPGT\r\n", "output": ["52"]}, {"input": "10\r\nABABABABAB\r\n",...
100
100
100
[{'input': '4\r\nNPGT\r\n', 'output': ['52']}, {'input': '50\r\nMGDXLMPDPKUQOIMTLDUDTGTOMJCSYNRTSQSJANYDDPWQYTDTAW\r\n', 'output': ['7']}, {'input': '33\r\nIQHJDOVAGCIAEBAIXQYQCDVZGVOYIIYPR\r\n', 'output': ['12']}, {'input': '50\r\nQFWWIROYKRLAYBPSEXATCWILUBAZPWSGSKLTBLZOLZPHJKQQGF\r\n', 'output': ['9']}, {'input': '5\...
[{'input': '50\r\nQFWWIROYKRLAYBPSEXATCWILUBAZPWSGSKLTBLZOLZPHJKQQGF\r\n', 'output': ['9']}, {'input': '8\r\nBBAACCZZ\r\n', 'output': ['14']}, {'input': '50\r\nZOMSHKIFVAMFATEIIEUJVITTYZGDWCGSOJMFQNYACRPOLGUZCM\r\n', 'output': ['9']}, {'input': '39\r\nIHESTJHHSZRSHNUSPGMHDTKOJFEFLAUDXUEQWLO\r\n', 'output': ['11']}, {'i...
[{'input': '8\r\nABCDABCD\r\n', 'output': ['13']}, {'input': '50\r\nGOHDHOWWPMZBSEKHDBDKLIYRFEPOUHIHOHPUMVDAQRZDJMUBWV\r\n', 'output': ['5']}, {'input': '32\r\nIWMQCTKRNXICANQUPLBOMDNRBOWWIXZB\r\n', 'output': ['14']}, {'input': '17\r\nGNPBRASKVPECJKECD\r\n', 'output': ['16']}, {'input': '10\r\nZZZZZZZZZZ\r\n', 'output'...
[{'input': '4\r\nAZTG\r\n', 'output': ['3']}, {'input': '17\r\nGNPBRASKVPECJKECD\r\n', 'output': ['16']}, {'input': '50\r\nALWLSFLXYPQYMIWXMYMXFYMIVFYJDTJAIGVOAUDAIIAHKNNVTX\r\n', 'output': ['13']}, {'input': '4\r\nACHG\r\n', 'output': ['12']}, {'input': '50\r\nZOMSHKIFVAMFATEIIEUJVITTYZGDWCGSOJMFQNYACRPOLGUZCM\r\n', '...
[{'input': '33\r\nIQHJDOVAGCIAEBAIXQYQCDVZGVOYIIYPR\r\n', 'output': ['12']}, {'input': '50\r\nALWLSFLXYPQYMIWXMYMXFYMIVFYJDTJAIGVOAUDAIIAHKNNVTX\r\n', 'output': ['13']}, {'input': '4\r\nNPGT\r\n', 'output': ['52']}, {'input': '6\r\nAFBAKC\r\n', 'output': ['16']}, {'input': '4\r\nACHG\r\n', 'output': ['12']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
235
100
100
100
["1 4 2", "5 5 5", "0 2 0"]
The only line contains three integers l, r and a (0 ≀ l, r, a ≀ 100) β€” the number of left-handers, the number of right-handers and the number of ambidexters at the training.
e8148140e61baffd0878376ac5f3857c
// Why do we fall ? So we can learn to pick ourselves up. import java.util.*; public class solve { static int mod = 1000000007; static int mod1 = 998244353; public static void main(String[] args){ Scanner sc = new Scanner(System.in); int lll = sc.nextInt(),rrr = sc.nextInt(),a = sc.nextInt(...
["6", "14", "0"]
Java
NoteIn the first example you can form a team of 6 players. You should take the only left-hander and two ambidexters to play with left hand, and three right-handers to play with right hand. The only person left can't be taken into the team.In the second example you can form a team of 14 people. You have to take all five...
Print a single even integerΒ β€” the maximum number of players in the team. It is possible that the team can only have zero number of players.
You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and exactly ...
[{"input": "1 4 2\r\n", "output": ["6"]}, {"input": "5 5 5\r\n", "output": ["14"]}, {"input": "0 2 0\r\n", "output": ["0"]}, {"input": "30 70 34\r\n", "output": ["128"]}, {"input": "89 32 24\r\n", "output": ["112"]}, {"input": "89 44 77\r\n", "output": ["210"]}, {"input": "0 0 0\r\n", "output": ["0"]}, {"input": "100 1...
100
100
100
[{'input': '97 97 0\r\n', 'output': ['194']}, {'input': '89 44 76\r\n', 'output': ['208']}, {'input': '1 2 3\r\n', 'output': ['6']}, {'input': '5 2 3\r\n', 'output': ['10']}, {'input': '0 2 0\r\n', 'output': ['0']}]
[{'input': '99 99 100\r\n', 'output': ['298']}, {'input': '30 70 35\r\n', 'output': ['130']}, {'input': '100 99 99\r\n', 'output': ['298']}, {'input': '14 81 1\r\n', 'output': ['30']}, {'input': '4 5 0\r\n', 'output': ['8']}]
[{'input': '100 100 99\r\n', 'output': ['298']}, {'input': '0 1 2\r\n', 'output': ['2']}, {'input': '49 82 73\r\n', 'output': ['204']}, {'input': '5 5 0\r\n', 'output': ['10']}, {'input': '62 81 75\r\n', 'output': ['218']}]
[{'input': '100 99 99\r\n', 'output': ['298']}, {'input': '0 100 0\r\n', 'output': ['0']}, {'input': '1 100 100\r\n', 'output': ['200']}, {'input': '83 86 99\r\n', 'output': ['268']}, {'input': '1 1 1\r\n', 'output': ['2']}]
[{'input': '74 71 75\r\n', 'output': ['220']}, {'input': '5 2 3\r\n', 'output': ['10']}, {'input': '32 61 89\r\n', 'output': ['182']}, {'input': '1 2 3\r\n', 'output': ['6']}, {'input': '14 81 1\r\n', 'output': ['30']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
50
236
100
100
90
["7 3\n3 5 7 1 6 2 8\n1 2 7", "4 4\n3 4 1 0\n0 1 7 9"]
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10$$$) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints. The next line contains $$$n$$$ distinct space-separated integers $$$x_1, x_2, \ldots, x_n$$$ ($$$0 \le x_i \le 9$$$) ...
f9044a4b4c3a0c2751217d9b31cd0c72
import java.util.*; public class A { public static void main(String[] args) { int n,m; Scanner s = new Scanner(System.in); n = s.nextInt(); m = s.nextInt(); int a[] = new int[n]; int b[] = new int[m]; for(int i = 0 ; i < n ; i++) { a[i]...
["7 1 2", "1 0"]
Java
NoteIn the first example, the only digits with fingerprints are $$$1$$$, $$$2$$$ and $$$7$$$. All three of them appear in the sequence you know, $$$7$$$ first, then $$$1$$$ and then $$$2$$$. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.In t...
In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.
You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequ...
[{"input": "7 3\r\n3 5 7 1 6 2 8\r\n1 2 7\r\n", "output": ["7 1 2"]}, {"input": "4 4\r\n3 4 1 0\r\n0 1 7 9\r\n", "output": ["1 0"]}, {"input": "9 4\r\n9 8 7 6 5 4 3 2 1\r\n2 4 6 8\r\n", "output": ["8 6 4 2"]}, {"input": "10 5\r\n3 7 1 2 4 6 9 0 5 8\r\n4 3 0 7 9\r\n", "output": ["3 7 4 9 0"]}, {"input": "5 5\r\n1 2 3 4 ...
100
100
100
[{'input': '10 6\r\n7 1 2 3 8 0 6 4 5 9\r\n1 5 8 2 3 6\r\n', 'output': ['1 2 3 8 6 5']}, {'input': '1 10\r\n9\r\n0 1 2 3 4 5 6 7 8 9\r\n', 'output': ['9']}, {'input': '10 5\r\n5 2 8 0 9 7 6 1 4 3\r\n9 6 4 1 2\r\n', 'output': ['2 9 6 1 4']}, {'input': '5 4\r\n7 0 1 4 9\r\n0 9 5 3\r\n', 'output': ['0 9']}, {'input': '6 3...
[{'input': '10 6\r\n7 1 2 3 8 0 6 4 5 9\r\n1 5 8 2 3 6\r\n', 'output': ['1 2 3 8 6 5']}, {'input': '3 6\r\n1 2 3\r\n4 5 6 1 2 3\r\n', 'output': ['1 2 3']}, {'input': '4 10\r\n8 3 9 6\r\n4 9 6 2 7 0 8 1 3 5\r\n', 'output': ['8 3 9 6']}, {'input': '6 1\r\n4 2 7 3 1 8\r\n9\r\n', 'output': ['']}, {'input': '5 10\r\n6 0 3 8...
[{'input': '3 7\r\n6 3 4\r\n4 9 0 1 7 8 6\r\n', 'output': ['6 4']}, {'input': '8 2\r\n7 2 9 6 1 0 3 4\r\n6 3\r\n', 'output': ['6 3']}, {'input': '3 6\r\n1 2 3\r\n4 5 6 1 2 3\r\n', 'output': ['1 2 3']}, {'input': '10 2\r\n1 0 3 5 8 9 4 7 6 2\r\n0 3\r\n', 'output': ['0 3']}, {'input': '10 1\r\n9 0 8 1 7 4 6 5 2 3\r\n0\r\...
[{'input': '1 2\r\n1\r\n1 0\r\n', 'output': ['1']}, {'input': '10 2\r\n1 0 3 5 8 9 4 7 6 2\r\n0 3\r\n', 'output': ['0 3']}, {'input': '6 3\r\n8 3 9 2 7 6\r\n5 4 3\r\n', 'output': ['3']}, {'input': '10 1\r\n9 6 2 0 1 8 3 4 7 5\r\n6\r\n', 'output': ['6']}, {'input': '10 5\r\n3 7 1 2 4 6 9 0 5 8\r\n4 3 0 7 9\r\n', 'output...
[{'input': '5 9\r\n3 7 9 2 4\r\n3 8 4 5 9 6 1 0 2\r\n', 'output': ['3 9 2 4']}, {'input': '8 2\r\n7 4 8 9 2 5 6 1\r\n6 4\r\n', 'output': ['4 6']}, {'input': '10 2\r\n4 9 6 8 3 0 1 5 7 2\r\n0 1\r\n', 'output': ['0 1']}, {'input': '6 3\r\n8 3 9 2 7 6\r\n5 4 3\r\n', 'output': ['3']}, {'input': '10 2\r\n7 1 0 2 4 6 5 9 3 8...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
237
100
100
100
["1", "2", "3"]
A single line contains a single integer n (1 ≀ n ≀ 4000).
aa2c3e94a44053a0d86f61da06681023
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...
["1", "3", "10"]
Java
NoteIf n = 1 there is only one such relationΒ β€” an empty one, i.e. . In other words, for a single element x of set A the following is hold: .If n = 2 there are three such relations. Let's assume that set A consists of two elements, x and y. Then the valid relations are , ρ = {(x, x)}, ρ = {(y, y)}. It is easy to see tha...
In a single line print the answer to the problem modulo 109 + 7.
Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.A set ρ of pairs (a, b) of elements of...
[{"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "3\r\n", "output": ["10"]}, {"input": "4\r\n", "output": ["37"]}, {"input": "5\r\n", "output": ["151"]}, {"input": "6\r\n", "output": ["674"]}, {"input": "7\r\n", "output": ["3263"]}, {"input": "8\r\n", "output": ["17007"]}, {"input": ...
100
100
100
[{'input': '2780\r\n', 'output': ['951043097']}, {'input': '1\r\n', 'output': ['1']}, {'input': '76\r\n', 'output': ['130527569']}, {'input': '3555\r\n', 'output': ['810675957']}, {'input': '6\r\n', 'output': ['674']}]
[{'input': '4000\r\n', 'output': ['341934157']}, {'input': '1234\r\n', 'output': ['845807965']}, {'input': '3000\r\n', 'output': ['949793998']}, {'input': '3555\r\n', 'output': ['810675957']}, {'input': '2780\r\n', 'output': ['951043097']}]
[{'input': '1234\r\n', 'output': ['845807965']}, {'input': '1730\r\n', 'output': ['730878735']}, {'input': '133\r\n', 'output': ['334338018']}, {'input': '777\r\n', 'output': ['765401747']}, {'input': '2999\r\n', 'output': ['634360769']}]
[{'input': '3000\r\n', 'output': ['949793998']}, {'input': '555\r\n', 'output': ['31983119']}, {'input': '2780\r\n', 'output': ['951043097']}, {'input': '2\r\n', 'output': ['3']}, {'input': '6\r\n', 'output': ['674']}]
[{'input': '555\r\n', 'output': ['31983119']}, {'input': '10\r\n', 'output': ['562595']}, {'input': '8\r\n', 'output': ['17007']}, {'input': '345\r\n', 'output': ['838683603']}, {'input': '20\r\n', 'output': ['654959364']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
238
100
100
100
["3", "4"]
The first line contains single integer $$$n$$$ ($$$3 \le n \le 500$$$) β€” the number of vertices in the regular polygon.
1bd29d7a8793c22e81a1f6fd3991307a
import java.util.*; import java.io.*; public class Solution { public static void main(String []ks) throws Exception { BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); long n=Long.parseLong(bf.readLine()); long a=2,b=3; long res=0; for(int i=3;i<=n;i+...
["6", "18"]
Java
NoteAccording to Wiki: polygon triangulation is the decomposition of a polygonal area (simple polygon) $$$P$$$ into a set of triangles, i. e., finding a set of triangles with pairwise non-intersecting interiors whose union is $$$P$$$.In the first example the polygon is a triangle, so we don't need to cut it further, so...
Print one integer β€” the minimum weight among all triangulations of the given polygon.
You are given a regular polygon with $$$n$$$ vertices labeled from $$$1$$$ to $$$n$$$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the initial polygon, there is no pair of triangles such that their intersection has non-zero ...
[{"input": "3\r\n", "output": ["6"]}, {"input": "4\r\n", "output": ["18"]}, {"input": "5\r\n", "output": ["38"]}, {"input": "6\r\n", "output": ["68"]}, {"input": "7\r\n", "output": ["110"]}, {"input": "8\r\n", "output": ["166"]}, {"input": "9\r\n", "output": ["238"]}, {"input": "10\r\n", "output": ["328"]}, {"input": "...
100
100
100
[{'input': '14\r\n', 'output': ['908']}, {'input': '233\r\n', 'output': ['4216366']}, {'input': '225\r\n', 'output': ['3796798']}, {'input': '108\r\n', 'output': ['419866']}, {'input': '4\r\n', 'output': ['18']}]
[{'input': '473\r\n', 'output': ['35274446']}, {'input': '470\r\n', 'output': ['34607508']}, {'input': '228\r\n', 'output': ['3950706']}, {'input': '225\r\n', 'output': ['3796798']}, {'input': '464\r\n', 'output': ['33298958']}]
[{'input': '461\r\n', 'output': ['32657238']}, {'input': '135\r\n', 'output': ['820078']}, {'input': '130\r\n', 'output': ['732288']}, {'input': '473\r\n', 'output': ['35274446']}, {'input': '479\r\n', 'output': ['36633918']}]
[{'input': '4\r\n', 'output': ['18']}, {'input': '10\r\n', 'output': ['328']}, {'input': '446\r\n', 'output': ['29572028']}, {'input': '106\r\n', 'output': ['396968']}, {'input': '105\r\n', 'output': ['385838']}]
[{'input': '461\r\n', 'output': ['32657238']}, {'input': '101\r\n', 'output': ['343398']}, {'input': '103\r\n', 'output': ['364206']}, {'input': '497\r\n', 'output': ['40920990']}, {'input': '4\r\n', 'output': ['18']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
239
100
100
100
["2 162", "4 42", "100 40021"]
The first line contains two positive integers a and b (1 ≀ a &lt; b ≀ 109)Β β€” the number which Vasily has and the number he wants to have.
fc3adb1a9a7f1122b567b4d8afd7b3f3
import java.util.*; public class transformation { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int num1 = scan.nextInt(); int num2 = scan.nextInt(),k=num2; ArrayList<Integer> arr = new ArrayList<>(); while(num2>num1){ if(num2%2==...
["YES\n5\n2 4 8 81 162", "NO", "YES\n5\n100 200 2001 4002 40021"]
Java
null
If there is no way to get b from a, print "NO" (without quotes). Otherwise print three lines. On the first line print "YES" (without quotes). The second line should contain single integer kΒ β€” the length of the transformation sequence. On the third line print the sequence of transformations x1, x2, ..., xk, where: x1 ...
Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number x by 2Β·x); append the digit 1 to the right of current number (that is, replace the number x by 10Β·x + 1). You need to help Vasily to transfo...
[{"input": "2 162\r\n", "output": ["YES\r\n5\r\n2 4 8 81 162"]}, {"input": "4 42\r\n", "output": ["NO"]}, {"input": "100 40021\r\n", "output": ["YES\r\n5\r\n100 200 2001 4002 40021"]}, {"input": "1 111111111\r\n", "output": ["YES\r\n9\r\n1 11 111 1111 11111 111111 1111111 11111111 111111111"]}, {"input": "1 1000000000\...
100
100
100
[{'input': '1 111111111\r\n', 'output': ['YES\r\n9\r\n1 11 111 1111 11111 111111 1111111 11111111 111111111']}, {'input': '79446 6355681\r\n', 'output': ['YES\r\n5\r\n79446 158892 317784 635568 6355681']}, {'input': '1 3\r\n', 'output': ['NO']}, {'input': '46646 373168844\r\n', 'output': ['YES\r\n7\r\n46646 466461 9329...
[{'input': '25987 51974222\r\n', 'output': ['YES\r\n5\r\n25987 259871 2598711 25987111 51974222']}, {'input': '29174 5834811\r\n', 'output': ['YES\r\n4\r\n29174 58348 583481 5834811']}, {'input': '1 3\r\n', 'output': ['NO']}, {'input': '1 1000000000\r\n', 'output': ['NO']}, {'input': '59139 946224\r\n', 'output': ['YES...
[{'input': '30070 300701\r\n', 'output': ['YES\r\n2\r\n30070 300701']}, {'input': '100 40021\r\n', 'output': ['YES\r\n5\r\n100 200 2001 4002 40021']}, {'input': '250000000 705032705\r\n', 'output': ['NO']}, {'input': '5440 27853056\r\n', 'output': ['YES\r\n11\r\n5440 10880 108801 217602 435204 870408 1740816 3481632 69...
[{'input': '5440 27853056\r\n', 'output': ['YES\r\n11\r\n5440 10880 108801 217602 435204 870408 1740816 3481632 6963264 13926528 27853056']}, {'input': '2 11\r\n', 'output': ['NO']}, {'input': '13494 1079528\r\n', 'output': ['YES\r\n5\r\n13494 134941 269882 539764 1079528']}, {'input': '25539 510782222\r\n', 'output': ...
[{'input': '13046 260921\r\n', 'output': ['YES\r\n3\r\n13046 26092 260921']}, {'input': '92387 184774\r\n', 'output': ['YES\r\n2\r\n92387 184774']}, {'input': '76259 610072\r\n', 'output': ['YES\r\n4\r\n76259 152518 305036 610072']}, {'input': '91939 9193911\r\n', 'output': ['YES\r\n3\r\n91939 919391 9193911']}, {'inpu...
100
100
100
100
100
100
100
100
100
100
100
100
100
90
100
240
100
100
98
["4\n5\n6\n3\n1\n2", "12\n11\n13\n20\n4\n6", "17\n14\n5\n21\n15\n17"]
The first line contains one integer $$$a$$$ $$$(1 \le a \le 100\,000)$$$ β€” the number of ties. The second line contains one integer $$$b$$$ $$$(1 \le b \le 100\,000)$$$ β€” the number of scarves. The third line contains one integer $$$c$$$ $$$(1 \le c \le 100\,000)$$$ β€” the number of vests. The fourth line contains one i...
84d9e7e9c9541d997e6573edb421ae0a
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; public class GFG { public static void main (String[] args) { Scanner s = new Scanner(System.in); int a = s.nextInt(); int b = s.nextInt(); int c = s.nextInt(); int d = s.nextInt(); int e = s.nex...
["6", "102", "325"]
Java
NoteIt is possible to compose three suits of the second type in the first example, and their total cost will be $$$6$$$. Since all jackets will be used, it's impossible to add anything to this set.The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second t...
Print one integer β€” the maximum total cost of some set of suits that can be composed from the delivered items.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of $$$a$$$ ties, $$$b$$$ scarves, $$$c$$$ vests and $$$d$$$ jackets.The store does not sell single clothing items β€” instead, it sells suits of two types: a suit of the first type consists of one tie and one jacket; a suit of th...
[{"input": "4\r\n5\r\n6\r\n3\r\n1\r\n2\r\n", "output": ["6"]}, {"input": "12\r\n11\r\n13\r\n20\r\n4\r\n6\r\n", "output": ["102"]}, {"input": "17\r\n14\r\n5\r\n21\r\n15\r\n17\r\n", "output": ["325"]}, {"input": "43475\r\n48103\r\n50473\r\n97918\r\n991\r\n974\r\n", "output": ["89936047"]}, {"input": "35361\r\n35182\r\n68...
100
100
100
[{'input': '630\r\n312\r\n279\r\n823\r\n316\r\n915\r\n', 'output': ['427189']}, {'input': '68576\r\n46084\r\n31772\r\n10708\r\n632\r\n408\r\n', 'output': ['6767456']}, {'input': '1\r\n4\r\n5\r\n6\r\n8\r\n8\r\n', 'output': ['40']}, {'input': '72593\r\n77891\r\n86639\r\n87424\r\n3\r\n617\r\n', 'output': ['48087346']}, {'...
[{'input': '1\r\n4\r\n5\r\n6\r\n8\r\n8\r\n', 'output': ['40']}, {'input': '406\r\n847\r\n512\r\n65\r\n86\r\n990\r\n', 'output': ['64350']}, {'input': '27989\r\n77786\r\n5733\r\n14112\r\n294\r\n715\r\n', 'output': ['6562521']}, {'input': '844\r\n909\r\n790\r\n209\r\n809\r\n949\r\n', 'output': ['198341']}, {'input': '353...
[{'input': '132\r\n402\r\n711\r\n790\r\n33\r\n837\r\n', 'output': ['340830']}, {'input': '27989\r\n77786\r\n5733\r\n14112\r\n294\r\n715\r\n', 'output': ['6562521']}, {'input': '100000\r\n100000\r\n100000\r\n100000\r\n1000\r\n1\r\n', 'output': ['100000000']}, {'input': '86516\r\n30436\r\n14408\r\n80824\r\n605\r\n220\r\n...
[{'input': '6\r\n1\r\n2\r\n5\r\n1\r\n1\r\n', 'output': ['5']}, {'input': '179\r\n762\r\n909\r\n155\r\n768\r\n278\r\n', 'output': ['119040']}, {'input': '25432\r\n28656\r\n46763\r\n79950\r\n64\r\n957\r\n', 'output': ['29051440']}, {'input': '17\r\n14\r\n5\r\n21\r\n15\r\n17\r\n', 'output': ['325']}, {'input': '129\r\n203...
[{'input': '1\r\n1\r\n1\r\n2\r\n100\r\n200\r\n', 'output': ['300']}, {'input': '68576\r\n46084\r\n31772\r\n10708\r\n632\r\n408\r\n', 'output': ['6767456']}, {'input': '72593\r\n77891\r\n86639\r\n87424\r\n3\r\n617\r\n', 'output': ['48087346']}, {'input': '627\r\n737\r\n778\r\n968\r\n870\r\n74\r\n', 'output': ['570724']}...
100
100
100
100
100
100
100
100
92
100
83.33
83.33
83.33
66.67
83.33
241
100
98.4
79.998
["8\nbacabcab", "4\nbcda", "6\nabbbbb"]
The only line of the input contains one integer $$$|s|$$$ ($$$1 \le |s| \le 100$$$) β€” the length of $$$s$$$. The second line of the input contains one string $$$s$$$ consisting of $$$|s|$$$ lowercase Latin letters.
9ce37bc2d361f5bb8a0568fb479b8a38
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); String str = in.next(); System.out.println(getAns(str, N)); in.close(); } public static int getAns(String str, int N) { int ans = 0; StringBuilder sb = new Str...
["4", "3", "5"]
Java
NoteThe first example is described in the problem statement. Note that the sequence of moves provided in the statement is not the only, but it can be shown that the maximum possible answer to this test is $$$4$$$.In the second example, you can remove all but one character of $$$s$$$. The only possible answer follows. ...
Print one integer β€” the maximum possible number of characters you can remove if you choose the sequence of moves optimally.
You are given a string $$$s$$$ consisting of lowercase Latin letters. Let the length of $$$s$$$ be $$$|s|$$$. You may perform several operations on this string.In one operation, you can choose some index $$$i$$$ and remove the $$$i$$$-th character of $$$s$$$ ($$$s_i$$$) if at least one of its adjacent characters is the...
[{"input": "8\r\nbacabcab\r\n", "output": ["4"]}, {"input": "4\r\nbcda\r\n", "output": ["3"]}, {"input": "6\r\nabbbbb\r\n", "output": ["5"]}, {"input": "1\r\na\r\n", "output": ["0"]}, {"input": "1\r\nt\r\n", "output": ["0"]}, {"input": "100\r\nciftajmzqbfkvbhnyugneialytrkwjlhzwltylptheadmypbjxdzkxnqovimgmzkwpuelzbbhcii...
100
100
100
[{'input': '6\r\nbbbbab\r\n', 'output': ['5']}, {'input': '1\r\na\r\n', 'output': ['0']}, {'input': '100\r\naaaaaaabaaaaaabcaaaaaaaaaaaaaaaaaaaabbbaaaaaaabefhklmnopsuxzywvtrqjigdcaaaaaaaaaaaaaaaaaaaaaaaabaaaa\r\n', 'output': ['32']}, {'input': '5\r\nbabaa\r\n', 'output': ['2']}, {'input': '100\r\nababaaaabaabaaaaaaabaa...
[{'input': '100\r\nababaaaabaabaaaaaaabaaaaaaaaaaaaacbaaaabaaaaaabaabaaaababaaaabaehijkmnpqvxzywutsrolgfdcbaaaabaabaaaa\r\n', 'output': ['40']}, {'input': '100\r\nacdfijmnorszzyyzzzzzzyzzyzzzzxwzzzzzyzzzzzzyzzzzzzzyzzzzzyzzzzzzyxzzzyzzzzzyzzzzzyzzyzzzzvutqplkhgeb\r\n', 'output': ['99']}, {'input': '100\r\naaaaabcjkprsv...
[{'input': '6\r\nbbbbab\r\n', 'output': ['5']}, {'input': '100\r\nciftajmzqbfkvbhnyugneialytrkwjlhzwltylptheadmypbjxdzkxnqovimgmzkwpuelzbbhciinfiyspfatgoexeezolulnliu\r\n', 'output': ['0']}, {'input': '100\r\nacdfijmnorszzyyzzzzzzyzzyzzzzxwzzzzzyzzzzzzyzzzzzzzyzzzzzyzzzzzzyxzzzyzzzzzyzzzzzyzzyzzzzvutqplkhgeb\r\n', 'out...
[{'input': '100\r\naaaabbbcccccccdddddeeeeeffgggghhhiijjjjkkkllmmnnnoooppqqqrrrrssssssttttuuuuuuuuvvvvvwwwwxxxxyyyyzzzz\r\n', 'output': ['96']}, {'input': '100\r\nabcdeghfgefedeefcabaaabcedfefedacbbcaaabehhjlkjikjloqrtuyzxwvspnmnlkjgfdcbacdcghfedfebaacbcbcdbccaaa\r\n', 'output': ['85']}, {'input': '6\r\nbbbbab\r\n', 'o...
[{'input': '9\r\nbaccbbaca\r\n', 'output': ['5']}, {'input': '4\r\nbcda\r\n', 'output': ['3']}, {'input': '6\r\nbbbbab\r\n', 'output': ['5']}, {'input': '100\r\nbldubjepvkwhjbxrueydtpparjszjgwpxjlqlpsmdrjoaagfnrohfcabchmdwaoctmilfbpztwjrfdgdioqggokdftcniqywmvjd\r\n', 'output': ['3']}, {'input': '7\r\ncddcbcb\r\n', 'out...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
242
100
100
100
["21", "20"]
The first line contains integer n (1 ≀ n ≀ 109).
ae20ae2a16273a0d379932d6e973f878
import java.io.*; import java.util.ArrayList; import java.util.StringTokenizer; /** * * @author arif_ * @date * @algo * @difficulty */ public class CF_876C { /* START OF I/O ROUTINE */ // PrintWriter for faster output public static PrintWriter out; // MyInputReader class for faster input pub...
["1\n15", "0"]
Java
NoteIn the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.In the second test case there are no such x.
In the first line print one integer kΒ β€” number of different values of x satisfying the condition. In next k lines print these values in ascending order.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain posi...
[{"input": "21\r\n", "output": ["1\r\n15"]}, {"input": "20\r\n", "output": ["0"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "2\r\n", "output": ["1\r\n1"]}, {"input": "3\r\n", "output": ["0"]}, {"input": "100000001\r\n", "output": ["2\r\n99999937\r\n 100000000", "2\r\n99999937 100000000", "2\r\n99999937\r\n1000000...
100
100
100
[{'input': '66\r\n', 'output': ['1\r\n60']}, {'input': '2\r\n', 'output': ['1\r\n1']}, {'input': '39\r\n', 'output': ['1\r\n33']}, {'input': '20\r\n', 'output': ['0']}, {'input': '100000001\r\n', 'output': ['2\r\n99999937\r\n 100000000', '2\r\n99999937 100000000', '2\r\n99999937\r\n100000000']}]
[{'input': '1000000000\r\n', 'output': ['1\r\n999999932']}, {'input': '101\r\n', 'output': ['2\r\n91\r\n100', '2\r\n91\r\n 100', '2\r\n91 100']}, {'input': '2\r\n', 'output': ['1\r\n1']}, {'input': '1\r\n', 'output': ['0']}, {'input': '21\r\n', 'output': ['1\r\n15']}]
[{'input': '66\r\n', 'output': ['1\r\n60']}, {'input': '3\r\n', 'output': ['0']}, {'input': '100000001\r\n', 'output': ['2\r\n99999937\r\n 100000000', '2\r\n99999937 100000000', '2\r\n99999937\r\n100000000']}, {'input': '39\r\n', 'output': ['1\r\n33']}, {'input': '20\r\n', 'output': ['0']}]
[{'input': '100\r\n', 'output': ['1\r\n86']}, {'input': '100000001\r\n', 'output': ['2\r\n99999937\r\n 100000000', '2\r\n99999937 100000000', '2\r\n99999937\r\n100000000']}, {'input': '39\r\n', 'output': ['1\r\n33']}, {'input': '3\r\n', 'output': ['0']}, {'input': '999999994\r\n', 'output': ['0']}]
[{'input': '11\r\n', 'output': ['1\r\n10']}, {'input': '3\r\n', 'output': ['0']}, {'input': '100\r\n', 'output': ['1\r\n86']}, {'input': '1000000000\r\n', 'output': ['1\r\n999999932']}, {'input': '1\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
243
100
100
100
["2\n5\n7", "4\n7\n13", "2\n3\n2"]
The first line contains the positive integer a (1 ≀ a ≀ 1000)Β β€” the number of lemons Nikolay has. The second line contains the positive integer b (1 ≀ b ≀ 1000)Β β€” the number of apples Nikolay has. The third line contains the positive integer c (1 ≀ c ≀ 1000)Β β€” the number of pears Nikolay has.
82a4a60eac90765fb62f2a77d2305c01
import java.util.Scanner; public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner scanner=new Scanner(System.in); int lemon = scanner.nextInt(); int apple = sc...
["7", "21", "0"]
Java
NoteIn the first example Nikolay can use 1 lemon, 2 apples and 4 pears, so the answer is 1 + 2 + 4 = 7.In the second example Nikolay can use 3 lemons, 6 apples and 12 pears, so the answer is 3 + 6 + 12 = 21.In the third example Nikolay don't have enough pears to cook any compote, so the answer is 0.
Print the maximum total number of lemons, apples and pears from which Nikolay can cook the compote.
Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. These fruitsΒ β€” lemons, ...
[{"input": "2\r\n5\r\n7\r\n", "output": ["7"]}, {"input": "4\r\n7\r\n13\r\n", "output": ["21"]}, {"input": "2\r\n3\r\n2\r\n", "output": ["0"]}, {"input": "1\r\n1\r\n1\r\n", "output": ["0"]}, {"input": "1\r\n2\r\n4\r\n", "output": ["7"]}, {"input": "1000\r\n1000\r\n1000\r\n", "output": ["1750"]}, {"input": "1\r\n1\r\n4\...
100
100
100
[{'input': '1000\r\n2\r\n1000\r\n', 'output': ['7']}, {'input': '109\r\n346\r\n811\r\n', 'output': ['763']}, {'input': '15\r\n313\r\n525\r\n', 'output': ['105']}, {'input': '104\r\n208\r\n413\r\n', 'output': ['721']}, {'input': '146\r\n291\r\n584\r\n', 'output': ['1015']}]
[{'input': '5\r\n4\r\n16\r\n', 'output': ['14']}, {'input': '1\r\n4\r\n8\r\n', 'output': ['7']}, {'input': '100\r\n4\r\n1000\r\n', 'output': ['14']}, {'input': '168\r\n454\r\n832\r\n', 'output': ['1176']}, {'input': '109\r\n346\r\n811\r\n', 'output': ['763']}]
[{'input': '104\r\n208\r\n413\r\n', 'output': ['721']}, {'input': '151\r\n308\r\n616\r\n', 'output': ['1057']}, {'input': '146\r\n421\r\n978\r\n', 'output': ['1022']}, {'input': '100\r\n200\r\n399\r\n', 'output': ['693']}, {'input': '67\r\n134\r\n267\r\n', 'output': ['462']}]
[{'input': '109\r\n346\r\n811\r\n', 'output': ['763']}, {'input': '1\r\n2\r\n3\r\n', 'output': ['0']}, {'input': '137\r\n422\r\n812\r\n', 'output': ['959']}, {'input': '22\r\n481\r\n633\r\n', 'output': ['154']}, {'input': '168\r\n454\r\n832\r\n', 'output': ['1176']}]
[{'input': '10\r\n2\r\n100\r\n', 'output': ['7']}, {'input': '189\r\n407\r\n966\r\n', 'output': ['1323']}, {'input': '70\r\n311\r\n685\r\n', 'output': ['490']}, {'input': '1\r\n1000\r\n1000\r\n', 'output': ['7']}, {'input': '1\r\n10\r\n10\r\n', 'output': ['7']}]
100
100
100
100
100
84.62
84.62
84.62
100
84.62
75
62.5
62.5
75
62.5
244
100
87.696
67.5
["5 2 6 3", "3 1 5 6", "8 3 3 2", "2 3 10 4"]
The only line of the input contains four integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ ($$$1 \le a, b, c, d \le 10^9$$$). It is possible that any two (or all three) ropewalkers are in the same position at the beginning of the performance.
47c07e46517dbc937e2e779ec0d74eb3
import static java.lang.StrictMath.abs; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Ropewalkers { static int a; static int b; static int c; static int d; static List <Integer> list = new ArrayList(); static int counte...
["2", "8", "2", "3"]
Java
NoteIn the first example: in the first two seconds Konrad moves for 2 positions to the right (to the position $$$8$$$), while Agafon and Boniface stay at their positions. Thus, the distance between Agafon and Boniface will be $$$|5 - 2| = 3$$$, the distance between Boniface and Konrad will be $$$|2 - 8| = 6$$$ and the ...
Output one integer β€” the minimum duration (in seconds) of the performance.
Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad.The rope is straight and infinite in both directions. At the beginning of the performance, Agafon, Boniface and Konrad are located in positions $$$a$$$, $$$b$$$ and $$$c$$$ respectively. At the end...
[{"input": "5 2 6 3\r\n", "output": ["2"]}, {"input": "3 1 5 6\r\n", "output": ["8"]}, {"input": "8 3 3 2\r\n", "output": ["2"]}, {"input": "2 3 10 4\r\n", "output": ["3"]}, {"input": "1000000000 1000000000 1000000000 1000000000\r\n", "output": ["2000000000"]}, {"input": "500000000 250000000 750000000 1000000000\r\n", ...
100
100
100
[{'input': '1 4 3 9\r\n', 'output': ['15']}, {'input': '8 3 3 2\r\n', 'output': ['2']}, {'input': '15 15 15 15\r\n', 'output': ['30']}, {'input': '1 2 9 5\r\n', 'output': ['4']}, {'input': '9 6 2 5\r\n', 'output': ['3']}]
[{'input': '15 15 15 15\r\n', 'output': ['30']}, {'input': '1 4 4 5\r\n', 'output': ['7']}, {'input': '5 5 2 6\r\n', 'output': ['9']}, {'input': '3 1 2 7\r\n', 'output': ['12']}, {'input': '8 3 3 2\r\n', 'output': ['2']}]
[{'input': '1 500000000 1000000000 1000000000\r\n', 'output': ['1000000001']}, {'input': '2 3 1 6\r\n', 'output': ['10']}, {'input': '2 2 3 4\r\n', 'output': ['7']}, {'input': '500000000 250000000 750000000 1000000000\r\n', 'output': ['1500000000']}, {'input': '9 6 2 5\r\n', 'output': ['3']}]
[{'input': '3 1 4 2\r\n', 'output': ['1']}, {'input': '5 5 4 1\r\n', 'output': ['1']}, {'input': '3 1 2 7\r\n', 'output': ['12']}, {'input': '15 15 15 15\r\n', 'output': ['30']}, {'input': '1000000000 1000000000 1000000000 1000000000\r\n', 'output': ['2000000000']}]
[{'input': '89 983 751 1000\r\n', 'output': ['1106']}, {'input': '1 3 3 6\r\n', 'output': ['10']}, {'input': '1 4 4 6\r\n', 'output': ['9']}, {'input': '500 1 500 1000\r\n', 'output': ['1501']}, {'input': '1 5 4 8\r\n', 'output': ['12']}]
100
100
100
100
100
100
100
100
100
100
75
75
50
75
50
245
100
100
65
["3 1\n-1 0 1", "2 1\n1 0", "1 1\n-1"]
The first line contains two integers $$$n$$$ and $$$p$$$ ($$$1 \leq n \leq 50$$$, $$$0 \leq p \leq 1$$$) β€” the number of pieces and Kuro's wanted parity. The second line contains $$$n$$$ integers $$$c_{1}, c_{2}, ..., c_{n}$$$ ($$$-1 \leq c_{i} \leq 1$$$) β€” the colors of the pieces.
aaf5f8afa71d9d25ebab405dddec78cd
import java.io.*; import java.util.*; public class Codeforces979E { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(br.readLine()); int ...
["6", "1", "2"]
Java
NoteIn the first example, there are $$$6$$$ ways to color the pieces and add the arrows, as are shown in the figure below. The scores are $$$3, 3, 5$$$ for the first row and $$$5, 3, 3$$$ for the second row, both from left to right.
Print a single integer β€” the number of ways to put the arrows and choose colors so the number of valid paths of alternating colors has the parity of $$$p$$$.
Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.Kuro challenged Katie to create a game with only a white paper, a pencil, a pair of scissors and a lot of ...
[{"input": "3 1\r\n-1 0 1\r\n", "output": ["6"]}, {"input": "2 1\r\n1 0\r\n", "output": ["1"]}, {"input": "1 1\r\n-1\r\n", "output": ["2"]}, {"input": "1 0\r\n-1\r\n", "output": ["0"]}, {"input": "1 1\r\n0\r\n", "output": ["1"]}, {"input": "5 1\r\n-1 -1 -1 -1 -1\r\n", "output": ["16512"]}, {"input": "5 0\r\n-1 -1 -1 -1...
100
100
100
[{'input': '6 1\r\n1 1 0 -1 -1 -1\r\n', 'output': ['133120']}, {'input': '10 1\r\n1 1 1 1 0 0 0 1 0 0\r\n', 'output': ['185921272']}, {'input': '6 0\r\n-1 0 -1 1 1 1\r\n', 'output': ['61440']}, {'input': '50 1\r\n-1 -1 1 0 1 1 0 -1 1 0 -1 -1 0 0 -1 -1 0 1 1 -1 1 0 -1 1 1 -1 -1 -1 1 -1 -1 0 -1 0 -1 0 0 -1 -1 0 1 -1 0 1 ...
[{'input': '4 1\r\n0 1 -1 -1\r\n', 'output': ['136']}, {'input': '29 1\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['733922348']}, {'input': '3 0\r\n0 0 0\r\n', 'output': ['0']}, {'input': '2 0\r\n-1 1\r\n', 'output': ['3']}, {'input': '46 0\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
[{'input': '17 0\r\n-1 0 -1 1 0 0 1 1 -1 -1 -1 -1 -1 1 1 -1 -1\r\n', 'output': ['555719737']}, {'input': '9 0\r\n1 1 0 0 1 -1 -1 0 0\r\n', 'output': ['438952513']}, {'input': '4 1\r\n0 1 -1 -1\r\n', 'output': ['136']}, {'input': '16 0\r\n-1 0 0 1 0 0 0 0 -1 -1 -1 -1 1 1 0 1\r\n', 'output': ['878929813']}, {'input': '42...
[{'input': '4 0\r\n1 -1 1 0\r\n', 'output': ['64']}, {'input': '1 0\r\n-1\r\n', 'output': ['0']}, {'input': '10 1\r\n1 1 1 -1 0 -1 -1 1 1 0\r\n', 'output': ['487370169']}, {'input': '7 0\r\n1 0 1 1 -1 1 1\r\n', 'output': ['2359296']}, {'input': '5 1\r\n-1 -1 -1 -1 -1\r\n', 'output': ['16512']}]
[{'input': '30 0\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['549790477']}, {'input': '31 0\r\n1 0 1 1 0 0 0 -1 -1 -1 -1 -1 0 1 1 1 0 -1 1 -1 -1 1 -1 1 1 0 0 1 1 -1 0\r\n', 'output': ['253181331']}, {'input': '7 0\r\n1 0 1 1 -1 1 1\r\n', 'output': ['2359296']}, {'input': '6 1\r\n1 1 ...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
246
100
100
100
["3\n1 3 5", "5\n1 0 1 5 1", "3\n4 3 1", "4\n3 9 9 3"]
The first line of input contains a non-negative integer n (1 ≀ n ≀ 100) β€” the length of the sequence. The second line contains n space-separated non-negative integers a1, a2, ..., an (0 ≀ ai ≀ 100) β€” the elements of the sequence.
2b8c2deb5d7e49e8e3ededabfd4427db
import java.io.*; import java.util.*; public class A { FScanner in = new FScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), true); void run() { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { int x = in.nextInt(...
["Yes", "Yes", "No", "No"]
Java
NoteIn the first example, divide the sequence into 1 subsegment: {1, 3, 5} and the requirements will be met.In the second example, divide the sequence into 3 subsegments: {1, 0, 1}, {5}, {1}.In the third example, one of the subsegments must start with 4 which is an even number, thus the requirements cannot be met.In th...
Output "Yes" if it's possible to fulfill the requirements, and "No" otherwise. You can output each letter in any case (upper or lower).
Where do odds begin, and where do they end? Where does hope emerge, and will they ever break?Given an integer sequence a1, a2, ..., an of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and ends with odd numbers.A subsegmen...
[{"input": "3\r\n1 3 5\r\n", "output": ["YES", "Yes"]}, {"input": "5\r\n1 0 1 5 1\r\n", "output": ["YES", "Yes"]}, {"input": "3\r\n4 3 1\r\n", "output": ["No", "NO"]}, {"input": "4\r\n3 9 9 3\r\n", "output": ["No", "NO"]}, {"input": "1\r\n1\r\n", "output": ["YES", "Yes"]}, {"input": "5\r\n100 99 100 99 99\r\n", "output...
100
100
100
[{'input': '4\r\n3 2 2 3\r\n', 'output': ['No', 'NO']}, {'input': '7\r\n1 0 1 1 0 0 1\r\n', 'output': ['YES', 'Yes']}, {'input': '5\r\n1 1 1 0 1\r\n', 'output': ['YES', 'Yes']}, {'input': '6\r\n1 1 0 0 1 1\r\n', 'output': ['No', 'NO']}, {'input': '7\r\n1 2 4 3 2 4 5\r\n', 'output': ['YES', 'Yes']}]
[{'input': '2\r\n1 1\r\n', 'output': ['No', 'NO']}, {'input': '5\r\n3 4 4 3 3\r\n', 'output': ['YES', 'Yes']}, {'input': '10\r\n3 4 2 4 3 2 2 4 4 3\r\n', 'output': ['No', 'NO']}, {'input': '5\r\n100 99 100 99 99\r\n', 'output': ['No', 'NO']}, {'input': '3\r\n1 0 2\r\n', 'output': ['No', 'NO']}]
[{'input': '6\r\n1 2 2 2 2 1\r\n', 'output': ['No', 'NO']}, {'input': '4\r\n3 9 2 3\r\n', 'output': ['No', 'NO']}, {'input': '5\r\n1 1 2 2 2\r\n', 'output': ['No', 'NO']}, {'input': '6\r\n1 1 2 2 1 1\r\n', 'output': ['No', 'NO']}, {'input': '6\r\n1 1 1 2 2 1\r\n', 'output': ['No', 'NO']}]
[{'input': '6\r\n1 1 1 1 1 1\r\n', 'output': ['No', 'NO']}, {'input': '28\r\n75 51 25 52 13 7 34 29 5 59 68 56 13 2 9 37 59 83 18 32 36 30 20 43 92 76 78 67\r\n', 'output': ['No', 'NO']}, {'input': '5\r\n1 2 2 5 5\r\n', 'output': ['YES', 'Yes']}, {'input': '5\r\n100 99 100 99 99\r\n', 'output': ['No', 'NO']}, {'input':...
[{'input': '6\r\n1 1 1 4 4 1\r\n', 'output': ['No', 'NO']}, {'input': '4\r\n3 2 2 3\r\n', 'output': ['No', 'NO']}, {'input': '5\r\n5 4 4 2 1\r\n', 'output': ['YES', 'Yes']}, {'input': '2\r\n54 21\r\n', 'output': ['No', 'NO']}, {'input': '7\r\n1 4 5 7 6 6 3\r\n', 'output': ['YES', 'Yes']}]
100
100
100
100
100
100
100
93.33
100
100
75
100
75
87.5
87.5
247
100
98.666
85
["2 2", "123 456789"]
The only line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 250$$$, $$$1 \le k \le 10^{9}$$$).
f67173c973c6f83e88bc0ddb0b9bfa93
//package cf589d2; import java.io.*; import java.util.*; import static java.lang.Math.*; public class E { static long MOD = 1000000007; public static void main(String[] args) { MyScanner sc = new MyScanner(); int n = sc.nextInt(); long k = sc.nextLong(); long[][] choose = new long[n + 1][n + 1]; long[][] p...
["7", "689974806"]
Java
NoteIn the first example, following $$$7$$$ cases are possible. In the second example, make sure you print the answer modulo $$$(10^{9} + 7)$$$.
Print the answer modulo $$$(10^{9} + 7)$$$.
You have $$$n \times n$$$ square grid and an integer $$$k$$$. Put an integer in each cell while satisfying the conditions below. All numbers in the grid should be between $$$1$$$ and $$$k$$$ inclusive. Minimum number of the $$$i$$$-th row is $$$1$$$ ($$$1 \le i \le n$$$). Minimum number of the $$$j$$$-th column is $...
[{"input": "2 2\r\n", "output": ["7"]}, {"input": "123 456789\r\n", "output": ["689974806"]}, {"input": "250 1000000000\r\n", "output": ["770503193"]}, {"input": "250 1\r\n", "output": ["1"]}, {"input": "1 3\r\n", "output": ["1"]}, {"input": "3 497285769\r\n", "output": ["790515254"]}, {"input": "3 212096267\r\n", "out...
100
100
100
[{'input': '216 639704712\r\n', 'output': ['319243107']}, {'input': '244 126314049\r\n', 'output': ['662993833']}, {'input': '216 411503551\r\n', 'output': ['618370501']}, {'input': '220 51931060\r\n', 'output': ['944377763']}, {'input': '214 431059147\r\n', 'output': ['37643610']}]
[{'input': '10 19549\r\n', 'output': ['843886139']}, {'input': '208 1\r\n', 'output': ['1']}, {'input': '1 3\r\n', 'output': ['1']}, {'input': '3 497285769\r\n', 'output': ['790515254']}, {'input': '216 411503551\r\n', 'output': ['618370501']}]
[{'input': '3 497285769\r\n', 'output': ['790515254']}, {'input': '216 411503551\r\n', 'output': ['618370501']}, {'input': '216 104981514\r\n', 'output': ['943178465']}, {'input': '250 1000000000\r\n', 'output': ['770503193']}, {'input': '242 106758452\r\n', 'output': ['437620405']}]
[{'input': '10 19549\r\n', 'output': ['843886139']}, {'input': '216 411503551\r\n', 'output': ['618370501']}, {'input': '236 1\r\n', 'output': ['1']}, {'input': '224 26911790\r\n', 'output': ['554883010']}, {'input': '216 639704712\r\n', 'output': ['319243107']}]
[{'input': '246 629926913\r\n', 'output': ['283598434']}, {'input': '208 1\r\n', 'output': ['1']}, {'input': '220 528762598\r\n', 'output': ['944995733']}, {'input': '218 548318195\r\n', 'output': ['721573920']}, {'input': '242 106758452\r\n', 'output': ['437620405']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
248
100
100
100
["1 0 0 1\n0 1 0 0\n0 0 1 0\n0 0 0 1", "0 1 1 0\n1 0 1 0\n1 1 0 0\n0 0 0 1", "1 0 0 0\n0 0 0 1\n0 0 0 0\n1 0 1 0"]
The input consists of four lines with each line describing a road part given in a counter-clockwise order. Each line contains four integers l, s, r, p β€” for the left, straight, right and pedestrian lights, respectively. The possible values are 0 for red light and 1 for green light.
44fdf71d56bef949ec83f00d17c29127
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int a[][] = new int[5][5]; for (int i = 1; i < a.length; i++) { for (int j = 1; j < a.length; j++) { a[i][j] = sc.nextInt(); } } if (a[1][4...
["YES", "NO", "NO"]
Java
NoteIn the first example, some accidents are possible because cars of part 1 can hit pedestrians of parts 1 and 4. Also, cars of parts 2 and 3 can hit pedestrians of part 4.In the second example, no car can pass the pedestrian crossing of part 4 which is the only green pedestrian light. So, no accident can occur.
On a single line, print "YES" if an accident is possible, and "NO" otherwise.
Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has 3 lanes getting into the intersection (one for each direction) and 3 lanes getting out of the intersection, so we have 4 parts in total. Each part has 4 lights, one for each lane...
[{"input": "1 0 0 1\r\n0 1 0 0\r\n0 0 1 0\r\n0 0 0 1\r\n", "output": ["YES"]}, {"input": "0 1 1 0\r\n1 0 1 0\r\n1 1 0 0\r\n0 0 0 1\r\n", "output": ["NO"]}, {"input": "1 0 0 0\r\n0 0 0 1\r\n0 0 0 0\r\n1 0 1 0\r\n", "output": ["NO"]}, {"input": "0 0 0 0\r\n0 0 0 1\r\n0 0 0 1\r\n0 0 0 1\r\n", "output": ["NO"]}, {"input": ...
100
100
100
[{'input': '0 0 0 0\r\n0 0 0 0\r\n0 0 0 0\r\n0 1 0 1\r\n', 'output': ['YES']}, {'input': '0 0 0 1\r\n1 0 0 0\r\n0 0 0 0\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input': '0 0 1 0\r\n0 0 0 0\r\n1 1 0 0\r\n0 0 0 1\r\n', 'output': ['NO']}, {'input': '0 0 1 0\r\n0 0 0 0\r\n0 0 0 1\r\n0 0 0 1\r\n', 'output': ['NO']}, {'input':...
[{'input': '0 0 0 1\r\n0 1 0 1\r\n0 0 0 0\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input': '1 0 1 0\r\n1 1 0 0\r\n1 1 0 0\r\n0 0 0 0\r\n', 'output': ['NO']}, {'input': '0 0 0 0\r\n0 0 0 0\r\n0 0 0 1\r\n0 0 1 0\r\n', 'output': ['NO']}, {'input': '1 1 0 1\r\n0 0 0 0\r\n0 0 0 0\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input':...
[{'input': '0 0 1 0\r\n0 0 0 0\r\n1 1 0 0\r\n0 0 0 1\r\n', 'output': ['NO']}, {'input': '0 1 0 1\r\n0 0 0 0\r\n0 0 0 0\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input': '0 0 0 1\r\n0 1 1 1\r\n0 0 0 0\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input': '0 0 0 0\r\n0 0 0 0\r\n0 0 0 0\r\n0 1 0 1\r\n', 'output': ['YES']}, {'input'...
[{'input': '0 0 0 0\r\n0 0 0 0\r\n0 0 1 1\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input': '0 1 0 0\r\n0 0 0 1\r\n0 0 0 0\r\n0 0 0 0\r\n', 'output': ['NO']}, {'input': '1 1 1 0\r\n0 1 0 1\r\n1 1 1 0\r\n1 1 1 1\r\n', 'output': ['YES']}, {'input': '0 1 0 0\r\n1 1 0 1\r\n1 0 0 1\r\n1 1 0 1\r\n', 'output': ['YES']}, {'input'...
[{'input': '1 1 0 0\r\n0 1 0 1\r\n1 1 1 0\r\n0 0 1 1\r\n', 'output': ['YES']}, {'input': '0 0 0 0\r\n0 0 1 0\r\n0 0 0 1\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input': '0 0 0 1\r\n0 1 1 1\r\n0 0 0 0\r\n0 0 0 0\r\n', 'output': ['YES']}, {'input': '0 0 0 0\r\n0 1 0 1\r\n1 0 1 1\r\n0 0 0 1\r\n', 'output': ['YES']}, {'input...
100
100
100
100
100
88.24
94.12
94.12
88.24
88.24
48.39
46.77
46.77
37.1
59.68
249
100
90.592
47.742
["3\n2 1 3", "3\n1 2 3"]
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) β€” the number of figures. The second line contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 3$$$, $$$a_i \ne a_{i + 1}$$$) β€” types of the figures.
6c8f028f655cc77b05ed89a668273702
import java.util.Scanner; public class InscribedFigures { public static void main(String[] args) { Scanner sc=new Scanner (System.in); int n=sc.nextInt(); int A[]=new int[n]; for (int x=0;x<n;x++) A[x]=sc.nextInt(); int s=0; int d=0; for (int x=0;x<n-1;x++) { if (A[x]+A[x+1]==5) { s=-1...
["Finite\n7", "Infinite"]
Java
NoteHere are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way.The distinct points where figures touch are marked red.In the second example the triangle and the square tou...
The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type.
The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier.Future students will be asked just a single question. They are given a sequence...
[{"input": "3\r\n2 1 3\r\n", "output": ["Finite\r\n7", "Finite\n7"]}, {"input": "3\r\n1 2 3\r\n", "output": ["Infinite"]}, {"input": "99\r\n3 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 3 1 3 1 2 1 2 1 2 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 ...
100
100
100
[{'input': '4\r\n3 1 2 1\r\n', 'output': ['Finite\r\n9', 'Finite\n9']}, {'input': '4\r\n2 3 1 2\r\n', 'output': ['Infinite']}, {'input': '3\r\n2 1 3\r\n', 'output': ['Finite\r\n7', 'Finite\n7']}, {'input': '2\r\n2 3\r\n', 'output': ['Infinite']}, {'input': '100\r\n2 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 3 1 2 1 3 1 2 1 3 1 3 1...
[{'input': '4\r\n3 1 2 1\r\n', 'output': ['Finite\r\n9', 'Finite\n9']}, {'input': '4\r\n1 3 1 2\r\n', 'output': ['Finite\r\n10', 'Finite\n10']}, {'input': '4\r\n3 1 2 3\r\n', 'output': ['Infinite']}, {'input': '5\r\n2 1 3 1 2\r\n', 'output': ['Finite\r\n13', 'Finite\n13']}, {'input': '3\r\n2 1 3\r\n', 'output': ['Finit...
[{'input': '15\r\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1\r\n', 'output': ['Finite\n42', 'Finite\r\n42']}, {'input': '4\r\n2 3 1 2\r\n', 'output': ['Infinite']}, {'input': '4\r\n3 1 3 2\r\n', 'output': ['Infinite']}, {'input': '2\r\n3 2\r\n', 'output': ['Infinite']}, {'input': '4\r\n3 1 2 3\r\n', 'output': ['Infinite']}]
[{'input': '11\r\n3 1 2 1 3 1 2 1 3 1 2\r\n', 'output': ['Finite\r\n32', 'Finite\n32']}, {'input': '3\r\n1 3 2\r\n', 'output': ['Infinite']}, {'input': '2\r\n3 1\r\n', 'output': ['Finite\r\n4', 'Finite\n4']}, {'input': '99\r\n1 2 1 2 1 2 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 3 1 2 1 3 1 ...
[{'input': '2\r\n3 1\r\n', 'output': ['Finite\r\n4', 'Finite\n4']}, {'input': '11\r\n3 1 2 1 3 1 2 1 3 1 2\r\n', 'output': ['Finite\r\n32', 'Finite\n32']}, {'input': '4\r\n3 1 2 3\r\n', 'output': ['Infinite']}, {'input': '4\r\n1 3 1 2\r\n', 'output': ['Finite\r\n10', 'Finite\n10']}, {'input': '2\r\n2 1\r\n', 'output': ...
100
100
100
100
100
100
100
100
100
100
94.44
88.89
94.44
94.44
88.89
250
100
100
92.22
["1 2 1000", "2 2 1000", "5 3 1103"]
Input consists of three integers n, k, m (1 ≀ n ≀ 1000, 1 ≀ k ≀ 100, 1 ≀ m ≀ 109).
656bf8df1e79499aa2ab2c28712851f0
import java.util.Arrays; import java.util.Scanner; import java.util.function.Function; public class CF287D { public static long modPower(long base, long exponent, long mod) { long result = 1; while (exponent > 0) { if ((exponent & 1) != 0) result = (result * base) % mod...
["4", "45", "590"]
Java
NoteA suffix of a string S is a non-empty string that can be obtained by removing some number (possibly, zero) of first characters from S.
Print the required number modulo m.
Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.First he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x &gt; 0 exist such that: Deci...
[{"input": "1 2 1000\r\n", "output": ["4"]}, {"input": "2 2 1000\r\n", "output": ["45"]}, {"input": "5 3 1103\r\n", "output": ["590"]}, {"input": "2 17 10000\r\n", "output": ["5"]}, {"input": "3 9 10000\r\n", "output": ["252"]}, {"input": "6 64 941761822\r\n", "output": ["46530"]}, {"input": "183 3 46847167\r\n", "outp...
100
100
100
[{'input': '12 39 618421525\r\n', 'output': ['115875938']}, {'input': '791 23 94030462\r\n', 'output': ['41862326']}, {'input': '561 69 310141994\r\n', 'output': ['245538618']}, {'input': '262 71 404639692\r\n', 'output': ['93447345']}, {'input': '261 32 49719977\r\n', 'output': ['19320923']}]
[{'input': '510 76 811693420\r\n', 'output': ['546301720']}, {'input': '1 2 1000\r\n', 'output': ['4']}, {'input': '621 43 356382217\r\n', 'output': ['251594310']}, {'input': '472 44 364550669\r\n', 'output': ['122479316']}, {'input': '434 6 56571287\r\n', 'output': ['56257936']}]
[{'input': '472 44 364550669\r\n', 'output': ['122479316']}, {'input': '312 41 915197716\r\n', 'output': ['912219984']}, {'input': '183 3 46847167\r\n', 'output': ['29891566']}, {'input': '1 2 2\r\n', 'output': ['0']}, {'input': '604 97 26180786\r\n', 'output': ['6950800']}]
[{'input': '176 70 196445230\r\n', 'output': ['64904804']}, {'input': '863 47 840397713\r\n', 'output': ['433465398']}, {'input': '1000 1 382210711\r\n', 'output': ['372462157']}, {'input': '510 76 811693420\r\n', 'output': ['546301720']}, {'input': '393 71 933802677\r\n', 'output': ['366541352']}]
[{'input': '674 22 494819681\r\n', 'output': ['19590614']}, {'input': '1000 13 10619863\r\n', 'output': ['8796170']}, {'input': '170 94 82742818\r\n', 'output': ['1117330']}, {'input': '543 98 508536403\r\n', 'output': ['117587951']}, {'input': '346 23 947672082\r\n', 'output': ['59151110']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
251
100
100
100
["8 5\n10 9 8 7 7 7 5 5", "4 2\n0 0 0 0"]
The first line of the input contains two integers n and k (1 ≀ k ≀ n ≀ 50) separated by a single space. The second line contains n space-separated integers a1, a2, ..., an (0 ≀ ai ≀ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i fro...
193ec1226ffe07522caf63e84a7d007f
import java.util.Scanner; public class NextRound2 { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n,k,score=-1,count=0; n = scan.nextInt(); k = scan.nextInt(); int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] ...
["6", "0"]
Java
NoteIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.In the second example nobody got a positive score.
Output the number of participants who advance to the next round.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." β€” an excerpt from contest rules.A total of n participants took part in the contest (n β‰₯ k), and you already know their scores. Calculate how many pa...
[{"input": "8 5\r\n10 9 8 7 7 7 5 5\r\n", "output": ["6"]}, {"input": "4 2\r\n0 0 0 0\r\n", "output": ["0"]}, {"input": "5 1\r\n1 1 1 1 1\r\n", "output": ["5"]}, {"input": "5 5\r\n1 1 1 1 1\r\n", "output": ["5"]}, {"input": "1 1\r\n10\r\n", "output": ["1"]}, {"input": "17 14\r\n16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0\...
100
100
100
[{'input': '8 3\r\n10 9 8 7 7 7 5 5\r\n', 'output': ['3']}, {'input': '50 25\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['26']}, {'input': '17 14\r\n16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0\r\n', 'output': ['14']}, {'input': '2 2\r\n10 10\r\n',...
[{'input': '5 5\r\n3 2 1 0 0\r\n', 'output': ['3']}, {'input': '50 44\r\n100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 58 58 55 55 54 52 48 47 45 44 44 38 36 32 31 28 28 25 25 24 24 24 22 17 15 14 13 12 4\r\n', 'output': ['44']}, {'input': '50 50\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
[{'input': '8 3\r\n10 9 8 7 7 7 5 5\r\n', 'output': ['3']}, {'input': '8 1\r\n10 9 8 7 7 7 5 5\r\n', 'output': ['1']}, {'input': '8 7\r\n10 9 8 7 7 7 5 5\r\n', 'output': ['8']}, {'input': '4 2\r\n0 0 0 0\r\n', 'output': ['0']}, {'input': '8 5\r\n10 9 8 7 7 7 5 5\r\n', 'output': ['6']}]
[{'input': '1 1\r\n10\r\n', 'output': ['1']}, {'input': '36 12\r\n90 87 86 85 83 80 79 78 76 70 69 69 61 61 59 58 56 48 45 44 42 41 33 31 27 25 23 21 20 19 15 14 12 7 5 5\r\n', 'output': ['12']}, {'input': '17 12\r\n99 88 86 82 75 75 74 65 58 52 45 30 21 16 7 2 2\r\n', 'output': ['12']}, {'input': '2 1\r\n10 0\r\n', 'o...
[{'input': '50 44\r\n100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 58 58 55 55 54 52 48 47 45 44 44 38 36 32 31 28 28 25 25 24 24 24 22 17 15 14 13 12 4\r\n', 'output': ['44']}, {'input': '10 3\r\n5 5 5 3 3 3 0 0 0 0\r\n', 'output': ['3']}, {'input': '11 6\r\n87 71 62 52 46 46 43 35 32 25 12\r\n', 'o...
100
100
100
100
100
100
100
100
100
92.86
90
90
90
80
60
252
100
98.572
82
["1 10 7", "4 0 9"]
The first line contains three integers a, b, mod (0 ≀ a, b ≀ 109, 1 ≀ mod ≀ 107).
8b6f633802293202531264446d33fee5
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; public class Game { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String[] input = bf.readLine().split(" "); String answer =...
["2", "1 000000001"]
Java
NoteThe lexical comparison of strings is performed by the &lt; operator in modern programming languages. String x is lexicographically less than string y if exists such i (1 ≀ i ≀ 9), that xi &lt; yi, and for any j (1 ≀ j &lt; i) xj = yj. These strings always have length 9.
If the first player wins, print "1" and the lexicographically minimum string s1 he has to write to win. If the second player wins, print the single number "2".
In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1, consisting of exactly nine digits and representing a number that does not exceed a. After that second player looks at s1 and writes a string s2, consisting of exactly nine digits and representi...
[{"input": "1 10 7\r\n", "output": ["2"]}, {"input": "4 0 9\r\n", "output": ["1 000000001"]}, {"input": "10 7 8\r\n", "output": ["2"]}, {"input": "6 4 10\r\n", "output": ["2"]}, {"input": "4 1 4\r\n", "output": ["2"]}, {"input": "4 7 9\r\n", "output": ["1 000000001"]}, {"input": "13 4 51\r\n", "output": ["1 000000001"]...
100
100
100
[{'input': '999999999 0 10000000\r\n', 'output': ['2']}, {'input': '2 1 3\r\n', 'output': ['1 000000001']}, {'input': '1000000000 9999991 10000000\r\n', 'output': ['2']}, {'input': '4 1 4\r\n', 'output': ['2']}, {'input': '116482865 344094604 3271060\r\n', 'output': ['2']}]
[{'input': '0 7 13\r\n', 'output': ['2']}, {'input': '0 3 3\r\n', 'output': ['2']}, {'input': '1000000000 0 2\r\n', 'output': ['2']}, {'input': '9902593 9902584 9902593\r\n', 'output': ['1 002490619']}, {'input': '815 216 182\r\n', 'output': ['2']}]
[{'input': '0 1 1\r\n', 'output': ['2']}, {'input': '1000000000 0 2\r\n', 'output': ['2']}, {'input': '1000000000 1000000000 9999999\r\n', 'output': ['2']}, {'input': '3966 5002 273075\r\n', 'output': ['1 000000008']}, {'input': '1 0 9\r\n', 'output': ['1 000000001']}]
[{'input': '0 0 11\r\n', 'output': ['2']}, {'input': '243 1001 1003\r\n', 'output': ['2']}, {'input': '1 0 9\r\n', 'output': ['1 000000001']}, {'input': '116482865 344094604 3271060\r\n', 'output': ['2']}, {'input': '4 3 12\r\n', 'output': ['1 000000001']}]
[{'input': '10 12000 12345\r\n', 'output': ['2']}, {'input': '1000000000 0 10000000\r\n', 'output': ['2']}, {'input': '0 1000000000 10000000\r\n', 'output': ['2']}, {'input': '23 0 23\r\n', 'output': ['1 000000001']}, {'input': '11 10 13\r\n', 'output': ['1 000000011']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
253
100
100
100
["3", "7"]
The only line of the input contains integer n (0 ≀ n ≀ 1018)Β β€” the number of Ayrat's moves.
a4b6a570f5e63462b68447713924b465
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * CodeForces : 338 * * @author vinaysaini E. Hexagons */ public class cf338e { static int dx[] = { 1, -1, -2, -1, 1,...
["-2 0", "3 2"]
Java
null
Print two integers x and yΒ β€” current coordinates of Ayrat coordinates.
Ayrat is looking for the perfect code. He decided to start his search from an infinite field tiled by hexagons. For convenience the coordinate system is introduced, take a look at the picture to see how the coordinates of hexagon are defined: Ayrat is searching through the field. He started at point (0, 0) and is mov...
[{"input": "3\r\n", "output": ["-2 0"]}, {"input": "7\r\n", "output": ["3 2"]}, {"input": "39\r\n", "output": ["5 6"]}, {"input": "14\r\n", "output": ["-2 -4"]}, {"input": "94\r\n", "output": ["8 8"]}, {"input": "60\r\n", "output": ["8 0"]}, {"input": "60\r\n", "output": ["8 0"]}, {"input": "59\r\n", "output": ["7 -2"]...
100
100
100
[{'input': '11\r\n', 'output': ['-3 2']}, {'input': '486639\r\n', 'output': ['-33 806']}, {'input': '0\r\n', 'output': ['0 0']}, {'input': '39\r\n', 'output': ['5 6']}, {'input': '26\r\n', 'output': ['-5 2']}]
[{'input': '8\r\n', 'output': ['2 4']}, {'input': '385078658398478614\r\n', 'output': ['358273010 -716546028']}, {'input': '39\r\n', 'output': ['5 6']}, {'input': '302486639\r\n', 'output': ['11555 -17054']}, {'input': '27719767248080188\r\n', 'output': ['-96124517 -192249026']}]
[{'input': '1941943667672759\r\n', 'output': ['-25442382 -50884744']}, {'input': '261252157843454379\r\n', 'output': ['-164822562 -590200144']}, {'input': '262078401021537803\r\n', 'output': ['439863347 302538706']}, {'input': '25\r\n', 'output': ['-4 4']}, {'input': '329939015655396840\r\n', 'output': ['-331631832 663...
[{'input': '13\r\n', 'output': ['-3 -2']}, {'input': '60\r\n', 'output': ['8 0']}, {'input': '441000740540275741\r\n', 'output': ['-383406115 -766812218']}, {'input': '262904639904653932\r\n', 'output': ['-378326148 -427475264']}, {'input': '2\r\n', 'output': ['-1 2']}]
[{'input': '259599671487287531\r\n', 'output': ['-252460838 -588330600']}, {'input': '257947185131120683\r\n', 'output': ['-53995102 -586455096']}, {'input': '94\r\n', 'output': ['8 8']}, {'input': '15\r\n', 'output': ['0 -4']}, {'input': '281824423976299408\r\n', 'output': ['-306498737 -612997466']}]
100
100
100
100
100
86.96
95.65
91.3
91.3
91.3
83.33
88.89
83.33
88.89
83.33
254
100
91.302
85.554
["6 1", "6 2", "60 5"]
The only line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 10^{15}$$$, $$$1 \leq k \leq 10^4$$$).
dc466d9c24b7dcb37c0e99337b4124d2
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main { class Node { long p; int a; public Node(long p,int a){ this.p=p; this.a=a; } } void solve() { long n=nl(); int k=ni(); ArrayList<Node> vec=new ArrayList<>(); for...
["3", "875000008", "237178099"]
Java
NoteIn the first example, after one step, the number written on the blackboard is $$$1$$$, $$$2$$$, $$$3$$$ or $$$6$$$ β€” each occurring with equal probability. Hence, the answer is $$$\frac{1+2+3+6}{4}=3$$$.In the second example, the answer is equal to $$$1 \cdot \frac{9}{16}+2 \cdot \frac{3}{16}+3 \cdot \frac{3}{16}+6...
Print a single integer β€” the expected value of the number on the blackboard after $$$k$$$ steps as $$$P \cdot Q^{-1} \pmod{10^9+7}$$$ for $$$P$$$, $$$Q$$$ defined above.
Makoto has a big blackboard with a positive integer $$$n$$$ written on it. He will perform the following action exactly $$$k$$$ times:Suppose the number currently written on the blackboard is $$$v$$$. He will randomly pick one of the divisors of $$$v$$$ (possibly $$$1$$$ and $$$v$$$) and replace $$$v$$$ with this divis...
[{"input": "6 1\r\n", "output": ["3"]}, {"input": "6 2\r\n", "output": ["875000008"]}, {"input": "60 5\r\n", "output": ["237178099"]}, {"input": "2 4\r\n", "output": ["562500005"]}, {"input": "12 3\r\n", "output": ["775462970"]}, {"input": "55 5\r\n", "output": ["789062507"]}, {"input": "935 9\r\n", "output": ["6588258...
100
100
100
[{'input': '866421317361600 10000\r\n', 'output': ['82212846']}, {'input': '60 5\r\n', 'output': ['237178099']}, {'input': '935 9\r\n', 'output': ['658825880']}, {'input': '890604418498560 9119\r\n', 'output': ['185509970']}, {'input': '817237005720659 4233\r\n', 'output': ['533017938']}]
[{'input': '1 1\r\n', 'output': ['1']}, {'input': '6 1\r\n', 'output': ['3']}, {'input': '999999999999999 8123\r\n', 'output': ['41003922']}, {'input': '128973636102142 5521\r\n', 'output': ['99152648']}, {'input': '357933504618282 1649\r\n', 'output': ['197730476']}]
[{'input': '5587021440 9995\r\n', 'output': ['360750834']}, {'input': '17297280 9994\r\n', 'output': ['94383698']}, {'input': '617673396283947 7777\r\n', 'output': ['488769014']}, {'input': '260858031033600 9696\r\n', 'output': ['692221824']}, {'input': '65214507758400 9997\r\n', 'output': ['677959603']}]
[{'input': '900018062553298 4801\r\n', 'output': ['345432320']}, {'input': '2 4\r\n', 'output': ['562500005']}, {'input': '890604418498560 9119\r\n', 'output': ['185509970']}, {'input': '617673396283947 7777\r\n', 'output': ['488769014']}, {'input': '900000720000023 9876\r\n', 'output': ['511266473']}]
[{'input': '17297280 9994\r\n', 'output': ['94383698']}, {'input': '2 4\r\n', 'output': ['562500005']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '999999999999993 8123\r\n', 'output': ['868053217']}, {'input': '609359740010496 1337\r\n', 'output': ['263703037']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
255
100
100
100
["4\n1 3 3 2", "3\n1 1 1", "4\n42 0 0 42"]
The first line contains a single integer n (1 ≀ n ≀ 100)Β β€” the number of participants. The next line contains a sequence of n integers a1, a2, ..., an (0 ≀ ai ≀ 600)Β β€” participants' scores. It's guaranteed that at least one participant has non-zero score.
3b520c15ea9a11b16129da30dcfb5161
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; import java.util.ArrayList; import java.util.TreeSet; import java.util.Collections; public class Hello { static class FastReader ...
["3", "1", "1"]
Java
NoteThere are three ways to choose a subset in sample case one. Only participants with 3 points will get diplomas. Participants with 2 or 3 points will get diplomas. Everyone will get a diploma! The only option in sample case two is to award everyone.Note that in sample case three participants with zero scores canno...
Print a single integerΒ β€” the desired number of ways.
The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria: At least one participant should get a diploma. ...
[{"input": "4\r\n1 3 3 2\r\n", "output": ["3"]}, {"input": "3\r\n1 1 1\r\n", "output": ["1"]}, {"input": "4\r\n42 0 0 42\r\n", "output": ["1"]}, {"input": "10\r\n1 0 1 0 1 0 0 0 0 1\r\n", "output": ["1"]}, {"input": "10\r\n572 471 540 163 50 30 561 510 43 200\r\n", "output": ["10"]}, {"input": "100\r\n122 575 426 445 1...
100
100
100
[{'input': '5\r\n1 0 0 1 2\r\n', 'output': ['2']}, {'input': '100\r\n572 471 540 163 50 30 561 510 43 200 213 387 500 424 113 487 357 333 294 337 435 202 447 494 485 465 161 344 470 559 104 356 393 207 224 213 511 514 60 386 149 216 392 229 429 173 165 401 395 150 127 579 344 390 529 296 225 425 318 79 465 447 177 110 ...
[{'input': '99\r\n5 4 13 2 5 6 2 10 10 1 2 6 7 9 6 3 5 7 1 10 2 2 7 0 2 11 11 3 1 13 3 10 6 2 0 3 0 5 0 1 4 11 1 1 7 0 12 7 5 12 0 2 12 9 8 3 4 3 4 11 4 10 2 3 10 12 5 6 1 11 2 0 8 7 9 1 3 12 2 3 9 3 7 13 7 13 0 11 8 12 2 5 9 4 0 6 6 2 13\r\n', 'output': ['13']}, {'input': '4\r\n1 1 1 2\r\n', 'output': ['2']}, {'input'...
[{'input': '100\r\n1 2 1 0 3 0 2 0 0 1 2 0 1 3 0 3 3 1 3 0 0 2 1 2 2 1 3 3 3 3 3 2 0 0 2 1 2 3 2 3 0 1 1 3 3 2 0 3 1 0 2 2 2 1 2 3 2 1 0 3 0 2 0 3 0 2 1 0 3 1 0 2 2 1 3 1 3 0 2 3 3 1 1 3 1 3 0 3 2 0 2 3 3 0 2 0 2 0 1 3\r\n', 'output': ['3']}, {'input': '2\r\n0 600\r\n', 'output': ['1']}, {'input': '34\r\n220 387 408 34...
[{'input': '99\r\n21 74 25 44 71 80 46 28 96 1 74 24 81 83 16 55 31 1 27 36 56 38 17 10 78 5 39 67 67 15 39 62 92 48 90 9 54 67 30 79 56 17 33 27 75 54 20 79 21 44 10 66 66 73 90 3 34 33 64 79 20 94 0 51 24 30 1 52 95 21 88 98 6 65 31 1 67 32 74 91 83 9 93 27 53 11 8 79 42 20 50 91 19 96 6 24 66 16 37\r\n', 'output': [...
[{'input': '100\r\n122 575 426 445 172 81 247 429 97 202 175 325 382 384 417 356 132 502 328 537 57 339 518 211 479 306 140 168 268 16 140 263 593 249 391 310 555 468 231 180 157 18 334 328 276 155 21 280 322 545 111 267 467 274 291 304 235 34 365 180 21 95 501 552 325 331 302 353 296 22 289 399 7 466 32 302 568 333 75...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
256
100
100
100
["6\nxxxiii", "5\nxxoxx", "10\nxxxxxxxxxx"]
The first line contains integer $$$n$$$ $$$(3 \le n \le 100)$$$ β€” the length of the file name. The second line contains a string of length $$$n$$$ consisting of lowercase Latin letters only β€” the file name.
8de14db41d0acee116bd5d8079cb2b02
import java.util.*; import java.lang.*; import java.io.*; public class A { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n,i,j,count,k; String t=br.readLine(); n=Integer.parseInt(t); ...
["1", "0", "8"]
Java
NoteIn the first example Polycarp tried to send a file with name contains number $$$33$$$, written in Roman numerals. But he can not just send the file, because it name contains three letters "x" in a row. To send the file he needs to remove any one of this letters.
Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0.
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the socia...
[{"input": "6\r\nxxxiii\r\n", "output": ["1\r\n", "1", "1\n"]}, {"input": "5\r\nxxoxx\r\n", "output": ["0\r\n", "0\n", "0"]}, {"input": "10\r\nxxxxxxxxxx\r\n", "output": ["8\n", "8", "8\r\n"]}, {"input": "100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n", "...
100
100
100
[{'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}, {'input': '99\r\nxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxa\r\n', 'output': ['0\r\n', '0\n', '0']}, ...
[{'input': '100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n', 'output': ['98', '98\n', '98\r\n']}, {'input': '5\r\nfcyju\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '34\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['0\r\n', '0\n', '0']}, {'i...
[{'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}, {'input': '99\r\nxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxa\r\n', 'output': ['0\r\n', '0\n', '0']}, ...
[{'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}, {'input': '5\r\nxxoxx\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '10\r\nxxxxxxxxxx\r\n', 'output': ['8\n', '8', '8\r\n']}, {'input': '100\r\nxxxxxxxxx...
[{'input': '100\r\nihygyvdvyeifomhxhkhdkimquvgallbqharcyriyqkidnwykozuhvkwdldlztpabgyuflikychqpdenwzgtlzotyumjgdsrbxxxx\r\n', 'output': ['2', '2\n', '2\r\n']}, {'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}...
100
100
100
100
100
100
100
100
100
100
90
90
90
90
100
257
100
100
92
["4 6", "9 7", "1 1"]
The only line of input contains two integers r and g, separated by a single space β€” the number of available red and green blocks respectively (0 ≀ r, g ≀ 2Β·105, r + g β‰₯ 1).
34b6286350e3531c1fbda6b0c184addc
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Abood2D { public static void main(String[] args) throws IOException { Scanner sc = new Sca...
["2", "6", "2"]
Java
NoteThe image in the problem statement shows all possible red-green towers for the first sample.
Output the only integer β€” the number of different possible red-green towers of height h moduloΒ 109 + 7.
There are r red and g green blocks for construction of the red-green tower. Red-green tower can be built following next rules: Red-green tower is consisting of some number of levels; Let the red-green tower consist of n levels, then the first level of this tower should consist of n blocks, second level β€” of n - 1 blo...
[{"input": "4 6\r\n", "output": ["2"]}, {"input": "9 7\r\n", "output": ["6"]}, {"input": "1 1\r\n", "output": ["2"]}, {"input": "3 3\r\n", "output": ["2"]}, {"input": "2 19\r\n", "output": ["1"]}, {"input": "18 3\r\n", "output": ["2"]}, {"input": "100000 1\r\n", "output": ["2"]}, {"input": "1 100000\r\n", "output": ["2...
100
100
100
[{'input': '18 3\r\n', 'output': ['2']}, {'input': '100000 1\r\n', 'output': ['2']}, {'input': '78250 121147\r\n', 'output': ['981737243']}, {'input': '121147 78249\r\n', 'output': ['64290784']}, {'input': '121146 78249\r\n', 'output': ['832902708']}]
[{'input': '10 10\r\n', 'output': ['18']}, {'input': '38 36\r\n', 'output': ['612']}, {'input': '100000 1\r\n', 'output': ['2']}, {'input': '199396 0\r\n', 'output': ['1']}, {'input': '199395 0\r\n', 'output': ['1']}]
[{'input': '0 199397\r\n', 'output': ['1']}, {'input': '199586 199586\r\n', 'output': ['876640810']}, {'input': '25580 17318\r\n', 'output': ['263898876']}, {'input': '1 1\r\n', 'output': ['2']}, {'input': '0 1\r\n', 'output': ['1']}]
[{'input': '0 199397\r\n', 'output': ['1']}, {'input': '200000 0\r\n', 'output': ['1']}, {'input': '18 3\r\n', 'output': ['2']}, {'input': '25580 17318\r\n', 'output': ['263898876']}, {'input': '100000 1\r\n', 'output': ['2']}]
[{'input': '200000 200000\r\n', 'output': ['206874596']}, {'input': '6 6\r\n', 'output': ['6']}, {'input': '199585 199585\r\n', 'output': ['199771918']}, {'input': '200000 0\r\n', 'output': ['1']}, {'input': '1 1\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
92.86
92.86
100
92.86
92.86
258
100
100
94.288
["19", "16"]
The first and only line contains an integer $$$r$$$ ($$$1 \le r \le 10^{12}$$$).
3ff1c25a1026c90aeb14d148d7fb96ba
//1184A1 import java.util.*; public class heidiA1{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); long r=sc.nextLong(); if(r%2==0||r<=3) System.out.println("NO"); else{ System.out.println("1"+" "+((r-3)/2)); } } }
["1 8", "NO"]
Java
null
Output integers $$$x, y$$$ such that $$$H(x,y) = r$$$ and $$$x$$$ is smallest possible, or "NO" if no such pair exists.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her to kill the Eleventh Doctor.Heidi figured out that Madame Kovarian uses a v...
[{"input": "19\r\n", "output": ["1 8"]}, {"input": "16\r\n", "output": ["NO"]}, {"input": "1\r\n", "output": ["NO"]}, {"input": "2\r\n", "output": ["NO"]}, {"input": "3\r\n", "output": ["NO"]}, {"input": "4\r\n", "output": ["NO"]}, {"input": "5\r\n", "output": ["1 1"]}, {"input": "6\r\n", "output": ["NO"]}, {"input": "...
100
100
100
[{'input': '943447972637\r\n', 'output': ['1 471723986317']}, {'input': '16\r\n', 'output': ['NO']}, {'input': '4\r\n', 'output': ['NO']}, {'input': '540024979445\r\n', 'output': ['1 270012489721']}, {'input': '16476190629\r\n', 'output': ['1 8238095313']}]
[{'input': '8\r\n', 'output': ['NO']}, {'input': '54433933447\r\n', 'output': ['1 27216966722']}, {'input': '7\r\n', 'output': ['1 2']}, {'input': '917861648772\r\n', 'output': ['NO']}, {'input': '29617919\r\n', 'output': ['1 14808958']}]
[{'input': '15\r\n', 'output': ['1 6']}, {'input': '18\r\n', 'output': ['NO']}, {'input': '29617919\r\n', 'output': ['1 14808958']}, {'input': '260158260522\r\n', 'output': ['NO']}, {'input': '2\r\n', 'output': ['NO']}]
[{'input': '10\r\n', 'output': ['NO']}, {'input': '15\r\n', 'output': ['1 6']}, {'input': '652509336151\r\n', 'output': ['1 326254668074']}, {'input': '426262703497\r\n', 'output': ['1 213131351747']}, {'input': '19\r\n', 'output': ['1 8']}]
[{'input': '688373050717\r\n', 'output': ['1 344186525357']}, {'input': '54336309171\r\n', 'output': ['1 27168154584']}, {'input': '962623690081\r\n', 'output': ['1 481311845039']}, {'input': '7505295085\r\n', 'output': ['1 3752647541']}, {'input': '250877914575\r\n', 'output': ['1 125438957286']}]
100
100
100
100
100
100
100
100
100
83.33
75
75
75
75
50
259
100
96.666
70
["24 0", "24 1", "24 -1", "4 -7", "1 1"]
The only line contains two integers $$$n$$$ and $$$p$$$ ($$$1 \leq n \leq 10^9$$$, $$$-1000 \leq p \leq 1000$$$).
9e86d87ce5a75c6a982894af84eb4ba8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.util.StringTokenizer; public class TaskC { public static String doMain(Reader reader) throws IOException { MyReader in = new MyReader(reader); int n = in.nextInt(); ...
["2", "3", "4", "2", "-1"]
Java
Note$$$0$$$-binary numbers are just regular binary powers, thus in the first sample case we can represent $$$24 = (2^4 + 0) + (2^3 + 0)$$$.In the second sample case, we can represent $$$24 = (2^4 + 1) + (2^2 + 1) + (2^0 + 1)$$$.In the third sample case, we can represent $$$24 = (2^4 - 1) + (2^2 - 1) + (2^2 - 1) + (2^2 ...
If it is impossible to represent $$$n$$$ as the sum of any number of $$$p$$$-binary numbers, print a single integer $$$-1$$$. Otherwise, print the smallest possible number of summands.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $$$p$$$ (which may be positive, negative, or zero). To combine their tastes, they invented $$$p$$$-binary numbers of the form $$$2^x + p$$$, where $$$x$$$ is a non-negativ...
[{"input": "24 0\r\n", "output": ["2"]}, {"input": "24 1\r\n", "output": ["3"]}, {"input": "24 -1\r\n", "output": ["4"]}, {"input": "4 -7\r\n", "output": ["2"]}, {"input": "1 1\r\n", "output": ["-1"]}, {"input": "10 7\r\n", "output": ["-1"]}, {"input": "3 -179\r\n", "output": ["5"]}, {"input": "12345678 -123\r\n", "out...
100
100
100
[{'input': '24 1\r\n', 'output': ['3']}, {'input': '2 1\r\n', 'output': ['1']}, {'input': '536870812 1\r\n', 'output': ['24']}, {'input': '536870812 -1\r\n', 'output': ['26']}, {'input': '9 8\r\n', 'output': ['1']}]
[{'input': '24 1\r\n', 'output': ['3']}, {'input': '1 -1\r\n', 'output': ['1']}, {'input': '13 6\r\n', 'output': ['-1']}, {'input': '12345678 -123\r\n', 'output': ['12']}, {'input': '3 2\r\n', 'output': ['1']}]
[{'input': '1 1\r\n', 'output': ['-1']}, {'input': '17 8\r\n', 'output': ['-1']}, {'input': '1999 999\r\n', 'output': ['-1']}, {'input': '2 1\r\n', 'output': ['1']}, {'input': '67108838 -1\r\n', 'output': ['26']}]
[{'input': '10 7\r\n', 'output': ['-1']}, {'input': '1001 500\r\n', 'output': ['-1']}, {'input': '13 -987\r\n', 'output': ['7']}, {'input': '536870812 1\r\n', 'output': ['24']}, {'input': '3 2\r\n', 'output': ['1']}]
[{'input': '24 1\r\n', 'output': ['3']}, {'input': '782 156\r\n', 'output': ['-1']}, {'input': '1 -1000\r\n', 'output': ['8']}, {'input': '1 1\r\n', 'output': ['-1']}, {'input': '678 169\r\n', 'output': ['-1']}]
100
100
100
100
100
94.44
100
100
100
100
83.33
100
100
100
100
260
100
98.888
96.666
["4", "3"]
The only line contains a single integer $$$n$$$ ($$$1 \le n \le 10^6$$$), denoting the required number of vertices.
821409c1b9bdcd18c4dcf35dc5116501
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class E { static int[] tree; static void fill(int idx) { if (idx >= tree.length) return; fill(2 * idx); fill(2 * idx + 1); tree[idx] = 1; if ...
["1", "0"]
Java
NoteIn the first example, this is the only tree that satisfies the conditions: In the second example, here are various trees that don't satisfy some condition:
Output the number of perfectly balanced striped binary search trees with $$$n$$$ vertices and distinct integer keys between $$$1$$$ and $$$n$$$, inclusive, modulo $$$998\,244\,353$$$.
Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than any key stored in the right subtree.The depth of a vertex is the number of ...
[{"input": "4\r\n", "output": ["1"]}, {"input": "3\r\n", "output": ["0"]}, {"input": "2\r\n", "output": ["1"]}, {"input": "5\r\n", "output": ["1"]}, {"input": "7\r\n", "output": ["0"]}, {"input": "8\r\n", "output": ["0"]}, {"input": "9\r\n", "output": ["1"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "21\r\n", "ou...
100
100
100
[{'input': '740812\r\n', 'output': ['0']}, {'input': '17\r\n', 'output': ['0']}, {'input': '549836\r\n', 'output': ['0']}, {'input': '796867\r\n', 'output': ['0']}, {'input': '7\r\n', 'output': ['0']}]
[{'input': '174762\r\n', 'output': ['1']}, {'input': '87380\r\n', 'output': ['1']}, {'input': '28\r\n', 'output': ['0']}, {'input': '43690\r\n', 'output': ['1']}, {'input': '360561\r\n', 'output': ['0']}]
[{'input': '16\r\n', 'output': ['0']}, {'input': '341\r\n', 'output': ['1']}, {'input': '175466\r\n', 'output': ['0']}, {'input': '174762\r\n', 'output': ['1']}, {'input': '20\r\n', 'output': ['1']}]
[{'input': '2730\r\n', 'output': ['1']}, {'input': '5460\r\n', 'output': ['1']}, {'input': '87381\r\n', 'output': ['1']}, {'input': '174761\r\n', 'output': ['1']}, {'input': '999999\r\n', 'output': ['0']}]
[{'input': '22\r\n', 'output': ['0']}, {'input': '988727\r\n', 'output': ['0']}, {'input': '699051\r\n', 'output': ['0']}, {'input': '11\r\n', 'output': ['0']}, {'input': '259060\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
91.67
100
100
100
91.67
261
100
100
96.668
["1 3", "10 15"]
The only line contains two integers a, b (1 ≀ a ≀ b ≀ 106) β€” the first and the last number typed by Max.
1193de6f80a9feee8522a404d16425b9
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; import java.math.*; public class S { public static void main (String[] args) { Scanner in=new Scanner(System.in); int a=in.nextInt(); int b=in.nextInt(); Map<Character,Integer> m= new HashMap<>(); m.put('0',6);m....
["12", "39"]
Java
null
Print the only integer a β€” the total number of printed segments.
Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display). Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total nu...
[{"input": "1 3\r\n", "output": ["12"]}, {"input": "10 15\r\n", "output": ["39"]}, {"input": "1 100\r\n", "output": ["928"]}, {"input": "100 10000\r\n", "output": ["188446"]}, {"input": "213 221442\r\n", "output": ["5645356"]}, {"input": "1 1000000\r\n", "output": ["28733372"]}, {"input": "1000000 1000000\r\n", "output...
100
100
100
[{'input': '2 1000000\r\n', 'output': ['28733370']}, {'input': '1 1000000\r\n', 'output': ['28733372']}, {'input': '100 10000\r\n', 'output': ['188446']}, {'input': '222145 353252\r\n', 'output': ['3860750']}, {'input': '1 999999\r\n', 'output': ['28733334']}]
[{'input': '10 15\r\n', 'output': ['39']}, {'input': '1 1000000\r\n', 'output': ['28733372']}, {'input': '2 1000000\r\n', 'output': ['28733370']}, {'input': '213 221442\r\n', 'output': ['5645356']}, {'input': '1 999999\r\n', 'output': ['28733334']}]
[{'input': '1 1000000\r\n', 'output': ['28733372']}, {'input': '1000000 1000000\r\n', 'output': ['38']}, {'input': '213 221442\r\n', 'output': ['5645356']}, {'input': '10 15\r\n', 'output': ['39']}, {'input': '1 100\r\n', 'output': ['928']}]
[{'input': '100 10000\r\n', 'output': ['188446']}, {'input': '222145 353252\r\n', 'output': ['3860750']}, {'input': '1 3\r\n', 'output': ['12']}, {'input': '192 200\r\n', 'output': ['122']}, {'input': '213 221442\r\n', 'output': ['5645356']}]
[{'input': '1 999999\r\n', 'output': ['28733334']}, {'input': '192 200\r\n', 'output': ['122']}, {'input': '1 1000000\r\n', 'output': ['28733372']}, {'input': '1000000 1000000\r\n', 'output': ['38']}, {'input': '222145 353252\r\n', 'output': ['3860750']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
262
100
100
100
["3 2", "3 3"]
The input data contains two space-separated positive integer numbers n and h (n ≀ 35, h ≀ n).
faf12a603d0c27f8be6bf6b02531a931
//package com.company; import java.io.*; public class Main { public static void main(String[] args)throws IOException{ BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); String[] line = buffer.readLine().split(" "); int nodes = Integer.parseInt(line[0]); in...
["5", "4"]
Java
null
Output one number β€” the answer to the problem. It is guaranteed that it does not exceed 9Β·1018.
In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phong β€” the oldest among the inhabitants of Mainframe. But still he managed to get some information from there. For example, he managed to learn that User launches games for pleasure β€” and then terribl...
[{"input": "3 2\r\n", "output": ["5"]}, {"input": "3 3\r\n", "output": ["4"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "2 1\r\n", "output": ["2"]}, {"input": "2 2\r\n", "output": ["2"]}, {"input": "27 11\r\n", "output": ["61162698256896"]}, {"input": "32 27\r\n", "output": ["22643872890880"]}, {"input": "4 1\r...
100
100
100
[{'input': '23 21\r\n', 'output': ['275251200']}, {'input': '21 12\r\n', 'output': ['12153990144']}, {'input': '24 20\r\n', 'output': ['8171945984']}, {'input': '2 1\r\n', 'output': ['2']}, {'input': '3 3\r\n', 'output': ['4']}]
[{'input': '4 4\r\n', 'output': ['8']}, {'input': '28 23\r\n', 'output': ['739948625920']}, {'input': '21 12\r\n', 'output': ['12153990144']}, {'input': '3 3\r\n', 'output': ['4']}, {'input': '7 7\r\n', 'output': ['64']}]
[{'input': '22 22\r\n', 'output': ['2097152']}, {'input': '4 3\r\n', 'output': ['14']}, {'input': '14 11\r\n', 'output': ['488448']}, {'input': '27 25\r\n', 'output': ['6081740800']}, {'input': '21 18\r\n', 'output': ['211156992']}]
[{'input': '34 1\r\n', 'output': ['812944042149730764']}, {'input': '4 4\r\n', 'output': ['8']}, {'input': '9 4\r\n', 'output': ['4862']}, {'input': '23 21\r\n', 'output': ['275251200']}, {'input': '33 4\r\n', 'output': ['212336130412243110']}]
[{'input': '27 15\r\n', 'output': ['25162319484928']}, {'input': '4 1\r\n', 'output': ['14']}, {'input': '32 27\r\n', 'output': ['22643872890880']}, {'input': '2 1\r\n', 'output': ['2']}, {'input': '20 14\r\n', 'output': ['1094473728']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
263
100
100
100
["2 3", "3 1"]
In the only line you are given two integers a, b (0 ≀ a, b ≀ 100) β€” the number of even and odd steps, accordingly.
ec5e3b3f5ee6a13eaf01b9a9a66ff037
import java.util.*; public class A761 { public static void main(String []args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m =sc.nextInt(); if(Math.abs(m-n) == 1 || (m+n!=0 && m==n) ) { System.out.println("YES"); } else ...
["YES", "NO"]
Java
NoteIn the first example one of suitable intervals is from 1 to 5. The interval contains two even stepsΒ β€” 2 and 4, and three odd: 1, 3 and 5.
In the only line print "YES", if the interval of steps described above exists, and "NO" otherwise.
On her way to programming school tiger Dasha faced her first test β€” a huge staircase! The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values β€” the number ...
[{"input": "2 3\r\n", "output": ["YES"]}, {"input": "3 1\r\n", "output": ["NO"]}, {"input": "5 4\r\n", "output": ["YES"]}, {"input": "9 9\r\n", "output": ["YES"]}, {"input": "85 95\r\n", "output": ["NO"]}, {"input": "0 1\r\n", "output": ["YES"]}, {"input": "89 25\r\n", "output": ["NO"]}, {"input": "74 73\r\n", "output"...
100
100
100
[{'input': '100 98\r\n', 'output': ['NO']}, {'input': '100 100\r\n', 'output': ['YES']}, {'input': '0 1\r\n', 'output': ['YES']}, {'input': '99 100\r\n', 'output': ['YES']}, {'input': '0 0\r\n', 'output': ['NO']}]
[{'input': '0 100\r\n', 'output': ['NO']}, {'input': '100 0\r\n', 'output': ['NO']}, {'input': '9 9\r\n', 'output': ['YES']}, {'input': '100 98\r\n', 'output': ['NO']}, {'input': '3 1\r\n', 'output': ['NO']}]
[{'input': '1 0\r\n', 'output': ['YES']}, {'input': '98 100\r\n', 'output': ['NO']}, {'input': '0 0\r\n', 'output': ['NO']}, {'input': '9 9\r\n', 'output': ['YES']}, {'input': '100 98\r\n', 'output': ['NO']}]
[{'input': '0 5\r\n', 'output': ['NO']}, {'input': '100 100\r\n', 'output': ['YES']}, {'input': '5 4\r\n', 'output': ['YES']}, {'input': '98 100\r\n', 'output': ['NO']}, {'input': '100 0\r\n', 'output': ['NO']}]
[{'input': '98 100\r\n', 'output': ['NO']}, {'input': '2 2\r\n', 'output': ['YES']}, {'input': '1 0\r\n', 'output': ['YES']}, {'input': '0 5\r\n', 'output': ['NO']}, {'input': '2 3\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
66.67
100
83.33
83.33
264
100
100
86.666
["3+2+1", "1+1+3+1+3", "2"]
The first line contains a non-empty string s β€” the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters "+". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.
76c7312733ef9d8278521cf09d3ccbc8
import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner lector = new Scanner(System.in); PriorityQueue<Integer> list = new PriorityQueue(); String s = lector.next(); int x; for(char c:s.toCharArray...
["1+2+3", "1+1+1+3+3", "2"]
Java
null
Print the new sum that Xenia can count.
Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xeni...
[{"input": "3+2+1\r\n", "output": ["1+2+3"]}, {"input": "1+1+3+1+3\r\n", "output": ["1+1+1+3+3"]}, {"input": "2\r\n", "output": ["2"]}, {"input": "2+2+1+1+3\r\n", "output": ["1+1+2+2+3"]}, {"input": "2+1+2+2+2+3+1+3+1+2\r\n", "output": ["1+1+1+2+2+2+2+2+3+3"]}, {"input": "1+2+1+2+2+2+2+1+3+3\r\n", "output": ["1+1+1+2+2...
100
100
100
[{'input': '2+2+1+1+3\r\n', 'output': ['1+1+2+2+3']}, {'input': '3+2+3+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+2+2+2+2+3+3+2+2+3+3+1+1+2+3+3+2+3+3+3\r\n', 'output': ['1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3']}, {'input': '3+2\r\n', 'output': ['...
[{'input': '1\r\n', 'output': ['1']}, {'input': '2+2+1+1+3\r\n', 'output': ['1+1+2+2+3']}, {'input': '2+2\r\n', 'output': ['2+2']}, {'input': '1+1+3+1+3\r\n', 'output': ['1+1+1+3+3']}, {'input': '3+2+1\r\n', 'output': ['1+2+3']}]
[{'input': '3+2+1\r\n', 'output': ['1+2+3']}, {'input': '3\r\n', 'output': ['3']}, {'input': '1\r\n', 'output': ['1']}, {'input': '2+1+2+2+2+3+1+3+1+2\r\n', 'output': ['1+1+1+2+2+2+2+2+3+3']}, {'input': '2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+3+2+2+2+1+3+1+3+3+3+1+2+1+2+2+2+2+3+1+1\r\n', 'output': ...
[{'input': '2+2\r\n', 'output': ['2+2']}, {'input': '3+2+1\r\n', 'output': ['1+2+3']}, {'input': '2+1\r\n', 'output': ['1+2']}, {'input': '2+2+1+1+3\r\n', 'output': ['1+1+2+2+3']}, {'input': '1+3\r\n', 'output': ['1+3']}]
[{'input': '3+1\r\n', 'output': ['1+3']}, {'input': '2+2+1+1+1+3+1+1+3+3+2+3+1+3+1+1+3+1+1+2+2+2+2+1+2+1+2+1+1+1+3+1+3+2+3+2+3+3+1+1+1+2+3+2+1+3+1+3+2+2\r\n', 'output': ['1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3']}, {'input': '2\r\n', 'output': ['2']}, {'input'...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
265
100
100
100
["18 2", "9 10", "1000000000000 5", "1000000000000 499999999999"]
The first (and the only) line of input contains two integers n and k (1 ≀ n, k ≀ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
405a70c3b3f1561a9546910ab3fb5c80
import java.io.*; import java.util.*; public class Training { public static void main(String[] args) throws IOException { Scanner input = new Scanner(System.in); long n = input.nextLong(),k= input.nextLong(); long a = n/2/(k+1); long b = a *k ; ...
["3 6 9", "0 0 9", "83333333333 416666666665 500000000002", "1 499999999999 500000000000"]
Java
null
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible. It's possible that there are no winners.
There are n students who have taken part in an olympiad. Now it's time to award the students.Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and cert...
[{"input": "18 2\r\n", "output": ["3 6 9"]}, {"input": "9 10\r\n", "output": ["0 0 9"]}, {"input": "1000000000000 5\r\n", "output": ["83333333333 416666666665 500000000002"]}, {"input": "1000000000000 499999999999\r\n", "output": ["1 499999999999 500000000000"]}, {"input": "1 1\r\n", "output": ["0 0 1"]}, {"input": "5 ...
100
100
100
[{'input': '42 6\r\n', 'output': ['3 18 21']}, {'input': '1000000000000 1000000006\r\n', 'output': ['499 499000002994 500999996507']}, {'input': '1000000000000 100000000001\r\n', 'output': ['4 400000000004 599999999992']}, {'input': '420506530901 752346673804\r\n', 'output': ['0 0 420506530901']}, {'input': '9999999999...
[{'input': '1000000000000 250000000001\r\n', 'output': ['1 250000000001 749999999998']}, {'input': '549755813888 134217728\r\n', 'output': ['2047 274743689216 275012122625']}, {'input': '420506530901 752346673804\r\n', 'output': ['0 0 420506530901']}, {'input': '1000000000000 32416187567\r\n', 'output': ['15 4862428135...
[{'input': '100000000000 578485652\r\n', 'output': ['86 49749766072 50250233842']}, {'input': '732577309725 132613\r\n', 'output': ['2762066 366285858458 366288689201']}, {'input': '1000000000000 250000000001\r\n', 'output': ['1 250000000001 749999999998']}, {'input': '1000000000000 1000\r\n', 'output': ['499500499 499...
[{'input': '1 1\r\n', 'output': ['0 0 1']}, {'input': '99999999999 15253636363\r\n', 'output': ['3 45760909089 54239090907']}, {'input': '1000000000000 7777777777\r\n', 'output': ['64 497777777728 502222222208']}, {'input': '999999999999 1000000000000\r\n', 'output': ['0 0 999999999999']}, {'input': '99999999999 333333...
[{'input': '99999999999 15253636363\r\n', 'output': ['3 45760909089 54239090907']}, {'input': '3107038133 596040207\r\n', 'output': ['2 1192080414 1914957717']}, {'input': '999999999999 10000000000\r\n', 'output': ['49 490000000000 509999999950']}, {'input': '100000000000 578485652\r\n', 'output': ['86 49749766072 5025...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
266
100
100
100
["5", "12"]
The first line of the input contains an integer x (1 ≀ x ≀ 1 000 000)Β β€” The coordinate of the friend's house.
4b3d65b1b593829e92c852be213922b6
import java.util.Scanner; public class Slonik { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int input = scan.nextInt(); float min = input / 5f; System.out.println((int)Math.ceil(min)); } }
["1", "3"]
Java
NoteIn the first sample the elephant needs to make one step of length 5 to reach the point x.In the second sample the elephant can get to point x if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach x in less than three moves.
Print the minimum number of steps that elephant needs to make to get from point 0 to point x.
An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x &gt; 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in ord...
[{"input": "5\r\n", "output": ["1"]}, {"input": "12\r\n", "output": ["3"]}, {"input": "999999\r\n", "output": ["200000"]}, {"input": "41\r\n", "output": ["9"]}, {"input": "1000000\r\n", "output": ["200000"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["1"]}, {"input": "3\r\n", "output": ["1"]}, ...
100
100
100
[{'input': '999998\r\n', 'output': ['200000']}, {'input': '999995\r\n', 'output': ['199999']}, {'input': '999996\r\n', 'output': ['200000']}, {'input': '3\r\n', 'output': ['1']}, {'input': '999991\r\n', 'output': ['199999']}]
[{'input': '1\r\n', 'output': ['1']}, {'input': '8901\r\n', 'output': ['1781']}, {'input': '3\r\n', 'output': ['1']}, {'input': '2\r\n', 'output': ['1']}, {'input': '999994\r\n', 'output': ['199999']}]
[{'input': '502877\r\n', 'output': ['100576']}, {'input': '999998\r\n', 'output': ['200000']}, {'input': '53\r\n', 'output': ['11']}, {'input': '999996\r\n', 'output': ['200000']}, {'input': '1\r\n', 'output': ['1']}]
[{'input': '534204\r\n', 'output': ['106841']}, {'input': '999999\r\n', 'output': ['200000']}, {'input': '2\r\n', 'output': ['1']}, {'input': '999993\r\n', 'output': ['199999']}, {'input': '5\r\n', 'output': ['1']}]
[{'input': '999992\r\n', 'output': ['199999']}, {'input': '729\r\n', 'output': ['146']}, {'input': '999999\r\n', 'output': ['200000']}, {'input': '53\r\n', 'output': ['11']}, {'input': '3\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
267
100
100
100
["5\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5\n2 2 3 3", "4\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5"]
The first line contains a single integer n (1 ≀ n ≀ 5). Next n lines contain four integers each, describing a single rectangle: x1, y1, x2, y2 (0 ≀ x1 &lt; x2 ≀ 31400, 0 ≀ y1 &lt; y2 ≀ 31400) β€” x1 and x2 are x-coordinates of the left and right edges of the rectangle, and y1 and y2 are y-coordinates of the bottom and to...
f63fc2d97fd88273241fce206cc217f2
import java.util.Scanner; public class Main { private static final int MAXN = 4000000; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] areas = new int[n]; int left = MAXN, right = 0, top = MAXN, bottom = 0; ...
["YES", "NO"]
Java
null
In a single line print "YES", if the given rectangles form a square, or "NO" otherwise.
You are given n rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle). Your task is to determine if the rectangl...
[{"input": "5\r\n0 0 2 3\r\n0 3 3 5\r\n2 0 5 2\r\n3 2 5 5\r\n2 2 3 3\r\n", "output": ["YES"]}, {"input": "4\r\n0 0 2 3\r\n0 3 3 5\r\n2 0 5 2\r\n3 2 5 5\r\n", "output": ["NO"]}, {"input": "5\r\n0 0 10000 20000\r\n10000 0 15000 19999\r\n10000 19999 14999 20000\r\n0 20000 15000 31400\r\n15000 0 31400 31400\r\n", "output":...
100
100
100
[{'input': '5\r\n0 0 10000 20000\r\n10000 0 15000 19999\r\n10000 19999 15000 20000\r\n0 20000 15000 31400\r\n15000 0 31400 31400\r\n', 'output': ['YES']}, {'input': '3\r\n25784 0 31400 20408\r\n0 20408 31400 20582\r\n15802 0 18106 20408\r\n', 'output': ['NO']}, {'input': '4\r\n0 0 1 2\r\n0 3 1 4\r\n0 4 1 5\r\n0 2 1 3\r...
[{'input': '2\r\n0 0 1 1\r\n2 2 3 3\r\n', 'output': ['NO']}, {'input': '2\r\n0 0 1 1\r\n1 1 2 2\r\n', 'output': ['NO']}, {'input': '4\r\n0 0 1 1\r\n5 5 6 6\r\n10 10 11 11\r\n13 13 14 14\r\n', 'output': ['NO']}, {'input': '5\r\n1349 0 1391 3766\r\n1234 0 1238 417\r\n1391 0 5000 3766\r\n1234 417 1238 3766\r\n1238 0 1349 ...
[{'input': '5\r\n0 7098 1 7460\r\n0 7460 1 15218\r\n0 15218 1 31400\r\n0 4974 1 7098\r\n0 0 1 4974\r\n', 'output': ['NO']}, {'input': '5\r\n0 0 10000 20000\r\n10000 0 15000 19999\r\n10000 19999 14999 20000\r\n0 20000 15000 31400\r\n15000 0 31400 31400\r\n', 'output': ['NO']}, {'input': '2\r\n1 1 5 5\r\n1 5 5 7\r\n', 'o...
[{'input': '1\r\n123 4819 5819 29511\r\n', 'output': ['NO']}, {'input': '5\r\n10359 859 28918 4384\r\n2895 26520 28918 26882\r\n2895 26424 28918 26520\r\n2895 859 10359 4384\r\n2895 4384 28918 26424\r\n', 'output': ['YES']}, {'input': '5\r\n0 0 10000 20000\r\n10000 0 15000 19999\r\n10000 19999 15000 20000\r\n0 20000 15...
[{'input': '5\r\n0 0 10000 20000\r\n10000 0 15000 19999\r\n10000 19999 15000 20000\r\n0 20000 15000 31400\r\n15000 0 31400 31400\r\n', 'output': ['YES']}, {'input': '5\r\n26466 0 26474 6206\r\n10906 0 17073 6321\r\n19720 0 26356 31400\r\n0 0 10906 7852\r\n0 21437 18466 31400\r\n', 'output': ['NO']}, {'input': '4\r\n180...
100
100
100
100
100
100
100
100
100
100
100
100
100
87.5
100
268
100
100
97.5
["2 3 1000000", "3 3 2"]
The first line contains three integers n, m, s (1 ≀ n, m, s ≀ 106) β€” length of the board, width of the board and length of the flea's jump.
e853733fb2ed87c56623ff9a5ac09c36
import java.io.*; import java.util.*; public class practice { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String ne...
["6", "4"]
Java
null
Output the only integer β€” the number of the required starting positions of the flea.
It is known that fleas in Berland can jump only vertically and horizontally, and the length of the jump is always equal to s centimeters. A flea has found herself at the center of some cell of the checked board of the size n × m centimeters (each cell is 1 × 1 centimeters). She can jump as she wishes for an arbitrary n...
[{"input": "2 3 1000000\r\n", "output": ["6"]}, {"input": "3 3 2\r\n", "output": ["4"]}, {"input": "1 2 3\r\n", "output": ["2"]}, {"input": "4 5 6\r\n", "output": ["20"]}, {"input": "9 8 7\r\n", "output": ["8"]}, {"input": "1000 1000 1000\r\n", "output": ["1000000"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": ...
100
100
100
[{'input': '1 2 3\r\n', 'output': ['2']}, {'input': '1000000 1000000 2\r\n', 'output': ['1000000000000']}, {'input': '1000 1000 1000\r\n', 'output': ['1000000']}, {'input': '303307 400683 999941\r\n', 'output': ['121529958681']}, {'input': '3 3 2\r\n', 'output': ['4']}]
[{'input': '9 8 7\r\n', 'output': ['8']}, {'input': '109785 447109 990618\r\n', 'output': ['49085861565']}, {'input': '923179 799988 998430\r\n', 'output': ['738532121852']}, {'input': '282798 941695 999998\r\n', 'output': ['266309462610']}, {'input': '105126 379125 460772\r\n', 'output': ['39855894750']}]
[{'input': '1 2 3\r\n', 'output': ['2']}, {'input': '999463 261665 981183\r\n', 'output': ['9566472400']}, {'input': '213927 672636 865\r\n', 'output': ['27867287808']}, {'input': '1000000 1000000 999999\r\n', 'output': ['4']}, {'input': '391814 220151 3756\r\n', 'output': ['16977831150']}]
[{'input': '43054 191 1\r\n', 'output': ['8223314']}, {'input': '1000000 1000000 123456\r\n', 'output': ['12358324224']}, {'input': '1000000 1000000 999999\r\n', 'output': ['4']}, {'input': '313667 778854 999813\r\n', 'output': ['244300797618']}, {'input': '61043 55049 998379\r\n', 'output': ['3360356107']}]
[{'input': '2 3 1000000\r\n', 'output': ['6']}, {'input': '3 3 2\r\n', 'output': ['4']}, {'input': '694117 431924 737\r\n', 'output': ['13934440800']}, {'input': '836832 336228 50\r\n', 'output': ['100850467200']}, {'input': '43496 179847 327622\r\n', 'output': ['7822625112']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
269
100
100
100
["7", "8", "9"]
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^9$$$).
5551742f6ab39fdac3930d866f439e3e
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Scanner; public class Main { ...
["4", "5", "5"]
Java
NoteIn the first sample, there are following possible weights of splits of $$$7$$$:Weight 1: [$$$\textbf 7$$$] Weight 2: [$$$\textbf 3$$$, $$$\textbf 3$$$, 1] Weight 3: [$$$\textbf 2$$$, $$$\textbf 2$$$, $$$\textbf 2$$$, 1] Weight 7: [$$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, ...
Output one integerΒ β€” the answer to the problem.
Let's define a split of $$$n$$$ as a nonincreasing sequence of positive integers, the sum of which is $$$n$$$. For example, the following sequences are splits of $$$8$$$: $$$[4, 4]$$$, $$$[3, 3, 2]$$$, $$$[2, 2, 1, 1, 1, 1]$$$, $$$[5, 2, 1]$$$.The following sequences aren't splits of $$$8$$$: $$$[1, 7]$$$, $$$[5, 4]$$$...
[{"input": "7\r\n", "output": ["4"]}, {"input": "8\r\n", "output": ["5"]}, {"input": "9\r\n", "output": ["5"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "286\r\n", "output": ["144"]}, {"input": "48\r\n", "output": ["25"]}, {"input": "941\r\n", "output": ["471"]}, {"input": "45154\r\n", "output": ["22578"]}, {"inp...
100
100
100
[{'input': '41909\r\n', 'output': ['20955']}, {'input': '97349542\r\n', 'output': ['48674772']}, {'input': '574128507\r\n', 'output': ['287064254']}, {'input': '5076901\r\n', 'output': ['2538451']}, {'input': '123957268\r\n', 'output': ['61978635']}]
[{'input': '60169\r\n', 'output': ['30085']}, {'input': '323926781\r\n', 'output': ['161963391']}, {'input': '751453521\r\n', 'output': ['375726761']}, {'input': '858771038\r\n', 'output': ['429385520']}, {'input': '58288\r\n', 'output': ['29145']}]
[{'input': '43255\r\n', 'output': ['21628']}, {'input': '29239\r\n', 'output': ['14620']}, {'input': '576768825\r\n', 'output': ['288384413']}, {'input': '31293802\r\n', 'output': ['15646902']}, {'input': '45154\r\n', 'output': ['22578']}]
[{'input': '17286\r\n', 'output': ['8644']}, {'input': '574128507\r\n', 'output': ['287064254']}, {'input': '29950\r\n', 'output': ['14976']}, {'input': '60324\r\n', 'output': ['30163']}, {'input': '79811\r\n', 'output': ['39906']}]
[{'input': '520778784\r\n', 'output': ['260389393']}, {'input': '2\r\n', 'output': ['2']}, {'input': '1960\r\n', 'output': ['981']}, {'input': '79811\r\n', 'output': ['39906']}, {'input': '60169\r\n', 'output': ['30085']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
270
100
100
100
["390", "7", "1000000000"]
The only input line contains the integer $$$n$$$ ($$$1 \le n \le 2\cdot10^9$$$).
38690bd32e7d0b314f701f138ce19dfb
import java.util.Scanner; public class Nirvana { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); Nirvana obj = new Nirvana(); System.out.println(obj.maxMultiply(n)); in.close(); } int maxMultiply(int n) { if(n == 0) return 1; int nextNum = n/1...
["216", "7", "387420489"]
Java
NoteIn the first example the maximum product is achieved for $$$389$$$ (the product of digits is $$$3\cdot8\cdot9=216$$$).In the second example the maximum product is achieved for $$$7$$$ (the product of digits is $$$7$$$).In the third example the maximum product is achieved for $$$999999999$$$ (the product of digits i...
Print the maximum product of digits among all integers from $$$1$$$ to $$$n$$$.
Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.Help Kurt find the maximum possible product of digits among all integers from $$$1$$$ to $$$n$$$.
[{"input": "390\r\n", "output": ["216"]}, {"input": "7\r\n", "output": ["7"]}, {"input": "1000000000\r\n", "output": ["387420489"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "9\r\n", "output": ["9"]}, {"input": "2000000000\r\n", "output": ["387420489"]}, {"input": "4876\r\n", "output": ["2268"]}, {"input": "88987...
100
100
100
[{'input': '1999999999\r\n', 'output': ['387420489']}, {'input': '261560170\r\n', 'output': ['47829690']}, {'input': '4876\r\n', 'output': ['2268']}, {'input': '480330141\r\n', 'output': ['133923132']}, {'input': '999\r\n', 'output': ['729']}]
[{'input': '1000000000\r\n', 'output': ['387420489']}, {'input': '25\r\n', 'output': ['10']}, {'input': '691993260\r\n', 'output': ['229582512']}, {'input': '19\r\n', 'output': ['9']}, {'input': '1\r\n', 'output': ['1']}]
[{'input': '3\r\n', 'output': ['3']}, {'input': '278\r\n', 'output': ['112']}, {'input': '389041744\r\n', 'output': ['102036672']}, {'input': '100\r\n', 'output': ['81']}, {'input': '9\r\n', 'output': ['9']}]
[{'input': '997\r\n', 'output': ['648']}, {'input': '2690\r\n', 'output': ['864']}, {'input': '480330141\r\n', 'output': ['133923132']}, {'input': '396579088\r\n', 'output': ['114791256']}, {'input': '1\r\n', 'output': ['1']}]
[{'input': '389041744\r\n', 'output': ['102036672']}, {'input': '892295273\r\n', 'output': ['306110016']}, {'input': '1999999999\r\n', 'output': ['387420489']}, {'input': '289664200\r\n', 'output': ['68024448']}, {'input': '997\r\n', 'output': ['648']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
271
100
100
100
["0 2", "2 0", "2 2", "2000 2000"]
The only line contains two integers $$$n$$$ and $$$m$$$ ($$$0 \le n,m \le 2\,000$$$).
a2fcad987e9b2bb3e6395654cd4fcfbb
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you https://www.a2oj.com/Ladder16.html */ impor...
["0", "2", "5", "674532367"]
Java
NoteIn the first example the only possible array is [-1,-1], its maximal prefix sum is equal to $$$0$$$. In the second example the only possible array is [1,1], its maximal prefix sum is equal to $$$2$$$. There are $$$6$$$ possible arrays in the third example:[1,1,-1,-1], f([1,1,-1,-1]) = 2[1,-1,1,-1], f([1,-1,1,-1]) =...
Output the answer to the problem modulo $$$998\: 244\: 853$$$.
Natasha's favourite numbers are $$$n$$$ and $$$1$$$, and Sasha's favourite numbers are $$$m$$$ and $$$-1$$$. One day Natasha and Sasha met and wrote down every possible array of length $$$n+m$$$ such that some $$$n$$$ of its elements are equal to $$$1$$$ and another $$$m$$$ elements are equal to $$$-1$$$. For each such...
[{"input": "0 2\r\n", "output": ["0"]}, {"input": "2 0\r\n", "output": ["2"]}, {"input": "2 2\r\n", "output": ["5"]}, {"input": "2000 2000\r\n", "output": ["674532367"]}, {"input": "0 0\r\n", "output": ["0"]}, {"input": "11 2\r\n", "output": ["716"]}, {"input": "1 4\r\n", "output": ["1"]}, {"input": "5 13\r\n", "output...
100
100
100
[{'input': '983 666\r\n', 'output': ['917123830']}, {'input': '2 0\r\n', 'output': ['2']}, {'input': '0 2000\r\n', 'output': ['0']}, {'input': '953 1797\r\n', 'output': ['557692333']}, {'input': '1 4\r\n', 'output': ['1']}]
[{'input': '1132 1727\r\n', 'output': ['878164775']}, {'input': '27 16\r\n', 'output': ['886006554']}, {'input': '1080 383\r\n', 'output': ['161999131']}, {'input': '983 666\r\n', 'output': ['917123830']}, {'input': '1942 1523\r\n', 'output': ['89088577']}]
[{'input': '756 1061\r\n', 'output': ['72270489']}, {'input': '27 16\r\n', 'output': ['886006554']}, {'input': '45 1323\r\n', 'output': ['357852234']}, {'input': '60 59\r\n', 'output': ['271173738']}, {'input': '149 821\r\n', 'output': ['64450770']}]
[{'input': '0 2\r\n', 'output': ['0']}, {'input': '1883 1513\r\n', 'output': ['265215482']}, {'input': '1994 1981\r\n', 'output': ['596939902']}, {'input': '2000 2000\r\n', 'output': ['674532367']}, {'input': '149 821\r\n', 'output': ['64450770']}]
[{'input': '1087 1050\r\n', 'output': ['973930225']}, {'input': '976 1698\r\n', 'output': ['621383232']}, {'input': '0 2000\r\n', 'output': ['0']}, {'input': '1132 1727\r\n', 'output': ['878164775']}, {'input': '2000 2000\r\n', 'output': ['674532367']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
272
100
100
100
["4", "5"]
The single line contains the positive integer n (1 ≀ n ≀ 1015).
689e7876048ee4eb7479e838c981f068
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; public class _486A_CalculatingFunction { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamR...
["2", "-3"]
Java
Notef(4) =  - 1 + 2 - 3 + 4 = 2f(5) =  - 1 + 2 - 3 + 4 - 5 =  - 3
Print f(n) in a single line.
For a positive integer n let's define a function f:f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a given integer n.
[{"input": "4\r\n", "output": ["2"]}, {"input": "5\r\n", "output": ["-3"]}, {"input": "1000000000\r\n", "output": ["500000000"]}, {"input": "1000000001\r\n", "output": ["-500000001"]}, {"input": "1000000000000000\r\n", "output": ["500000000000000"]}, {"input": "100\r\n", "output": ["50"]}, {"input": "101\r\n", "output"...
100
100
100
[{'input': '5\r\n', 'output': ['-3']}, {'input': '10000000000001\r\n', 'output': ['-5000000000001']}, {'input': '101\r\n', 'output': ['-51']}, {'input': '29906716\r\n', 'output': ['14953358']}, {'input': '62\r\n', 'output': ['31']}]
[{'input': '105\r\n', 'output': ['-53']}, {'input': '10000000000001\r\n', 'output': ['-5000000000001']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '100000000000000\r\n', 'output': ['50000000000000']}, {'input': '999999999999999\r\n', 'output': ['-500000000000000']}]
[{'input': '104\r\n', 'output': ['52']}, {'input': '145645214654154\r\n', 'output': ['72822607327077']}, {'input': '5\r\n', 'output': ['-3']}, {'input': '100\r\n', 'output': ['50']}, {'input': '98979894985999\r\n', 'output': ['-49489947493000']}]
[{'input': '208170109961052\r\n', 'output': ['104085054980526']}, {'input': '4018154546667\r\n', 'output': ['-2009077273334']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '109\r\n', 'output': ['-55']}, {'input': '100\r\n', 'output': ['50']}]
[{'input': '98979894985999\r\n', 'output': ['-49489947493000']}, {'input': '1000000000\r\n', 'output': ['500000000']}, {'input': '1000000000000000\r\n', 'output': ['500000000000000']}, {'input': '5\r\n', 'output': ['-3']}, {'input': '100\r\n', 'output': ['50']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
273
100
100
100
["4\n6\n1\n1\n1\n1", "1\n10\n5", "3\n6\n1\n6\n5", "3\n7\n1\n6\n5"]
The first line contains a single integer $$$n$$$ $$$(1 \le n \le 100)$$$ β€” the number of benches in the park. The second line contains a single integer $$$m$$$ $$$(1 \le m \le 10\,000)$$$ β€” the number of people additionally coming to the park. Each of the next $$$n$$$ lines contains a single integer $$$a_i$$$ $$$(1 \le...
78f696bd954c9f0f9bb502e515d85a8d
import java.util.* ; public class contes { public static void main(String ar[]) { Scanner sc = new Scanner(System.in) ; int n = sc.nextInt() ; int m = sc.nextInt() ; int max = 0 ; int sum = 0 ; for(int i = 0 ; i <n ; i++) { int k = sc.nextInt() ; ...
["3 7", "15 15", "6 12", "7 13"]
Java
NoteIn the first example, each of four benches is occupied by a single person. The minimum $$$k$$$ is $$$3$$$. For example, it is possible to achieve if two newcomers occupy the first bench, one occupies the second bench, one occupies the third bench, and two remaining β€” the fourth bench. The maximum $$$k$$$ is $$$7$$$...
Print the minimum possible $$$k$$$ and the maximum possible $$$k$$$, where $$$k$$$ is the maximum number of people sitting on one bench after additional $$$m$$$ people came to the park.
There are $$$n$$$ benches in the Berland Central park. It is known that $$$a_i$$$ people are currently sitting on the $$$i$$$-th bench. Another $$$m$$$ people are coming to the park and each of them is going to have a seat on some bench out of $$$n$$$ available.Let $$$k$$$ be the maximum number of people sitting on one...
[{"input": "4\r\n6\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["3 7"]}, {"input": "1\r\n10\r\n5\r\n", "output": ["15 15"]}, {"input": "3\r\n6\r\n1\r\n6\r\n5\r\n", "output": ["6 12"]}, {"input": "3\r\n7\r\n1\r\n6\r\n5\r\n", "output": ["7 13"]}, {"input": "10\r\n1000\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n10...
100
100
100
[{'input': '2\r\n16\r\n2\r\n100\r\n', 'output': ['100 116']}, {'input': '10\r\n1\r\n5\r\n5\r\n5\r\n5\r\n4\r\n5\r\n5\r\n5\r\n5\r\n5\r\n', 'output': ['5 6']}, {'input': '100\r\n300\r\n1\r\n1\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n2\r\n1\r\n1\r\n2\r\n2\r\n1\r\n1\r\n2\r\n1\r\n1\r\n2\r\n1\r\n2\r\n2\r\n2\r...
[{'input': '10\r\n1000\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n', 'output': ['200 1100']}, {'input': '100\r\n3241\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n10...
[{'input': '10\r\n10\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n', 'output': ['2 11']}, {'input': '100\r\n3241\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r...
[{'input': '100\r\n10000\r\n54\r\n54\r\n50\r\n52\r\n55\r\n51\r\n50\r\n53\r\n50\r\n56\r\n50\r\n51\r\n51\r\n52\r\n54\r\n50\r\n54\r\n52\r\n53\r\n56\r\n55\r\n51\r\n52\r\n55\r\n56\r\n52\r\n52\r\n56\r\n51\r\n56\r\n51\r\n51\r\n55\r\n54\r\n52\r\n55\r\n51\r\n55\r\n56\r\n54\r\n55\r\n54\r\n56\r\n56\r\n51\r\n52\r\n52\r\n56\r\n51\r...
[{'input': '51\r\n10000\r\n54\r\n23\r\n93\r\n86\r\n57\r\n68\r\n42\r\n33\r\n47\r\n18\r\n78\r\n41\r\n35\r\n92\r\n32\r\n97\r\n74\r\n93\r\n27\r\n59\r\n90\r\n23\r\n79\r\n96\r\n77\r\n29\r\n88\r\n83\r\n83\r\n46\r\n94\r\n61\r\n56\r\n68\r\n43\r\n15\r\n79\r\n26\r\n36\r\n99\r\n36\r\n55\r\n77\r\n23\r\n15\r\n12\r\n84\r\n57\r\n82\r\...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
274
100
100
100
["AS\n2H 4C TH JH AD", "2H\n3D 4C AC KD AS", "4D\nAS AC AD AH 5H"]
The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand. Each string is two characters long. The first character denotes the rank and belongs to the set $$$\{{\tt 2}, {\tt 3}, {\tt 4}, {\tt 5}, {\tt 6}, {\tt 7}, {...
699444eb6366ad12bc77e7ac2602d74b
import java.util.Scanner; public class Solution{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=5; String[] arr=new String[t]; String my=sc.next(); for(int i=0;i<t;i++){ arr[i]=sc.next(); } String ans="NO"; ...
["YES", "NO", "YES"]
Java
NoteIn the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.In the second example, you cannot play any card.In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the ...
If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO". You can print each letter in any case (upper or lower).
Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".To play Mau-Mau, you need a pack of $$$52$$$ cards. Each card has a suit (Diamonds β€” D, Clubs β€” C, Spades β€” S,...
[{"input": "AS\r\n2H 4C TH JH AD\r\n", "output": ["YES", "yes", "Yes"]}, {"input": "2H\r\n3D 4C AC KD AS\r\n", "output": ["No", "NO", "no"]}, {"input": "4D\r\nAS AC AD AH 5H\r\n", "output": ["YES", "yes", "Yes"]}, {"input": "3D\r\n8S 4S 2C AS 6H\r\n", "output": ["No", "NO", "no"]}, {"input": "7H\r\nTC 4C KC AD 9S\r\n",...
100
100
100
[{'input': '2D\r\n2H 3H 4H 5H 6H\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'AS\r\n2H 4C TH JH KS\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': '2S\r\n2D 3D 4D 5D 6D\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'AC\r\n2D 3D 4D 5C 6D\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': '4H\r\nJH QC 5H 9H KD...
[{'input': 'AS\r\n4H 4C TH JH TS\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': '4S\r\n9D 4D 5S 7D 5D\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': '7H\r\nTC 4C KC AD 9S\r\n', 'output': ['No', 'NO', 'no']}, {'input': 'QC\r\nQD KS AH 7S 2S\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'AS\r\n2S 3D 4D 5D 6D\r\...
[{'input': '2H\r\n3D 4C AC KD AS\r\n', 'output': ['No', 'NO', 'no']}, {'input': 'KH\r\n3C QD 9S KS 8D\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'KS\r\nAD 2D 3D 4D 5D\r\n', 'output': ['No', 'NO', 'no']}, {'input': '4H\r\nJH QC 5H 9H KD\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'AS\r\n2H 4C TH JH 3S\r\n',...
[{'input': '9H\r\nKC 6D KD 4C 2S\r\n', 'output': ['No', 'NO', 'no']}, {'input': 'AS\r\n2H 4C TH JH KS\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': '7H\r\nTC 4C KC AD 9S\r\n', 'output': ['No', 'NO', 'no']}, {'input': 'AS\r\n2H 4C TH JH AD\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'KH\r\n3C QD 9S KS 8D\r\n',...
[{'input': '4H\r\nJH QC 5H 9H KD\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': '2S\r\n2D 3D 4D 5D 6D\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'AS\r\n4H 4C TH JH TS\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'AS\r\n2S 3D 4D 5D 6D\r\n', 'output': ['YES', 'yes', 'Yes']}, {'input': 'QC\r\nQD KS AH 7S 2S...
100
100
100
100
100
100
100
100
100
100
87.5
100
100
100
87.5
275
100
100
95
["3\n1 4 6", "5\n1 2 3 4 5", "5\n1 2 3 7 8"]
The first line contains a single integer n (3 ≀ n ≀ 100)Β β€” the number of holds. The next line contains n space-separated integers ai (1 ≀ ai ≀ 1000), where ai is the height where the hold number i hangs. The sequence ai is increasing (i.e. each element except for the first one is strictly larger than the previous one).
8a8013f960814040ac4bf229a0bd5437
import java.io.*; import java.util.*; public class Minimum{ public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[]tab = new int [n]; /* BufferedReader br = new BufferedReader( ...
["5", "2", "4"]
Java
NoteIn the first sample you can remove only the second hold, then the sequence looks like (1, 6), the maximum difference of the neighboring elements equals 5.In the second test after removing every hold the difficulty equals 2.In the third test you can obtain sequences (1, 3, 7, 8), (1, 2, 7, 8), (1, 2, 3, 8), for whic...
Print a single number β€” the minimum difficulty of the track after removing a single hold.
Mike is trying rock climbing but he is awful at it. There are n holds on the wall, i-th hold is at height ai off the ground. Besides, let the sequence ai increase, that is, ai &lt; ai + 1 for all i from 1 to n - 1; we will call such sequence a track. Mike thinks that the track a1, ..., an has difficulty . In other word...
[{"input": "3\r\n1 4 6\r\n", "output": ["5"]}, {"input": "5\r\n1 2 3 4 5\r\n", "output": ["2"]}, {"input": "5\r\n1 2 3 7 8\r\n", "output": ["4"]}, {"input": "3\r\n1 500 1000\r\n", "output": ["999"]}, {"input": "10\r\n1 2 3 4 5 6 7 8 9 10\r\n", "output": ["2"]}, {"input": "10\r\n1 4 9 16 25 36 49 64 81 100\r\n", "output...
100
100
100
[{'input': '38\r\n1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000\r\n', 'output': ['54']}, {'input': '28\r\n1 38 75 112 149 186 223 260 297 334 371 408 445 482 519 556 593 630 667 704 741 778 815 852 889 926 963 1000\r\n...
[{'input': '3\r\n1 4 6\r\n', 'output': ['5']}, {'input': '81\r\n6 7 22 23 27 38 40 56 59 71 72 78 80 83 86 92 95 96 101 122 125 127 130 134 154 169 170 171 172 174 177 182 184 187 195 197 210 211 217 223 241 249 252 253 256 261 265 269 274 277 291 292 297 298 299 300 302 318 338 348 351 353 381 386 387 397 409 410 419 ...
[{'input': '5\r\n1 2 3 7 8\r\n', 'output': ['4']}, {'input': '3\r\n1 500 1000\r\n', 'output': ['999']}, {'input': '100\r\n6 16 26 36 46 56 66 76 86 96 106 116 126 136 146 156 166 176 186 196 206 216 226 236 246 256 266 276 286 296 306 316 326 336 346 356 366 376 386 396 406 416 426 436 446 456 466 476 486 496 506 516 5...
[{'input': '100\r\n6 16 26 36 46 56 66 76 86 96 106 116 126 136 146 156 166 176 186 196 206 216 226 236 246 256 266 276 286 296 306 316 326 336 346 356 366 376 386 396 406 416 426 436 446 456 466 476 486 496 506 516 526 536 546 556 566 576 586 596 606 616 626 636 646 656 666 676 686 696 706 716 726 736 746 756 766 776 ...
[{'input': '100\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 ...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
276
100
100
100
["3 5", "7 11", "7 9"]
The first and only input line contains two positive integers β€” n and m (2 ≀ n &lt; m ≀ 50). It is guaranteed that n is prime. Pretests contain all the cases with restrictions 2 ≀ n &lt; m ≀ 4.
9d52ff51d747bb59aa463b6358258865
import java.util.Arrays; import java.util.List; import java.util.Scanner; public class PanoramixsPrediction { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); Integer[] a = new Integer[] {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31...
["YES", "YES", "NO"]
Java
null
Print YES, if m is the next prime number after n, or NO otherwise.
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.The next prime number after x is the smallest prime number greater than x. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note that th...
[{"input": "3 5\r\n", "output": ["YES"]}, {"input": "7 11\r\n", "output": ["YES"]}, {"input": "7 9\r\n", "output": ["NO"]}, {"input": "2 3\r\n", "output": ["YES"]}, {"input": "2 4\r\n", "output": ["NO"]}, {"input": "3 4\r\n", "output": ["NO"]}, {"input": "5 7\r\n", "output": ["YES"]}, {"input": "11 13\r\n", "output": [...
100
100
100
[{'input': '47 48\r\n', 'output': ['NO']}, {'input': '5 15\r\n', 'output': ['NO']}, {'input': '17 19\r\n', 'output': ['YES']}, {'input': '3 4\r\n', 'output': ['NO']}, {'input': '19 23\r\n', 'output': ['YES']}]
[{'input': '41 43\r\n', 'output': ['YES']}, {'input': '41 49\r\n', 'output': ['NO']}, {'input': '3 7\r\n', 'output': ['NO']}, {'input': '23 25\r\n', 'output': ['NO']}, {'input': '7 11\r\n', 'output': ['YES']}]
[{'input': '2 11\r\n', 'output': ['NO']}, {'input': '5 7\r\n', 'output': ['YES']}, {'input': '47 50\r\n', 'output': ['NO']}, {'input': '31 33\r\n', 'output': ['NO']}, {'input': '5 11\r\n', 'output': ['NO']}]
[{'input': '41 43\r\n', 'output': ['YES']}, {'input': '19 23\r\n', 'output': ['YES']}, {'input': '7 8\r\n', 'output': ['NO']}, {'input': '31 33\r\n', 'output': ['NO']}, {'input': '3 7\r\n', 'output': ['NO']}]
[{'input': '7 8\r\n', 'output': ['NO']}, {'input': '3 9\r\n', 'output': ['NO']}, {'input': '3 4\r\n', 'output': ['NO']}, {'input': '3 6\r\n', 'output': ['NO']}, {'input': '37 41\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
75
100
75
75
277
100
100
85
["3 5", "4 8"]
The only line of the input contains two integers n and t (1 ≀ n ≀ 10, 0 ≀ t ≀ 10 000)Β β€” the height of the pyramid and the number of seconds Vlad will be pouring champagne from the bottle.
b2b49b7f6e3279d435766085958fb69d
import java.io.*; import java.util.StringTokenizer; /** * Created by sachin.goyal on 16/05/16. */ public class MainB { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); ...
["4", "6"]
Java
NoteIn the first sample, the glasses full after 5 seconds are: the top glass, both glasses on the second level and the middle glass at the bottom level. Left and right glasses of the bottom level will be half-empty.
Print the single integerΒ β€” the number of completely full glasses after t seconds.
Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is n. The top level consists of only 1 glass, that stands on 2 glasses on the second level (co...
[{"input": "3 5\r\n", "output": ["4"]}, {"input": "4 8\r\n", "output": ["6"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "10 10000\r\n", "output": ["55"]}, {"input": "1 10000\r\n", "output": ["1"]}, {"input": "10 1\r\n", "output": ["1"]}, {"input": "1 0\r\n", "output": ["0"]}, {"input": "10 0\r\n", "output": ["0...
100
100
100
[{'input': '2 2\r\n', 'output': ['1']}, {'input': '9 256\r\n', 'output': ['43']}, {'input': '7 214\r\n', 'output': ['28']}, {'input': '10 153\r\n', 'output': ['47']}, {'input': '9 511\r\n', 'output': ['45']}]
[{'input': '10 1023\r\n', 'output': ['55']}, {'input': '7 120\r\n', 'output': ['26']}, {'input': '10 512\r\n', 'output': ['53']}, {'input': '5 9999\r\n', 'output': ['15']}, {'input': '9 254\r\n', 'output': ['41']}]
[{'input': '9 253\r\n', 'output': ['41']}, {'input': '5 30\r\n', 'output': ['13']}, {'input': '10 5\r\n', 'output': ['4']}, {'input': '10 127\r\n', 'output': ['47']}, {'input': '6 52\r\n', 'output': ['19']}]
[{'input': '6 32\r\n', 'output': ['19']}, {'input': '10 153\r\n', 'output': ['47']}, {'input': '9 512\r\n', 'output': ['45']}, {'input': '5 31\r\n', 'output': ['15']}, {'input': '7 128\r\n', 'output': ['28']}]
[{'input': '8 254\r\n', 'output': ['34']}, {'input': '5 30\r\n', 'output': ['13']}, {'input': '3 6\r\n', 'output': ['4']}, {'input': '7 127\r\n', 'output': ['28']}, {'input': '10 68\r\n', 'output': ['41']}]
100
100
100
100
100
90.48
90.48
90.48
90.48
90.48
95
95
95
95
95
278
100
90.48
95
["3\n0 2 1", "2\n1 1"]
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 100$$$)Β β€” the number of floors. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq 100$$$)Β β€” the number of people on each floor.
a5002ddf9e792cb4b4685e630f1e1b8f
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { Scanner scanner = new Scanner(...
["16", "4"]
Java
NoteIn the first example, the answer can be achieved by choosing the second floor as the $$$x$$$-th floor. Each person from the second floor (there are two of them) would spend $$$4$$$ units of electricity per day ($$$2$$$ to get down and $$$2$$$ to get up), and one person from the third would spend $$$8$$$ units of el...
In a single line, print the answer to the problemΒ β€” the minimum number of electricity units.
The Fair Nut lives in $$$n$$$ story house. $$$a_i$$$ people live on the $$$i$$$-th floor of the house. Every person uses elevator twice a day: to get from the floor where he/she lives to the ground (first) floor and to get from the first floor to the floor where he/she lives, when he/she comes back home in the evening....
[{"input": "3\r\n0 2 1\r\n", "output": ["16"]}, {"input": "2\r\n1 1\r\n", "output": ["4"]}, {"input": "1\r\n1\r\n", "output": ["0"]}, {"input": "3\r\n1 3 3\r\n", "output": ["36"]}, {"input": "3\r\n3 2 3\r\n", "output": ["32"]}, {"input": "5\r\n2 10 6 3 1\r\n", "output": ["140"]}, {"input": "5\r\n6 4 10 5 10\r\n", "outp...
100
100
100
[{'input': '3\r\n4 2 5\r\n', 'output': ['48']}, {'input': '100\r\n95 49 40 82 80 78 4 86 37 94 1 46 85 6 41 87 100 69 100 87 12 61 55 81 81 32 40 54 22 32 24 73 61 68 76 16 83 76 73 77 41 37 88 46 72 63 2 37 14 49 45 81 75 56 10 99 73 85 41 17 5 2 16 75 28 53 35 77 66 53 69 82 50 95 2 12 95 62 84 46 29 95 91 49 78 14 8...
[{'input': '100\r\n23 39 85 46 97 72 41 70 37 18 8 40 33 61 12 79 51 78 61 66 85 97 78 14 70 47 100 40 15 40 61 52 19 30 14 91 82 56 10 6 68 24 97 61 31 78 18 45 88 6 37 38 51 86 37 42 58 30 79 56 50 14 61 18 13 20 57 3 93 15 24 74 32 21 71 93 2 66 25 75 75 10 86 82 30 31 6 49 15 33 100 35 1 96 87 83 29 21 41 22\r\n', ...
[{'input': '3\r\n1 2 2\r\n', 'output': ['24']}, {'input': '3\r\n4 5 5\r\n', 'output': ['60']}, {'input': '3\r\n10 5 8\r\n', 'output': ['84']}, {'input': '3\r\n0 2 1\r\n', 'output': ['16']}, {'input': '5\r\n8 1 3 4 9\r\n', 'output': ['220']}]
[{'input': '3\r\n2 1 3\r\n', 'output': ['28']}, {'input': '5\r\n8 1 3 4 9\r\n', 'output': ['220']}, {'input': '100\r\n95 72 38 75 62 87 87 30 11 65 35 75 16 73 65 23 18 48 19 4 22 42 14 60 49 83 59 15 60 51 27 80 97 35 37 100 64 81 22 38 54 71 52 20 5 20 52 73 42 98 78 86 26 55 25 57 14 97 36 81 71 54 71 51 3 4 8 74 82...
[{'input': '3\r\n5 2 2\r\n', 'output': ['24']}, {'input': '3\r\n8 6 1\r\n', 'output': ['32']}, {'input': '100\r\n95 72 38 75 62 87 87 30 11 65 35 75 16 73 65 23 18 48 19 4 22 42 14 60 49 83 59 15 60 51 27 80 97 35 37 100 64 81 22 38 54 71 52 20 5 20 52 73 42 98 78 86 26 55 25 57 14 97 36 81 71 54 71 51 3 4 8 74 82 21 7...
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
279
100
100
100
["3\n1 -2 0", "6\n16 23 16 15 42 8"]
The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of elements in a. The second line contains n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100) β€” the elements of sequence a.
4b5d14833f9b51bfd336cc0e661243a5
import java.util.Scanner; public class a { public static void main(String[]args) { Scanner input=new Scanner (System.in); int n=input.nextInt(); int b=0; int c=0; int []x=new int [101]; int k=0; while (k<n) { x[k]=input.nextInt(); k=k+1; } int y=x[0]; for (in...
["3", "120"]
Java
NoteIn the first example we may choose b = {1, 0}, c = { - 2}. Then B = 1, C =  - 2, B - C = 3.In the second example we choose b = {16, 23, 16, 15, 42, 8}, c = {} (an empty sequence). Then B = 120, C = 0, B - C = 120.
Print the maximum possible value of B - C, where B is the sum of elements of sequence b, and C is the sum of elements of sequence c.
You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences. Let B be the sum of elements belonging to b, and C be the sum of elements belonging to c (if some of these sequences is empty, then ...
[{"input": "3\r\n1 -2 0\r\n", "output": ["3"]}, {"input": "6\r\n16 23 16 15 42 8\r\n", "output": ["120"]}, {"input": "1\r\n-1\r\n", "output": ["1"]}, {"input": "100\r\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -1...
100
100
100
[{'input': '4\r\n1 -1 1 -1\r\n', 'output': ['4']}, {'input': '5\r\n100 -100 -1 2 100\r\n', 'output': ['303']}, {'input': '2\r\n9 69\r\n', 'output': ['78']}, {'input': '4\r\n2 5 -2 4\r\n', 'output': ['13']}, {'input': '1\r\n-1\r\n', 'output': ['1']}]
[{'input': '6\r\n4 4 4 -3 -3 2\r\n', 'output': ['20']}, {'input': '1\r\n-1\r\n', 'output': ['1']}, {'input': '2\r\n9 71\r\n', 'output': ['80']}, {'input': '5\r\n5 5 -10 -1 1\r\n', 'output': ['22']}, {'input': '6\r\n-1 2 4 -5 -3 55\r\n', 'output': ['70']}]
[{'input': '3\r\n1 1 1\r\n', 'output': ['3']}, {'input': '4\r\n0 0 0 -1\r\n', 'output': ['1']}, {'input': '6\r\n-5 -4 -3 -2 -1 0\r\n', 'output': ['15']}, {'input': '3\r\n-2 -5 10\r\n', 'output': ['17']}, {'input': '5\r\n-1 -2 3 1 2\r\n', 'output': ['9']}]
[{'input': '6\r\n-2 3 -4 5 6 -1\r\n', 'output': ['21']}, {'input': '3\r\n1 1 1\r\n', 'output': ['3']}, {'input': '2\r\n-5 1\r\n', 'output': ['6']}, {'input': '4\r\n1 -1 1 -1\r\n', 'output': ['4']}, {'input': '6\r\n4 4 4 -3 -3 2\r\n', 'output': ['20']}]
[{'input': '18\r\n-21 12 65 66 -24 62 82 35 -45 -47 28 37 5 -32 22 -14 -69 -95\r\n', 'output': ['761']}, {'input': '5\r\n1 -2 3 1 2\r\n', 'output': ['9']}, {'input': '3\r\n-1 2 3\r\n', 'output': ['6']}, {'input': '4\r\n2 2 -2 4\r\n', 'output': ['10']}, {'input': '100\r\n-59 -33 34 0 69 24 -22 58 62 -36 5 45 -19 -73 61 ...
100
100
100
100
100
100
100
100
100
86.96
100
100
100
100
78.57
280
100
97.392
95.714
["12345"]
The only line of the input contains a positive integer five digit number for which the activation code should be found.
51b1c216948663fff721c28d131bf18f
import java.util.Scanner; public class Problem_11 { static long p = 100000; public static void main(String[] args) { Scanner input = new Scanner(System.in); String s = input.nextLine(); //13542 long n = Long.valueOf(s.substring(0, 1) + s.substring(2, 3) + s.substring(4, 5) + s....
["71232"]
Java
null
Output exactly 5 digits without spaces between them β€” the found activation code of the program.
The protection of a popular program developed by one of IT City companies is organized the following way. After installation it outputs a random five digit number which should be sent in SMS to a particular phone number. In response an SMS activation code arrives.A young hacker Vasya disassembled the program and found ...
[{"input": "12345\r\n", "output": ["71232"]}, {"input": "13542\r\n", "output": ["84443"]}, {"input": "71232\r\n", "output": ["10151"]}, {"input": "11111\r\n", "output": ["36551"]}, {"input": "10000\r\n", "output": ["00000"]}, {"input": "99999\r\n", "output": ["99999"]}, {"input": "91537\r\n", "output": ["27651"]}, {"in...
100
100
100
[{'input': '13542\r\n', 'output': ['84443']}, {'input': '10000\r\n', 'output': ['00000']}, {'input': '12345\r\n', 'output': ['71232']}, {'input': '41675\r\n', 'output': ['61851']}, {'input': '11111\r\n', 'output': ['36551']}]
[{'input': '71232\r\n', 'output': ['10151']}, {'input': '32036\r\n', 'output': ['82432']}, {'input': '91537\r\n', 'output': ['27651']}, {'input': '12345\r\n', 'output': ['71232']}, {'input': '70809\r\n', 'output': ['00000']}]
[{'input': '71232\r\n', 'output': ['10151']}, {'input': '70809\r\n', 'output': ['00000']}, {'input': '10000\r\n', 'output': ['00000']}, {'input': '41675\r\n', 'output': ['61851']}, {'input': '12345\r\n', 'output': ['71232']}]
[{'input': '70809\r\n', 'output': ['00000']}, {'input': '13542\r\n', 'output': ['84443']}, {'input': '91537\r\n', 'output': ['27651']}, {'input': '32036\r\n', 'output': ['82432']}, {'input': '99999\r\n', 'output': ['99999']}]
[{'input': '71232\r\n', 'output': ['10151']}, {'input': '41675\r\n', 'output': ['61851']}, {'input': '32036\r\n', 'output': ['82432']}, {'input': '70809\r\n', 'output': ['00000']}, {'input': '91537\r\n', 'output': ['27651']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
281
100
100
100
["3\n11 23", "5\n01 07"]
The first line contains a single integer x (1 ≀ x ≀ 60). The second line contains two two-digit integers, hh and mm (00 ≀ hh ≀ 23, 00 ≀ mm ≀ 59).
5ecd569e02e0164a5da9ff549fca3ceb
import java.util.*; public class JamieAndAlarmSnooze { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); int h=sc.nextInt(); int m=sc.nextInt(); int c=0; while (h%10!=7 && m%10!=7) { m-=x; c++; if (m<0) { h--; m+=60; } if (h<0...
["2", "0"]
Java
NoteIn the first sample, Jamie needs to wake up at 11:23. So, he can set his alarm at 11:17. He would press the snooze button when the alarm rings at 11:17 and at 11:20.In the second sample, Jamie can set his alarm at exactly at 01:07 which is lucky.
Print the minimum number of times he needs to press the button.
Jamie loves sleeping. One day, he decides that he needs to wake up at exactly hh: mm. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every x minutes until hh: mm is reached, and only then he will wake up. He wants to kno...
[{"input": "3\r\n11 23\r\n", "output": ["2"]}, {"input": "5\r\n01 07\r\n", "output": ["0"]}, {"input": "34\r\n09 24\r\n", "output": ["3"]}, {"input": "2\r\n14 37\r\n", "output": ["0"]}, {"input": "14\r\n19 54\r\n", "output": ["9"]}, {"input": "42\r\n15 44\r\n", "output": ["12"]}, {"input": "46\r\n02 43\r\n", "output": ...
100
100
100
[{'input': '16\r\n00 16\r\n', 'output': ['24']}, {'input': '58\r\n22 54\r\n', 'output': ['6']}, {'input': '1\r\n00 53\r\n', 'output': ['6']}, {'input': '59\r\n08 00\r\n', 'output': ['1']}, {'input': '60\r\n05 47\r\n', 'output': ['0']}]
[{'input': '13\r\n08 28\r\n', 'output': ['3']}, {'input': '20\r\n03 58\r\n', 'output': ['30']}, {'input': '60\r\n16 13\r\n', 'output': ['9']}, {'input': '11\r\n00 10\r\n', 'output': ['3']}, {'input': '60\r\n05 36\r\n', 'output': ['12']}]
[{'input': '60\r\n01 05\r\n', 'output': ['8']}, {'input': '40\r\n13 37\r\n', 'output': ['0']}, {'input': '58\r\n22 54\r\n', 'output': ['6']}, {'input': '31\r\n13 34\r\n', 'output': ['7']}, {'input': '29\r\n12 39\r\n', 'output': ['8']}]
[{'input': '1\r\n00 01\r\n', 'output': ['4']}, {'input': '60\r\n01 20\r\n', 'output': ['8']}, {'input': '1\r\n05 25\r\n', 'output': ['8']}, {'input': '40\r\n13 37\r\n', 'output': ['0']}, {'input': '44\r\n20 20\r\n', 'output': ['4']}]
[{'input': '60\r\n05 07\r\n', 'output': ['0']}, {'input': '1\r\n20 21\r\n', 'output': ['4']}, {'input': '59\r\n06 18\r\n', 'output': ['9']}, {'input': '2\r\n00 02\r\n', 'output': ['182']}, {'input': '35\r\n15 25\r\n', 'output': ['13']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
282
100
100
100
["047", "16", "472747"]
The single line contains a non-empty string s whose length can range from 1 to 50, inclusive. The string only contains digits. The string can contain leading zeroes.
639b8b8d0dc42df46b139f0aeb3a7a0a
import java.lang.*; import java.util.*; public class Luckysubstring { public static void main(String[] args) { Scanner in = new Scanner(System.in); String input = in.nextLine(); int count4 = 0; int count7 = 0; in.close(); if (input.contains("4") || input.contains("7"...
["4", "-1", "7"]
Java
NoteThe lexicographical comparison of strings is performed by the &lt; operator in the modern programming languages. String x is lexicographically less than string y either if x is a prefix of y, or exists such i (1 ≀ i ≀ min(|x|, |y|)), that xi &lt; yi and for any j (1 ≀ j &lt; i) xj = yj. Here |a| denotes the length ...
In the only line print the answer to Petya's problem. If the sought string does not exist, print "-1" (without quotes).
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.One day Petya was delivered a string s, containing only digits. He needs to find a string that represe...
[{"input": "047\r\n", "output": ["4"]}, {"input": "16\r\n", "output": ["-1"]}, {"input": "472747\r\n", "output": ["7"]}, {"input": "1925\r\n", "output": ["-1"]}, {"input": "5486846414848445484\r\n", "output": ["4"]}, {"input": "516160414\r\n", "output": ["4"]}, {"input": "9458569865994896\r\n", "output": ["4"]}, {"inpu...
100
100
100
[{'input': '4\r\n', 'output': ['4']}, {'input': '74747474747474747474747774747474747474747474747474\r\n', 'output': ['7']}, {'input': '44101164480392494025995467\r\n', 'output': ['4']}, {'input': '16\r\n', 'output': ['-1']}, {'input': '74747474747474747474747474747474744474747474747474\r\n', 'output': ['4']}]
[{'input': '11536708648794535307468278326553811\r\n', 'output': ['7']}, {'input': '472747\r\n', 'output': ['7']}, {'input': '8679647744\r\n', 'output': ['4']}, {'input': '538772857\r\n', 'output': ['7']}, {'input': '7665711\r\n', 'output': ['7']}]
[{'input': '16\r\n', 'output': ['-1']}, {'input': '44\r\n', 'output': ['4']}, {'input': '74747474747474747474747474747474747474747474747474\r\n', 'output': ['4']}, {'input': '9589\r\n', 'output': ['-1']}, {'input': '8175012266795100056032281135654854227489558885698\r\n', 'output': ['4']}]
[{'input': '23607019991994\r\n', 'output': ['4']}, {'input': '8175012266795100056032281135654854227489558885698\r\n', 'output': ['4']}, {'input': '007\r\n', 'output': ['7']}, {'input': '22438808523154336905543301642540261833729318191\r\n', 'output': ['4']}, {'input': '637789221789855555993957058\r\n', 'output': ['7']}]
[{'input': '74\r\n', 'output': ['4']}, {'input': '047\r\n', 'output': ['4']}, {'input': '07\r\n', 'output': ['7']}, {'input': '4\r\n', 'output': ['4']}, {'input': '91076008557028243309\r\n', 'output': ['7']}]
100
100
100
100
100
100
93.75
93.75
93.75
93.75
91.67
91.67
83.33
91.67
91.67
283
100
95
90.002
["2\n2 8", "3\n5 1 10", "7\n3 3 2 7 9 6 8"]
The first line contains integer n (1 ≀ n ≀ 20). The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 25) β€” the number of times Greg repeats the exercises.
579021de624c072f5e0393aae762117e
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main{ public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringToken...
["biceps", "back", "chest"]
Java
NoteIn the first sample Greg does 2 chest, 8 biceps and zero back exercises, so the biceps gets the most exercises.In the second sample Greg does 5 chest, 1 biceps and 10 back exercises, so the back gets the most exercises.In the third sample Greg does 18 chest, 12 biceps and 8 back exercises, so the chest gets the mos...
Print word "chest" (without the quotes), if the chest gets the most exercise, "biceps" (without the quotes), if the biceps gets the most exercise and print "back" (without the quotes) if the back gets the most exercise. It is guaranteed that the input is such that the answer to the problem is unambiguous.
Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was n integers a1, a2, ..., an. These numbers mean that Greg needs to do exactly n exercises today. Besides, Greg should repeat the i-th in order exercise ai times.Greg now only does three types of exercises: "chest" exercises, "...
[{"input": "2\r\n2 8\r\n", "output": ["biceps"]}, {"input": "3\r\n5 1 10\r\n", "output": ["back"]}, {"input": "7\r\n3 3 2 7 9 6 8\r\n", "output": ["chest"]}, {"input": "4\r\n5 6 6 2\r\n", "output": ["chest"]}, {"input": "5\r\n8 2 2 6 3\r\n", "output": ["chest"]}, {"input": "6\r\n8 7 2 5 3 4\r\n", "output": ["chest"]}, ...
100
100
100
[{'input': '3\r\n21 11 19\r\n', 'output': ['chest']}, {'input': '18\r\n1 17 13 6 11 10 25 13 24 9 21 17 3 1 17 12 25 21\r\n', 'output': ['back']}, {'input': '19\r\n3 1 3 15 15 25 10 25 23 10 9 21 13 23 19 3 24 21 14\r\n', 'output': ['back']}, {'input': '10\r\n4 9 8 5 3 8 8 10 4 2\r\n', 'output': ['biceps']}, {'input': ...
[{'input': '11\r\n10 9 7 6 1 3 9 7 1 3 5\r\n', 'output': ['chest']}, {'input': '16\r\n10 15 2 17 22 12 14 14 6 11 4 13 9 8 21 14\r\n', 'output': ['chest']}, {'input': '7\r\n3 3 2 7 9 6 8\r\n', 'output': ['chest']}, {'input': '6\r\n8 7 2 5 3 4\r\n', 'output': ['chest']}, {'input': '8\r\n5 16 8 9 17 16 14 7\r\n', 'output...
[{'input': '17\r\n7 22 9 22 8 7 20 22 23 5 12 11 1 24 17 20 10\r\n', 'output': ['biceps']}, {'input': '4\r\n12 15 1 13\r\n', 'output': ['chest']}, {'input': '3\r\n21 11 19\r\n', 'output': ['chest']}, {'input': '7\r\n11 1 16 20 21 25 20\r\n', 'output': ['chest']}, {'input': '20\r\n2 1 2 2 1 2 2 1 2 1 1 1 1 1 1 1 1 1 1 2...
[{'input': '6\r\n8 7 2 5 3 4\r\n', 'output': ['chest']}, {'input': '1\r\n10\r\n', 'output': ['chest']}, {'input': '8\r\n7 2 9 10 3 8 10 6\r\n', 'output': ['chest']}, {'input': '16\r\n12 6 18 6 25 7 3 1 1 17 25 17 6 8 17 8\r\n', 'output': ['biceps']}, {'input': '16\r\n10 15 2 17 22 12 14 14 6 11 4 13 9 8 21 14\r\n', 'ou...
[{'input': '9\r\n5 4 2 3 4 4 5 2 2\r\n', 'output': ['chest']}, {'input': '15\r\n4 19 10 6 16 12 5 11 7 23 1 24 11 7 17\r\n', 'output': ['back']}, {'input': '7\r\n3 3 2 7 9 6 8\r\n', 'output': ['chest']}, {'input': '17\r\n13 8 13 4 9 21 10 10 9 22 14 23 22 7 6 14 19\r\n', 'output': ['chest']}, {'input': '10\r\n1 9 20 18...
100
100
100
100
100
100
95.24
95.24
95.24
95.24
85.71
78.57
78.57
78.57
78.57
284
100
96.192
79.998
["6 3"]
The only line of the input contains two integers: n and k (1 ≀ n ≀ 109, 0 ≀ k ≀ n).
bdccf34b5a5ae13238c89a60814b9f86
import java.util.*; import java.io.*; import java.math.*; public class scorify{ public static void main(String[] args){ Scanner in=new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); System.out.print((n>k && k>0) ? 1 : 0 ); if(k!=n){ if(k>1) System.out.print(" " + ( ( (...
["1 3"]
Java
NoteIn the sample test, the number of good apartments could be minimum possible if, for example, apartments with indices 1, 2 and 3 were inhabited. In this case only apartment 4 is good. The maximum possible number could be, for example, if apartments with indices 1, 3 and 5 were inhabited. In this case all other apart...
Print the minimum possible and the maximum possible number of apartments good for Maxim.
Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartments that are numbered from 1 to n and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are available for sale.Maxim often visits his...
[{"input": "6 3\r\n", "output": ["1 3"]}, {"input": "10 1\r\n", "output": ["1 2"]}, {"input": "10 9\r\n", "output": ["1 1"]}, {"input": "8 0\r\n", "output": ["0 0"]}, {"input": "8 8\r\n", "output": ["0 0"]}, {"input": "966871928 890926970\r\n", "output": ["1 75944958"]}, {"input": "20 2\r\n", "output": ["1 4"]}, {"inpu...
100
100
100
[{'input': '1000000000 1000000000\r\n', 'output': ['0 0']}, {'input': '982 867\r\n', 'output': ['1 115']}, {'input': '1000000000 0\r\n', 'output': ['0 0']}, {'input': '998 333\r\n', 'output': ['1 665']}, {'input': '8 0\r\n', 'output': ['0 0']}]
[{'input': '9 4\r\n', 'output': ['1 5']}, {'input': '1000000000 1000000000\r\n', 'output': ['0 0']}, {'input': '2 1\r\n', 'output': ['1 1']}, {'input': '4 1\r\n', 'output': ['1 2']}, {'input': '10 3\r\n', 'output': ['1 6']}]
[{'input': '35679021 9137902\r\n', 'output': ['1 18275804']}, {'input': '2 0\r\n', 'output': ['0 0']}, {'input': '2 2\r\n', 'output': ['0 0']}, {'input': '89 4\r\n', 'output': ['1 8']}, {'input': '8 0\r\n', 'output': ['0 0']}]
[{'input': '777 113\r\n', 'output': ['1 226']}, {'input': '1000000000 1000000000\r\n', 'output': ['0 0']}, {'input': '12 5\r\n', 'output': ['1 7']}, {'input': '999 333\r\n', 'output': ['1 666']}, {'input': '10 9\r\n', 'output': ['1 1']}]
[{'input': '6 3\r\n', 'output': ['1 3']}, {'input': '2 0\r\n', 'output': ['0 0']}, {'input': '966871928 890926970\r\n', 'output': ['1 75944958']}, {'input': '1000 333\r\n', 'output': ['1 666']}, {'input': '1000000000 0\r\n', 'output': ['0 0']}]
100
100
100
100
100
100
100
100
100
90
77.78
83.33
72.22
66.67
66.67
285
100
98
73.334
["5 3\nxyabd", "7 4\nproblem", "2 2\nab", "12 1\nabaabbaaabbb"]
The first line of input contains two integersΒ β€” $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) – the number of available stages and the number of stages to use in the rocket. The second line contains string $$$s$$$, which consists of exactly $$$n$$$ lowercase Latin letters. Each letter defines a new stage, which can ...
56b13d313afef9dc6c6ba2758b5ea313
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out ...
["29", "34", "-1", "1"]
Java
NoteIn the first example, the following rockets satisfy the condition: "adx" (weight is $$$1+4+24=29$$$); "ady" (weight is $$$1+4+25=30$$$); "bdx" (weight is $$$2+4+24=30$$$); "bdy" (weight is $$$2+4+25=31$$$).Rocket "adx" has the minimal weight, so the answer is $$$29$$$.In the second example, target rocket is "belo"....
Print a single integerΒ β€” the minimal total weight of the rocket or -1, if it is impossible to build the rocket at all.
Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the stringΒ β€” concatenation of letters, which correspond to the stages.There are $$$n$$$ stages available. The ...
[{"input": "5 3\r\nxyabd\r\n", "output": ["29"]}, {"input": "7 4\r\nproblem\r\n", "output": ["34"]}, {"input": "2 2\r\nab\r\n", "output": ["-1"]}, {"input": "12 1\r\nabaabbaaabbb\r\n", "output": ["1"]}, {"input": "50 13\r\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": ["169"]}, {"input": "50 14\r\n...
100
100
100
[{'input': '2 2\r\nab\r\n', 'output': ['-1']}, {'input': '7 4\r\nproblem\r\n', 'output': ['34']}, {'input': '3 1\r\nzzz\r\n', 'output': ['26']}, {'input': '2 2\r\nad\r\n', 'output': ['5']}, {'input': '13 13\r\nuwgmkyqeiaocs\r\n', 'output': ['169']}]
[{'input': '50 13\r\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['169']}, {'input': '13 13\r\nhzdxpbfvrltnj\r\n', 'output': ['182']}, {'input': '2 2\r\nad\r\n', 'output': ['5']}, {'input': '10 8\r\nsmzeblyjqw\r\n', 'output': ['113']}, {'input': '50 1\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
[{'input': '10 8\r\nsmzeblyjqw\r\n', 'output': ['113']}, {'input': '38 2\r\nvjzarfykmrsrvwbwfwldsulhxtykmjbnwmdufa\r\n', 'output': ['5']}, {'input': '5 3\r\nxyabd\r\n', 'output': ['29']}, {'input': '2 1\r\nac\r\n', 'output': ['1']}, {'input': '40 30\r\nxumfrflllrrgswehqtsskefixhcxjrxbjmrpsshv\r\n', 'output': ['-1']}]
[{'input': '3 3\r\naoz\r\n', 'output': ['42']}, {'input': '50 31\r\nahbyyoxltryqdmvenemaqnbakglgqolxnaifnqtoclnnqiabpz\r\n', 'output': ['-1']}, {'input': '3 1\r\nzzz\r\n', 'output': ['26']}, {'input': '4 3\r\nadjz\r\n', 'output': ['15']}, {'input': '50 13\r\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'out...
[{'input': '2 2\r\nab\r\n', 'output': ['-1']}, {'input': '50 13\r\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['169']}, {'input': '1 1\r\nc\r\n', 'output': ['3']}, {'input': '50 14\r\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['-1']}, {'input': '50 1\r\naaaaaaaaaaaaaaaaa...
100
100
100
100
100
100
100
100
100
100
100
92.86
100
100
100
286
100
100
98.572
["...QK...\n........\n........\n........\n........\n........\n........\n...rk...", "rnbqkbnr\npppppppp\n........\n........\n........\n........\nPPPPPPPP\nRNBQKBNR", "rppppppr\n...k....\n........\n........\n........\n........\nK...Q...\n........"]
The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knigh...
44bed0ca7a8fb42fb72c1584d39a4442
import java.io.*; import java.util.Scanner; public class codeforce519A { static PrintWriter out; static StreamTokenizer sin; static BufferedReader bin; static void setupOut() { out = new PrintWriter(System.out); } static void setupString() { bin = new BufferedReader(new Input...
["White", "Draw", "Black"]
Java
NoteIn the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5.In the second test sample the weights of the positions of the black and the white pieces are equal to 39.In the third test sample the weight of the position of the white piece...
Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal.
A and B are preparing themselves for programming contests.To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.For each chess piece we know its weight: the queen's weight is 9, the rook's weight is 5, the bishop's weight ...
[{"input": "...QK...\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n...rk...\r\n", "output": ["White"]}, {"input": "rnbqkbnr\r\npppppppp\r\n........\r\n........\r\n........\r\n........\r\nPPPPPPPP\r\nRNBQKBNR\r\n", "output": ["Draw"]}, {"input": "rppppppr\r\n...k....\r\n........\r\n........\...
100
100
100
[{'input': '........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nNN......\r\n........\r\n', 'output': ['White']}, {'input': 'b.......\r\nPP......\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n', 'output': ['Black']}, {'input': '...QK...\r\n........\r\n........\r\n...........
[{'input': 'Q.......\r\nkkk.....\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n', 'output': ['White']}, {'input': 'rppppppr\r\n...k....\r\n........\r\n........\r\n........\r\n........\r\nK...Q...\r\n........\r\n', 'output': ['Black']}, {'input': 'b.......\r\nPP......\r\n........\r\n...........
[{'input': '........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nkkkkkB..\r\n', 'output': ['White']}, {'input': 'b.......\r\nPPPP....\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n', 'output': ['White']}, {'input': '........\r\n........\r\n........\r\n...........
[{'input': 'q.......\r\nPPPPPPPP\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n', 'output': ['Black']}, {'input': '........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n.......K\r\n', 'output': ['Draw']}, {'input': 'N.......\r\n........\r\n........\r\n........\...
[{'input': 'n.......\r\nPPPP....\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n', 'output': ['White']}, {'input': '........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n......Bp\r\n', 'output': ['White']}, {'input': 'r.......\r\nPPPPP...\r\n........\r\n...........
100
100
100
100
100
87.8
90.24
90.24
87.8
87.8
83.33
86.67
86.67
83.33
83.33
287
100
88.776
84.666
["9", "7"]
The first line contains an integer n (1 ≀ n ≀ 106) β€” the n mentioned in the statement.
25e5afcdf246ee35c9cef2fcbdd4566e
import java.io.*; import java.util.*; public class A { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(); long max = 1; for (int a = Math.max(1, n - 100); a <= n; a++) for (in...
["504", "210"]
Java
NoteThe least common multiple of some positive integers is the least positive integer which is multiple for each of them.The result may become very large, 32-bit integer won't be enough. So using 64-bit integers is recommended.For the last example, we can chose numbers 7, 6, 5 and the LCM of them is 7Β·6Β·5 = 210. It is ...
Print a single integer β€” the maximum possible LCM of three not necessarily distinct positive integers that are not greater than n.
Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.But I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be distinct) which are not greater than n. Can you help me to find the ...
[{"input": "9\r\n", "output": ["504"]}, {"input": "7\r\n", "output": ["210"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "5\r\n", "output": ["60"]}, {"input": "6\r\n", "output": ["60"]}, {"input": "33\r\n", "output": ["32736"]}, {"input": "21\r\n", "output": ["7980"]}, {"input": "2\r\n", "output": ["2"]}, {"input"...
100
100
100
[{'input': '29\r\n', 'output': ['21924']}, {'input': '816923\r\n', 'output': ['545182335484592526']}, {'input': '20\r\n', 'output': ['6460']}, {'input': '520731\r\n', 'output': ['141201007712496270']}, {'input': '636\r\n', 'output': ['254839470']}]
[{'input': '341\r\n', 'output': ['39303660']}, {'input': '30\r\n', 'output': ['21924']}, {'input': '688507\r\n', 'output': ['326379736779169710']}, {'input': '829\r\n', 'output': ['567662724']}, {'input': '12\r\n', 'output': ['990']}]
[{'input': '7\r\n', 'output': ['210']}, {'input': '829\r\n', 'output': ['567662724']}, {'input': '796\r\n', 'output': ['501826260']}, {'input': '12\r\n', 'output': ['990']}, {'input': '836603\r\n', 'output': ['585540171302562606']}]
[{'input': '3\r\n', 'output': ['6']}, {'input': '816923\r\n', 'output': ['545182335484592526']}, {'input': '605\r\n', 'output': ['220348260']}, {'input': '245\r\n', 'output': ['14526540']}, {'input': '732\r\n', 'output': ['389016270']}]
[{'input': '816923\r\n', 'output': ['545182335484592526']}, {'input': '9\r\n', 'output': ['504']}, {'input': '30\r\n', 'output': ['21924']}, {'input': '642635\r\n', 'output': ['265393998349453470']}, {'input': '763116\r\n', 'output': ['444394078546562430']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
288
100
100
100
["3 4 11\n1 2 3 4", "5 5 10\n1 2 4 8 16"]
The first line contains three integer numbers n, k and M (1 ≀ n ≀ 45, 1 ≀ k ≀ 45, 0 ≀ M ≀ 2Β·109). The second line contains k integer numbers, values tj (1 ≀ tj ≀ 1000000), where tj is the time in minutes required to solve j-th subtask of any task.
d659e92a410c1bc836be64fc1c0db160
import java.util.Arrays; import java.util.Scanner; public class Mathshow1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); int m = input.nextInt(); int[] a...
["6", "7"]
Java
NoteIn the first example Polycarp can complete the first task and spend 1 + 2 + 3 + 4 = 10 minutes. He also has the time to solve one subtask of the second task in one minute.In the second example Polycarp can solve the first subtask of all five tasks and spend 5Β·1 = 5 minutes. Also he can solve the second subtasks of ...
Print the maximum amount of points Polycarp can earn in M minutes.
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him tj minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.By solving sub...
[{"input": "3 4 11\r\n1 2 3 4\r\n", "output": ["6"]}, {"input": "5 5 10\r\n1 2 4 8 16\r\n", "output": ["7"]}, {"input": "1 1 0\r\n2\r\n", "output": ["0"]}, {"input": "1 1 1\r\n1\r\n", "output": ["2"]}, {"input": "2 1 0\r\n2\r\n", "output": ["0"]}, {"input": "2 2 2\r\n2 3\r\n", "output": ["1"]}, {"input": "4 2 15\r\n1 4...
100
100
100
[{'input': '5 4 11\r\n2 1 3 4\r\n', 'output': ['8']}, {'input': '6 1 2\r\n4\r\n', 'output': ['0']}, {'input': '18 3 36895\r\n877 2054 4051\r\n', 'output': ['28']}, {'input': '4 2 15\r\n1 4\r\n', 'output': ['9']}, {'input': '1 5 44\r\n2 19 18 6 8\r\n', 'output': ['4']}]
[{'input': '1 1 1\r\n1\r\n', 'output': ['2']}, {'input': '2 2 8\r\n12 1\r\n', 'output': ['2']}, {'input': '5 3 2000000000\r\n1 3 6\r\n', 'output': ['20']}, {'input': '11 2 20\r\n1 9\r\n', 'output': ['13']}, {'input': '5 3 49\r\n1 3 6\r\n', 'output': ['18']}]
[{'input': '2 1 0\r\n1\r\n', 'output': ['0']}, {'input': '3 4 11\r\n1 2 3 4\r\n', 'output': ['6']}, {'input': '45 28 33631968\r\n5905 17124 64898 40912 75855 53868 27056 18284 63975 51975 27182 94373 52477 260 87551 50223 73798 77430 17510 15226 6269 43301 39592 27043 15546 60047 83400 63983\r\n', 'output': ['979']}, {...
[{'input': '1 13 878179\r\n103865 43598 180009 528483 409585 449955 368163 381135 713512 645876 241515 20336 572091\r\n', 'output': ['5']}, {'input': '11 3 38\r\n1 9 9\r\n', 'output': ['15']}, {'input': '1 1 0\r\n2\r\n', 'output': ['0']}, {'input': '3 2 1\r\n1 1\r\n', 'output': ['1']}, {'input': '1 1 2\r\n3\r\n', 'outp...
[{'input': '2 4 15\r\n8 3 7 8\r\n', 'output': ['3']}, {'input': '5 4 11\r\n2 1 3 4\r\n', 'output': ['8']}, {'input': '40 1 8\r\n3\r\n', 'output': ['4']}, {'input': '5 3 11\r\n1 1 2\r\n', 'output': ['11']}, {'input': '2 1 1\r\n1\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
100
100
90
90
100
289
100
100
96
["1 3 8 1 1", "4 2 9 4 2", "5 5 25 4 3", "100 100 1000000000000000000 100 100"]
The first and the only line contains five integers n, m, k, x and y (1 ≀ n, m ≀ 100, 1 ≀ k ≀ 1018, 1 ≀ x ≀ n, 1 ≀ y ≀ m).
e61debcad37eaa9a6e21d7a2122b8b21
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
["3 2 3", "2 1 1", "1 1 1", "101010101010101 50505050505051 50505050505051"]
Java
NoteThe order of asking pupils in the first test: the pupil from the first row who seats at the first table, it means it is Sergei; the pupil from the first row who seats at the second table; the pupil from the first row who seats at the third table; the pupil from the first row who seats at the first table, it me...
Print three integers: the maximum number of questions a particular pupil is asked, the minimum number of questions a particular pupil is asked, how many times the teacher asked Sergei.
On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.Seating in the class looks like a rectangle, where n rows with m pupils in each. The teacher asks pupils in the following order: at first, she asks all pupils from the first row in the order of their...
[{"input": "1 3 8 1 1\r\n", "output": ["3 2 3", "3 2 3"]}, {"input": "4 2 9 4 2\r\n", "output": ["2 1 1"]}, {"input": "5 5 25 4 3\r\n", "output": ["1 1 1"]}, {"input": "100 100 1000000000000000000 100 100\r\n", "output": ["101010101010101 50505050505051 50505050505051"]}, {"input": "3 2 15 2 2\r\n", "output": ["4 2 3"...
100
100
100
[{'input': '4 30 766048376 1 23\r\n', 'output': ['8511649 4255824 4255825']}, {'input': '4 1 5 3 1\r\n', 'output': ['2 1 2']}, {'input': '1 100 1000000000000000000 1 35\r\n', 'output': ['10000000000000000 10000000000000000 10000000000000000', '10000000000000000 10000000000000000 10000000000000000']}, {'input': '100 10...
[{'input': '4 5 93 1 2\r\n', 'output': ['6 3 4']}, {'input': '2 6 4 1 3\r\n', 'output': ['1 0 1']}, {'input': '3 1 6 2 1\r\n', 'output': ['3 1 3']}, {'input': '5 99 1000000000000000000 4 12\r\n', 'output': ['2525252525252526 1262626262626263 2525252525252525']}, {'input': '3 5 21 1 2\r\n', 'output': ['2 1 1']}]
[{'input': '7 32 461672865 4 11\r\n', 'output': ['2404547 1202273 2404546']}, {'input': '2 3 4 2 3\r\n', 'output': ['1 0 0']}, {'input': '56 83 4572 35 22\r\n', 'output': ['1 0 1']}, {'input': '19 73 1193 12 46\r\n', 'output': ['1 0 1']}, {'input': '4 2 9 4 2\r\n', 'output': ['2 1 1']}]
[{'input': '91 15 237966754 78 6\r\n', 'output': ['176272 88136 176272']}, {'input': '27 34 77794947 24 4\r\n', 'output': ['88004 44002 88004']}, {'input': '4 1 8 3 1\r\n', 'output': ['3 1 2']}, {'input': '100 100 1000000000000000000 1 1\r\n', 'output': ['101010101010101 50505050505051 50505050505051']}, {'input': '92 ...
[{'input': '4 5 93 1 2\r\n', 'output': ['6 3 4']}, {'input': '5 3 100 2 1\r\n', 'output': ['9 4 9']}, {'input': '10 44 222787770 9 25\r\n', 'output': ['562596 281298 562596']}, {'input': '56 83 4572 35 22\r\n', 'output': ['1 0 1']}, {'input': '2 6 4 1 3\r\n', 'output': ['1 0 1']}]
100
100
100
100
100
95.65
84.78
84.78
84.78
84.78
97.83
82.61
80.43
76.09
82.61
290
100
86.954
83.914
["5 2 3", "8 2 4"]
The only line contains three integers n, b, p (1 ≀ n, b, p ≀ 500) β€” the number of participants and the parameters described in the problem statement.
eb815f35e9f29793a120d120968cfe34
import java.util.Scanner; /** * Created by Peter on 13.04.2016. */ public class TaskA { int n, b, p; TaskA(Scanner sc) { n = sc.nextInt(); b = sc.nextInt(); p = sc.nextInt(); } private int getGamePlayed() { int nn = n; int ans = 0; while (nn > 1 ) { ...
["20 15", "35 32"]
Java
NoteIn the first example will be three rounds: in the first round will be two matches and for each match 5 bottles of water are needed (two for each of the participants and one for the judge), in the second round will be only one match, so we need another 5 bottles of water, in the third round will also be only one ...
Print two integers x and y β€” the number of bottles and towels need for the tournament.
A tennis tournament with n participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out.The tournament takes place in the following way (below, m is the number of the participants of the current round): let k be the maximal power of the number 2 such that k...
[{"input": "5 2 3\r\n", "output": ["20\r\n15", "20 15"]}, {"input": "8 2 4\r\n", "output": ["35\r\n32", "35 32"]}, {"input": "10 1 500\r\n", "output": ["27 5000", "27\r\n5000"]}, {"input": "20 500 1\r\n", "output": ["19019\r\n20", "19019 20"]}, {"input": "100 123 99\r\n", "output": ["24453\r\n9900", "24453 9900"]}, {"i...
100
100
100
[{'input': '10 1 500\r\n', 'output': ['27 5000', '27\r\n5000']}, {'input': '1 2 100\r\n', 'output': ['0 100', '0\r\n100']}, {'input': '1 3 4\r\n', 'output': ['0\r\n4', '0 4']}, {'input': '53 1 1\r\n', 'output': ['156\r\n53', '156 53']}, {'input': '67 1 1\r\n', 'output': ['198 67', '198\r\n67']}]
[{'input': '349 2 5\r\n', 'output': ['1740\r\n1745', '1740 1745']}, {'input': '1 100 90\r\n', 'output': ['0 90', '0\r\n90']}, {'input': '1 2 1\r\n', 'output': ['0 1', '0\r\n1']}, {'input': '20 500 1\r\n', 'output': ['19019\r\n20', '19019 20']}, {'input': '1 500 499\r\n', 'output': ['0\r\n499', '0 499']}]
[{'input': '10 1 500\r\n', 'output': ['27 5000', '27\r\n5000']}, {'input': '53 1 1\r\n', 'output': ['156\r\n53', '156 53']}, {'input': '1 3 5\r\n', 'output': ['0 5', '0\r\n5']}, {'input': '1 2 133\r\n', 'output': ['0 133', '0\r\n133']}, {'input': '57 1 1\r\n', 'output': ['168 57', '168\r\n57']}]
[{'input': '1 100 90\r\n', 'output': ['0 90', '0\r\n90']}, {'input': '10 10 10\r\n', 'output': ['189\r\n100', '189 100']}, {'input': '1 500 500\r\n', 'output': ['0\r\n500', '0 500']}, {'input': '1 345 345\r\n', 'output': ['0 345', '0\r\n345']}, {'input': '10 1 500\r\n', 'output': ['27 5000', '27\r\n5000']}]
[{'input': '1 3 4\r\n', 'output': ['0\r\n4', '0 4']}, {'input': '1 2 133\r\n', 'output': ['0 133', '0\r\n133']}, {'input': '1 12 13\r\n', 'output': ['0 13', '0\r\n13']}, {'input': '67 1 1\r\n', 'output': ['198 67', '198\r\n67']}, {'input': '1 1 1\r\n', 'output': ['0 1', '0\r\n1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
291
100
100
100
["4 5\n2 3 1 4 4", "3 3\n3 1 2"]
The first line contains two integer numbers n, m (1 ≀ n, m ≀ 100). The second line contains m integer numbers l1, l2, ..., lm (1 ≀ li ≀ n) β€” indices of leaders in the beginning of each step.
4a7c959ca279d0a9bd9bbf0ce88cf72b
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import...
["3 1 2 4", "-1"]
Java
NoteLet's follow leadership in the first example: Child 2 starts. Leadership goes from 2 to 2 + a2 = 3. Leadership goes from 3 to 3 + a3 = 5. As it's greater than 4, it's going in a circle to 1. Leadership goes from 1 to 1 + a1 = 4. Leadership goes from 4 to 4 + a4 = 8. Thus in circle it still remains at 4.
Print such permutation of n numbers a1, a2, ..., an that leaders in the game will be exactly l1, l2, ..., lm if all the rules are followed. If there are multiple solutions print any of them. If there is no permutation which satisfies all described conditions print -1.
n children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation a1, a2, ..., an of length n. It is an integer sequence such that each integer from 1 to n appears exactly once in it.The game consists of m steps. On each step the current leader with index i counts out ai p...
[{"input": "4 5\r\n2 3 1 4 4\r\n", "output": ["3 1 2 4"]}, {"input": "3 3\r\n3 1 2\r\n", "output": ["-1"]}, {"input": "1 100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
100
100
100
[{'input': '4 4\r\n1 4 1 1\r\n', 'output': ['-1']}, {'input': '10 20\r\n10 1 5 7 1 2 5 3 6 3 9 4 3 4 9 6 8 4 9 6\r\n', 'output': ['-1']}, {'input': '66 67\r\n19 9 60 40 19 48 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 ...
[{'input': '20 5\r\n1 20 2 19 3\r\n', 'output': ['19 17 1 3 5 6 7 8 9 10 11 12 13 14 15 16 18 20 4 2']}, {'input': '6 5\r\n1 2 4 1 3\r\n', 'output': ['-1']}, {'input': '2 3\r\n1 1 2\r\n', 'output': ['-1']}, {'input': '2 5\r\n1 2 2 1 1\r\n', 'output': ['-1']}, {'input': '66 67\r\n19 9 60 40 19 48 5 58 5 58 5 58 5 58 5 5...
[{'input': '3 3\r\n3 1 2\r\n', 'output': ['-1']}, {'input': '2 3\r\n2 2 1\r\n', 'output': ['-1']}, {'input': '6 8\r\n2 5 4 2 5 4 2 5\r\n', 'output': ['1 3 2 4 5 6']}, {'input': '20 5\r\n1 20 2 19 3\r\n', 'output': ['19 17 1 3 5 6 7 8 9 10 11 12 13 14 15 16 18 20 4 2']}, {'input': '19 19\r\n1 19 2 18 3 17 4 16 5 15 6 14...
[{'input': '2 3\r\n2 2 1\r\n', 'output': ['-1']}, {'input': '6 5\r\n1 2 4 1 3\r\n', 'output': ['-1']}, {'input': '2 3\r\n1 1 2\r\n', 'output': ['-1']}, {'input': '10 5\r\n7 7 9 9 3\r\n', 'output': ['-1']}, {'input': '4 3\r\n2 3 4\r\n', 'output': ['-1']}]
[{'input': '10 5\r\n7 7 9 9 3\r\n', 'output': ['-1']}, {'input': '4 6\r\n2 3 1 4 4 1\r\n', 'output': ['-1']}, {'input': '4 5\r\n2 3 1 4 4\r\n', 'output': ['3 1 2 4']}, {'input': '27 28\r\n8 18 27 24 20 8 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23\r\n', 'output': ['-1']}, {'input': '4 3\r\n2 3 4\r...
100
100
100
100
100
70.45
100
100
70.45
90.91
46.15
84.62
96.15
46.15
65.38
292
100
86.362
67.69
["abacaba", "jinotega"]
In the only line of input there is a string S of lowercase English letters (1 ≀ |S| ≀ 500)Β β€” the identifiers of a program with removed whitespace characters.
c4551f66a781b174f95865fa254ca972
import java.util.HashMap; import java.util.Scanner; public class CODE_OBSTUFICATIION { public static void main(String[] args) { Scanner nik = new Scanner(System.in); String s = nik.next(); boolean b = true; HashMap<Character, Integer> hm = new HashMap<>(); for (int i = 0; i < s.length(); i++) { int te...
["YES", "NO"]
Java
NoteIn the first sample case, one possible list of identifiers would be "number string number character number string number". Here how Kostya would obfuscate the program: replace all occurences of number with a, the result would be "a string a character a string a", replace all occurences of string with b, the result ...
If this program can be a result of Kostya's obfuscation, print "YES" (without quotes), otherwise print "NO".
Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest.To obfuscate the code, Kostya first looks at the first variable name used in his program and repla...
[{"input": "abacaba\r\n", "output": ["YES"]}, {"input": "jinotega\r\n", "output": ["No", "NO"]}, {"input": "aaaaaaaaaaa\r\n", "output": ["YES"]}, {"input": "aba\r\n", "output": ["YES"]}, {"input": "bab\r\n", "output": ["No", "NO"]}, {"input": "a\r\n", "output": ["YES"]}, {"input": "abcdefghijklmnopqrstuvwxyz\r\n", "out...
100
100
100
[{'input': 'bb\r\n', 'output': ['No', 'NO']}, {'input': 'aaaaaaaaaaa\r\n', 'output': ['YES']}, {'input': 'darbbbcwynbbbbaacbkvbakavabbbabzajlbajryaabbbccxraakgniagbtsswcfbkubdmcasccepybkaefcfsbzdddxgcjadybcfjtmqbspflqrdghgfwnccfveogdmifkociqscahdejctacwzbkhihajfilrgcjiofwfklifobozikcmvcfeqlidrgsgdfxffaaebzjxngsjxiclyol...
[{'input': 'aacb\r\n', 'output': ['No', 'NO']}, {'input': 'aabbbd\r\n', 'output': ['No', 'NO']}, {'input': 'aaac\r\n', 'output': ['No', 'NO']}, {'input': 'bc\r\n', 'output': ['No', 'NO']}, {'input': 'abcdeghijklmnopqrstuvwxyz\r\n', 'output': ['No', 'NO']}]
[{'input': 'ade\r\n', 'output': ['No', 'NO']}, {'input': 'bcd\r\n', 'output': ['No', 'NO']}, {'input': 'darbbbcwynbbbbaacbkvbakavabbbabzajlbajryaabbbccxraakgniagbtsswcfbkubdmcasccepybkaefcfsbzdddxgcjadybcfjtmqbspflqrdghgfwnccfveogdmifkociqscahdejctacwzbkhihajfilrgcjiofwfklifobozikcmvcfeqlidrgsgdfxffaaebzjxngsjxiclyolhj...
[{'input': 'za\r\n', 'output': ['No', 'NO']}, {'input': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaababaaababaabababccbabdbcbadccacdbdedabbeecbcabbdcaecdabbedddafeffaccgeacefbcahabfiiegecdbebabhhbdgfeghhbfahgagefbgghdbhadeicbdfgdchhefhigfcgdhcihecacfhadfgfejccibcjkfhbigbealjjkfldiecfdcafbamgfkbjlbifldghmiifkkg...
[{'input': 'abd\r\n', 'output': ['No', 'NO']}, {'input': 'zx\r\n', 'output': ['No', 'NO']}, {'input': 'aaaaaaac\r\n', 'output': ['No', 'NO']}, {'input': 'aabbbd\r\n', 'output': ['No', 'NO']}, {'input': 'fihyxmbnzq\r\n', 'output': ['No', 'NO']}]
100
100
100
100
100
100
100
100
100
100
100
66.67
66.67
100
66.67
293
100
100
80.002
["20 2\n9 19", "2 1\n16 12"]
The first line of input contains two integers a and b (1 ≀ a, b ≀ 100). The second line contains two integers c and d (1 ≀ c, d ≀ 100).
158cb12d45f4ee3368b94b2b622693e7
import java.util.Scanner; public class A787 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int accel1 = scanner.nextInt(); int initialVal1 = scanner.nextInt(); int accel2 = scanner.nextInt(); int initialVal2 = scanner.nextInt(); int time = checkHit(accel1, initialVal1...
["82", "-1"]
Java
NoteIn the first sample testcase, Rick's 5th scream and Morty's 8th time are at time 82. In the second sample testcase, all Rick's screams will be at odd times and Morty's will be at even times, so they will never scream at the same time.
Print the first time Rick and Morty will scream at the same time, or  - 1 if they will never scream at the same time.
A monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b, b + a, b + 2a, b + 3a, ... and Morty screams at times d, d + c, d + 2c, d + 3c, .... The Monster will catch them if at any point they scream at the same time, so it ...
[{"input": "20 2\r\n9 19\r\n", "output": ["82"]}, {"input": "2 1\r\n16 12\r\n", "output": ["-1"]}, {"input": "39 52\r\n88 78\r\n", "output": ["1222"]}, {"input": "59 96\r\n34 48\r\n", "output": ["1748"]}, {"input": "87 37\r\n91 29\r\n", "output": ["211"]}, {"input": "11 81\r\n49 7\r\n", "output": ["301"]}, {"input": "3...
100
100
100
[{'input': '69 30\r\n41 16\r\n', 'output': ['1410']}, {'input': '7 25\r\n39 85\r\n', 'output': ['319']}, {'input': '94 55\r\n20 96\r\n', 'output': ['-1']}, {'input': '87 22\r\n98 32\r\n', 'output': ['718']}, {'input': '41 85\r\n95 46\r\n', 'output': ['331']}]
[{'input': '2 2\r\n2 10\r\n', 'output': ['10']}, {'input': '97 2\r\n99 100\r\n', 'output': ['4852']}, {'input': '40 4\r\n81 40\r\n', 'output': ['364']}, {'input': '2 3\r\n2 5\r\n', 'output': ['5']}, {'input': '2 3\r\n4 99\r\n', 'output': ['99']}]
[{'input': '87 22\r\n98 32\r\n', 'output': ['718']}, {'input': '94 37\r\n34 7\r\n', 'output': ['789']}, {'input': '97 2\r\n99 100\r\n', 'output': ['4852']}, {'input': '98 1\r\n99 2\r\n', 'output': ['9605']}, {'input': '59 70\r\n48 54\r\n', 'output': ['1014']}]
[{'input': '98 1\r\n99 2\r\n', 'output': ['9605']}, {'input': '100 100\r\n100 100\r\n', 'output': ['100']}, {'input': '3 2\r\n7 2\r\n', 'output': ['2']}, {'input': '18 18\r\n71 71\r\n', 'output': ['1278']}, {'input': '2 10\r\n6 20\r\n', 'output': ['20']}]
[{'input': '2 3\r\n2 3\r\n', 'output': ['3']}, {'input': '18 18\r\n71 71\r\n', 'output': ['1278']}, {'input': '1 5\r\n1 5\r\n', 'output': ['5']}, {'input': '3 7\r\n3 6\r\n', 'output': ['-1']}, {'input': '17 19\r\n44 75\r\n', 'output': ['427']}]
100
100
100
100
100
95
90
90
90
95
78.57
50
71.43
71.43
85.71
294
100
92
71.428
["4 2", "3 1"]
The only line contains two integers $$$n$$$ and $$$m~(1 \le n \le 10^5, 0 \le m \le \frac{n (n - 1)}{2})$$$. It is guaranteed that there exists a graph without any self-loops or multiple edges with such number of vertices and edges.
daf0dd781bf403f7c1bb668925caa64d
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); long vertexes = in.nextLong(); long edges = in.nextLong(); long max = 0; if (edges == 0) { System.out.println(vertexes + " " + vertexes)...
["0 1", "1 1"]
Java
NoteIn the first example it is possible to construct a graph with $$$0$$$ isolated vertices: for example, it should contain edges $$$(1, 2)$$$ and $$$(3, 4)$$$. To get one isolated vertex, we may construct a graph with edges $$$(1, 2)$$$ and $$$(1, 3)$$$. In the second example the graph will always contain exactly one ...
In the only line print two numbers $$$min$$$ and $$$max$$$ β€” the minimum and maximum number of isolated vertices, respectively.
Vasya has got an undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connect the same pair of vertices. Since the graph is undirected, the pai...
[{"input": "4 2\r\n", "output": ["0 1"]}, {"input": "3 1\r\n", "output": ["1 1"]}, {"input": "20 55\r\n", "output": ["0 9"]}, {"input": "20 54\r\n", "output": ["0 9"]}, {"input": "20 56\r\n", "output": ["0 8"]}, {"input": "100000 3950493829\r\n", "output": ["0 11111"]}, {"input": "100000 49997\r\n", "output": ["6 99683...
100
100
100
[{'input': '100000 3950493829\r\n', 'output': ['0 11111']}, {'input': '2 1\r\n', 'output': ['0 0']}, {'input': '5 10\r\n', 'output': ['0 0']}, {'input': '6 15\r\n', 'output': ['0 0']}, {'input': '5 5\r\n', 'output': ['0 1']}]
[{'input': '4 2\r\n', 'output': ['0 1']}, {'input': '100 100\r\n', 'output': ['0 85']}, {'input': '4 6\r\n', 'output': ['0 0']}, {'input': '3 1\r\n', 'output': ['1 1']}, {'input': '100000 4999950000\r\n', 'output': ['0 0']}]
[{'input': '5 10\r\n', 'output': ['0 0']}, {'input': '2 0\r\n', 'output': ['2 2']}, {'input': '6740 22710430\r\n', 'output': ['0 0']}, {'input': '10 45\r\n', 'output': ['0 0']}, {'input': '6 15\r\n', 'output': ['0 0']}]
[{'input': '1 0\r\n', 'output': ['1 1']}, {'input': '20 56\r\n', 'output': ['0 8']}, {'input': '5 5\r\n', 'output': ['0 1']}, {'input': '5 10\r\n', 'output': ['0 0']}, {'input': '15 4\r\n', 'output': ['7 11']}]
[{'input': '6 15\r\n', 'output': ['0 0']}, {'input': '1 0\r\n', 'output': ['1 1']}, {'input': '100000 4999950000\r\n', 'output': ['0 0']}, {'input': '5 5\r\n', 'output': ['0 1']}, {'input': '100 0\r\n', 'output': ['100 100']}]
100
100
100
100
100
89.47
89.47
89.47
100
100
83.33
91.67
75
100
83.33
295
100
93.682
86.666
["3 2\n50 85 250\n10 15 25", "3 6\n50 85 250\n10 15 25", "8 1\n10 20 30 40 50 60 70 80\n8 10 58 63 71 72 75 76"]
The first line contains two integers n and c (1 ≀ n ≀ 50, 1 ≀ c ≀ 1000)Β β€” the number of problems and the constant representing the speed of loosing points. The second line contains n integers p1, p2, ..., pn (1 ≀ pi ≀ 1000, pi &lt; pi + 1)Β β€” initial scores. The third line contains n integers t1, t2, ..., tn (1 ≀ ti ≀ 1...
8c704de75ab85f9e2c04a926143c8b4a
import java.util.Scanner; public class A17 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int c = sc.nextInt(); int[] score = new int[n]; int[] minute = new int[n]; for (int i = 0; i < n; i++) { score[i] = sc....
["Limak", "Radewoosh", "Tie"]
Java
NoteIn the first sample, there are 3 problems. Limak solves them as follows: Limak spends 10 minutes on the 1-st problem and he gets 50 - cΒ·10 = 50 - 2Β·10 = 30 points. Limak spends 15 minutes on the 2-nd problem so he submits it 10 + 15 = 25 minutes after the start of the contest. For the 2-nd problem he gets 85 - 2Β·...
Print "Limak" (without quotes) if Limak will get more points in total. Print "Radewoosh" (without quotes) if Radewoosh will get more points in total. Print "Tie" (without quotes) if Limak and Radewoosh will get the same total number of points.
Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order.There will be n problems. The i-th problem has initial score pi and it takes exactly ti minutes to solve it. Problems are sorted by difficultyΒ β€” it's ...
[{"input": "3 2\r\n50 85 250\r\n10 15 25\r\n", "output": ["Limak"]}, {"input": "3 6\r\n50 85 250\r\n10 15 25\r\n", "output": ["Radewoosh"]}, {"input": "8 1\r\n10 20 30 40 50 60 70 80\r\n8 10 58 63 71 72 75 76\r\n", "output": ["Tie"]}, {"input": "4 1\r\n3 5 6 9\r\n1 2 4 8\r\n", "output": ["Limak"]}, {"input": "4 1\r\n1 ...
100
100
100
[{'input': '1 13\r\n866\r\n10\r\n', 'output': ['Tie']}, {'input': '1 10\r\n546\r\n45\r\n', 'output': ['Tie']}, {'input': '4 1\r\n4 6 9 10\r\n3 4 5 7\r\n', 'output': ['Radewoosh']}, {'input': '3 2\r\n50 85 250\r\n10 15 25\r\n', 'output': ['Limak']}, {'input': '50 20\r\n21 43 51 99 117 119 158 167 175 190 196 244 250 316...
[{'input': '4 1\r\n3 5 6 9\r\n1 2 4 8\r\n', 'output': ['Limak']}, {'input': '4 1\r\n4 6 9 10\r\n2 3 4 5\r\n', 'output': ['Radewoosh']}, {'input': '50 35\r\n9 17 28 107 136 152 169 174 186 188 201 262 291 312 324 330 341 358 385 386 393 397 425 431 479 498 502 523 530 540 542 554 578 588 622 623 684 696 709 722 784 819 ...
[{'input': '32 6\r\n25 77 141 148 157 159 192 196 198 244 245 255 332 392 414 457 466 524 575 603 629 700 738 782 838 841 845 847 870 945 984 985\r\n1 2 4 5 8 9 10 12 13 14 15 16 17 18 20 21 22 23 24 26 28 31 38 39 40 41 42 43 45 47 48 49\r\n', 'output': ['Radewoosh']}, {'input': '50 20\r\n21 43 51 99 117 119 158 167 1...
[{'input': '4 1\r\n3 5 6 9\r\n1 2 4 8\r\n', 'output': ['Limak']}, {'input': '4 1\r\n1 6 7 10\r\n2 7 8 10\r\n', 'output': ['Tie']}, {'input': '3 1\r\n1 50 809\r\n2 8 800\r\n', 'output': ['Limak']}, {'input': '50 1\r\n5 14 18 73 137 187 195 197 212 226 235 251 262 278 287 304 310 322 342 379 393 420 442 444 448 472 483 4...
[{'input': '50 20\r\n21 43 51 99 117 119 158 167 175 190 196 244 250 316 335 375 391 403 423 428 451 457 460 480 487 522 539 559 566 584 598 602 604 616 626 666 675 730 771 787 828 841 861 867 886 889 898 970 986 991\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3...
100
100
100
100
100
100
100
100
100
100
100
100
100
93.75
100
296
100
100
98.75
["6\n1 2 4 3 3 2", "1\n100"]
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) β€” the number of coins. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$) β€” values of coins.
f30329023e84b4c50b1b118dc98ae73c
import java.util.*; public class Watermelon { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int[n]; int c[] = new int[101]; for(int i=0; i<n; i++) { a[i] = sc.nextInt(); c[a[i]]++; } int max...
["2", "1"]
Java
null
Print only one integer β€” the minimum number of pockets Polycarp needs to distribute all the coins so no two coins with the same value are put into the same pocket.
Polycarp has $$$n$$$ coins, the value of the $$$i$$$-th coin is $$$a_i$$$. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket.For example, if Polycarp has got six coins represented as an array $$$a = [1, 2, 4, 3, 3, 2]$$$, he can distribu...
[{"input": "6\r\n1 2 4 3 3 2\r\n", "output": ["2"]}, {"input": "1\r\n100\r\n", "output": ["1"]}, {"input": "100\r\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1...
100
100
100
[{'input': '11\r\n1 2 3 4 5 6 7 8 9 1 1\r\n', 'output': ['3']}, {'input': '100\r\n45 29 5 2 6 50 22 36 14 15 9 48 46 20 8 37 7 47 12 50 21 38 18 27 33 19 40 10 5 49 38 42 34 37 27 30 35 24 10 3 40 49 41 3 4 44 13 25 28 31 46 36 23 1 1 23 7 22 35 26 21 16 48 42 32 8 11 16 34 11 39 32 47 28 43 41 39 4 14 19 26 45 13 18 1...
[{'input': '56\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['56']}, {'input': '16\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['16']}, {'input': '14\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['14']}, {'input': '100\r\n100...
[{'input': '6\r\n1 2 4 3 3 2\r\n', 'output': ['2']}, {'input': '1\r\n100\r\n', 'output': ['1']}, {'input': '99\r\n35 96 73 72 70 83 22 93 98 75 45 32 81 82 45 54 25 7 53 72 29 2 94 19 21 98 34 28 39 99 55 85 44 23 6 47 98 2 33 34 19 57 49 35 67 4 60 4 4 23 55 6 57 66 16 68 34 45 84 79 48 63 4 9 46 88 98 13 19 27 83 12 ...
[{'input': '10\r\n1 2 3 4 5 6 7 8 9 10\r\n', 'output': ['1']}, {'input': '7\r\n1 2 3 4 5 6 7\r\n', 'output': ['1']}, {'input': '99\r\n35 96 73 72 70 83 22 93 98 75 45 32 81 82 45 54 25 7 53 72 29 2 94 19 21 98 34 28 39 99 55 85 44 23 6 47 98 2 33 34 19 57 49 35 67 4 60 4 4 23 55 6 57 66 16 68 34 45 84 79 48 63 4 9 46 8...
[{'input': '14\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['14']}, {'input': '6\r\n1 2 4 3 3 2\r\n', 'output': ['2']}, {'input': '1\r\n100\r\n', 'output': ['1']}, {'input': '7\r\n1 2 3 3 3 1 2\r\n', 'output': ['3']}, {'input': '7\r\n1 2 3 4 5 6 7\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
297
100
100
100
["3 4", "2 1"]
The only line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \leq N, M \leq 10^9$$$) β€” the number of rows and columns in the grid.
a91aab4c0618d036c81022232814ef44
import java.util.*; import java.math.*; public class Dominoes { public static void main(String[] args) { Scanner o = new Scanner(System.in); int n = o.nextInt(), m = o.nextInt(); BigInteger b1 = BigInteger.valueOf(n), b2 = BigInteger.valueOf(m); if( n == 1 && m == 1) System.out.println(0); else...
["9", "1"]
Java
NoteThe picture below is the grid that Pak Chanek has in the first example. The picture below is an example of a tight domino in the grid.
An integer representing the number of distinct tight dominoes in the grid.
Pak Chanek has a grid that has $$$N$$$ rows and $$$M$$$ columns. Each row is numbered from $$$1$$$ to $$$N$$$ from top to bottom. Each column is numbered from $$$1$$$ to $$$M$$$ from left to right.Each tile in the grid contains a number. The numbers are arranged as follows: Row $$$1$$$ contains integers from $$$1$$$ ...
[{"input": "3 4\n", "output": ["\n9", "9", "9\n\n", "9\n\n", "\n\n\n9\n", "9\n", "\n9\n", "\n\n\n\n\n\n\n\n9\n", "9\n"]}, {"input": "2 1\n", "output": ["\n1", "1\n", "1", "1\n\n", "\n1\n", "1\n\n", "\n\n1\n", "1\n", "\n\n\n\n\n1\n"]}, {"input": "1 1\n", "output": ["\n0\n", "\n0", "0\n\n", "0\n\n", "0\n", "0\n", "\n\n0\...
100
100
100
[{'input': '636562060 1\n', 'output': ['\n636562059', '636562059\n\n', '636562059\n', '636562059', '\n636562059\n', '636562059\n', '636562059\n\n']}, {'input': '2 1\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n', '\n\n\n\n\n1\n']}, {'input': '1000000000 1000000000\n', 'output': ['99999999...
[{'input': '1 2\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n']}, {'input': '1000000000 1\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}, {'input': '3 4\n', 'output': ['\n9', '9', '9\n\n', '9\n\n', '\n\n\n9\n', ...
[{'input': '1 589284012\n', 'output': ['589284011\n', '\n589284011', '589284011', '589284011\n\n', '589284011\n\n', '\n589284011\n', '589284011\n']}, {'input': '1000000000 1000000000\n', 'output': ['999999999000000000\n', '999999999000000000\n\n', '999999999000000000\n\n', '999999999000000000\n', '999999999000000000']}...
[{'input': '2 1000000000\n', 'output': ['1999999998\n\n', '\n1999999998\n', '1999999998\n', '1999999998', '1999999998\n', '\n1999999998', '1999999998\n\n']}, {'input': '636562060 1\n', 'output': ['\n636562059', '636562059\n\n', '636562059\n', '636562059', '\n636562059\n', '636562059\n', '636562059\n\n']}, {'input': '2 ...
[{'input': '1000000000 1\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}, {'input': '1 1000000000\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}, {'input': '30001 30...
100
100
100
100
100
88.89
88.89
77.78
100
88.89
50
83.33
66.67
100
83.33
298
100
88.89
76.666
["3 3 1", "4 4 1", "6 7 2"]
The first and only line contains three integers: n, m, k (1 ≀ n, m, k ≀ 1000).
309d2d46086d526d160292717dfef308
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { long mod = 1000000007; Scanner in = new ...
["1", "9", "75"]
Java
NoteTwo ways to play the game are considered different if the final pictures are different. In other words, if one way contains a rectangle that is not contained in the other way.In the first sample Anna, who performs her first and only move, has only one possible action plan β€” insert a 1 × 1 square inside the given 3 ...
Print the single number β€” the number of the ways to play the game. As this number can be very big, print the value modulo 1000000007 (109 + 7).
In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n × m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint inside the last-painted rectangle a new lesser rectangle (along the grid lines...
[{"input": "3 3 1\r\n", "output": ["1"]}, {"input": "4 4 1\r\n", "output": ["9"]}, {"input": "6 7 2\r\n", "output": ["75"]}, {"input": "5 5 3\r\n", "output": ["0"]}, {"input": "2 2 1\r\n", "output": ["0"]}, {"input": "999 999 499\r\n", "output": ["1"]}, {"input": "456 876 1000\r\n", "output": ["0"]}, {"input": "3 5 1\r...
100
100
100
[{'input': '956 926 201\r\n', 'output': ['186215807']}, {'input': '5 7 2\r\n', 'output': ['15']}, {'input': '456 876 1000\r\n', 'output': ['0']}, {'input': '188 413 35\r\n', 'output': ['103598368']}, {'input': '589 898 280\r\n', 'output': ['752764170']}]
[{'input': '277 939 15\r\n', 'output': ['934000455']}, {'input': '954 950 732\r\n', 'output': ['0']}, {'input': '5 5 3\r\n', 'output': ['0']}, {'input': '611 229 104\r\n', 'output': ['737450171']}, {'input': '3 1000 1\r\n', 'output': ['498501']}]
[{'input': '611 229 104\r\n', 'output': ['737450171']}, {'input': '354 923 125\r\n', 'output': ['708700715']}, {'input': '580 1000 203\r\n', 'output': ['693824000']}, {'input': '734 917 148\r\n', 'output': ['80695422']}, {'input': '1000 1000 500\r\n', 'output': ['0']}]
[{'input': '705 155 490\r\n', 'output': ['0']}, {'input': '3 5 1\r\n', 'output': ['6']}, {'input': '356 628 17\r\n', 'output': ['665796305']}, {'input': '409 92 105\r\n', 'output': ['0']}, {'input': '86 564 16\r\n', 'output': ['966200617']}]
[{'input': '307 190 52\r\n', 'output': ['186536168']}, {'input': '3 3 1\r\n', 'output': ['1']}, {'input': '6 7 2\r\n', 'output': ['75']}, {'input': '840 474 207\r\n', 'output': ['895622621']}, {'input': '10 13 3\r\n', 'output': ['77616']}]
100
100
100
100
100
100
100
100
100
93.33
87.5
87.5
87.5
100
75
299
100
98.666
87.5
["3\n7 20 88", "9\n16 20 30 40 50 60 70 80 90", "9\n15 20 30 40 50 60 70 80 90"]
The first line of the input contains one integer n (1 ≀ n ≀ 90)Β β€” the number of interesting minutes. The second line contains n integers t1, t2, ..., tn (1 ≀ t1 &lt; t2 &lt; ... tn ≀ 90), given in the increasing order.
5031b15e220f0ff6cc1dd3731ecdbf27
import static java.lang.System.*; import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(in); int n = sc.nextInt(); int sum = 0; int m = 0; while (n --> 0 && (m - (m = sc.nextInt...
["35", "15", "90"]
Java
NoteIn the first sample, minutes 21, 22, ..., 35 are all boring and thus Limak will turn TV off immediately after the 35-th minute. So, he would watch the game for 35 minutes.In the second sample, the first 15 minutes are boring.In the third sample, there are no consecutive 15 boring minutes. So, Limak will watch the w...
Print the number of minutes Limak will watch the game.
Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off.You know that there will be n interesting minutes t1, t2, ..., tn. Your t...
[{"input": "3\r\n7 20 88\r\n", "output": ["35"]}, {"input": "9\r\n16 20 30 40 50 60 70 80 90\r\n", "output": ["15"]}, {"input": "9\r\n15 20 30 40 50 60 70 80 90\r\n", "output": ["90"]}, {"input": "30\r\n6 11 12 15 22 24 30 31 32 33 34 35 40 42 44 45 47 50 53 54 57 58 63 67 75 77 79 81 83 88\r\n", "output": ["90"]}, {"i...
100
100
100
[{'input': '8\r\n15 20 30 40 50 60 73 83\r\n', 'output': ['90']}, {'input': '25\r\n1 2 3 4 5 6 7 8 9 10 11 23 36 50 65 81 82 83 84 85 86 87 88 89 90\r\n', 'output': ['80']}, {'input': '9\r\n15 20 30 40 50 60 70 80 90\r\n', 'output': ['90']}, {'input': '1\r\n1\r\n', 'output': ['16']}, {'input': '12\r\n14 22 27 31 35 44 ...
[{'input': '2\r\n1 18\r\n', 'output': ['16']}, {'input': '8\r\n1 16 30 31 32 33 34 50\r\n', 'output': ['49']}, {'input': '9\r\n16 20 30 40 50 60 70 80 90\r\n', 'output': ['15']}, {'input': '9\r\n15 28 39 48 55 60 63 64 74\r\n', 'output': ['89']}, {'input': '1\r\n16\r\n', 'output': ['15']}]
[{'input': '84\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84\r\n', 'output': ['90']}, {'input': '14\r\n14 22 27 31 35 44...
[{'input': '3\r\n1 20 90\r\n', 'output': ['16']}, {'input': '72\r\n3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89\r\n', 'output': ['54']}, {'input': '8\r\n5 1...
[{'input': '8\r\n10 20 30 40 50 60 70 80\r\n', 'output': ['90']}, {'input': '3\r\n1 20 90\r\n', 'output': ['16']}, {'input': '84\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66...
100
100
100
100
100
100
100
92.31
100
100
100
90
90
100
100
300
100
98.462
96