source
stringclasses
4 values
task_type
stringclasses
1 value
in_source_id
stringlengths
0
138
problem
stringlengths
219
13.2k
gold_standard_solution
stringlengths
0
413k
problem_id
stringlengths
5
10
metadata
dict
verification_info
dict
taco
verifiable_code
https://codeforces.com/problemset/problem/1295/A
Solve the following coding problem using the programming language python: You have a large electronic screen which can display up to $998244353$ decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of $7$ segments which can be turned on and o...
```python t = int(input()) for i in range(t): n = int(input()) int_part = n // 2 ost = n - int_part * 2 number = '' for i in range(int_part - 1): number += '1' if ost == 0: number += '1' else: number = '7' + number print(number) ```
vfc_87404
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1295/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n4\n", "output": "7\n11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30...
taco
verifiable_code
https://www.codechef.com/problems/LUCKY1
Solve the following coding problem using the programming language python: Chef 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. Let F_{d}(x) equals to the...
```python def precompute(): n = 100000 d = {0: 1} s4 = [0] s7 = [0] for i in range(1, n + 1): v = str(i) s4.append(s4[-1] + v.count('4')) s7.append(s7[-1] + v.count('7')) s4_7 = [0] for i in range(1, n + 1): s4_7.append(s4[i] - s7[i]) ans = [0] for i in range(1, n + 1): v = s4_7[i] if v in d: an...
vfc_87408
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LUCKY1", "time_limit": "0.508134 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n10\n100", "output": "6\n31\n1266", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3\n10\n000", "output": "6\n31\n0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/987/E
Solve the following coding problem using the programming language python: Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times takes ...
```python n = int(input()) a = list(map(int, input().split())) b = [x for x in range(1, n + 1)] c = [(x, y) for (x, y) in zip(a, b)] d = set(c) cnt = 0 while d: x = d.pop() sti = x[1] while x[0] != sti: x = c[x[0] - 1] cnt += 1 if x in d: d.remove(x) else: break if cnt % 2 == n * 3 % 2: print('Petr') ...
vfc_87420
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/987/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 4 5 1 3\n", "output": "Petr\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/RUMBLING
Solve the following coding problem using the programming language python: The Rumbling is a hypothetical cataclysmic event involving Karl Fritz's Wall Titans marching across the Earth, destroying all life upon it. Eren Yeager who possesses the Founding Titan has decided to begin The Rumbling to show the true power of ...
```python for _ in range(int(input())): N = int(input()) S = input() (R, L) = list(map(int, input().split())) energy = [] east_vals = {'N': min(R, 3 * L), 'S': min(L, 3 * R), 'E': 0, 'W': min(2 * L, 2 * R)} west_vals = {'N': min(L, 3 * R), 'S': min(R, 3 * L), 'W': 0, 'E': min(2 * L, 2 * R)} sm1 = 0 sm2 = 0 for...
vfc_87424
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RUMBLING", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\nSENWS\n2 1", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/HECS2020/problems/CC002
Solve the following coding problem using the programming language python: Kabir wants to impress Tara by showing her his problem solving skills. He has decided to give the correct answer to the next question which will be asked by his Algorithms teacher. The question asked is: Find the sum of alternate consecutive d$d...
```python for t in range(int(input().strip())): d = int(input().strip()) (L, R) = map(int, input().strip().split(' ')) if L % 2 == 0: L += 1 sum = ((R - L + 2) // 2 // d + 1) // 2 - 1 sum = sum * 2 * d * (sum + 1) * d + (sum + 1) * d * (L + d - 1) print(sum % 1000000007) ```
vfc_87432
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/HECS2020/problems/CC002", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n10 33\n", "output": "114\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1285/E
Solve the following coding problem using the programming language python: There are $n$ segments on a $Ox$ axis $[l_1, r_1]$, $[l_2, r_2]$, ..., $[l_n, r_n]$. Segment $[l, r]$ covers all points from $l$ to $r$ inclusive, so all $x$ such that $l \le x \le r$. Segments can be placed arbitrarily  — be inside each other,...
```python from sys import stdin input = stdin.buffer.readline t = int(input()) while t: t -= 1 n = int(input()) seg = [] for i in range(n): (l, r) = map(int, input().split()) seg.append((l, 0, i)) seg.append((r, 1, i)) seg.sort() ans = 0 seq = [] active = set() increase = [0] * -~n for (pos, p, i) in se...
vfc_87436
{ "difficulty": "hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1285/E", "time_limit": "4 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 4\n2 3\n3 6\n5 7\n3\n5 5\n5 5\n5 5\n6\n3 3\n1 1\n5 5\n1 5\n2 2\n4 4\n", "output": "2\n1\n5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/812/B
Solve the following coding problem using the programming language python: Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off. Th...
```python (n, m) = map(int, input().split()) p = [input() for y in range(n)][::-1] l = r = d = 0 i = j = 0 for (y, t) in enumerate(p): if '1' in t: (l, r) = (min(l - i, r - j) + 2 * m + 2, min(l + i, r + j)) (i, j) = (t.find('1'), t.rfind('1')) (l, r, d) = (l - i, r + j, y) print(min(l, r) + d) ```
vfc_87444
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/812/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n0010\n0100\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n001000\n000010\n000010\n", "output": "12\n", "type": "stdin_stdout" }, { "fn...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/check-if-given-four-points-form-a-square3026/1
Solve the following coding problem using the programming language python: Given coordinates of four points in a plane. Find if the four points form a square or not. Example 1: Input: points=(0,0),(0,1),(1,0),(1,1) Output: 1 Explanation: These points form a square. Example 2: Input: points=(0,0),(1,1),(1,0),(0,2) Outpu...
```python class Solution: def fourPointSquare(self, points): def distance(x, y): return (x[0] - y[0]) * (x[0] - y[0]) + (x[1] - y[1]) * (x[1] - y[1]) record = dict() for i in range(4): for j in range(i + 1, 4): dist = distance(points[i], points[j]) record[dist] = record.get(dist) + 1 if dist in r...
vfc_87452
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/check-if-given-four-points-form-a-square3026/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "points=(0,0),(0,1),(1,0),(1,1)", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "points=(0,0),(1,1),(1,0),(0,2)", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/821/B
Solve the following coding problem using the programming language python: Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a poi...
```python import sys def main(): (m, b) = list(map(int, sys.stdin.readline().split())) def calc(y): x = (b - y) * m return (y * (y + 1) * (x + 1) >> 1) + (x * (x + 1) * (y + 1) >> 1) res = 0 for i in range(b + 1): t = calc(i) if t > res: res = t print(res) main() ```
vfc_87453
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/821/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 5\n", "output": "30\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/641/B
Solve the following coding problem using the programming language python: Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it. That ele...
```python f = lambda : list(map(int, input().split())) (n, m, q) = f() p = [[0] * m for j in range(n)] for t in [list(f()) for k in range(q)][::-1]: j = t[1] - 1 if t[0] == 1: p[j].insert(0, p[j].pop()) elif t[0] == 2: s = p[-1][j] for i in range(n - 1, 0, -1): p[i][j] = p[i - 1][j] p[0][j] = s else: p...
vfc_87457
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/641/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8\n", "output": "8 2 \n1 8 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 2\n1 2\n3 2 2 5\n", "output": "0 0 0 \n0 0 5 \n0 0 0...
taco
verifiable_code
https://www.codechef.com/problems/GALACTIK
Solve the following coding problem using the programming language python: It's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all the planets in the galaxy. Each planet of the galaxy has a government. Some governments have a mutual agreemen...
```python class DisjointSet: def __init__(self, n, cost): self.parent = [i for i in range(n + 1)] self.rank = [1] * (n + 1) self.cost = cost self.visited = [0] * (n + 1) def find(self, x): if self.parent[x] != x: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def union(self, x, y)...
vfc_87461
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GALACTIK", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 6\n1 2\n2 3\n1 3\n4 5\n5 6\n4 6\n1\n3\n5\n2\n4\n6", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/ANUTHM
Solve the following coding problem using the programming language python: -----Problem description----- As a holiday gift, Tojo received a probability problem. The problem read as follows Consider an N by M grid. Rows are numbered 1 to N, from top to bottom. Columns are numbered 1 to M, from left to right. You are ini...
```python for _ in range(int(input())): (N, M) = map(int, input().split()) print('{:.6f}'.format(N + M - 1)) ```
vfc_87465
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ANUTHM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n1 6\n", "output": "3.000000\n6.000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2\n1 6", "output": "2.0\n6.0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/PIZPAR
Solve the following coding problem using the programming language python: Chef is planning a huge party for all of you and has ordered M pizzas. He wants to invite as many people to the party. However, he knows that everyone will have exactly one slice of a pizza (regardless of the size) and he wants to make sure that...
```python (m, n) = [int(i) for i in input().split()] arr = list(map(int, input().split())) arr = sorted(arr, reverse=True) ans = 0 w = 0 q = m for m in range(q): if arr[m] > n: w = 1 break ans += 1 + arr[m] * (arr[m] + 1) // 2 n -= arr[m] if n == 0: print(ans) elif w == 1: print(ans + q - m + n * (n + 1) // 2)...
vfc_87469
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PIZPAR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 10\n1 2 3 4 5\n\n", "output": "31\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: When you enter 8 numbers from 0 to 9, write a program that outputs the difference between the largest integer and the smallest integer that can sort the 8 numbers. The number that can be sorted may start from 0, such as 00135569. Input Given...
```python n = int(input()) for _ in range(n): c = [i for i in input()] Max = int(''.join(sorted(c, reverse=True))) Min = int(''.join(sorted(c))) print(Max - Min) ```
vfc_87473
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n65539010\n102034250", "output": "96417531\n543098655\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n65539010\n31390532", "output": "96417531\n94099851\n", "type": "stdin...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/race-in-fooland4522/1
Solve the following coding problem using the programming language python: Fooland city has a special multi-lane running track. Lanes are numbered from 1 to Tracks. The lanes have N horizontal barriers lying on it (due to some digging and construction work). The i^{th }barrier cover lanes from Li1 to Li2 (both inclusiv...
```python class Solution: def emptyLanes(self, arr, n, tracks): arr.sort() res = 0 for i in range(1, len(arr)): if arr[res][1] >= arr[i][0]: arr[res][0] = min(arr[res][0], arr[i][0]) arr[res][1] = max(arr[res][1], arr[i][1]) else: res += 1 arr[res] = arr[i] ans = 0 if arr[0][0] != 1: ...
vfc_87478
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/race-in-fooland4522/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5, Track = 20\nL_{i} = {(1 3), (5 8), (8 13), \n (14 15), (9 12)}", "output": "6", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/nearest-multiple-of-102437/1
Solve the following coding problem using the programming language python: Given a string N representing a positive number. The task is to round N to the nearest multiple of 10. Note: If you are having two multiple equally apart from N then we will choose the smallest element among them. Example 1: Input : N = 15 ...
```python class Solution: def roundToNearest(self, N): N = int(N) if N % 10 <= 5: a = N // 10 return a * 10 else: return (N // 10 + 1) * 10 ```
vfc_87479
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/nearest-multiple-of-102437/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 15", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 29", "output": "30", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: The events have started and one of them is Void fnx, the most anticipated Coding Event of the college. This year, one question has been bugging the coders for hours, Help them solve it. It goes as follows: The palindromic number 595 can be writ...
```python from math import * def palindrome( s ): return s[ ::-1 ] == s def f(N): seen = {} sqrtN = int( sqrt( N ) ) for i in range( 1, sqrtN ): s = i * i for j in range( i + 1, sqrtN ): s += j * j if s > N: break if palindrome( str( s ) ): seen[ s ] ...
vfc_87480
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "111 555", "output": "1978", "type": "stdin_stdout" }, { "fn_name": null, "input": "67890 987601", "output": "663362", "type": "stdin_stdout" }, { "fn_name": null, "inp...
taco
verifiable_code
Solve the following coding problem using the programming language python: "It all started with a kiss." Chotu was up all night, planning for his first kiss. He has collected the data about all the kissing spots in Allahabad. According to his survey there are N kissing spots in the city, each spot i is associated with...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' import sys n=eval(input()) s=[int(i) for i in input().split()] t=eval(input()) s.sort() for i in range(n): x=t-s[i] l=0 r=n-1 while(l<r): if s[l]+...
vfc_87484
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\n73774251 157903956 196664 242906818 8042396 15858008 19867680 34774560 280752912 42385434 72997932 18879260 1109762 7449876 92876805 25276230 41471705 45640980 9030204 3209724 13447992 95373824 24697530 110175681 4571640 1081...
taco
verifiable_code
https://codeforces.com/problemset/problem/225/A
Solve the following coding problem using the programming language python: A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the gi...
```python q = int(input()) w = int(input()) k = 0 for i in range(q): e = list(map(int, input().split())) if w in e or 7 - w in e: print('NO') k = 1 break if k == 0: print('YES') ```
vfc_87488
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/225/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n2 6\n5 4\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "96\n4\n1 5\n5 1\n6 5\n2 1\n2 1\n2 6\n6 5\n6 5\n6 2\n2 6\n1 5\n6 5\n1 5\n2 6\n6 5\n5 6\n2 1\n2 6\n1 2\n1 5\n...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/355f731797ea1acbd5ab698b19eb1c3c469aa837/1
Solve the following coding problem using the programming language python: There are N buildings in Linear Land. They appear in a linear line one after the other and their heights are given in the array arr[]. Geek wants to select three buildings in Linear Land and remodel them as recreational spots. The third of the s...
```python class Solution: def recreationalSpot(self, arr, n): k = -10 ** 9 s = [] for i in range(n - 1, -1, -1): if arr[i] < k: return True else: while len(s) != 0 and arr[i] > s[-1]: k = s[-1] s.pop() s.append(arr[i]) return False ```
vfc_87496
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/355f731797ea1acbd5ab698b19eb1c3c469aa837/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 6\narr[] = {4, 7, 11, 5, 13, 2}", "output": "True", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/split-the-binary-string-into-substrings-with-equal-number-of-0s-and-1s/1
Solve the following coding problem using the programming language python: Given binary string str of length N. The task is to find the maximum count of consecutive substrings str can be divided into such that all the substrings are balanced i.e. they have an equal number of 0s and 1s. If it is not possible to split st...
```python class Solution: def maxSubStr(self, input_str): count = 0 balance = 0 for ch in input_str: if ch == '0': balance += 1 elif ch == '1': balance -= 1 if balance == 0: count += 1 if balance != 0: return -1 return count ```
vfc_87501
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/split-the-binary-string-into-substrings-with-equal-number-of-0s-and-1s/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"0100110101\"", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"0111100010\"", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/844/C
Solve the following coding problem using the programming language python: You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence als...
```python n = int(input()) a = list(map(int, input().split())) a = sorted(range(n), key=lambda i: a[i]) s = [] for i in range(n): if a[i] + 1: l = [] s.append(l) while a[i] + 1: l.append(i + 1) (a[i], i) = (-1, a[i]) print(len(s)) for l in s: print(len(l), *l) ```
vfc_87502
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/844/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\n", "output": "2\n1 1\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "50\n39 7 45 25 31 26 50 11 19 37 8 16 22 33 14 6 12 46 49 48 29 27 41 15 34 24 3 13 20 47 9 36 5 43 40 21 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/515/A
Solve the following coding problem using the programming language python: Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance in horizontal or vertic...
```python (a, b, s) = map(int, input().split()) if (s - abs(a) - abs(b)) % 2 == 1 or s < abs(a) + abs(b): print('NO') else: print('YES') ```
vfc_87506
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/515/A", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "-203250176 -30379840 233630015\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "-133874494 857573117 991447611\n", "output": "Yes\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://www.codechef.com/problems/RECNDSUB
Solve the following coding problem using the programming language python: Chef has a sequence $A$ of $N$ integers such that $|A_{i}| ≤ 1$. For each $x$ such that $-N ≤ x ≤ N$, find the number of non-empty subsequences of $A$ whose sum of elements is $x$. Since that answer may be too large, print this modulo $163,577,...
```python import math import sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from functools import lru_cache, reduce from heapq import heapify, heappop, heappush from itertools import chain, combinations, permutations, product from typing import List, Dict input = sy...
vfc_87510
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RECNDSUB", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n1 0\n3\n-1 1 -1\n", "output": "0 0 1 2 0\n0 1 3 2 1 0 0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/799/C
Solve the following coding problem using the programming language python: Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can b...
```python import operator def maxl(l, m, mx): for i in range(len(l) - 1): (b1, p1) = l[i] if b1 + l[i + 1][0] <= mx: break for j in range(i + 1, len(l)): (b2, p2) = l[j] if b1 + b2 <= mx: break if p1 + p2 <= m: mx = b1 + b2 break return mx fc = [] fd = [] (n, c, d) = list(map(int, input...
vfc_87514
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/799/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 7 6\n10 8 C\n4 3 C\n5 6 D\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4 5\n2 5 C\n2 1 D\n", "output": "0\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://codeforces.com/problemset/problem/985/E
Solve the following coding problem using the programming language python: Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence a_1, a_2, ..., a_{n} of ...
```python import sys, math, queue MOD = 998244353 sys.setrecursionlimit(1000000) def check(i): if not dp[i][2]: return False if i < 0: return True return check(i - dp[i][1]) (n, k, d) = map(int, input().split()) if k == 1: print('YES') return a = sorted(map(int, input().split())) dp = [None for i in range(n)]...
vfc_87518
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/985/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3 10\n7 2 7 7 4 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2 3\n4 5 3 13 4 10\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn...
taco
verifiable_code
https://codeforces.com/problemset/problem/1392/C
Solve the following coding problem using the programming language python: Omkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible. Omkar currently has $n$ supports arranged in a line, the $i$-th of which has height $a_i$. Omkar wants to build his w...
```python t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) s = 0 for i in range(n - 1): if a[i] > a[i + 1]: s += a[i] - a[i + 1] print(s) ```
vfc_87531
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1392/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n5 3 2 5\n5\n1 2 3 5 3\n3\n1 1 1\n", "output": "3\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1\n1\n", "output": "0\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1602/A
Solve the following coding problem using the programming language python: You are given a string $s$. You need to find two non-empty strings $a$ and $b$ such that the following conditions are satisfied: Strings $a$ and $b$ are both subsequences of $s$. For each index $i$, character $s_i$ of string $s$ must belong to...
```python def read_nums(): return [int(x) for x in input().split()] def solve(): s = input() a = min(s) i = s.index(a) b = s[:i] + s[i + 1:] print(a, b) def main(): (t,) = read_nums() for _ in range(t): solve() main() ```
vfc_87535
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1602/A", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nfc\naaaa\nthebrightboiler\n", "output": "c f\na aaa\nb therightboiler\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nkbxiahaosfyclumgnaczggrnljumplxknibxmeedvnefh\ndkqosshpegwunnzso...
taco
verifiable_code
https://www.codechef.com/COOK69/problems/MOVIEWKN
Solve the following coding problem using the programming language python: Little Egor is a huge movie fan. He likes watching different kinds of movies: from drama movies to comedy movies, from teen movies to horror movies. He is planning to visit cinema this weekend, but he's not sure which movie he should watch. Ther...
```python def bestMovie(): tests = int(input()) for t in range(tests): n = int(input()) L = list(map(int, input().split())) R = list(map(int, input().split())) maxIndex = -1 maxValue = 0 for i in range(n): prod = L[i] * R[i] if maxValue < prod: maxValue = prod maxIndex = i elif maxValue =...
vfc_87539
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK69/problems/MOVIEWKN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n1 2\n2 1\n4\n2 1 4 1\n2 4 1 4\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/474/B
Solve the following coding problem using the programming language python: It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch. Marmot brought Mole n ordered piles of worms such that i-th pile contains a_{i} worms. He labeled all these worms with consecutive integers: worms in first pile ...
```python n = int(input()) a = [int(i) for i in input().split()] m = int(input()) q = [int(i) for i in input().split()] b = [a[0]] for i in range(1, len(a)): b.append(a[i] + b[i - 1]) for i in range(len(q)): l = -1 r = len(a) while r - l > 1: mid = (l + r) // 2 if b[mid] < q[i]: l = mid else: r = mid p...
vfc_87544
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/474/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 7 3 4 9\n3\n1 25 11\n", "output": "1\n5\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 7 3 4 9\n3\n1 4 11\n", "output": "1\n2\n3\n", "type": "stdin_stdout" },...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/c-corresponding-position-in-the-two-strings-that-hold-exactly-the-same-characters5013/1
Solve the following coding problem using the programming language python: Given two strings A and B of equal length, find how many times the corresponding position in the two strings hold exactly the same character. The comparison should not be case sensitive. Example 1: Input: A = choice B = chancE Output: 4 Explan...
```python class Solution: def sameChar(self, A, B): A = A.lower() B = B.lower() c = 0 n = len(B) for i in range(n): if A[i] == B[i]: c += 1 return c ```
vfc_87548
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/c-corresponding-position-in-the-two-strings-that-hold-exactly-the-same-characters5013/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A = choice \nB = chancE", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "A = Geek \nB = gang", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Monk loves cakes! He visits the Binary Bakery to buy some of his favorite cheesecakes. The owner of the bakery, Bob, is a clever man. He does not want Monk to finish all his cheesecakes. Hence, he plays a game. The Monk is given N numbers and ...
```python import operator t=eval(input('')) cnt=0 def num_of_one(n): cnte=0 while n: n=n&n-1 cnte+=1 return cnte while t>cnt: num_of_one_list=[] n,k=input('').split(' ') num_list=input('').split(' ') for i in range(int(n)): num_of_one_list.append(num_of_one(int(num_list[i]))) sorted_x=[y for (y,x) in so...
vfc_87553
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n1000 887\n94625 95469 92038 95916 93405 95533 97004 92469 99853 94992 90361 99819 93294 97195 94036 99404 98767 95404 91711 93214 93100 93751 92139 95437 94993 91759 99572 96270 93789 99623 92472 99493 96170 95589 95408 99576 9...
taco
verifiable_code
https://www.codechef.com/STRG2020/problems/TOTCARS
Solve the following coding problem using the programming language python: There are total $N$ cars in a sequence with $ith$ car being assigned with an alphabet equivalent to the $ith$ alphabet of string $S$ . Chef has been assigned a task to calculate the total number of cars with alphabet having a unique even value i...
```python arr = list(input()) n = len(arr) ans = list() li = ['b', 'd', 'f', 'h', 'j', 'l', 'n', 'p', 'r', 't', 'v', 'x', 'z'] s = set(arr) temp = s.intersection(li) for _ in range(int(input())): (x, y) = list(map(int, input().split())) li = list(temp) c = 0 for i in range(x - 1, y): if arr[i] in li: c += 1 ...
vfc_87557
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/STRG2020/problems/TOTCARS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "bbccdd\n5\n1 2\n3 4\n5 6\n1 6\n2 5\n", "output": "1\n0\n1\n2\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/47/E
Solve the following coding problem using the programming language python: Bertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian system of coordinates, ...
```python import sys from array import array from math import pi, sin, cos from bisect import bisect_left def input(): return sys.stdin.buffer.readline().decode('utf-8') (n, v) = map(int, input().split()) v = float(v) alpha = [float(input()) for _ in range(n)] m = int(input()) wall = sorted((tuple(map(float, input()....
vfc_87561
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/47/E", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 417\n0.0303\n0.7536\n0.7225\n0.2404\n0.2432\n0.4583\n3\n979.9372 477.1436\n469.9804 408.1158\n923.2564 220.5522\n", "output": "469.980400000 8.014848928\n17707.905316391 0.000000000\n469.980400000 403.227402023\n469.9804000...
taco
verifiable_code
https://www.hackerrank.com/challenges/fun-with-1010/problem
Solve the following coding problem using the programming language python: When you look at photographs of watches and clocks, you'll find that they almost always show the time 10:10. There are lots of theories and even urban legends about this. For example, when showing 10:10, the hands look like a smile, and so you a...
```python import sys def read_one(): return sys.stdin.readline().strip() def read_spaced(): return sys.stdin.readline().strip().split() def read_spaced_int(): return map(int, read_spaced()) mod = 2 * 10 ** 6 + 3 N_max = mod - 1 fac = [1] * (N_max + 1) invfac = [1] * (N_max + 1) inv2 = pow(2, mod - 2, mod) for i i...
vfc_87565
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/fun-with-1010/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 3\n3 3\n", "output": "3\n62\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1651/C
Solve the following coding problem using the programming language python: There is a classroom with two rows of computers. There are $n$ computers in each row and each computer has its own grade. Computers in the first row has grades $a_1, a_2, \dots, a_n$ and in the second row — $b_1, b_2, \dots, b_n$. Initially, al...
```python from bisect import bisect_right def helper(ele, l1): ind = bisect_right(l1, ele) if ind == len(l1): return abs(l1[ind - 1] - ele) elif ind == 0: return abs(l1[0] - ele) else: return min(abs(l1[ind - 1] - ele), abs(l1[ind] - ele)) for _ in range(int(input())): n = int(input()) a = [int(i) for i in...
vfc_87569
{ "difficulty": "medium", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1651/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 10 1\n20 4 25\n4\n1 1 1 1\n1000000000 1000000000 1000000000 1000000000\n", "output": "31\n1999999998\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3\n69 69 69\n69 69 69\n", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/844/A
Solve the following coding problem using the programming language python: Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible. String s consists only of lowercase Latin letters, and it is allowed to change char...
```python string = input() k = int(input()) mas = list(string) mas1 = [] for i in mas: if i not in mas1: mas1.append(i) if k > len(string): print('impossible') elif len(mas1) <= k: print(k - len(mas1)) else: print('0') ```
vfc_87584
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/844/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "yandex\n6\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "yahoo\n5\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
taco
verifiable_code
https://codeforces.com/problemset/problem/926/I
Solve the following coding problem using the programming language python: Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute. Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that perio...
```python n = int(input()) times = [] for _ in range(n): time = str(input()) times.append((int(time[:2]), int(time[3:]))) times.sort() def to_minutes(a): return 60 * a[0] + a[1] def to_hours(a): return (a // 60, a % 60) def pad(a): return ('0' if a < 10 else '') + str(a) longest = 0 for i in range(1, n): longe...
vfc_87588
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/926/I", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n05:43\n", "output": "23:59\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n22:00\n03:21\n16:03\n09:59\n", "output": "06:37\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/pronic-number0729/1
Solve the following coding problem using the programming language python: A pronic number is a number which is the product of two consecutive integers. Find all Pronic Numbers less than or equal to the given integer N. The first few Pronic numbers are: 0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132 and so on. Example ...
```python class Solution: def pronicNumbers(self, N): i = 0 k = [] j = 0 while j < N: j = i * (i + 1) if j > N: break k.append(j) i = i + 1 return k ```
vfc_87593
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/pronic-number0729/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 6", "output": "0 2 6", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 56", "output": "0 2 6 12 20 30 42 56", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1562/A
Solve the following coding problem using the programming language python: You are given two integers $l$ and $r$, $l\le r$. Find the largest possible value of $a mod b$ over all pairs $(a, b)$ of integers for which $r\ge a \ge b \ge l$. As a reminder, $a mod b$ is a remainder we get when dividing $a$ by $b$. For exam...
```python import sys import math for t in range(int(input())): (l, r) = map(int, sys.stdin.readline().split()) if l <= math.ceil(r / 2): print(math.ceil(r / 2) - 1) else: print(r % l) ```
vfc_87594
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1562/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1\n999999999 1000000000\n8 26\n1 999999999\n", "output": "0\n1\n12\n499999999\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1\n999999999 1000000000\n9 26\n1 999999999\n", ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Relative B man came to A child's house. He is 3 years old and loves singing. He is singing the song "Kobutanuki Tsuneko" (written and composed by Naozumi Yamamoto), which he learned from kindergarten. In this song, the four words "kobuta," "racc...
```python from collections import * def searchnode(i, u, path): r = 1 u[i] = 1 for j in range(26): if path[i, j] and (not u[j]): r += searchnode(j, u, path) return r def chrtoint(a): return ord(a) - ord('a') while 1: n = int(input()) if n == 0: break inp = [input() for i in range(n)] (front, back) = (...
vfc_87598
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "output": "NG\nOK\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\napple\nyellow\ngeorgia...
taco
verifiable_code
https://codeforces.com/problemset/problem/1445/D
Solve the following coding problem using the programming language python: You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q). Let's sort p in non-decreasing order, and...
```python def ncr(n, r, p): num = den = 1 for i in range(r): num = num * (n - i) % p den = den * (i + 1) % p return num * pow(den, p - 2, p) % p n = int(input()) a = sorted(list(map(int, input().split()))) ans = 0 for i in range(n): ans += abs(a[i] - a[2 * n - 1 - i]) fac = ncr(2 * n, n, 998244353) print(fac * ...
vfc_87602
{ "difficulty": "hard", "memory_limit": "512.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1445/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n2 5 6 25 22 21 7 9 7 22 25 25 22 24\n", "output": "370656", "type": "stdin_stdout" }, { "fn_name": null, "input": "16\n998244362 998244362 998244362 998244362 998244362 998244362 998244362 9982443...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/check-if-possible-to-move-from-given-coordinate-to-desired-coordinate5944/1
Solve the following coding problem using the programming language python: Given two coordinates (x, y) and (a, b). Find if it is possible to reach (x,y) from (a,b). Only possible moves from any coordinate (i, j) are- (i-j, j) (i, i-j) (i+j, j) (i, i+j) Example 1: Input: x = 1, y = 1, a = 2, b = 3 Output: 1 Expla...
```python class Solution: def isPossible(self, x, y, a, b): def gcd(x, y): x = abs(x) y = abs(y) if x < y: (x, y) = (y, x) while y: (x, y) = (y, x % y) return x if gcd(x, y) == gcd(a, b): return 1 else: return 0 ```
vfc_87606
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/check-if-possible-to-move-from-given-coordinate-to-desired-coordinate5944/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "x = 1, y = 1, a = 2, b = 3", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "x = 35, y = 15, a = 20, b = 25", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1612/A
Solve the following coding problem using the programming language python: Let's denote the Manhattan distance between two points $p_1$ (with coordinates $(x_1, y_1)$) and $p_2$ (with coordinates $(x_2, y_2)$) as $d(p_1, p_2) = |x_1 - x_2| + |y_1 - y_2|$. For example, the distance between two points with coordinates $(...
```python def solution(b_x, b_y): if (b_x + b_y) % 2: return '-1 -1' distance = (b_x + b_y) // 2 if distance < b_x: return f'{distance} 0' return f'{b_x} {distance - b_x}' print(*(solution(*map(int, input().split())) for _ in range(int(input()))), sep='\n') ```
vfc_87607
{ "difficulty": "easy", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1612/A", "time_limit": "3 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n49 3\n2 50\n13 0\n0 41\n42 0\n0 36\n13 37\n42 16\n42 13\n0 0\n", "output": "26 0\n2 24\n-1 -1\n-1 -1\n21 0\n0 18\n13 12\n29 0\n-1 -1\n0 0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup ...
```python def biggest_cup(s, v): try: return s.index(v) except ValueError: return 127 def neighbors(s): a = biggest_cup(s, 0) b = biggest_cup(s, 1) c = biggest_cup(s, 2) if b > a: t = list(s) t[a] = 1 yield tuple(t) elif b < a: t = list(s) t[b] = 0 yield tuple(t) if c > b: t = list(s) t[b] ...
vfc_87611
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n1 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0", "output": "9\n3\n0\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 8\n0\n1 1\n2 2 3\n4 7\n2 1 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1108/D
Solve the following coding problem using the programming language python: You have a garland consisting of $n$ lamps. Each lamp is colored red, green or blue. The color of the $i$-th lamp is $s_i$ ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp me...
```python n = int(input()) s = input() s = list(s) if len(s) <= 2 and len(set(s)) > 1: print(0) print(''.join(s)) elif len(s) == 2: print(1) bam = 'RGB' print(s[0] + bam[(bam.index(s[0]) + 1) % 3]) else: perekras = 0 for t in range(1, len(s) - 1): if s[t - 1] == s[t] and s[t] == s[t + 1]: z = {'R', 'G', 'B'...
vfc_87615
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1108/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\nRBGRRBRGG\n", "output": "2\nRBGRGBRGR\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\nBBBGBRRR\n", "output": "2\nBRBGBRGR\n", "type": "stdin_stdout" }, { "f...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/xor-game2143/1
Solve the following coding problem using the programming language python: Given a positive number k, we need to find a minimum value of positive integer n, such that XOR of n and n+1 is equal to k. If no such n exist then print -1. Example 1: Input: k = 3 Output: 1 Explaination: 1 xor 2 = 3. Example 2: Input: k = 6 Ou...
```python class Solution: def xorCal(self, k): if k == 1: return 2 if k & k + 1 == 0: return k >> 1 return -1 ```
vfc_87619
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/xor-game2143/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "k = 3", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "k = 6", "output": "-1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/954/G
Solve the following coding problem using the programming language python: Today you are going to lead a group of elven archers to defend the castle that is attacked by an army of angry orcs. Three sides of the castle are protected by impassable mountains and the remaining side is occupied by a long wall that is split ...
```python import sys border = 1 << 30 def build(x=0): res = [0, 0] i = 0 while x and i < 30: if x & 1: res[1] += 1 << i x >>= 1 i += 1 i = 0 while x: if x & 1: res[0] += 1 << i x >>= 1 i += 1 return res (n, r, k) = map(int, sys.stdin.buffer.readline().decode('utf-8').split()) a = list(map(int, ...
vfc_87620
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/954/G", "time_limit": "1.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 0 0\n1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 10\n23\n", "output": "33\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-shortest-safe-route-in-a-matrix/1
Solve the following coding problem using the programming language python: Given a path in the form of a rectangular matrix having few landmines arbitrarily placed (marked as 0), calculate length of the shortest safe route possible from any cell in the first column to any cell in the last column of the matrix. We have ...
```python from typing import List from typing import List class Solution: def findShortestPath(self, mat: List[List[int]]) -> int: (n, m) = (len(mat), len(mat[0])) dr = [(-1, 0), (0, 1), (1, 0), (0, -1)] def outBounds(i, j): if i <= -1 or i >= n or j <= -1 or (j >= m): return True return False de...
vfc_87624
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-shortest-safe-route-in-a-matrix/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "[1 0 1 1 1]\r\n[1 1 1 1 1]\r\n[1 1 1 1 1]\r\n[1 1 1 0 1]\r\n[1 1 1 1 0]", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "[1 1 1 1 1]\r\n[1 1 0 1 1]\r\n[1 1 1 1 1]", "outp...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/an-easy-problem0811/1
Solve the following coding problem using the programming language python: Given 5 integers K, L, R, X, Y. Find whether there exists two integers A and B such that A / B = K where L ≤ A ≤ R and X ≤ B ≤ Y. Example 1: Input: K = 1, L = 1, R = 10 X = 1, Y = 10 Output: 1 Explanation: A = 1 , B = 1 exists such that L...
```python class Solution: def easyProblem(self, K, L, R, X, Y): left = X right = Y while left <= right: mid = (left + right) // 2 A = K * mid if A >= L and A <= R: return 1 elif A < L: left = mid + 1 else: right = mid - 1 return 0 ```
vfc_87625
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/an-easy-problem0811/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "K = 1, L = 1, R = 10\r\n X = 1, Y = 10", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "K = 1, L = 1, R = 5\r\n X = 6, Y = 10", "output": "0", "type": ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1056/E
Solve the following coding problem using the programming language python: One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe to be a response from aliens! The scientists now...
```python def gethash(l, r): return (ha[r] - ha[l] * p[r - l] % mod + mod) % mod def check(lenx, leny): ha_0 = -1 ha_1 = -1 j = 0 for i in range(m): if s[i] == '0': tmp = gethash(j, j + lenx) if ha_0 == -1: ha_0 = tmp elif ha_0 != tmp: return 0 j += lenx else: tmp = gethash(j, j + leny)...
vfc_87626
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1056/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "01\naaaaaa\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "001\nkokokokotlin\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://www.codechef.com/INOIPRAC/problems/INOI1502
Solve the following coding problem using the programming language python: Indian National Olympiad in Informatics 2015 A string is any nonempty sequence of 0s and 1s. Examples of strings are 00, 101, 111000, 1, 0, 01. The length of a string is the number of symbols in it. For example, the length of 111000 is 6. If u a...
```python def offset(l, flag): x = 0 for i in range(1, len(l)): temp = [] for j in range(i): v = getbig(l[i], l[j], fs) if v > 1: temp.append(v) if flag: x += 2 ** v - 2 else: x -= 2 ** v - 2 x += offset(temp, not flag) return x def getbig(v1, v2, factors): x = 1 for f in factors...
vfc_87631
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/INOIPRAC/problems/INOI1502", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 176\n", "output": "6\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/APRPS
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Vietnamese as well. It is well-known that ∑sqrt(a_{i}), a_{i} ∈ N is a root of some integer-coefficient polynomial. For example: sqrt(2) is a root of polynomial: x^{2} − 2. Now, your task is to ...
```python P = 10 ** 9 + 7 from math import ceil, log def addpolymod(p, q): l = max(len(p), len(q)) r = p + [0] * (l - len(p)) s = q + [0] * (l - len(q)) return [(r[i] + s[i]) % P for i in range(l)] def multpolymod(p, q): l = len(p) + len(q) - 1 r = [0] * l if len(p) <= len(q): for i in range(len(p)): for ...
vfc_87639
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/APRPS", "time_limit": "4 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n2\n2\n2 3", "output": "2\n1000000005 0 1\n4\n1 0 999999997 0 1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/INTSEQ
Solve the following coding problem using the programming language python: You are given an integer K. Consider an integer sequence A = [A_{1}, A_{2}, \ldots, A_{N}]. Define another sequence S of length N, such that S_{i} = A_{1} + A_{2} + \ldots + A_{i} for each 1 ≤ i ≤ N. A is said to be *interesting* if A_{i} + S...
```python for _ in range(int(input())): n = int(input()) i = 2 c = 0 while n % i == 0: i *= 2 c += 1 print(c) ```
vfc_87643
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/INTSEQ", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n8\n4", "output": "3\n2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/646/A
Solve the following coding problem using the programming language python: Три брата договорились о встрече. Пронумеруем братьев следующим образом: пусть старший брат имеет номер 1, средний брат имеет номер 2, а младший брат — номер 3. Когда пришло время встречи, один из братьев опоздал. По заданным номерам двух брат...
```python print(6 - sum(map(int, input().split()))) ```
vfc_87647
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/646/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n",...
taco
verifiable_code
Solve the following coding problem using the programming language python: Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. Constraint...
```python while 1: (a, op, b) = input().split() (a, b) = (int(a), int(b)) if op == '+': print(a + b) if op == '-': print(a - b) if op == '*': print(a * b) if op == '/': print(int(a / b)) if op == '?': break ```
vfc_87651
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n-1 ? 0", "output": "3\n38\n26\n10\n108\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 , 81\n-1 ? 0", ...
taco
verifiable_code
https://www.codechef.com/problems/PSHOT
Solve the following coding problem using the programming language python: Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. Teams $A$ and $B$ are having a penalty shoot-out to decide the winner of their football match. Each team gets to take a shot $N$ times, and...
```python def score(s, i): if i == '1': return s + 1 else: return s t = int(input()) for _ in range(t): n = int(input()) s = str(input()) a = 0 b = 0 for i in range(2 * n): if i % 2 == 1: b = score(b, s[i]) if b + (n - (i + 1) // 2) < a or a + (n - (i + 1) // 2) < b: print(i + 1) break elif...
vfc_87660
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PSHOT", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n101011\n3\n100001", "output": "4\n6", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: This problem of Oz is very straight forward. You are given N distinct prime integers i.e p1, p2,..., pN and an interval [L,R]. Calculate number of integers in this interval that are divisible by at least one of the given primes. Input : First ...
```python T=int(input()) for i in range(T): N,L,R=list(map(int, input().split())) arrP=list(map(int, input().split())) bits=[[] for _ in range(N+1)] for i in range(1,pow(2,N)): bits[bin(i).count("1")].append(i) # calc for L-1, R inclusive from 1: numL=0 numR=0 muls=[1] sign=1 for i in range(N): for num in...
vfc_87664
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n9 346129721967920801 346129721968467407\n193 601 71 101 3 883 613 53 439\n2 575503551000013020 575503551000154577\n769 281\n1 150218079127109492 150218079127360393\n163\n10 348854893696888512 348854893697299413\n929 317 263 397...
taco
verifiable_code
https://codeforces.com/problemset/problem/1405/A
Solve the following coding problem using the programming language python: A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is als...
```python for _ in range(int(input())): input() print(*[*map(int, input().split())][::-1]) ```
vfc_87672
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1405/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n1 2\n6\n2 1 6 5 4 3\n5\n2 4 3 1 5\n", "output": "2 1 \n3 4 5 6 1 2 \n5 1 3 4 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2\n1 2\n6\n2 1 6 5 4 3\n5\n2 4 3 1 5\n", "out...
taco
verifiable_code
https://codeforces.com/problemset/problem/1614/B
Solve the following coding problem using the programming language python: The company "Divan's Sofas" is planning to build $n + 1$ different buildings on a coordinate line so that: the coordinate of each building is an integer number; no two buildings stand at the same point. Let $x_i$ be the coordinate of the $i$-...
```python class Input: def __init__(self, file=''): self.file = file if file: self.f = open(file, 'r') self.read = self.f.readline else: self.read = input inp = Input('') t = int(inp.read()) for _ in range(t): n = int(inp.read()) a = list(map(int, inp.read().split(' '))) sorted_id = sorted(list(rang...
vfc_87680
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1614/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3\n1 2 3\n5\n3 8 10 6 1\n5\n1 1 1 1 1\n1\n0\n", "output": "14\n1 3 0 2\n78\n2 0 1 3 4 5\n18\n2 5 0 4 1 3\n0\n0 1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/ENDE2020/problems/ENCDEC03
Solve the following coding problem using the programming language python: Bob just learned about bitwise operators. Since Alice is an expert, she decided to play a game, she will give a number $x$ to Bob and will ask some questions: There will be 4 different kinds of queries:- - Alice gives an integer $i$ and Bob has...
```python t = int(input()) while t > 0: (n, q) = list(map(int, input().split())) blst = [0] for i in range(1, 65): blst.append(0) i = 1 while n > 0: if n % 2: blst[i] = 1 n //= 2 i += 1 while q > 0: n = int(input()) if n == 1: p = int(input()) if blst[p]: print('ON') else: print('O...
vfc_87690
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENDE2020/problems/ENCDEC03", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 2\n2\n1\n1\n1\n", "output": "ON\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1059/D
Solve the following coding problem using the programming language python: There is a forest that we model as a plane and live $n$ rare animals. Animal number $i$ has its lair in the point $(x_{i}, y_{i})$. In order to protect them, a decision to build a nature reserve has been made. The reserve must have a form of a ...
```python (n, l, r) = (0, -100000000, 1000000000) (x, y) = ([], []) def cal(mid): mx = 0 for i in range(n): mx = max(mx, (x[i] - mid) ** 2 / (2 * y[i]) + y[i] / 2) return mx n = int(input()) for i in range(n): (a, b) = map(int, input().split()) (x.append(a), y.append(b)) for i in range(1, n): if y[i] * y[0] < ...
vfc_87694
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1059/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n0 1\n", "output": "0.4999999998750000\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/414/B
Solve the following coding problem using the programming language python: Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programmin...
```python import math def C(n, k): w = 1 for i in range(n - k + 1, n + 1): w *= i for i in range(1, k + 1): w //= i return w def multiples(limit): tmp = 1 m = limit for j in range(2, limit + 1): no_multiples = 0 while m % j == 0: no_multiples += 1 m //= j if no_multiples: tmp *= C(no_multipl...
vfc_87698
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/414/B", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1707 1117\n", "output": "237674323", "type": "stdin_stdout" }, { "fn_name": null, "input": "1766 1038\n", "output": "435768250", "type": "stdin_stdout" }, { "fn_name": null,...
taco
verifiable_code
https://www.codechef.com/BTCD2012/problems/KMIN
Solve the following coding problem using the programming language python: Jack and Jill got into a serious fight. Jack didn't not belive Jill when she said that her memory was far better than the others. He asked her to prove it as follows :- - Jack would dictate a long list of numbers to her. At any point after he...
```python import operator N = eval(input()) N = int(N) k = eval(input()) k = int(k) list = [] for i in range(k): a = eval(input()) a = int(a) list.append(a) list.sort() for i in range(k, N): a = eval(input()) a = int(a) if a >= 0: if a < list[k - 1]: list.pop() list.append(a) list.sort() else: print...
vfc_87702
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/BTCD2012/problems/KMIN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n2\n3\n2\n-1\n-1\n1\n-1\n", "output": "3\n3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n5\n3\n6\n1\n4\n2\n9\n3\n1\n0\n-1\n", "output": "3\n", "type": "stdin_stdout...
taco
verifiable_code
https://codeforces.com/problemset/problem/1244/G
Solve the following coding problem using the programming language python: Demonstrative competitions will be held in the run-up to the 20NN Berlatov Olympic Games. Today is the day for the running competition! Berlatov team consists of 2n runners which are placed on two running tracks; n runners are placed on each tr...
```python (n, t) = [int(i) for i in input().split()] import os def tr(qq): return qq * (qq + 1) // 2 if t < tr(n): print(-1) exit() upp = 2 * (tr(n) - tr(n // 2)) if n % 2 == 1: upp -= (n + 1) // 2 if t >= upp: os.write(1, (str(upp) + '\n').encode()) ans = list(range(1, n + 1)) os.write(1, (' '.join([str(a) for...
vfc_87706
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1244/G", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 81\n", "output": "80\n1 2 3 4 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n", "output": "-1\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://www.codechef.com/problems/CRDGAME
Solve the following coding problem using the programming language python: Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef is playing a card game with his friend Morty Smith. The rules of the game are as follows: - There are two piles of cards, pile $A$ an...
```python for _ in range(int(input())): n = int(input()) (ctot, mtot) = (0, 0) for r in range(n): (c, m) = input().split() (cs, ms) = (0, 0) for dc in c: cs += int(dc) for dm in m: ms += int(dm) if cs == ms: ctot += 1 mtot += 1 elif cs > ms: ctot += 1 else: mtot += 1 else: if ctot ...
vfc_87710
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CRDGAME", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n10 4\n8 12\n7 6\n2\n5 10\n3 4", "output": "0 2\n2 1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/9/B
Solve the following coding problem using the programming language python: And again a misfortune fell on Poor Student. He is being late for an exam. Having rushed to a bus stop that is in point (0, 0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the direction of increasing x. Po...
```python TN = 1 def solution(): import math (n, v_b, v_s) = map(int, input().split()) x = list(map(int, input().split())) (x_u, y_u) = map(int, input().split()) a_s = 111111111000000000000000000000000 ans = 0 for i in range(1, n): if x[i] / v_b + math.sqrt((x_u - x[i]) ** 2 + y_u ** 2) / v_s <= a_s: a_s =...
vfc_87714
{ "difficulty": "easy", "memory_limit": "64.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/9/B", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1 1\n0 100000\n-100000 -100000\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "55 11 44\n0 3343 3387 3470 3825 3832 3971 4026 4043 4389 4492 4886 5015 5084 5161 5436 559...
taco
verifiable_code
https://codeforces.com/problemset/problem/976/C
Solve the following coding problem using the programming language python: You are given a sequence a_1, a_2, ..., a_{n} of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment a_{i} lies within segment a_{j}. Segment [l_1, r_1] lies within segment [l_2, r_...
```python from collections import Counter import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 import math class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = 'x' in file.mode or 'r' not in file.mode self.write = self.bu...
vfc_87722
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/976/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 10\n2 9\n3 9\n2 3\n2 9\n", "output": "2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 5\n2 6\n6 20\n", "output": "-1 -1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/stock-buy-and-sell2615/1
Solve the following coding problem using the programming language python: The cost of stock on each day is given in an array price[] of size n. Find all the days on which you buy and sell the stock so that in between those days your profit is maximum. Note: The output format is as follows - (buy_day sell_day) (buy_da...
```python def stockBuySell(p, n): start = 0 i = 1 ans = [] while i < n: if p[i - 1] < p[i]: i += 1 else: if start != i - 1: ans.append([start, i - 1]) start = i i += 1 if start != n - 1: ans.append([start, n - 1]) if not ans: print('No Profit') return else: for i in ans: print('(' ...
vfc_87726
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/stock-buy-and-sell2615/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "stockBuySell", "input": "n = 4\r\nprice[] = {3, 4, 1, 5}", "output": "5", "type": "function_call" }, { "fn_name": "stockBuySell", "input": "n = 5\r\nprice[] = {1, 3, 5, 7, 9}", "output": "8", "type": "f...
taco
verifiable_code
Solve the following coding problem using the programming language python: Zeke loves to spend time with Penny and likes her. Penny is having an issue to solve a mathematics problem and is confused. She seeks Zeke's help as she feels he could help her with the problem. He finds this problem very simple. The problem is ...
```python import sys i=0 t= eval(input()) t= int(t) while i<t: a,b,c= list(map(int,sys.stdin.readline().split())) if a > b and a > c: if b > c: temp= a a=c c=temp else: temp= a a=b b=temp temp1=c c=b b=temp1 if b > a and b > c: if a > c: temp= a a=c ...
vfc_87731
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\n1804289384 846930887 1681692778\n1714636916 1957747794 424238336\n719885387 1649760493 596516650\n1189641422 1025202363 1350490028\n783368691 1102520060 2044897764\n1967513927 1365180541 1540383427\n304089173 1303455737 35005...
taco
verifiable_code
Solve the following coding problem using the programming language python: Taro and Hanako decided to play hit-and-blow. The hit-and-blow rules are as follows. * Separated into questioners and respondents. * The questioner decides a 4-digit number (correct answer) that does not include duplicate numbers. * Respondents...
```python while 1: (x, y) = map(list, input().split()) if x == ['0'] and y == ['0']: break h = b = 0 for i in range(len(x)): if x[i] == y[i]: h += 1 elif y[i] in x: b += 1 print('%d %d' % (h, b)) ```
vfc_87739
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1234 10660\n1234 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n2 1\n4 0\n1 3\n0 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1234 10660\n1964 1354\n1234 1234\n1230 1023...
taco
verifiable_code
https://www.codechef.com/problems/MAGICMOD
Solve the following coding problem using the programming language python: You are given an array A of N integers . You want to convert the array A into a permutation of N integers. To do this, you can apply the following operation on array A exactly once . Pick an integer X, where 1 ≤ X ≤ 2\cdot 10^{7}. For each i , ...
```python import math import bisect def check(x, l, n): if x < n: return 0 sa = set({}) for i in range(len(l)): b = l[i] % x if b > n or b == 0 or b in sa: return 0 sa.add(b) return 1 for _ in range(int(input())): n = int(input()) l = list(map(int, input().strip().split())) s = sum(l) - n * (n + 1) /...
vfc_87743
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MAGICMOD", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n2 7 1\n2\n2 2", "output": "YES 4\nNO", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/7ba682ec660335b1627f2183f63bd2c8a37391ec/1
Solve the following coding problem using the programming language python: Given an array A[ ] of N integers and an integer X. In one operation, you can change the i^{th} element of the array to any integer value where 1 ≤ i ≤ N. Calculate minimum number of such operations required such that the bitwise AND of all the ...
```python class Solution: def count(self, N, A, X): (res, bitset) = (N, 0) for i in range(32, -1, -1): if X & 1 << i > 0: bitset |= 1 << i else: count = 0 temp = bitset | 1 << i for num in A: if num & temp != temp: count += 1 res = min(res, count) return res ```
vfc_87747
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/7ba682ec660335b1627f2183f63bd2c8a37391ec/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4, X = 2\nA[] = {3, 1, 2, 7}", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3, X = 1\nA[] = {2, 2, 2}", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/734/A
Solve the following coding problem using the programming language python: Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie. Now Anton wonders, who won more games, he or Dan...
```python a = int(input()) results = input() Anton = results.count('A') Danny = results.count('D') if Anton == Danny: print('Friendship') elif Anton > Danny: print('Anton') else: print('Danik') ```
vfc_87748
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/734/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nADAAAA\n", "output": "Anton\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\nDDDAADA\n", "output": "Danik\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/product-sum3012/1
Solve the following coding problem using the programming language python: Given two integers a and b. Write a program to find the number of digits in the product of these two integers. Example 1: Input: a = 12, b = 4 Output: 2 Explanation: 12*4 = 48 Hence its a 2 digit number. Example 2: Input: a = -24, b = 33 Output...
```python class Solution: def countDigits(self, a, b): s = a * b s = abs(s) return len(str(s)) ```
vfc_87752
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/product-sum3012/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a = 12, b = 4", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "a = -24, b = 33", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1265/A
Solve the following coding problem using the programming language python: A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not. Ahcl wants to construct a beautiful string. He has a string $s$, cons...
```python t = int(input()) s = [] for kfnf in range(0, t): a = input() if 'aa' in a or 'bb' in a or 'cc' in a: s.append(-1) elif 'a' not in a and 'b' not in a and ('c' not in a): j = len(a) l = j % 3 i = '' i += int(j // 3) * 'abc' if l <= 1: i += l * 'a' else: i += 'ab' s.append(i) else: u ...
vfc_87753
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1265/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\na???cb\na??bbc\na?b?c\n", "output": "ababcb\n-1\nacbac\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "23\n?\n??\n???\n????\n????\n?a\n?b\n?c\na?\nb?\nc?\n?a?\n?b?\n?c?\na?a\na?b\na?c\n...
taco
verifiable_code
https://www.codechef.com/problems/ATTND
Solve the following coding problem using the programming language python: Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef is teaching a cooking course. There are $N$ students attending the course, numbered $1$ through $N$. Before each lesson, Chef has to t...
```python for k in range(int(input())): n = int(input()) l = [] s = [] for i in range(n): a = input() x = a.split(' ') l.append(x[0]) s.append(x[1]) for i in range(len(l)): if l.count(l[i]) >= 2: print(l[i], s[i]) else: print(l[i]) ```
vfc_87757
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ATTND", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\nhasan jaddouh\nfarhod khakimiyon\nkerim kochekov\nhasan khateeb", "output": "hasan jaddouh\nfarhod\nkerim\nhasan khateeb", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SUBARRAYGAME
Solve the following coding problem using the programming language python: We define the *goodness* of any array B of length M as: \sum_{i = 1}^{M - 1} |B_{i + 1} - B_{i}| (Here |X| denotes the absolute value of X). In particular, *goodness* of any array of length 1 is 0. Alice and Bob have an array A containing N dis...
```python for _ in range(int(input())): n = int(input()) a = [*map(int, input().split())] total = [] x = 0 cost = 0 for i in range(1, n - 1): if (a[i] - a[i - 1]) * (a[i] - a[i + 1]) > 0: total.append(cost) cost = 0 else: cost += 1 total += [cost] for i in total: x ^= i print(['Bob', 'Alice'][x ...
vfc_87761
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SUBARRAYGAME", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 3 2\n4\n1 2 3 4\n", "output": "Bob\nAlice\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/QFUN2020/problems/CHEFCAKE
Solve the following coding problem using the programming language python: During Quarantine Time Chef is at home and he was quite confused about what to cook so, he went to his son and asked about what would he prefer to have? He replied, cakes. Now, chef cook $N$ number of cake and number of layers for every cake is ...
```python from math import factorial test_cases = int(input()) for _ in range(test_cases): n = int(input()) sum1 = 0 final_sum = 0 num = list(map(int, input().split())) rep_time = factorial(n - 1) rep_count = dict() for i in num: if i in rep_count: rep_count[i] += 1 else: rep_count[i] = 1 for j in rep...
vfc_87765
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/QFUN2020/problems/CHEFCAKE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n2 3 5\n", "output": "2220\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/COUPON
Solve the following coding problem using the programming language python: Alice likes to shop online. The main reason is that she gets a lot of discounts! There are M online shops from where she purchases her items. The prices of the same item vary in both the shops. She needs to buy N items in all. And each she can b...
```python for i in range(int(input())): (N, M) = list(map(int, input().split(' '))) C = [list(map(int, input().split(' '))) for _ in range(N)] D = [list(map(int, input().split(' '))) for _ in range(N)] dp = [[0] * M for _ in range(N)] for j in range(M): dp[0][j] = C[0][j] min_value = min(dp[0]) for i in range(...
vfc_87775
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/COUPON", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n3 4\n1 2\n1 0\n0 1\n2 4\n1 2 3 4\n4 3 2 1\n2 3 2 1\n1 2 1 1", "output": "3\n2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/mila-and-strings0435/1
Solve the following coding problem using the programming language python: Given a string S consisting of only lowercase characters. Find the lexicographically smallest string after removing exactly k characters from the string. But you have to correct the value of k, i.e., if the length of the string is a power of 2, ...
```python from collections import deque class Solution: def ispower(ob, k): return True if k & k - 1 == 0 else False def lexicographicallySmallest(ob, S, k): st = deque() top = -1 n = len(S) k = k // 2 if ob.ispower(n) else 2 * k if k >= n: return '-1' ans = '' for ch in S: while k > 0 and to...
vfc_87779
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/mila-and-strings0435/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"fooland\", k = 2", "output": "\"and\"", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"code\", k = 4", "output": "\"cd\"", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/majority-element-1587115620/1
Solve the following coding problem using the programming language python: Given an array A of N elements. Find the majority element in the array. A majority element in an array A of size N is an element that appears more than N/2 times in the array. Example 1: Input: N = 3 A[] = {1,2,3} Output: -1 Explanation: Sin...
```python class Solution: def majorityElement(self, A, N): flag = True re = N // 2 dict = {} if N == 1: return A[0] else: for i in A: if i in dict: dict[i] += 1 else: dict[i] = 0 for i in dict: if dict[i] >= re: flag = False return i if flag == True: return -1 ```
vfc_87780
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/majority-element-1587115620/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3 \r\nA[] = {1,2,3}", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5 \r\nA[] = {3,1,3,3,2}", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/AUG12/problems/LEBOMBS
Solve the following coding problem using the programming language python: The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent ...
```python import sys T = int(sys.stdin.readline().strip()) for t in range(T): sys.stdin.readline().strip() st = '0' + sys.stdin.readline().strip() + '0' res = 0 for i in range(1, len(st) - 1): if st[i] == st[i - 1] == st[i + 1] == '0': res += 1 print(res) ```
vfc_87781
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AUG12/problems/LEBOMBS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n010\n5\n10001\n7\n0000000\n", "output": "0\n1\n7\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: You are on a game show "Who Wants to Be a Millionaire".The host presents you "N" number of closed doors.There is huge prize behind one door while there are sumo wrestlers behind rest of the doors.Initially you are asked to choose a door.After th...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' for i in range(eval(input())): n = float(input()) p = (n-1) / n print('%f' % p) ```
vfc_87793
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n10\n", "output": "0.998131\n0.995763\n0.995816\n0.998994\n0.998888\n0.994924\n0.998932\n0.998305\n0.998938\n0.909091\n0.994505\n0.998800\n0.998473\n0.998895\n0.995536\n0.986301\n0.996183\n0.997118\n0.998946\n0.998733\n0...
taco
verifiable_code
https://codeforces.com/problemset/problem/239/A
Solve the following coding problem using the programming language python: Valera had two bags of potatoes, the first of these bags contains x (x ≥ 1) potatoes, and the second — y (y ≥ 1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains x potatoes) Valera lost. Valera remembers that the ...
```python (y, k, n) = map(int, input().split()) l1 = n % k n -= l1 t = n - y if t == 0: print(-1) elif y >= n: print(-1) elif t < k: print(t) else: li = [] for i in range(t, 0, -k): li.append(i) print(*li[::-1]) ```
vfc_87797
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/239/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 1 10\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 6 40\n", "output": "2 8 14 20 26 \n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-the-median0527/1
Solve the following coding problem using the programming language python: Given an array arr[] of N integers, calculate the median Example 1: Input: N = 5 arr[] = 90 100 78 89 67 Output: 89 Explanation: After sorting the array middle element is the median Example 2: Input: N = 4 arr[] = 56 67 30 79 Output: 61 Expl...
```python class Solution: def find_median(self, v): n = len(v) v.sort() if n == 0: return -1 if n == 1: return int(v[0]) if n == 2: return int((v[0] + v[1]) / 2) if n >= 3: if n % 2 == 0: p1 = int(n / 2) p2 = int(n / 2 - 1) return int((v[p1] + v[p2]) / 2) else: return int(v[...
vfc_87805
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-the-median0527/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5\narr[] = 90 100 78 89 67", "output": "89", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4\narr[] = 56 67 30 79", "output": "61", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/226/A
Solve the following coding problem using the programming language python: An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!). The flying saucer, on which the brave pioneers set off, consists of three sections. These ...
```python (n, m) = map(int, input().split()) def fast_power(base, exp): res = 1 while exp > 0: if exp % 2 == 1: res = res * base % m base = base * base % m exp //= 2 return res print((fast_power(3, n) - 1 + m) % m) ```
vfc_87807
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/226/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 81\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n", "output": "2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/DIGARR
Solve the following coding problem using the programming language python: Given a positive integer N, MoEngage wants you to determine if it is possible to rearrange the digits of N (in decimal representation) and obtain a [multiple] of 5. For example, when N = 108, we can rearrange its digits to construct 180 = 36 \...
```python for i in range(int(input())): n = int(input()) num = input() c = 0 l = ['0', '5'] for i in num: if i in l: print('Yes') c += 1 break if c == 0: print('No') ```
vfc_87811
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DIGARR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n115\n3\n103\n3\n119", "output": "Yes\nYes\nNo", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/262/D
Solve the following coding problem using the programming language python: Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters. Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant from 1 to n. Maxim knows the...
```python n = int(input()) arr = list(map(int, input().split())) p = int(input()) dp = [[[0 for k in range(n + 1)] for i in range(p + 1)] for i in range(n + 1)] for j in range(p + 1): for k in range(n + 1): dp[0][j][k] = 1 for i in range(1, n + 1): for j in range(p + 1): for k in range(1, n + 1): if j >= arr[k...
vfc_87816
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/262/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n20\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 1 2\n3\n", "output": "1.5000000000\n", "type": "stdin...
taco
verifiable_code
Solve the following coding problem using the programming language python: Saurav has put up Chinese food stall in the college fest. He has arranged everything but he was not able to find chop-sticks in any shop. He decided to make some himself. After hours of efforts, he was able to collect a few ice cream sticks that...
```python for _ in range(eval(input())): a,b = list(map(int,input().split())) li=[] for x in range(0,int(a)): li.append(eval(input())) li= sorted(li) co=0 for y in range(0,int(a-1)): for z in range(y+1,int(a)): if li[z]-li[y]==b: co+=1 if li[z]-li[y]>=b: break print(co) ```
vfc_87820
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 5\n1\n6", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-the-number-of-subarrays/1
Solve the following coding problem using the programming language python: Given an array A[] of N integers and a range(L, R). The task is to find the number of subarrays having sum in the range L to R (inclusive). Example 1: Input: N = 3, L = 3, R = 8 A[] = {1, 4, 6} Output: 3 Explanation: The subarrays are [1,4], [...
```python class Solution: def countSub(self, arr, n, x): st = 0 end = 0 sum = 0 cnt = 0 while end < n: sum += arr[end] while st <= end and sum > x: sum -= arr[st] st += 1 cnt += end - st + 1 end += 1 return cnt def countSubarray(self, N, A, L, R): Rcnt = self.countSub(A, N, R) Lc...
vfc_87824
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-the-number-of-subarrays/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3, L = 3, R = 8\nA[] = {1, 4, 6}", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4, L = 4, R = 13\nA[] = {2, 3, 5, 8}", "output": "6", "type": "stdin_stdou...
taco
verifiable_code
Solve the following coding problem using the programming language python: All space-time unified dimension sugoroku tournament. You are representing the Earth in the 21st century in the tournament, which decides only one Sugoroku absolute champion out of more than 500 trillion participants. The challenge you are curr...
```python import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10 ** 7) inf = 10 ** 20 eps = 1.0 / 10 ** 10 mod = 10 ** 9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (...
vfc_87825
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11\n0\n1\n-2\n0\n-4\n1\n-1\n2\n0\n0\n0", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n0\n0\n7\n0\n2\n0\n0\n3\n-5\n-2\n1\n0", "output": "1\n", "type": "stdin...
taco
verifiable_code
https://codeforces.com/problemset/problem/1111/A
Solve the following coding problem using the programming language python: We all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name $s$ can transform to another superhero with name $t$ if $s$ can be made equal to $t$ by ...
```python s = input() t = input() count = 0 def isvowel(a): if a == 'a' or a == 'e' or a == 'i' or (a == 'o') or (a == 'u'): return True else: return False if len(s) != len(t): print('No') exit() for i in range(0, len(s)): if isvowel(s[i]) != isvowel(t[i]): print('No') exit() print('Yes') ```
vfc_87829
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1111/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a\nu\n", "output": "Yes\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/NOTIME
Solve the following coding problem using the programming language python: Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Only $x$ hours are left for the March Long Challenge and Chef is only left with the last problem unsolved. However, he is sure that he cannot solve t...
```python (N, H, x) = map(int, input().split()) lst = [int(i) for i in input().split()][0:N] if H > x: for tz in lst: if x + tz >= H: print('YES') break else: print('NO') ```
vfc_87833
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/NOTIME", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 5 3\n1 2", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 6 3\n1 2", "output": "NO", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/522/C
Solve the following coding problem using the programming language python: Polycarp is flying in the airplane. Finally, it is his favorite time — the lunchtime. The BerAvia company stewardess is giving food consecutively to all the passengers from the 1-th one to the last one. Polycarp is sitting on seat m, that means,...
```python import sys n = int(input()) for i in range(n): sys.stdin.readline() (q, w) = map(int, sys.stdin.readline().split()) kol = list(map(int, sys.stdin.readline().split())) r = [] e = [] for ii in range(q - 1): (a, s) = map(int, sys.stdin.readline().split()) a -= 1 r.append(a) e.append(s) rw = [0 for...
vfc_87838
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/522/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n\n3 4\n2 3 2 1\n1 0\n0 0\n\n5 5\n1 2 1 3 1\n3 0\n0 0\n2 1\n4 0\n", "output": "YNNY\nYYYNY\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n\n2 1\n42\n0 0\n\n2 1\n2\n0 0\n\n2 1\n42\n1 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1099/A
Solve the following coding problem using the programming language python: Today's morning was exceptionally snowy. Meshanya decided to go outside and noticed a huge snowball rolling down the mountain! Luckily, there are two stones on that mountain. Initially, snowball is at height $h$ and it has weight $w$. Each seco...
```python (m, n) = map(int, input().split()) (x1, y1) = map(int, input().split()) (x2, y2) = map(int, input().split()) v = m for i in range(n, 0, -1): v += i if y1 == i: v -= x1 if y2 == i: v -= x2 if v < 0: v = 0 print(v) ```
vfc_87842
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1099/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n1 1\n1 2\n", "output": "8", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Rahul's Dad is the CEO of one of the leading companies. Every time somebody seeks for an appointment he calls up his secretary and asks her whether the day is a Sunday or not. He has to keep his caller on hold and is unhappy about it. Knowing th...
```python t = int(input()) def anchor_day(year): centurie = year[0] + year[1] centurie = int(centurie) if centurie % 4 == 1: return 6 elif centurie % 4 == 2: return 4 elif centurie % 4 == 3: return 2 elif centurie % 4 == 0: return 1 def doomsday_num(year, month): if leap_year(year) == "normal": dooms...
vfc_87851
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10000\n8 2386\n10 2415\n6 2335\n11 2492\n10 2421\n3 2027\n3 2059\n12 2426\n1 2426\n5 2236\n12 2368\n4 2429\n3 2030\n3 2123\n8 2135\n6 2302\n7 2058\n6 2167\n2 2456\n8 2042\n10 2373\n10 2419\n9 2037\n3 2324\n12 2370\n6 2026\n8 2480\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/889/D
Solve the following coding problem using the programming language python: You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines. Multiset is a set where equal elem...
```python from fractions import Fraction import time class Point: def __init__(self, x, y): self.x = x self.y = y def to_tuple(self): return (self.x, self.y) def __repr__(self): return 'Point({}, {})'.format(self.x, self.y) def __eq__(self, other): return self.to_tuple() == other.to_tuple() def __h...
vfc_87855
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/889/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n0 5\n1 0\n2 3\n3 2\n4 6\n5 9\n6 1\n7 8\n8 4\n9 7\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n-7 6\n-16 11\n-9 -5\n3 4\n-8 12\n-17 6\n2 -1\n-5 15\n-7 4\n-6 -2\n...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/longest-palindrome-in-a-string3411/1
Solve the following coding problem using the programming language python: Given a string S, find the longest palindromic substring in S. Substring of string S: S[ i . . . . j ] where 0 ≤ i ≤ j < len(S). Palindrome string: A string that reads the same backward. More formally, S is a palindrome if reverse(S) = S. In cas...
```python class Solution: def longestPalin(self, s): n = len(s) r = s[::-1] if r == s: return s elif n == 1: return s for i in range(n, 0, -1): for j in range(n - i + 1): h = s[j:i + j] if h == h[::-1]: return h ```
vfc_87859
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/longest-palindrome-in-a-string3411/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"aaaabbaa\"", "output": "aabbaa", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"abc\"", "output": "a", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/VANDH
Solve the following coding problem using the programming language python: Chef built a binary string S that has exactly N hills and M valleys. A hill is any index 1 < i < |S| such that both its neighbors are strictly smaller than it, i.e, S_{i-1} < S_{i} and S_{i+1} < S_{i}. A valley is any index 1 < i < |S| such th...
```python def soln(n: int, m: int) -> int: if n >= m: great = '1' less = '0' else: great = '0' less = '1' s = less for i in range(min(n, m)): s += great + less if n == m: s += great print(len(s)) print(s) return for i in range(abs(n - m)): s += great + less * 2 print(len(s) - 1) print(s[:len...
vfc_87864
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/VANDH", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 2\n2 3\n3 3", "output": "7\n0101010\n7\n1010101\n8\n01010101", "type": "stdin_stdout" } ] }