EtashGuha commited on
Commit
dedf231
·
verified ·
1 Parent(s): 11fed6e

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. code_contests-0100/environment/Dockerfile +5 -0
  2. code_contests-0100/instruction.md +36 -0
  3. code_contests-0106/environment/Dockerfile +5 -0
  4. code_contests-0108/environment/Dockerfile +5 -0
  5. code_contests-0109/environment/Dockerfile +5 -0
  6. code_contests-0109/instruction.md +67 -0
  7. code_contests-0131/environment/Dockerfile +5 -0
  8. code_contests-0131/instruction.md +101 -0
  9. code_contests-0136/environment/Dockerfile +5 -0
  10. code_contests-0136/instruction.md +67 -0
  11. code_contests-0139/environment/Dockerfile +5 -0
  12. code_contests-0153/environment/Dockerfile +5 -0
  13. code_contests-0154/environment/Dockerfile +5 -0
  14. code_contests-0154/instruction.md +76 -0
  15. code_contests-0155/environment/Dockerfile +5 -0
  16. code_contests-0198/environment/Dockerfile +5 -0
  17. code_contests-0303/environment/Dockerfile +5 -0
  18. code_contests-0303/instruction.md +65 -0
  19. code_contests-0304/environment/Dockerfile +5 -0
  20. code_contests-0304/instruction.md +58 -0
  21. code_contests-0333/environment/Dockerfile +5 -0
  22. code_contests-0358/environment/Dockerfile +5 -0
  23. code_contests-0361/environment/Dockerfile +5 -0
  24. code_contests-0367/environment/Dockerfile +5 -0
  25. code_contests-0392/environment/Dockerfile +5 -0
  26. code_contests-0393/environment/Dockerfile +5 -0
  27. code_contests-0395/environment/Dockerfile +5 -0
  28. code_contests-0506/environment/Dockerfile +5 -0
  29. code_contests-0506/instruction.md +166 -0
  30. code_contests-0508/environment/Dockerfile +5 -0
  31. code_contests-0530/environment/Dockerfile +5 -0
  32. code_contests-0530/instruction.md +104 -0
  33. code_contests-0531/environment/Dockerfile +5 -0
  34. code_contests-0552/environment/Dockerfile +5 -0
  35. code_contests-0552/instruction.md +85 -0
  36. code_contests-0555/environment/Dockerfile +5 -0
  37. code_contests-0555/instruction.md +57 -0
  38. code_contests-0562/environment/Dockerfile +5 -0
  39. code_contests-0565/environment/Dockerfile +5 -0
  40. code_contests-0590/environment/Dockerfile +5 -0
  41. code_contests-0590/instruction.md +44 -0
  42. code_contests-0591/environment/Dockerfile +5 -0
  43. code_contests-0596/environment/Dockerfile +5 -0
  44. code_contests-0599/environment/Dockerfile +5 -0
  45. code_contests-0599/instruction.md +78 -0
  46. code_contests-0703/environment/Dockerfile +5 -0
  47. code_contests-0705/environment/Dockerfile +5 -0
  48. code_contests-0757/environment/Dockerfile +5 -0
  49. code_contests-0758/environment/Dockerfile +5 -0
  50. code_contests-0758/instruction.md +93 -0
code_contests-0100/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0100/instruction.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # p01974 Pigeonhole principle
2
+
3
+ ## Problem Description
4
+ problem
5
+
6
+ Given $ N $ different natural numbers $ a_i $. I decided to make a pair by choosing a different natural number from the given natural numbers. Output one pair that can be created with a value difference that is a multiple of $ N -1 $.
7
+
8
+ It should be noted that such a pair always exists.
9
+
10
+
11
+
12
+
13
+
14
+ Example
15
+
16
+ Input
17
+
18
+ 5
19
+ 1 2 4 7 10
20
+
21
+
22
+ Output
23
+
24
+ 2 10
25
+
26
+ ## Contest Information
27
+ - **Contest ID**: 0
28
+ - **Problem Index**:
29
+ - **Points**: 0.0
30
+ - **Rating**: 0
31
+ - **Tags**:
32
+ - **Time Limit**: {'seconds': 1, 'nanos': 0} seconds
33
+ - **Memory Limit**: 268435456 bytes
34
+
35
+ ## Task
36
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0106/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0108/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0109/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0109/instruction.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # walk
2
+
3
+ ## Problem Description
4
+ Chef and his girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed one by one. Before walking Chef and his girlfriend stay at the beginning of the first segment, they want to achieve the end of the last segment.
5
+ There are few problems:
6
+
7
+ At the beginning Chef should choose constant integer - the velocity of mooving. It can't be changed inside one segment.
8
+ The velocity should be decreased by at least 1 after achieving the end of some segment.
9
+ There is exactly one shop on each segment. Each shop has an attractiveness. If it's attractiveness is W and Chef and his girlfriend move with velocity V then if V < W girlfriend will run away into the shop and the promenade will become ruined.
10
+
11
+ Chef doesn't want to lose her girl in such a way, but he is an old one, so you should find the minimal possible velocity at the first segment to satisfy all conditions.
12
+  
13
+
14
+
15
+ Input
16
+
17
+ The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
18
+ The first line of each test case contains a single integer N denoting the number of segments. The second line contains N space-separated integers W1, W2, ..., WN denoting the attractiveness of shops.
19
+
20
+  
21
+
22
+ Output
23
+
24
+ For each test case, output a single line containing the minimal possible velocity at the beginning.
25
+
26
+  
27
+
28
+ Constraints
29
+
30
+ 1 ≤ T ≤ 10
31
+ 1 ≤ N ≤ 10^5
32
+ 1 ≤ Wi ≤ 10^6
33
+
34
+  
35
+
36
+ Example
37
+ Input:
38
+
39
+ 2
40
+ 5
41
+ 6 5 4 3 2
42
+ 5
43
+ 3 4 3 1 1
44
+
45
+ Output:
46
+
47
+ 6
48
+ 5
49
+  
50
+
51
+ Explanation
52
+ Example case 1.
53
+ If we choose velocity 6, on the first step we have 6 ≥ 6 everything is OK, then we should decrease the velocity to 5 and on the 2nd segment we'll receive 5 ≥ 5, again OK, and so on.
54
+ Example case 2.
55
+ If we choose velocity 4, the promanade will be ruined on the 2nd step (we sould decrease our velocity, so the maximal possible will be 3 which is less than 4).
56
+
57
+ ## Contest Information
58
+ - **Contest ID**: 0
59
+ - **Problem Index**:
60
+ - **Points**: 0.0
61
+ - **Rating**: 0
62
+ - **Tags**: None
63
+ - **Time Limit**: None seconds
64
+ - **Memory Limit**: 0 bytes
65
+
66
+ ## Task
67
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0131/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0131/instruction.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1470_E. Strange Permutation
2
+
3
+ ## Problem Description
4
+ Alice had a permutation p_1, p_2, …, p_n. Unfortunately, the permutation looked very boring, so she decided to change it and choose some non-overlapping subranges of this permutation and reverse them. The cost of reversing a single subrange [l, r] (elements from position l to position r, inclusive) is equal to r - l, and the cost of the operation is the sum of costs of reversing individual subranges. Alice had an integer c in mind, so she only considered operations that cost no more than c.
5
+
6
+ Then she got really bored, and decided to write down all the permutations that she could possibly obtain by performing exactly one operation on the initial permutation. Of course, Alice is very smart, so she wrote down each obtainable permutation exactly once (no matter in how many ways it can be obtained), and of course the list was sorted lexicographically.
7
+
8
+ Now Bob would like to ask Alice some questions about her list. Each question is in the following form: what is the i-th number in the j-th permutation that Alice wrote down? Since Alice is too bored to answer these questions, she asked you to help her out.
9
+
10
+ Input
11
+
12
+ The first line contains a single integer t (1 ≤ t ≤ 30) — the number of test cases.
13
+
14
+ The first line of each test case contains three integers n, c, q (1 ≤ n ≤ 3 ⋅ 10^4, 1 ≤ c ≤ 4, 1 ≤ q ≤ 3 ⋅ 10^5) — the length of the permutation, the maximum cost of the operation, and the number of queries.
15
+
16
+ The next line of each test case contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, p_i ≠ p_j if i ≠ j), describing the initial permutation.
17
+
18
+ The following q lines describe the queries. Each of them contains two integers i and j (1 ≤ i ≤ n, 1 ≤ j ≤ 10^{18}), denoting parameters of this query.
19
+
20
+ It is guaranteed that the sum of values n over all test cases does not exceed 3 ⋅ 10^5, and the sum of values q over all test cases does not exceed 3 ⋅ 10^5.
21
+
22
+ Output
23
+
24
+ For each query output the answer for this query, or -1 if j-th permutation does not exist in her list.
25
+
26
+ Examples
27
+
28
+ Input
29
+
30
+
31
+ 2
32
+ 3 1 9
33
+ 1 2 3
34
+ 1 1
35
+ 2 1
36
+ 3 1
37
+ 1 2
38
+ 2 2
39
+ 3 2
40
+ 1 3
41
+ 2 3
42
+ 3 3
43
+ 6 4 4
44
+ 6 5 4 3 1 2
45
+ 1 1
46
+ 3 14
47
+ 1 59
48
+ 2 6
49
+
50
+
51
+ Output
52
+
53
+
54
+ 1
55
+ 2
56
+ 3
57
+ 1
58
+ 3
59
+ 2
60
+ 2
61
+ 1
62
+ 3
63
+ 1
64
+ 4
65
+ -1
66
+ 5
67
+
68
+
69
+ Input
70
+
71
+
72
+ 1
73
+ 12 4 2
74
+ 1 2 3 4 5 6 7 8 9 10 11 12
75
+ 2 20
76
+ 2 21
77
+
78
+
79
+ Output
80
+
81
+
82
+ 2
83
+ 2
84
+
85
+ Note
86
+
87
+ In the first test case, Alice wrote down the following permutations: [1, 2, 3], [1, 3, 2], [2, 1, 3].
88
+
89
+ Note that, for a permutation [3, 2, 1] Alice would have to reverse the whole array, and it would cost her 2, which is greater than the specified value c=1. The other two permutations can not be obtained by performing exactly one operation described in the problem statement.
90
+
91
+ ## Contest Information
92
+ - **Contest ID**: 1470
93
+ - **Problem Index**: E
94
+ - **Points**: 2000.0
95
+ - **Rating**: 3200
96
+ - **Tags**: binary search, combinatorics, data structures, dp, graphs, implementation, two pointers
97
+ - **Time Limit**: {'seconds': 3, 'nanos': 0} seconds
98
+ - **Memory Limit**: 256000000 bytes
99
+
100
+ ## Task
101
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0136/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0136/instruction.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 195_A. Let's Watch Football
2
+
3
+ ## Problem Description
4
+ Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
5
+
6
+ The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
7
+
8
+ Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
9
+
10
+ Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
11
+
12
+ Input
13
+
14
+ The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
15
+
16
+ Output
17
+
18
+ Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
19
+
20
+ Examples
21
+
22
+ Input
23
+
24
+ 4 1 1
25
+
26
+
27
+ Output
28
+
29
+ 3
30
+
31
+
32
+ Input
33
+
34
+ 10 3 2
35
+
36
+
37
+ Output
38
+
39
+ 5
40
+
41
+
42
+ Input
43
+
44
+ 13 12 1
45
+
46
+
47
+ Output
48
+
49
+ 1
50
+
51
+ Note
52
+
53
+ In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
54
+
55
+ In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
56
+
57
+ ## Contest Information
58
+ - **Contest ID**: 195
59
+ - **Problem Index**: A
60
+ - **Points**: 500.0
61
+ - **Rating**: 1000
62
+ - **Tags**: binary search, brute force, math
63
+ - **Time Limit**: {'seconds': 2, 'nanos': 0} seconds
64
+ - **Memory Limit**: 256000000 bytes
65
+
66
+ ## Task
67
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0139/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0153/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0154/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0154/instruction.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 621_D. Rat Kwesh and Cheese
2
+
3
+ ## Problem Description
4
+ Wet Shark asked Rat Kwesh to generate three positive real numbers x, y and z, from 0.1 to 200.0, inclusive. Wet Krash wants to impress Wet Shark, so all generated numbers will have exactly one digit after the decimal point.
5
+
6
+ Wet Shark knows Rat Kwesh will want a lot of cheese. So he will give the Rat an opportunity to earn a lot of cheese. He will hand the three numbers x, y and z to Rat Kwesh, and Rat Kwesh will pick one of the these twelve options:
7
+
8
+ 1. a1 = xyz;
9
+ 2. a2 = xzy;
10
+ 3. a3 = (xy)z;
11
+ 4. a4 = (xz)y;
12
+ 5. a5 = yxz;
13
+ 6. a6 = yzx;
14
+ 7. a7 = (yx)z;
15
+ 8. a8 = (yz)x;
16
+ 9. a9 = zxy;
17
+ 10. a10 = zyx;
18
+ 11. a11 = (zx)y;
19
+ 12. a12 = (zy)x.
20
+
21
+
22
+
23
+ Let m be the maximum of all the ai, and c be the smallest index (from 1 to 12) such that ac = m. Rat's goal is to find that c, and he asks you to help him. Rat Kwesh wants to see how much cheese he gets, so he you will have to print the expression corresponding to that ac.
24
+
25
+ Input
26
+
27
+ The only line of the input contains three space-separated real numbers x, y and z (0.1 ≤ x, y, z ≤ 200.0). Each of x, y and z is given with exactly one digit after the decimal point.
28
+
29
+ Output
30
+
31
+ Find the maximum value of expression among xyz, xzy, (xy)z, (xz)y, yxz, yzx, (yx)z, (yz)x, zxy, zyx, (zx)y, (zy)x and print the corresponding expression. If there are many maximums, print the one that comes first in the list.
32
+
33
+ xyz should be outputted as x^y^z (without brackets), and (xy)z should be outputted as (x^y)^z (quotes for clarity).
34
+
35
+ Examples
36
+
37
+ Input
38
+
39
+ 1.1 3.4 2.5
40
+
41
+
42
+ Output
43
+
44
+ z^y^x
45
+
46
+
47
+ Input
48
+
49
+ 2.0 2.0 2.0
50
+
51
+
52
+ Output
53
+
54
+ x^y^z
55
+
56
+
57
+ Input
58
+
59
+ 1.9 1.8 1.7
60
+
61
+
62
+ Output
63
+
64
+ (x^y)^z
65
+
66
+ ## Contest Information
67
+ - **Contest ID**: 621
68
+ - **Problem Index**: D
69
+ - **Points**: 2000.0
70
+ - **Rating**: 2400
71
+ - **Tags**: brute force, constructive algorithms, math
72
+ - **Time Limit**: {'seconds': 2, 'nanos': 0} seconds
73
+ - **Memory Limit**: 256000000 bytes
74
+
75
+ ## Task
76
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0155/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0198/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0303/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0303/instruction.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # p01219 Private Teacher
2
+
3
+ ## Problem Description
4
+ You are working as a private teacher. Since you are giving lessons to many pupils, you are very busy, especially during examination seasons. This season is no exception in that regard.
5
+
6
+ You know days of the week convenient for each pupil, and also know how many lessons you have to give to him or her. You can give just one lesson only to one pupil on each day. Now, there are only a limited number of weeks left until the end of the examination. Can you finish all needed lessons?
7
+
8
+
9
+
10
+ Input
11
+
12
+ The input consists of multiple data sets. Each data set is given in the following format:
13
+
14
+
15
+ N W
16
+ t1 c1
17
+ list-of-days-of-the-week
18
+ t2 c2
19
+ list-of-days-of-the-week
20
+ ...
21
+ tN cN
22
+ list-of-days-of-the-week
23
+
24
+
25
+ A data set begins with a line containing two integers N (0 < N ≤ 100) and W (0 < W ≤ 1010 ). N is the number of pupils. W is the number of remaining weeks. The following 2N lines describe information about the pupils. The information for each pupil is given in two lines. The first line contains two integers ti and ci. ti (0 < ti ≤ 1010 ) is the number of lessons that the i-th pupil needs. ci (0 < ci ≤ 7) is the number of days of the week convenient for the i-th pupil. The second line is the list of ci convenient days of the week (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday).
26
+
27
+ The end of input is indicated by a line that contains two zeros. This line should not be processed.
28
+
29
+ Output
30
+
31
+ For each data set, print “Yes” if you can finish all lessons, or “No” otherwise.
32
+
33
+ Example
34
+
35
+ Input
36
+
37
+ 2 2
38
+ 6 3
39
+ Monday Tuesday Wednesday
40
+ 8 4
41
+ Thursday Friday Saturday Sunday
42
+ 2 2
43
+ 7 3
44
+ Monday Tuesday Wednesday
45
+ 9 4
46
+ Thursday Friday Saturday Sunday
47
+ 0 0
48
+
49
+
50
+ Output
51
+
52
+ Yes
53
+ No
54
+
55
+ ## Contest Information
56
+ - **Contest ID**: 0
57
+ - **Problem Index**:
58
+ - **Points**: 0.0
59
+ - **Rating**: 0
60
+ - **Tags**:
61
+ - **Time Limit**: {'seconds': 8, 'nanos': 0} seconds
62
+ - **Memory Limit**: 134217728 bytes
63
+
64
+ ## Task
65
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0304/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0304/instruction.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # p01353 Rabbit Plays Games!
2
+
3
+ ## Problem Description
4
+ A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
5
+
6
+ It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ≤ n is the information of each enemy.
7
+
8
+ The battle is turn-based. Each turn, the surviving characters attack in descending order of agility. The enemy always attacks the hero. The hero attacks one enemy, but which enemy to attack Can be selected by the main character every turn. When a character with attack power a attacks a character with defense power d, max {a − d, 0} damage is dealt. The total damage received is greater than or equal to the value of physical strength. The character becomes incapacitated immediately. The battle ends when the main character becomes incapacitated, or when all the enemies become incapacitated.
9
+
10
+
11
+
12
+ Input
13
+
14
+ 1 ≤ n ≤ 40 000
15
+ 1 ≤ hi, ai, di, si ≤ 1 000 000 000 (integer)
16
+ si are all different.
17
+
18
+ Output
19
+
20
+ When the hero is sure to be incapacitated, output -1. Otherwise, output the minimum total damage to the hero in one line.
21
+
22
+ Examples
23
+
24
+ Input
25
+
26
+ 2
27
+ 10 3 1 2
28
+ 2 4 1 3
29
+ 2 2 1 1
30
+
31
+
32
+ Output
33
+
34
+ 4
35
+
36
+
37
+ Input
38
+
39
+ 1
40
+ 1 1 1 1
41
+ 10000 10000 10000 10000
42
+
43
+
44
+ Output
45
+
46
+ -1
47
+
48
+ ## Contest Information
49
+ - **Contest ID**: 0
50
+ - **Problem Index**:
51
+ - **Points**: 0.0
52
+ - **Rating**: 0
53
+ - **Tags**:
54
+ - **Time Limit**: {'seconds': 1, 'nanos': 0} seconds
55
+ - **Memory Limit**: 134217728 bytes
56
+
57
+ ## Task
58
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0333/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0358/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0361/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0367/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0392/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0393/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0395/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0506/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0506/instruction.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # p00395 Maze and Items
2
+
3
+ ## Problem Description
4
+ Maze & Items is a puzzle game in which the player tries to reach the goal while collecting items. The maze consists of $W \times H$ grids, and some of them are inaccessible to the player depending on the items he/she has now. The score the player earns is defined according to the order of collecting items. The objective of the game is, after starting from a defined point, to collect all the items using the least number of moves before reaching the goal. There may be multiple routes that allow the least number of moves. In that case, the player seeks to maximize his/her score.
5
+
6
+ One of the following symbols is assigned to each of the grids. You can move to one of the neighboring grids (horizontally or vertically, but not diagonally) in one time, but you cannot move to the area outside the maze.
7
+
8
+ Symbol| Description
9
+ ---|---
10
+ .| Always accessible
11
+ | Always inaccessible
12
+ Number 0, 1,.., 9| Always accessible and an item (with its specific number) is located in the grid.
13
+ Capital letter A, B, ..., J| Accessible only when the player does NOT have the corresponding item. Each of A, B, ..., J takes a value from 0 to 9.
14
+ Small letter a, b, ..., j| Accessible only when the player DOES have the corresponding item. Each of a, b, ..., j takes one value from 0 to 9. | S| Starting grid. Always accessible.
15
+ T| Goal grid. Always accessible.
16
+
17
+
18
+
19
+ The player fails to complete the game if he/she has not collected all the items before reaching the goal. When entering a grid in which an item is located, it’s the player’s option to collect it or not. The player must keep the item once he/she collects it, and it disappears from the maze.
20
+
21
+ Given the state information of the maze and a table that defines the collecting order dependent scores, make a program that works out the minimum number of moves required to collect all the items before reaching the goal, and the maximum score gained through performing the moves.
22
+
23
+
24
+
25
+ Input
26
+
27
+ The input is given in the following format.
28
+
29
+
30
+ $W$ $H$
31
+ $row_1$
32
+ $row_2$
33
+ ...
34
+ $row_H$
35
+ $s_{00}$ $s_{01}$ ... $s_{09}$
36
+ $s_{10}$ $s_{11}$ ... $s_{19}$
37
+ ...
38
+ $s_{90}$ $s_{91}$ ... $s_{99}$
39
+
40
+
41
+ The first line provides the number of horizontal and vertical grids in the maze $W$ ($4 \leq W \leq 1000$) and $H$ ($4 \leq H \leq 1000$). Each of the subsequent $H$ lines provides the information on the grid $row_i$ in the $i$-th row from the top of the maze, where $row_i$ is a string of length $W$ defined in the table above. A letter represents a grid. Each of the subsequent 10 lines provides the table that defines collecting order dependent scores. An element in the table $s_{ij}$ ($0 \leq s_{ij} \leq 100$) is an integer that defines the score when item $j$ is collected after the item $i$ (without any item between them). Note that $s_{ii} = 0$.
42
+
43
+ The grid information satisfies the following conditions:
44
+
45
+ * Each of S, T, 0, 1, ..., 9 appears in the maze once and only once.
46
+ * Each of A, B, ..., J, a, b, ..., j appears in the maze no more than once.
47
+
48
+ Output
49
+
50
+ Output two items in a line separated by a space: the minimum number of moves and the maximum score associated with that sequence of moves. Output "-1" if unable to attain the game’s objective.
51
+
52
+ Examples
53
+
54
+ Input
55
+
56
+ 12 5
57
+ .....S......
58
+ .abcdefghij.
59
+ .0123456789.
60
+ .ABCDEFGHIJ.
61
+ .....T......
62
+ 0 1 0 0 0 0 0 0 0 0
63
+ 2 0 0 0 0 0 0 0 0 0
64
+ 0 0 0 0 0 0 0 0 0 0
65
+ 0 0 0 0 0 0 0 0 0 0
66
+ 0 0 0 0 0 0 0 0 0 0
67
+ 0 0 0 0 0 0 0 0 0 0
68
+ 0 0 0 0 0 0 0 0 0 0
69
+ 0 0 0 0 0 0 0 0 0 0
70
+ 0 0 0 0 0 0 0 0 0 0
71
+ 0 0 0 0 0 0 0 0 0 0
72
+
73
+
74
+ Output
75
+
76
+ 26 2
77
+
78
+
79
+ Input
80
+
81
+ 4 5
82
+ 0jSB
83
+ .
84
+ 1234
85
+ 5678
86
+ 9..T
87
+ 0 0 0 0 0 0 0 0 0 0
88
+ 0 0 0 0 0 0 0 0 0 0
89
+ 0 0 0 0 0 0 0 0 0 0
90
+ 0 0 0 0 0 0 0 0 0 0
91
+ 0 0 0 0 0 0 0 0 0 0
92
+ 0 0 0 0 0 0 0 0 0 0
93
+ 0 0 0 0 0 0 0 0 0 0
94
+ 0 0 0 0 0 0 0 0 0 0
95
+ 0 0 0 0 0 0 0 0 0 0
96
+ 0 0 0 0 0 0 0 0 0 0
97
+
98
+
99
+ Output
100
+
101
+ 31 0
102
+
103
+
104
+ Input
105
+
106
+ 7 7
107
+ 1.3#8.0
108
+ .###.#
109
+ .###.#
110
+ 5..S..9
111
+ .#T#.#
112
+ .###.#
113
+ 4.2#6.7
114
+ 0 0 0 0 0 0 0 0 1 0
115
+ 0 0 0 1 0 0 0 0 0 0
116
+ 0 0 0 0 7 0 0 0 0 0
117
+ 0 2 0 0 0 0 0 0 0 0
118
+ 0 0 3 0 0 0 0 0 0 0
119
+ 0 0 0 0 0 0 0 0 0 0
120
+ 0 0 0 0 0 0 0 0 0 0
121
+ 0 0 0 0 0 0 8 0 0 0
122
+ 2 0 0 0 0 0 0 0 0 0
123
+ 0 0 0 0 0 0 0 0 0 0
124
+
125
+
126
+ Output
127
+
128
+ 53 19
129
+
130
+
131
+ Input
132
+
133
+ 5 6
134
+ ..S..
135
+
136
+ 01234
137
+ 56789
138
+
139
+ ..T..
140
+ 0 0 0 0 0 0 0 0 0 0
141
+ 0 0 0 0 0 0 0 0 0 0
142
+ 0 0 0 0 0 0 0 0 0 0
143
+ 0 0 0 0 0 0 0 0 0 0
144
+ 0 0 0 0 0 0 0 0 0 0
145
+ 0 0 0 0 0 0 0 0 0 0
146
+ 0 0 0 0 0 0 0 0 0 0
147
+ 0 0 0 0 0 0 0 0 0 0
148
+ 0 0 0 0 0 0 0 0 0 0
149
+ 0 0 0 0 0 0 0 0 0 0
150
+
151
+
152
+ Output
153
+
154
+ -1
155
+
156
+ ## Contest Information
157
+ - **Contest ID**: 0
158
+ - **Problem Index**:
159
+ - **Points**: 0.0
160
+ - **Rating**: 0
161
+ - **Tags**:
162
+ - **Time Limit**: {'seconds': 4, 'nanos': 0} seconds
163
+ - **Memory Limit**: 268435456 bytes
164
+
165
+ ## Task
166
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0508/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0530/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0530/instruction.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1080_C. Masha and two friends
2
+
3
+ ## Problem Description
4
+ Recently, Masha was presented with a chessboard with a height of n and a width of m.
5
+
6
+ The rows on the chessboard are numbered from 1 to n from bottom to top. The columns are numbered from 1 to m from left to right. Therefore, each cell can be specified with the coordinates (x,y), where x is the column number, and y is the row number (do not mix up).
7
+
8
+ Let us call a rectangle with coordinates (a,b,c,d) a rectangle lower left point of which has coordinates (a,b), and the upper right one — (c,d).
9
+
10
+ The chessboard is painted black and white as follows:
11
+
12
+ <image> An example of a chessboard.
13
+
14
+ Masha was very happy with the gift and, therefore, invited her friends Maxim and Denis to show off. The guys decided to make her a treat — they bought her a can of white and a can of black paint, so that if the old board deteriorates, it can be repainted. When they came to Masha, something unpleasant happened: first, Maxim went over the threshold and spilled white paint on the rectangle (x_1,y_1,x_2,y_2). Then after him Denis spilled black paint on the rectangle (x_3,y_3,x_4,y_4).
15
+
16
+ To spill paint of color color onto a certain rectangle means that all the cells that belong to the given rectangle become color. The cell dyeing is superimposed on each other (if at first some cell is spilled with white paint and then with black one, then its color will be black).
17
+
18
+ Masha was shocked! She drove away from the guests and decided to find out how spoiled the gift was. For this, she needs to know the number of cells of white and black color. Help her find these numbers!
19
+
20
+ Input
21
+
22
+ The first line contains a single integer t (1 ≤ t ≤ 10^3) — the number of test cases.
23
+
24
+ Each of them is described in the following format:
25
+
26
+ The first line contains two integers n and m (1 ≤ n,m ≤ 10^9) — the size of the board.
27
+
28
+ The second line contains four integers x_1, y_1, x_2, y_2 (1 ≤ x_1 ≤ x_2 ≤ m, 1 ≤ y_1 ≤ y_2 ≤ n) — the coordinates of the rectangle, the white paint was spilled on.
29
+
30
+ The third line contains four integers x_3, y_3, x_4, y_4 (1 ≤ x_3 ≤ x_4 ≤ m, 1 ≤ y_3 ≤ y_4 ≤ n) — the coordinates of the rectangle, the black paint was spilled on.
31
+
32
+ Output
33
+
34
+ Output t lines, each of which contains two numbers — the number of white and black cells after spilling paint, respectively.
35
+
36
+ Example
37
+
38
+ Input
39
+
40
+
41
+ 5
42
+ 2 2
43
+ 1 1 2 2
44
+ 1 1 2 2
45
+ 3 4
46
+ 2 2 3 2
47
+ 3 1 4 3
48
+ 1 5
49
+ 1 1 5 1
50
+ 3 1 5 1
51
+ 4 4
52
+ 1 1 4 2
53
+ 1 3 4 4
54
+ 3 4
55
+ 1 2 4 2
56
+ 2 1 3 3
57
+
58
+
59
+ Output
60
+
61
+
62
+ 0 4
63
+ 3 9
64
+ 2 3
65
+ 8 8
66
+ 4 8
67
+
68
+ Note
69
+
70
+ Explanation for examples:
71
+
72
+ The first picture of each illustration shows how the field looked before the dyes were spilled. The second picture of each illustration shows how the field looked after Maxim spoiled white dye (the rectangle on which the dye was spilled is highlighted with red). The third picture in each illustration shows how the field looked after Denis spoiled black dye (the rectangle on which the dye was spilled is highlighted with red).
73
+
74
+ In the first test, the paint on the field changed as follows:
75
+
76
+ <image>
77
+
78
+ In the second test, the paint on the field changed as follows:
79
+
80
+ <image>
81
+
82
+ In the third test, the paint on the field changed as follows:
83
+
84
+ <image>
85
+
86
+ In the fourth test, the paint on the field changed as follows:
87
+
88
+ <image>
89
+
90
+ In the fifth test, the paint on the field changed as follows:
91
+
92
+ <image>
93
+
94
+ ## Contest Information
95
+ - **Contest ID**: 1080
96
+ - **Problem Index**: C
97
+ - **Points**: 1250.0
98
+ - **Rating**: 1500
99
+ - **Tags**: implementation
100
+ - **Time Limit**: {'seconds': 1, 'nanos': 0} seconds
101
+ - **Memory Limit**: 256000000 bytes
102
+
103
+ ## Task
104
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0531/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0552/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0552/instruction.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 166_A. Rank List
2
+
3
+ ## Problem Description
4
+ Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.
5
+
6
+ You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either pa > pb, or pa = pb and ta < tb.
7
+
8
+ It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places y + 1, y + 2, ..., y + x. The teams that performed worse than the teams from this group, get their places in the results table starting from the y + x + 1-th place.
9
+
10
+ Your task is to count what number of teams from the given list shared the k-th place.
11
+
12
+ Input
13
+
14
+ The first line contains two integers n and k (1 ≤ k ≤ n ≤ 50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1 ≤ pi, ti ≤ 50) — the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces.
15
+
16
+ Output
17
+
18
+ In the only line print the sought number of teams that got the k-th place in the final results' table.
19
+
20
+ Examples
21
+
22
+ Input
23
+
24
+ 7 2
25
+ 4 10
26
+ 4 10
27
+ 4 10
28
+ 3 20
29
+ 2 1
30
+ 2 1
31
+ 1 10
32
+
33
+
34
+ Output
35
+
36
+ 3
37
+
38
+
39
+ Input
40
+
41
+ 5 4
42
+ 3 1
43
+ 3 1
44
+ 5 3
45
+ 3 1
46
+ 3 1
47
+
48
+
49
+ Output
50
+
51
+ 4
52
+
53
+ Note
54
+
55
+ The final results' table for the first sample is:
56
+
57
+ * 1-3 places — 4 solved problems, the penalty time equals 10
58
+ * 4 place — 3 solved problems, the penalty time equals 20
59
+ * 5-6 places — 2 solved problems, the penalty time equals 1
60
+ * 7 place — 1 solved problem, the penalty time equals 10
61
+
62
+
63
+
64
+ The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.
65
+
66
+ The final table for the second sample is:
67
+
68
+ * 1 place — 5 solved problems, the penalty time equals 3
69
+ * 2-5 places — 3 solved problems, the penalty time equals 1
70
+
71
+
72
+
73
+ The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams.
74
+
75
+ ## Contest Information
76
+ - **Contest ID**: 166
77
+ - **Problem Index**: A
78
+ - **Points**: 500.0
79
+ - **Rating**: 1100
80
+ - **Tags**: binary search, implementation, sortings
81
+ - **Time Limit**: {'seconds': 2, 'nanos': 0} seconds
82
+ - **Memory Limit**: 256000000 bytes
83
+
84
+ ## Task
85
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0555/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0555/instruction.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 233_C. Cycles
2
+
3
+ ## Problem Description
4
+ John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3.
5
+
6
+ A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph edge.
7
+
8
+ John has been painting for long, but he has not been a success. Help him find such graph. Note that the number of vertices there shouldn't exceed 100, or else John will have problems painting it.
9
+
10
+ Input
11
+
12
+ A single line contains an integer k (1 ≤ k ≤ 105) — the number of cycles of length 3 in the required graph.
13
+
14
+ Output
15
+
16
+ In the first line print integer n (3 ≤ n ≤ 100) — the number of vertices in the found graph. In each of next n lines print n characters "0" and "1": the i-th character of the j-th line should equal "0", if vertices i and j do not have an edge between them, otherwise it should equal "1". Note that as the required graph is undirected, the i-th character of the j-th line must equal the j-th character of the i-th line. The graph shouldn't contain self-loops, so the i-th character of the i-th line must equal "0" for all i.
17
+
18
+ Examples
19
+
20
+ Input
21
+
22
+ 1
23
+
24
+
25
+ Output
26
+
27
+ 3
28
+ 011
29
+ 101
30
+ 110
31
+
32
+
33
+ Input
34
+
35
+ 10
36
+
37
+
38
+ Output
39
+
40
+ 5
41
+ 01111
42
+ 10111
43
+ 11011
44
+ 11101
45
+ 11110
46
+
47
+ ## Contest Information
48
+ - **Contest ID**: 233
49
+ - **Problem Index**: C
50
+ - **Points**: 500.0
51
+ - **Rating**: 1600
52
+ - **Tags**: binary search, constructive algorithms, graphs, greedy
53
+ - **Time Limit**: {'seconds': 1, 'nanos': 0} seconds
54
+ - **Memory Limit**: 256000000 bytes
55
+
56
+ ## Task
57
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0562/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0565/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0590/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0590/instruction.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # diamonds-4
2
+
3
+ ## Problem Description
4
+ Roman loved diamonds. Monica decided to give him a beautiful gift on Valentine's Day. Her idea of diamonds was different though. She lit up all the windows of her rectangular building with N floors and M windows on each floor, with 2 shapes - / or \ . According to her, a diamond was made when such a shape was created:
5
+
6
+ /
7
+ /
8
+
9
+ Given the shape of lights in all the windows, help Roman count the number of diamonds formed.
10
+ Note: The components of the diamond should be adjacent to each other.
11
+
12
+ Input:
13
+ First line contains T - the number of testcases.
14
+ For each testcase,
15
+ First line contains 2 space-separated positive integers - N and M - the no. of floors in the building and the no. of windows on each floor respectively.
16
+ N lines follow - each line contains M space-separated characters. Every character is either or / .
17
+
18
+ Output:
19
+ Print a single integer - the total no. of diamonds formed.
20
+
21
+ Constraints:
22
+ 1 ≤ T ≤ 5
23
+ 2 ≤ N, M ≤ 1000
24
+
25
+ SAMPLE INPUT
26
+ 1
27
+ 2 4
28
+ / \ / \
29
+ \ / \ /
30
+
31
+ SAMPLE OUTPUT
32
+ 2
33
+
34
+ ## Contest Information
35
+ - **Contest ID**: 0
36
+ - **Problem Index**:
37
+ - **Points**: 0.0
38
+ - **Rating**: 0
39
+ - **Tags**: None
40
+ - **Time Limit**: None seconds
41
+ - **Memory Limit**: 0 bytes
42
+
43
+ ## Task
44
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0591/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0596/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0599/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0599/instruction.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # p02734 AtCoder Beginner Contest 159 - Knapsack for All Segments
2
+
3
+ ## Problem Description
4
+ Given are a sequence of N integers A_1, A_2, \ldots, A_N and a positive integer S.
5
+ For a pair of integers (L, R) such that 1\leq L \leq R \leq N, let us define f(L, R) as follows:
6
+
7
+
8
+ * f(L, R) is the number of sequences of integers (x_1, x_2, \ldots , x_k) such that L \leq x_1 < x_2 < \cdots < x_k \leq R and A_{x_1}+A_{x_2}+\cdots +A_{x_k} = S.
9
+
10
+
11
+
12
+ Find the sum of f(L, R) over all pairs of integers (L, R) such that 1\leq L \leq R\leq N. Since this sum can be enormous, print it modulo 998244353.
13
+
14
+ Constraints
15
+
16
+ * All values in input are integers.
17
+ * 1 \leq N \leq 3000
18
+ * 1 \leq S \leq 3000
19
+ * 1 \leq A_i \leq 3000
20
+
21
+ Input
22
+
23
+ Input is given from Standard Input in the following format:
24
+
25
+
26
+ N S
27
+ A_1 A_2 ... A_N
28
+
29
+
30
+ Output
31
+
32
+ Print the sum of f(L, R), modulo 998244353.
33
+
34
+ Examples
35
+
36
+ Input
37
+
38
+ 3 4
39
+ 2 2 4
40
+
41
+
42
+ Output
43
+
44
+ 5
45
+
46
+
47
+ Input
48
+
49
+ 5 8
50
+ 9 9 9 9 9
51
+
52
+
53
+ Output
54
+
55
+ 0
56
+
57
+
58
+ Input
59
+
60
+ 10 10
61
+ 3 1 4 1 5 9 2 6 5 3
62
+
63
+
64
+ Output
65
+
66
+ 152
67
+
68
+ ## Contest Information
69
+ - **Contest ID**: 0
70
+ - **Problem Index**:
71
+ - **Points**: 0.0
72
+ - **Rating**: 0
73
+ - **Tags**:
74
+ - **Time Limit**: {'seconds': 2, 'nanos': 0} seconds
75
+ - **Memory Limit**: 1073741824 bytes
76
+
77
+ ## Task
78
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.
code_contests-0703/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0705/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0757/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0758/environment/Dockerfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ FROM ubuntu:24.04
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
code_contests-0758/instruction.md ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1508_C. Complete the MST
2
+
3
+ ## Problem Description
4
+ As a teacher, Riko Hakozaki often needs to help her students with problems from various subjects. Today, she is asked a programming task which goes as follows.
5
+
6
+ You are given an undirected complete graph with n nodes, where some edges are pre-assigned with a positive weight while the rest aren't. You need to assign all unassigned edges with non-negative weights so that in the resulting fully-assigned complete graph the [XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) sum of all weights would be equal to 0.
7
+
8
+ Define the ugliness of a fully-assigned complete graph the weight of its [minimum spanning tree](https://en.wikipedia.org/wiki/Minimum_spanning_tree), where the weight of a spanning tree equals the sum of weights of its edges. You need to assign the weights so that the ugliness of the resulting graph is as small as possible.
9
+
10
+ As a reminder, an undirected complete graph with n nodes contains all edges (u, v) with 1 ≤ u < v ≤ n; such a graph has (n(n-1))/(2) edges.
11
+
12
+ She is not sure how to solve this problem, so she asks you to solve it for her.
13
+
14
+ Input
15
+
16
+ The first line contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ m ≤ min(2 ⋅ 10^5, (n(n-1))/(2) - 1)) — the number of nodes and the number of pre-assigned edges. The inputs are given so that there is at least one unassigned edge.
17
+
18
+ The i-th of the following m lines contains three integers u_i, v_i, and w_i (1 ≤ u_i, v_i ≤ n, u ≠ v, 1 ≤ w_i < 2^{30}), representing the edge from u_i to v_i has been pre-assigned with the weight w_i. No edge appears in the input more than once.
19
+
20
+ Output
21
+
22
+ Print on one line one integer — the minimum ugliness among all weight assignments with XOR sum equal to 0.
23
+
24
+ Examples
25
+
26
+ Input
27
+
28
+
29
+ 4 4
30
+ 2 1 14
31
+ 1 4 14
32
+ 3 2 15
33
+ 4 3 8
34
+
35
+
36
+ Output
37
+
38
+
39
+ 15
40
+
41
+
42
+ Input
43
+
44
+
45
+ 6 6
46
+ 3 6 4
47
+ 2 4 1
48
+ 4 5 7
49
+ 3 4 10
50
+ 3 5 1
51
+ 5 2 15
52
+
53
+
54
+ Output
55
+
56
+
57
+ 0
58
+
59
+
60
+ Input
61
+
62
+
63
+ 5 6
64
+ 2 3 11
65
+ 5 3 7
66
+ 1 4 10
67
+ 2 4 14
68
+ 4 3 8
69
+ 2 5 6
70
+
71
+
72
+ Output
73
+
74
+
75
+ 6
76
+
77
+ Note
78
+
79
+ The following image showcases the first test case. The black weights are pre-assigned from the statement, the red weights are assigned by us, and the minimum spanning tree is denoted by the blue edges.
80
+
81
+ <image>
82
+
83
+ ## Contest Information
84
+ - **Contest ID**: 1508
85
+ - **Problem Index**: C
86
+ - **Points**: 1500.0
87
+ - **Rating**: 2500
88
+ - **Tags**: bitmasks, brute force, data structures, dfs and similar, dsu, graphs, greedy, trees
89
+ - **Time Limit**: {'seconds': 3, 'nanos': 0} seconds
90
+ - **Memory Limit**: 256000000 bytes
91
+
92
+ ## Task
93
+ Solve this competitive programming problem. Provide a complete solution that handles all the given constraints and edge cases.