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://www.hackerrank.com/challenges/symmetric-difference/problem
Solve the following coding problem using the programming language python: Objective Today, we're learning about a new data type: sets. Concept If the inputs are given on one line separated by a character (the delimiter), use split() to get the separate values in the form of a list. The delimiter is space (ascii ...
```python list1size = input() list1 = input().split() intlist1 = list(map(int, list1)) list2size = input() list2 = input().split() intlist2 = list(map(int, list2)) a = set(intlist1) b = set(intlist2) c = a ^ b lprint = sorted(c) for i in range(len(lprint)): print(lprint[i]) ```
vfc_141421
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/symmetric-difference/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 4 5 9\n4\n2 4 11 12\n", "output": "5\n9\n11\n12\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Subodhians are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which 1 is carried from one digit position to be added to the next - to be a significant challenge. Your job is to cou...
```python n=int(input()) s="" for i in range(0,n): s=input().split(" ") a=s[0] b=s[1] cnt=0 for j in range(0,len(a)): if((int(a[j])+int(b[j]))>9): cnt=cnt+1 if(cnt==0): print('No carry operation') elif(cnt==1): print(cnt,'carry operation') else: print(cnt,'carry operations') ```
vfc_141425
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5555555555 5555555555\n1111111111 1111111111\n5111111111 5111111111", "output": "No carry operation\n3 carry operations\n1 carry operation", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
taco
verifiable_code
https://codeforces.com/problemset/problem/266/C
Solve the following coding problem using the programming language python: You are given a square matrix consisting of n rows and n columns. We assume that the rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to n from left to right. Some cells (n - 1 cells in total) of the the matri...
```python import os from io import BytesIO, IOBase import sys def main(): n = int(input()) row = [0] * n col = [0] * n a = [[0 for j in range(n)] for i in range(n)] for i in range(n - 1): (x, y) = map(int, input().split()) row[x - 1] += 1 col[y - 1] += 1 a[x - 1][y - 1] = 1 ans = [] for i in range(n): ...
vfc_141429
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/266/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "15\n5 12\n4 5\n1 2\n1 5\n12 11\n11 14\n15 3\n7 2\n10 6\n3 10\n1 4\n9 9\n8 13\n11 5\n", "output": "21\n1 5 2\n2 12 1\n1 4 3\n2 5 2\n1 1 4\n2 5 3\n1 4 5\n1 12 6\n2 11 5\n1 11 7\n2 14 6\n1 15 8\n2 11 7\n1 11 9\n2 14 9\n1 1 11\n1...
taco
verifiable_code
https://codeforces.com/problemset/problem/381/A
Solve the following coding problem using the programming language python: Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can t...
```python def main(): n = int(input()) s = input().split(' ') r1 = 0 r2 = 0 t = 0 while len(s) != 0: temp = max((int(s[0]), int(s[len(s) - 1]))) i = 0 if temp == int(s[0]): i = 0 else: i = len(s) - 1 if t == 0: r1 += temp t = 1 else: r2 += temp t = 0 s.pop(i) print(r1, r2) main() ...
vfc_141433
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/381/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 1 2 10\n", "output": "12 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 2 3 4 5 6 7\n", "output": "16 12\n", "type": "stdin_stdout" }, { "fn_name": n...
taco
verifiable_code
https://www.codechef.com/COMT2020/problems/HELPTECH
Solve the following coding problem using the programming language python: Mr. Das is a teacher teaching for several years in a school. He is not computer savvy. Due to lockdown, now he has to take classes online. Recently he took an online exam for students of different classes. Now, he will call parents of all the st...
```python try: t = int(input()) for j in range(t): n = int(input()) x = [] p = [] m = [] for i in range(n): (X, P, M) = list(map(str, input().split())) x.append(X) p.append(int(P)) m.append(int(M)) avg = sum(m) / n for i in m: if i < avg: z = sorted([k for k in m if k < avg]) for...
vfc_141438
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COMT2020/problems/HELPTECH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\nRahul 1345964789 47\nRupendra 1457856987 58\nPriya 1478569820 45\n2\nTanuja 4310779415 97\nAkash 3689781245 43\n", "output": "Priya 1478569820 45\nRahul 1345964789 47\nAkash 3689781245 43\n", "type": "stdin_stdout...
taco
verifiable_code
Solve the following coding problem using the programming language python: Rahulis planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Darshit: one is black and the other is white. To make her happy, Darshit has to buy B number of black gifts and W number of whi...
```python T = eval(input()) for t in range(0,T): B,W = list(map(int,input().split())) X,Y,Z = list(map(int, input().split())) total=0 if(X<Y): total = total + X*B if(X+Z < Y): total = total + (X+Z)*W else: total = total + Y*W else : total = total + Y*W if(Y+Z < X): total = total + (Y+Z)*B else: total =...
vfc_141443
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n10 10\n1 1 1\n5 9\n2 3 4\n3 6\n9 1 1\n7 7\n4 2 1\n3 3\n1 9 2", "output": "20\n37\n12\n35\n12", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/arranging-the-array1131/1
Solve the following coding problem using the programming language python: You are given an array of size N. Rearrange the given array in-place such that all the negative numbers occur before all non-negative numbers. (Maintain the order of all -ve and non-negative numbers as given in the original array). Example 1: In...
```python def Rearrange(a, n): neg = 0 for i in range(n): if a[i] < 0: c = a.pop(i) a.insert(neg, c) neg += 1 return a ```
vfc_141447
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/arranging-the-array1131/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4\nArr[] = {-3, 3, -2, 2}", "output": "-3 -2 3 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4\nArr[] = {-3, 1, 0, -2}", "output": "-3 -2 1 0", "type": "stdin_stdout"...
taco
verifiable_code
https://www.codechef.com/problems/WATERCOOLER2
Solve the following coding problem using the programming language python: The summer is at its peak in Chefland. Chef is planning to purchase a water cooler to keep his room cool. He has two options available: Rent a cooler at the cost of X coins per month. Purchase a cooler for Y coins. Chef wonders what is the max...
```python for i in range(int(input())): (x, y) = map(int, input().split()) if x >= y: print(0) else: s = y // x if y % x == 0: s -= 1 print(s) ```
vfc_141448
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/WATERCOOLER2", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 12\n5 5", "output": "2\n0", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: The bloodiest battle of World War II has started. Germany and its allies have attacked the Soviet union army to gain control of the city of Stalingrad (now Volgograd) in the south-western Soviet Union.The war has become intensive and the soviet ...
```python def area(x1,y1,x2,y2,x3,y3): a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0 if a<0: a*=-1 return a o=[] t = eval(input()) for i in range(0,t): l = input() x1 = int(l.split()[0]) y1 = int(l.split()[1]) x2 = int(l.split()[2]) y2 = int(l.split()[3]) x3 = int(l.split()[4]) y3 = int(l.split()[5]) x4 = in...
vfc_141456
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n-1 0 1 0 0 1 3 3\n-5 0 5 0 0 5 1 0\n\n", "output": "OUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nINSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\nOUTSIDE\n...
taco
verifiable_code
https://www.codechef.com/problems/J7
Solve the following coding problem using the programming language python: Johnny needs to make a rectangular box for his physics class project. He has bought P cm of wire and S cm^{2} of special paper. He would like to use all the wire (for the 12 edges) and paper (for the 6 sides) to make the box. What is the largest...
```python for _ in range(int(input())): (p, s) = map(int, input().split()) y2 = (p - (p ** 2 - 4 * 6 * s) ** (1 / 2)) / 12 x2 = (s - 2 * y2 * y2) / (4 * y2) first = round(x2 * y2 * y2, 2) print(first) ```
vfc_141461
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/J7", "time_limit": "0.206667 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n20 14\n20 16", "output": "3.00\n4.15", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n20 14\n20 14", "output": "3.0\n3.0\n", "type": "stdin_stdout" }, { "fn_na...
taco
verifiable_code
https://codeforces.com/problemset/problem/1582/F1
Solve the following coding problem using the programming language python: This is an easier version of the problem with smaller constraints. Korney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, ...
```python import sys import math import random import heapq input = sys.stdin.readline def pow(a, n): if n == 0: return 1 x = pow(a, n // 2) if n % 2 == 0: return x * x else: return x * x * a def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a def bs(arr, le, ri): l = 0 arr.sort() r = len(arr)...
vfc_141465
{ "difficulty": "medium_hard", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1582/F1", "time_limit": "1.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 2 2 4\n", "output": "4\n0 2 4 6 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n1 0 1 7 12 5 3 2\n", "output": "12\n0 1 2 3 4 5 6 7 10 11 12 13 \n", "type": "stdin_std...
taco
verifiable_code
https://codeforces.com/problemset/problem/1219/C
Solve the following coding problem using the programming language python: Alice became interested in periods of integer numbers. We say positive $X$ integer number is periodic with length $L$ if there exists positive integer number $P$ with $L$ digits such that $X$ can be written as $PPPP…P$. For example: $X = 123123...
```python n = int(input()) s = input() ans = s[:n] if n == len(s): ans = list(ans) for i in range(n - 1, -1, -1): if ans[i] != '9': ans[i] = chr(ord(ans[i]) + 1) break else: ans[i] = chr(ord('0')) ans = ''.join(ans) print(ans) elif len(s) % n or ans == '9' * n: print(('1' + '0' * (n - 1)) * (len(s) //...
vfc_141469
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1219/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n123456\n", "output": "124124\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/831/E
Solve the following coding problem using the programming language python: Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the same integers on them. Vasily decided to sort the cards. To do...
```python import sys fin = sys.stdin fout = sys.stdout n = int(fin.readline()) a = list(map(int, fin.readline().split())) def solution(n, a): sorted_arr = [(i, elem) for (i, elem) in enumerate(a)] sorted_arr.sort(key=lambda x: (x[1], x[0])) sorted_indexes = [x[0] for x in sorted_arr] cnt = 0 current_n = n prev_i...
vfc_141473
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/831/E", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "87\n12 2 2 10 12 1 5 9 15 2 4 7 7 14 8 10 1 6 7 6 13 15 10 6 2 11 13 1 15 14 8 8 4 7 11 12 3 15 9 2 13 1 7 11 2 1 13 11 8 14 2 2 12 7 13 4 13 3 13 3 11 1 7 13 15 8 12 4 12 4 1 4 9 3 13 12 10 15 14 10 7 7 7 2 7 6 10\n", "outpu...
taco
verifiable_code
https://www.codechef.com/problems/DEVSPORTS
Solve the following coding problem using the programming language python: Recently, Devendra went to Goa with his friends. Devendra is well known for not following a budget. He had Rs. Z at the start of the trip and has already spent Rs. Y on the trip. There are three kinds of water sports one can enjoy, with prices ...
```python t = int(input()) for i in range(t): (z, y, a, b, c) = map(int, input().split()) left = z - y if a + b + c <= left: print('YES') else: print('NO') ```
vfc_141478
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DEVSPORTS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n25000 22000 1000 1500 700\n10000 7000 100 300 500\n15000 5000 2000 5000 3000", "output": "NO\nYES\nYES", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/158/A
Solve the following coding problem using the programming language python: "Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules. A total of n participants took part in ...
```python (x, y) = map(int, input().split()) z = list(map(int, input().split())) i = 0 count = 0 for i in range(0, x): if z[i] > 0: if z[i] >= z[y - 1]: count = count + 1 print(count) ```
vfc_141483
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/158/A", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 3\n10 9 8 7 7 7 5 5\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 7\n10 9 8 7 7 7 5 5\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/next-optimal-move-in-tic-tac-toe2842/1
Solve the following coding problem using the programming language python: You are given a middle game situation of the game Tic Tac Toe. It is given that it is player "X's" turn and you need to give to most optimal position for the turn. The situation is given as a 3 x 3 character matrix board. '_' refers to the place...
```python import math class Solution: def findBestMove(self, board): tup = self.minimax(True, board, 1)[1] return (str(tup[0]), str(tup[1])) def minimax(self, is_max, board, depth): score = self.evaluate(board) moves = self.getMoves(board) if len(moves) == 0 or score != 0: return (0 if score == 0 else...
vfc_141487
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/next-optimal-move-in-tic-tac-toe2842/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "board = {{o, _, _}, \n {_, _, _}, \n {_, _, _}}", "output": "1 1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/180/D
Solve the following coding problem using the programming language python: Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner. Two young parents abac and bbad think what name to give to their first-born child. They de...
```python def findmin(lcopy, toexceed): toex = ord(toexceed) - 97 for each in lcopy[toex + 1:]: if each > 0: return True return False def arrange(lcopy, toexceed=None): if toexceed is None: ans = '' for i in range(26): ans += chr(i + 97) * lcopy[i] return ans ans = '' for i in range(ord(toexceed) -...
vfc_141488
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/180/D", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "z\na\n", "output": "z\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abc\naaac\n", "output": "abc\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
taco
verifiable_code
Solve the following coding problem using the programming language python: Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. With her previous research, foxes in the forest are k...
```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 = [(0, -1), (1, 0), (0, 1), (-1, 0)] ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), ...
vfc_141500
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1 4\n2 2 3", "output": "7 / 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1 3\n2 2 3", "output": "6 / 1\n", "type": "stdin_stdout" }, { "fn_name": n...
taco
verifiable_code
Solve the following coding problem using the programming language python: Shil has an array of N elements A1 , A2, ... ,AN . He also has an integer K. He wants to find out value of Square Sum for every i from 1 to N-K+1. The value of Square Sum for certain i is defined as Σ1≤ j ≤ K (j^2 Ai+j-1). Input: First line of...
```python [N, K] = list(map(int, input().split())) A = list(map(int, input().split())) modN = 10**9+7 S_1 = 0 S_2 = 0 S_3 = 0 for i in range(0, K): S_3 = (S_3 + A[i]) % modN S_2 = (S_2 + (i+1) * A[i]) % modN S_1 = (S_1 + (i+1)**2 * A[i]) % modN output = [] output.append(S_1) for i in range(0, N-K): S_1 = (S_1 + ...
vfc_141506
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000 20\n8496 30761 3421 473 16593 17555 30078 29591 13937 10077 5470 383 29018 16639 161 20859 7517 30038 5571 27104 520 7681 30452 5875 25120 15372 1318 18860 28491 27851 4452 21434 9740 9737 14437 9414 9716 32099 7265 27900 2306...
taco
verifiable_code
https://codeforces.com/problemset/problem/1427/A
Solve the following coding problem using the programming language python: You are given an array of $n$ integers $a_1,a_2,\dots,a_n$. You have to create an array of $n$ integers $b_1,b_2,\dots,b_n$ such that: The array $b$ is a rearrangement of the array $a$, that is, it contains the same values and each value appe...
```python t = int(input()) for i in range(t): n = int(input()) lst = list(map(int, input().split())) sums = sum(lst) if sums == 0: print('NO') else: print('YES') if sums < 0: lst.sort() for j in lst: print(j, end=' ') print() elif sums > 0: lst.sort(reverse=True) for j in lst: print(...
vfc_141511
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1427/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n1 -2 3 -4\n3\n0 0 0\n5\n1 -1 1 -1 1\n6\n40 -31 -9 0 13 -40\n", "output": "YES\n1 -2 3 -4\nNO\nYES\n1 1 -1 1 -1\nYES\n-40 13 40 0 -9 -31\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
taco
verifiable_code
https://www.hackerrank.com/challenges/poker-nim-1/problem
Solve the following coding problem using the programming language python: Poker Nim is another $2$-player game that's a simple variation on a Nim game. The rules of the games are as follows: The game starts with $n$ piles of chips indexed from $\mbox{0}$ to $n-1$. Each pile $\boldsymbol{i}$ (where $0\leq i<n$) has $c...
```python test = int(input()) for _ in range(test): (n, pile) = map(int, input().strip().split()) ar = list(map(int, input().strip().split())) xor = 0 for n in ar: xor = xor ^ n if xor == 0: print('Second') else: print('First') ```
vfc_141515
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/poker-nim-1/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 5\n1 2\n3 5\n2 1 3\n", "output": "First\nSecond\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: problem JOI City will hold a large-scale exposition. There are two themes for this exposition, and each of the N exhibition facilities in JOI City will exhibit on one of the two themes. The location of the facility is represented by plane coo...
```python import sys from sys import stdin input = stdin.readline (x, y) = ([], []) n = int(input()) for i in range(n): (a, b) = map(int, input().split()) x.append(a + b) y.append(a - b) (xmin, xmax) = (min(x), max(x)) (ymin, ymax) = (min(y), max(y)) ans1 = ans2 = 0 for i in range(n): d1 = max(x[i] - xmin, y[i] - y...
vfc_141519
{ "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": "5\n-1 0\n1 0\n-1 -2\n0 1\n-1 1", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n-2 0\n1 0\n0 -2\n0 2\n-1 1", "output": "4\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://www.codechef.com/problems/CLPERM
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian. Today is Chef's birthday. His mom gifted him a truly lovable gift, a permutation of first N positive integers. She placed the permutation on a very long table in front of Chef and lef...
```python def nsum(a, b): n1 = b * (b - 1) // 2 - a * (a + 1) // 2 return n1 test = int(input()) for it in range(test): broken = False brokenAt = None tolook = 0 (n, k) = [int(x) for x in input().strip().split()] if k != 0: lost = [int(x) for x in input().strip().split()] lost.sort() if lost[0] in (1, 2): ...
vfc_141525
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CLPERM", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 2\n3 5\n5 1\n1", "output": "Mom\nChef", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 2\n3 5\n7 1\n1", "output": "Mom\nChef\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
Solve the following coding problem using the programming language python: All the students in NIT are very lazy. They want to have maximum time for rest. But due to college rules, they must maintain 75% attendance at the end of every week. Given the schedule of a week, tell them what is the maximum amount of time the...
```python from math import ceil tt = 24 * 60 * 60 * 7 for _ in range(int(input())): tc = 0 cl = [] for __ in range(7): a = list(map(int, input().split())) dc = a[0] tc += dc for i in range(1, dc*2, 2): cl.append(a[i+1] - a[i]) cl.sort() tc = int(ceil(tc*3/4.0)) print(tt - sum(cl[:tc])) ```
vfc_141529
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n282 107 272 291 298 307 503 533 534 546 548 672 758 832 892 976 1025 1065 1112 1303 1324 1422 1427 1444 1480 1546 1629 1665 1746 1760 1843 1873 1902 1910 2003 2097 2176 2181 2257 2282 2311 2340 2384 2489 2634 2935 2968 3052 306...
taco
verifiable_code
https://codeforces.com/problemset/problem/1040/B
Solve the following coding problem using the programming language python: Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over. This time Miroslav laid out $n$ skewers parallel to each other, and e...
```python (n, k) = map(int, input().split()) g = k k = 2 * k + 1 if n % k == 0: d = n // k else: d = n // k + 1 a = [0] * d s = d * k - n if g - s < 0: a[0] = 1 else: a[0] = g - s + 1 for i in range(1, d): a[i] = a[i - 1] + k print(d) print(*a, sep=' ') ```
vfc_141533
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1040/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2\n", "output": "2\n1 6 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n", "output": "2\n1 4 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1261/E
Solve the following coding problem using the programming language python: You are given an integer array a_1, a_2, ..., a_n, where a_i represents the number of blocks at the i-th position. It is guaranteed that 1 ≤ a_i ≤ n. In one operation you can choose a subset of indices of the given array and remove one block i...
```python n = int(input()) (v, c) = (list([[0, 0]]), list()) z = ['0' for i in range(n)] for (i, x) in enumerate(input().split()): v.append([int(x), i]) v.sort(reverse=True) def S_N_U_F_F(z, v, c): (y, k, x, count) = (-1, 0, len(v) - 1, len(v) - 1) while v[0][0] != 0: if k > 0 and k < len(v) - 1: z[v[y + k][1]...
vfc_141538
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1261/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 1 1 1 1 1 1\n", "output": "8\n1000000\n0100000\n0010000\n0001000\n0000100\n0000010\n0000001\n0000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1\n", "output": "3\n10\...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/minimum-difference-pair5444/1
Solve the following coding problem using the programming language python: Given an unsorted array, find the minimum difference between any pair in given array. Example 1: Input: nums = [2, 4, 5, 9, 7] Output: 1 Explanation: Difference between 5 and 4 is 1. Example 2: Input: nums = [3, 10, 8, 6] Output: 2 Explanation...
```python class Solution: def minimum_difference(self, nums): nums.sort() ans = float('inf') for i in range(len(nums) - 1): ans = min(ans, abs(nums[i] - nums[i + 1])) return ans ```
vfc_141546
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/minimum-difference-pair5444/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "nums = [2, 4, 5, 9, 7]", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/class-1-dealing-with-complex-numbers/problem
Solve the following coding problem using the programming language python: =====Problem Statement===== For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations. The real and imaginary precision part should be ...
```python import math class ComplexNumber(object): def __init__(self, real, compl): self.real = real self.compl = compl pass def __str__(self): if self.compl >= 0: return '{0:.2f}'.format(self.real) + '+' + '{0:.2f}'.format(self.compl) + 'i' return '{0:.2f}'.format(self.real) + '-' + '{0:.2f}'.format(...
vfc_141548
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/class-1-dealing-with-complex-numbers/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n5 6", "output": "7.00+7.00i\n-3.00-5.00i\n4.00+17.00i\n0.26-0.11i\n2.24+0.00i\n7.81+0.00i", "type": "stdin_stdout" }, { "fn_name": null, "input": "5.9 6\n9 10", "output": "14.90+16.00i\n-3...
taco
verifiable_code
https://codeforces.com/problemset/problem/1606/A
Solve the following coding problem using the programming language python: You are given a string $s$ of length $n$ consisting of characters a and/or b. Let $\operatorname{AB}(s)$ be the number of occurrences of string ab in $s$ as a substring. Analogically, $\operatorname{BA}(s)$ is the number of occurrences of ba in...
```python for _ in range(int(input())): s = input() n = len(s) ab = 0 ba = 0 for i in range(n - 1): if s[i] == 'a' and s[i + 1] == 'b': ab += 1 elif s[i] == 'b' and s[i + 1] == 'a': ba += 1 if ab == ba: print(s) elif s[0] == 'a': print('b' + s[1:]) else: print('a' + s[1:]) ```
vfc_141550
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1606/A", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nb\naabbbabaa\nabbb\nabbaab\n", "output": "b\naabbbabaa\nbbbb\nbbbaab\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\naaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbab\n", "output": "b...
taco
verifiable_code
https://codeforces.com/problemset/problem/1372/C
Solve the following coding problem using the programming language python: Patrick likes to play baseball, but sometimes he will spend so many hours hitting home runs that his mind starts to get foggy! Patrick is sure that his scores across $n$ sessions follow the identity permutation (ie. in the first game he scores $...
```python import math as mt for x in range(int(input())): n = int(input()) l = list(map(int, input().split())) ans = 0 tmp = -1 flag = 1 for i in range(n): if l[i] != i + 1: ans += 1 if tmp != -1 and i > tmp + 1: flag = 0 tmp = i if ans == 0: print(0) else: print(2 - flag) ```
vfc_141554
{ "difficulty": "medium", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1372/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 2 3 4 5\n7\n3 2 4 5 1 6 7\n", "output": "0\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n6\n1 5 3 4 2 6\n6\n5 1 3 4 2 6\n6\n1 5 3 4 6 2\n6\n5 1 3 4 6 2\n", "output": ...
taco
verifiable_code
https://codeforces.com/problemset/problem/659/B
Solve the following coding problem using the programming language python: Very soon Berland will hold a School Team Programming Olympiad. From each of the m Berland regions a team of two people is invited to participate in the olympiad. The qualifying contest to form teams was held and it was attended by n Berland stu...
```python def STR(): return list(input()) def INT(): return int(input()) def MAP(): return map(int, input().split()) def MAP2(): return map(float, input().split()) def LIST(): return list(map(int, input().split())) def STRING(): return input() import string import sys from heapq import heappop, heappush from...
vfc_141558
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/659/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\nIvanov 1 763\nAndreev 2 800\nPetrov 1 595\nSidorov 1 790\nSemenov 2 503\n", "output": "Sidorov Ivanov\nAndreev Semenov\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\nIvanov 1 80...
taco
verifiable_code
https://www.hackerrank.com/challenges/dortmund-dilemma/problem
Solve the following coding problem using the programming language python: Borussia Dortmund are a famous football ( soccer ) club from Germany. Apart from their fast-paced style of playing, the thing that makes them unique is the hard to pronounce names of their players ( błaszczykowski , papastathopoulos , großkreutz...
```python import math MODULO = 10 ** 9 + 9 MAXN = 10 ** 5 + 5 def plus(x, y): return (x + y) % MODULO def minus(x, y): return (x - y) % MODULO def times(x, y): return x * y % MODULO def power(x, y): return pow(x, y, MODULO) def nCr(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))...
vfc_141566
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/dortmund-dilemma/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n2 1\n4 2\n", "output": "0 \n26 \n2600 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 \n2 2\n5 1\n3 2\n6 2\n1 3\n", "output": "0\n26\n650\n13650\n0\n", "type": "s...
taco
verifiable_code
Solve the following coding problem using the programming language python: Manu is a very bright student and had learned c++ Programming on her own.She has covered loops and if/else.She is a very inquisitive child and always love to discover new things.Same applies to programming she learns various syntax.One day while...
```python t = int(input()) def prob(n,k): norig = n p = 1.0 while k>0: p *= (float(n)/norig) n-=1 k -=1 return p for T in range(t): (k,n) = tuple(map(int, (str(input()).split(' ')))) print(("%.9f"%(1-prob(n,k)))) ```
vfc_141570
{ "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\n17 277\n35 390\n37 682\n12 133\n43 991\n37 381\n29 865\n32 1084\n23 352\n7 210\n16 245\n54 558\n57 1062\n5 451\n2 233\n17 445\n69 691\n38 823\n103 1071\n62 976\n28 955\n2 136\n51 670\n18 578\n40 984\n14 398\n11 447\n10 753\n5...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/minimum-sum-of-factors5829/1
Solve the following coding problem using the programming language python: Given a number N.Find the minimum sum of its factors. Example 1: Input: N=10 Output: 7 Explanation: There are two ways to factories N, which are 10=1*10(sum=10+1=11) 10=2*5(sum=2+5=7) Thus, the answer is 7. Example 2: Input: N=12 Output: 7 Expla...
```python class Solution: def sumOfFactors(self, N): if N <= 2: return 1 p = N k = int(N ** 0.5) s = 0 for i in range(2, k + 1): while N % i == 0: s += i N = N // i if s == 0: return p + 1 if N != 1: return s + N return s ```
vfc_141574
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/minimum-sum-of-factors5829/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N=10", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "input": "N=12", "output": "7", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1368/C
Solve the following coding problem using the programming language python: Leo Jr. draws pictures in his notebook with checkered sheets (that is, each sheet has a regular square grid printed on it). We can assume that the sheets are infinitely large in any direction. To draw a picture, Leo Jr. colors some of the cells...
```python from os import path import sys from functools import cmp_to_key as ctk from collections import deque, defaultdict as dd from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right from itertools import permutations from datetime import datetime from math import ceil, sqrt, log, gcd...
vfc_141575
{ "difficulty": "medium", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1368/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "16\n0 0\n0 1\n1 0\n1 1\n1 2\n2 1\n2 2\n2 3\n3 2\n3 3\n3 4\n4 3\n4 4\n4 5\n5 4\n5 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "7\n0 0\n0 1\n1 0\...
taco
verifiable_code
https://codeforces.com/problemset/problem/1113/B
Solve the following coding problem using the programming language python: One day Sasha visited the farmer 2D and his famous magnetic farm. On this farm, the crop grows due to the influence of a special magnetic field. Maintaining of the magnetic field is provided by $n$ machines, and the power of the $i$-th machine i...
```python import math def deli(x): b = [] for i in range(2, x // 2 + 6): if x % i == 0: b.append(i) b.append(x) return b n = int(input()) a = list(map(int, input().split())) a.sort() mini = min(a) ans = 0 for i in range(n): if a[i] != mini: c = deli(a[i]) for j in c: fr = mini + a[i] tec = mini * j...
vfc_141579
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1113/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n4 2 4 4\n", "output": "14\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1153/A
Solve the following coding problem using the programming language python: It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor litt...
```python I = lambda : map(int, input().split()) (n, t) = I() T = [] for _ in range(n): (s, d) = I() s -= t T.append(s % d if s < 0 else s) print(T.index(min(T)) + 1) ```
vfc_141588
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1153/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n6 4\n9 5\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n3 3\n2 5\n5 6\n4 9\n6 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_n...
taco
verifiable_code
https://codeforces.com/problemset/problem/1331/D
Solve the following coding problem using the programming language python: -----Input----- The only line of the input contains a 7-digit hexadecimal number. The first "digit" of the number is letter A, the rest of the "digits" are decimal digits 0-9. -----Output----- Output a single integer. -----Examples----- In...
```python s = input() if int(s[-1]) % 2 == 0: print('0') else: print('1') ```
vfc_141596
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1331/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A278832\n", "output": "", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Description IIT Gandhinagar has a strong policy against plagiarism. The institute decides to develop a program that measures how different two texts are from each other. Suppose there are two text strings A and B, the program should be able to c...
```python def editDistance(str1, str2, m, n): dp = [[0 for x in range(n+1)] for x in range(m+1)] for i in range(m+1): for j in range(n+1): if i == 0: dp[i][j] = j elif j == 0: dp[i][j] = i elif str1[i-1] == str2[j-1]: dp[i][j] = dp[i-1][j-1] else: dp[i][j] = 1 + min(dp[i][j-1],dp[i-1...
vfc_141601
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abcdef\nghijkl", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "the os module provides dozens of functions for interacting with the operating system\nfor interaction with the ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Hit n nails one by one at the coordinates P1 (x1, y1), P2 (x2, y2), P3 (x3, y3), ..., Pn (xn, yn) on the flat plate, and put them on the rubber band ring. Surround it with a single rubber band so that all the nails fit inside. At this time, the ...
```python def cross(a, b): return a.real * b.imag - a.imag * b.real def convex_hull(p): pp = sorted(p, key=lambda x: (x.imag, x.real)) n = len(pp) (ans, j) = ([0] * (n + 1), 0) for i in range(n): while j > 1 and cross(ans[j - 1] - ans[j - 2], pp[i] - ans[j - 1]) < 0: j -= 1 ans[j] = pp[i] j += 1 k = j ...
vfc_141605
{ "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": "4\n1.0,0.0\n0.0,1.0\n2.0,1.0\n1.0,2.0\n9\n-509.94,892.63\n567.62,639.99\n-859.32,-64.84\n-445.99,383.96\n667.54,430.49\n551.12,828.21\n-940.2,-877.2\n-361.62,-970\n-125.42,-178.48\n0", "output": "0\n3\n", "type": "stdin...
taco
verifiable_code
Solve the following coding problem using the programming language python: Ashima's mid term exams are just over. Since, its raining heavily outside, she can't go shopping. So, she and her best friend Aishwarya have now decided to chill out by eating pizza, chocolates, biscuits, etc.. and playing some indoor games. The...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' loop=eval(input()) d=[] for i in range(0,loop): a=input().split() a=list(map(int, a)) b=a.index(max(a)) if (a[0]%2==0 and a[1]%2==0 and a[2]%2==0): d.append('Aishwarya')...
vfc_141609
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10000\n51 65 30\n9 3 92\n44 99 18\n13 84 84\n25 8 31\n20 16 35\n68 1 70\n12 81 96\n100 65 32\n15 6 30\n51 93 1\n9 14 44\n56 96 14\n92 74 74\n90 59 26\n93 18 0\n46 33 87\n78 92 19\n11 28 61\n23 45 43\n49 12 1\n20 0 92\n6 82 36\n65 6...
taco
verifiable_code
https://www.codechef.com/problems/DIVGAME
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian as well. Mike and his friend Tom are playing a very interesting game right now. Here is the description of the game: Initially, there is a positive integer N written on the desk, whic...
```python def div(x): if x == 16 or x == 34 or x == 289: return 'Tom' elif x == 17 or x & 1 == 0: return 'Mike' else: t = int(x ** 0.5) for i in range(3, t + 1, 2): if x % i == 0: return 'Mike' return 'Tom' for v in range(int(input())): x = int(input()) print(div(x)) ```
vfc_141613
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DIVGAME", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 \n5 \n3 \n2 \n4", "output": "Tom\nTom\nMike\nMike", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/APPLORNG
Solve the following coding problem using the programming language python: Bob has X rupees and goes to a market. The cost of apples is Rs. A per kg and the cost of oranges is Rs. B per kg. Determine whether he can buy at least 1 kg each of apples and oranges. ------ Input Format ------ - The first line of input wi...
```python m = int(input()) (a, b) = map(int, input().split(' ')) if a + b <= m: print('Yes') else: print('No') ```
vfc_141617
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/APPLORNG", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "14 \n2 2", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 \n1 1", "output": "No", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/penalty-shooters4238/1
Solve the following coding problem using the programming language python: Geek and Nerd are strikers playing football with their friend the Goalie. Their energies are denoted by X,Y and Z respectively. Strikers can only score a goal if the Goalie's energy is a factor of their energy. For every goal scored the energy ...
```python class Solution: def goals(self, X, Y, Z): c1 = 0 c2 = 0 while Z > 1: if X % Z == 0: c1 += 1 X -= 1 if Y % Z == 0: c2 += 1 Y -= 1 else: Z -= 1 val = [c1, c2] return val ```
vfc_141621
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/penalty-shooters4238/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "X = 4, Y = 9, Z = 5", "output": "3 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "X = 13, Y = 10, Z = 7", "output": "0 3", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: See Russian Translation W.T.H.S.E.C Confused? Well it stands for Welcome To HackerEarth September Easy Challenge :). It's quite amazing when long words like this get reduced to such a short string. They sound pretty cool and often make the cha...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' m=[] for i in range(eval(input())): m.append(input()) f=input() p=list(map(str,input().split())) p=list(p) k=[x for x in p if x not in m] o=[] for i in k: if(i>len(k)): a...
vfc_141623
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nharsh\n1\nranjan", "output": "Q.T.A.B.Q.M.O.E.S.F.Q", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\nhey\nall\ni\nam\nfine\nwassup\nyou\n8\nhey all i am fine wassup you two", "out...
taco
verifiable_code
https://codeforces.com/problemset/problem/166/B
Solve the following coding problem using the programming language python: You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches. The vertices of both p...
```python def convex_hull(points): points = sorted(set(points)) if len(points) <= 1: return points def cross(o, a, b): return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) lower = [] for p in points: while len(lower) >= 2 and cross(lower[-2], lower[-1], p) < 0: lower.pop() lower.append(...
vfc_141627
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/166/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n-1000000000 1000000000\n1000000000 0\n1000 -1000000000\n3\n1000 -999999999\n1000 0\n1001 0\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 3\n3 0\n0 -3\n-3 0\n4\...
taco
verifiable_code
https://codeforces.com/problemset/problem/810/B
Solve the following coding problem using the programming language python: Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant. Shop, where Noora...
```python (n, f) = map(int, input().split()) tally = [] for i in range(n): (a, b) = map(int, input().split()) tally.append([a, b]) diff = [] total = 0 for i in range(n): total += min(tally[i][1], tally[i][0]) diff.append(min(2 * tally[i][0], tally[i][1]) - min(tally[i][1], tally[i][0])) diff.sort() for i in range(f...
vfc_141635
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/810/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n2 1\n3 5\n2 3\n1 5\n", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1\n0 2\n0 3\n3 5\n0 6\n", "output": "5", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/AVG
Solve the following coding problem using the programming language python: Chef had a sequence of positive integers with length $N + K$. He managed to calculate the arithmetic average of all elements of this sequence (let's denote it by $V$), but then, his little brother deleted $K$ elements from it. All deleted elemen...
```python test = int(input()) for _ in range(test): (n, k, v) = tuple(map(int, input().split())) nlist = list(map(int, input().split())) sumOfList = sum(nlist) result = (v * (n + k) - sumOfList) / k if result > 0 and result % 1 == 0: print(int(result)) else: print(-1) ```
vfc_141639
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/AVG", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3 4\n2 7 3\n3 1 4\n7 6 5\n3 3 4\n2 8 3\n", "output": "4\n-1\n-1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/383/A
Solve the following coding problem using the programming language python: Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows ...
```python from collections import * from itertools import accumulate def arr_sum(arr): arr.appendleft(0) return list(accumulate(arr, lambda x, y: x + y)) def solve(): (ans1, ans0) = (0, 0) for i in range(n): if a[i]: ans1 += n - (i + 1) - (mem[-1] - mem[i + 1]) else: ans0 += mem[i] return min(ans0, ans...
vfc_141643
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/383/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0 1 0\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 0 1 0 1\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
taco
verifiable_code
https://codeforces.com/problemset/problem/647/B
Solve the following coding problem using the programming language python: Карта звёздного неба представляет собой прямоугольное поле, состоящее из n строк по m символов в каждой строке. Каждый символ — это либо «.» (означает пустой участок неба), либо «*» (означает то, что в этом месте на небе есть звезда). Новое из...
```python (n, m) = input().split() n = int(n) m = int(m) a = [] N = n for i in range(n): a.append(input().split()) for i in range(n): if a[i][0].find('*') == -1: n -= 1 else: break if n != 1: for i in range(len(a) - 1, -1, -1): if a[i][0].find('*') == -1: n -= 1 else: break M = m br = 0 for i in range...
vfc_141656
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/647/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n....\n..*.\n...*\n..**\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3\n*.*\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": ...
taco
verifiable_code
Solve the following coding problem using the programming language python: You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task. The space station is made up with a number of units, ...
```python import math class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y:...
vfc_141662
{ "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": "3\n10.000 10.000 50.000 10.000\n40.000 10.000 50.9661040800581 10.000\n40.000 40.000 50.000 10.000\n2\n30.000 30.000 30.000 20.000\n40.000 40.000 40.000 20.000\n5\n5.729 15.143 3.996 25.837\n6.013 14.372 4.818 10.671\n80.115 63.292...
taco
verifiable_code
https://www.hackerrank.com/challenges/2s-complement/problem
Solve the following coding problem using the programming language python: Understanding $2$'s complement representation is fundamental to learning about Computer Science. It allows us to write negative numbers in binary. The leftmost digit is used as a sign bit. If it is $1$, we have a negative number and it is repr...
```python t = int(input()) def gen(num): if num == '': return 0 elif num == '1': return 1 elif num == '0': return 0 elif num[0] == '0': return gen(num[1:]) else: return int(num[1:], 2) + 1 + gen(num[1:]) + 2 ** (len(num) - 2) * (len(num) - 1) def func(a, b): if a < 0 and b >= 0: if a + b + 1 == 0: ...
vfc_141666
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/2s-complement/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n-2 0\n-3 4\n-1 4\n", "output": "63\n99\n37\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n-5 0\n1 7\n-6 -3\n3 6\n", "output": "155\n12\n122\n7\n", "type": "stdin_stdout"...
taco
verifiable_code
https://www.codechef.com/problems/BALLCOL
Solve the following coding problem using the programming language python: There are $n$ red balls kept on the positive $X$ axis, and $m$ blue balls kept on the positive $Y$ axis. You are given the positions of the balls. For each $i$ from $1$ to $n$, the $i$-th red ball has the coordinates $(x_i, 0)$, where $x_i$ is a...
```python import sys (n, m) = map(int, input().split()) red = [] for i in range(n): (a, b) = map(int, input().split()) red.append(a * b) d = {} for i in range(m): (a, b) = map(int, input().split()) p = a * b if p in d: d[p] += 1 else: d[p] = 1 an = 0 for i in range(n): if red[i] in d and d[red[i]] > 0: an ...
vfc_141670
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BALLCOL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n1 2\n2 1\n\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n1 2\n2 1\n1 2\n\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Differential pulse code modulation is one of the compression methods mainly used when compressing audio signals. The audio signal is treated as an integer sequence (impulse sequence) on the computer. The integer sequence is a sample of the inpu...
```python def solve(): from sys import stdin INF = float('inf') f_i = stdin while True: (N, M) = map(int, f_i.readline().split()) if N == 0: break C = tuple((int(f_i.readline()) for i in range(M))) tbl_1 = tuple((tuple((255 if i + c > 255 else 0 if i + c < 0 else i + c for c in C)) for i in range(256))) ...
vfc_141675
{ "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": "2 7\n4\n2\n1\n0\n-1\n-2\n-4\n131\n137\n2 7\n4\n2\n1\n0\n-1\n-2\n-4\n124\n123\n10 7\n-4\n-2\n-1\n0\n1\n2\n4\n132\n134\n135\n134\n132\n128\n124\n122\n121\n122\n5 1\n255\n0\n0\n0\n0\n0\n4 1\n0\n255\n0\n255\n0\n0 0", "output": "2...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-minimum-s-t-cut-in-a-flow-network2902/1
Solve the following coding problem using the programming language python: Given a weighted graph of N vertices numbered from 0 to N-1 in the form of adjacency matrix A[ ][ ] and two integers S denoting the number of source vertex and T denoting the number of sink vertex. The task is to find minimum capacity s-t cut of...
```python from collections import defaultdict, deque import copy class Graph: def __init__(self, graph): self.graph = graph self.org_graph = [i[:] for i in graph] self.ROW = len(graph) self.COL = len(graph[0]) def BFS(self, s, t, parent): visited = [False] * self.ROW queue = [] queue.append(s) visi...
vfc_141679
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-minimum-s-t-cut-in-a-flow-network2902/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 2\nA[][] = [[0, 3],\n [0, 0]]\nS = 0\nT = 1", "output": "0 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5\nA[][] = [[0, 0, 0, 0, 0],\n [0, 0, 2, 3, 0],\n ...
taco
verifiable_code
https://www.codechef.com/problems/P7SWAPS
Solve the following coding problem using the programming language python: Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. A permutation is an array consisting of $N$ distinct integers from $1$ to $N$ in arbitrary order. Chef has two permutation arrays $A$ and $P$ of len...
```python def get_value(k, ind, cycles, cycle, index_in_cycle): m = len(cycles[cycle[ind]]) return cycles[cycle[ind]][index_in_cycle[ind] - k % m] - 1 def determine_cycles(p, n, cycles): visited = [False] * n i = 1 while i <= n: if not visited[i - 1]: visited[i - 1] = True cycles.append([i]) j = p[i - ...
vfc_141680
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/P7SWAPS", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n 3\n 1 2 3\n 2 3 1\n 3\n 1\n 2 2 3\n 3 1", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/KBIGNUMB
Solve the following coding problem using the programming language python: Eugene has to do his homework. But today, he is feeling very lazy and wants to you do his homework. His homework has the following given maths problem. You are given three integers: A, N, M. You write the number A appended to itself N times in a...
```python for _ in range(int(input())): (a, n, m) = map(int, input().split(' ')) s = len(str(a)) c = 10 ** s - 1 w = c * m b = pow(10, n * s, w) - 1 d = b // c ans = d % m * (a % m) print(ans % m) ```
vfc_141689
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/KBIGNUMB", "time_limit": "4 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n12 2 17\n523 3 11\n\n\n", "output": "5\n6\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/761/A
Solve the following coding problem using the programming language python: On her way to programming school tiger Dasha faced her first test — a huge staircase! [Image] The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with...
```python (a, b) = map(int, input().split()) print('YES' if abs(a - b) < 2 and a + b > 0 else 'NO') ```
vfc_141698
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/761/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n", "output": "NO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1584/B
Solve the following coding problem using the programming language python: David was given a red checkered rectangle of size $n \times m$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as man...
```python T = int(input()) for case in range(T): (n, m) = map(int, input().split()) s = n * m if s % 3 == 2: res = s // 3 + 1 else: res = s // 3 + s % 3 print(res) ```
vfc_141702
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1584/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3\n2 2\n2 5\n3 5\n", "output": "1\n2\n4\n5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/AMR15ROL/problems/AMR15D
Solve the following coding problem using the programming language python: Bhallaladeva was an evil king who ruled the kingdom of Maahishmati. He wanted to erect a 100ft golden statue of himself and he looted gold from several places for this. He even looted his own people, by using the following unfair strategy: There...
```python import math n = int(input()) a = sorted(map(int, input().split())) l = [0] * n for i in range(n): l[i] = a[i] + l[i - 1] for q in range(int(input())): print(l[int(math.ceil(float(n) / (int(input()) + 1))) - 1]) ```
vfc_141707
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AMR15ROL/problems/AMR15D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 2 1 4\n2\n0\n2\n", "output": "10\n3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/75/C
Solve the following coding problem using the programming language python: Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers. A common divisor for two positive numbers is a number which both numbers are di...
```python import math from sys import * from bisect import bisect_right input = stdin.readline print = stdout.write (a, b) = map(int, input().split()) n = int(input()) gcd = math.gcd(a, b) factors = [] i = 1 while i * i <= gcd: if gcd % i == 0: factors.append(gcd // i) if i * i != gcd: factors.append(gcd // (gc...
vfc_141715
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/75/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "90 100\n8\n55 75\n46 68\n44 60\n32 71\n43 75\n23 79\n47 86\n11 57\n", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "48 72\n2\n8 29\n29 37\n", ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/smallest-subarray-with-sum-greater-than-x5651/1
Solve the following coding problem using the programming language python: Given an array of integers (A[]) and a number x, find the smallest subarray with sum greater than the given value. If such a subarray do not exist return 0 in that case. Note: The answer always exists. It is guaranteed that x doesn't exceed the...
```python class Solution: def smallestSubWithSum(self, a, n, x): start = 0 end = 1 s = a[start] ans = n + 1 if s > x: return 1 if end < n: s += a[end] while start < n and end < n: if s > x: ans = min(ans, end - start + 1) s -= a[start] start += 1 else: end += 1 if end < n...
vfc_141719
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/smallest-subarray-with-sum-greater-than-x5651/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A[] = {1, 4, 45, 6, 0, 19}\nx = 51", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "A[] = {1, 10, 5, 2, 7}\n x = 9", "output": "1", "type": "stdin_stdout" ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/min-subsets-with-consecutive-numbers0601/1
Solve the following coding problem using the programming language python: Given an array of distinct positive numbers, the task is to calculate the minimum number of subsets (or subsequences) from the array such that each subset contains consecutive numbers. Example 1: Input: N = 10 Arr[] = {100, 56, 5, 6, 102, 58, ...
```python class Solution: def numofsubset(self, arr, n): arr.sort() subsets = 1 i = 0 while i < n - 1: if arr[i + 1] != arr[i] + 1: subsets += 1 i += 1 return subsets ```
vfc_141720
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/min-subsets-with-consecutive-numbers0601/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 10\nArr[] = {100, 56, 5, 6, 102, 58, 101, 57, 7, 103}", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3\nArr[] = {10, 100, 105}", "output": "3", "type": "s...
taco
verifiable_code
Solve the following coding problem using the programming language python: Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence. Input The input consists of multiple datasets. Each...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) if N == 0: return False mi = su = 0 ans = -10 ** 9 for i in range(N): a = int(readline()) su += a ans = max(ans, su - mi) mi = min(su, mi) print(ans) return True while solve(): ... ```
vfc_141721
{ "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": "7\n-5\n-2\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0", "output": "19\n14\n1001\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n-5\n-2\n6\n4\n9...
taco
verifiable_code
https://www.hackerrank.com/challenges/correctness-invariant/problem
Solve the following coding problem using the programming language python: In the previous challenge, you wrote code to perform an Insertion Sort on an unsorted array. But how would you prove that the code is correct? I.e. how do you show that for any input your code will provide the right output? Loop Invariant In ...
```python num_integers = int(input()) str_in = [int(x) for x in input().strip().split(' ')] print(' '.join([str(x) for x in sorted(str_in)])) ```
vfc_141725
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/correctness-invariant/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n7 4 3 5 6 2\n", "output": "2 3 4 5 6 7\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/391/C1
Solve the following coding problem using the programming language python: This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points. Manao decided to pursue a fighter's c...
```python m = 301000 ns = [0] * m es = [0] * m c = [0] * m b = [0] * m t = [0] * m P = 0 def add(b, k): k = t[k] while k: e = es[k] if b[-1] > e: b[-1] = e b[e] += 1 k = ns[k] def delete(b): for i in range(b[m - 1], m + 1): if b[i]: b[i] -= 1 b[-1] = i return i def calc(k): nonlocal b q = ...
vfc_141729
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/391/C1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 1\n1 4\n2 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n3 2\n4 0\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": nul...
taco
verifiable_code
https://codeforces.com/problemset/problem/793/D
Solve the following coding problem using the programming language python: Bankopolis is an incredible city in which all the n crossroads are located on a straight line and numbered from 1 to n along it. On each crossroad there is a bank office. The crossroads are connected with m oriented bicycle lanes (the i-th lane...
```python import sys from functools import lru_cache input = sys.stdin.readline def inpl(): return list(map(int, input().split())) @lru_cache(maxsize=None) def recur(v, s, e, k): if k == 0: return 0 elif k > e - s + 1: return INF ret = INF for nv in edge[v]: if not s <= nv <= e: continue tmp = [0] * 2...
vfc_141733
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/793/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n10\n2 4 420\n4 5 974\n5 1 910\n1 3 726\n1 2 471\n5 2 94\n3 2 307\n2 5 982\n5 4 848\n3 5 404\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n4\n5 4 614\n4 1 177\...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/maximum-distance3248/1
Solve the following coding problem using the programming language python: There are N bikes and each can cover 100 km when fully fueled. What is the maximum amount of distance you can go using N bikes? You may assume that all bikes are similar and a bike takes 1 litre to cover 1 km. Note: The answer may contain decima...
```python class Solution: def maxDist(self, N): dist_covered = 0 fuel = 100 while N > 0: dist_covered = dist_covered + fuel / N N = N - 1 return int(dist_covered) ```
vfc_141737
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/maximum-distance3248/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 2", "output": "150", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3", "output": "183", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/TRPLSRT
Solve the following coding problem using the programming language python: Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. You are given a permutation $p_{1}, p_{2}, \ldots, p_{N}$ of the integers $1$ through $N$. You may perform up to $K$ operations of the follo...
```python for tc in range(int(input())): (n, k) = [int(a) for a in input().split()] a = [0] + [int(a) for a in input().split()] res = [] for i1 in range(1, n): while a[i1] != i1 and a[a[i1]] != i1: i2 = a[i1] i3 = a[i2] res += [[i1, i2, i3]] (a[i2], a[i3], a[i1]) = (i2, i3, a[i3]) pair = [(i1, a[i1])...
vfc_141738
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TRPLSRT", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2\n3 2 4 1", "output": "1\n1 3 4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/978/A
Solve the following coding problem using the programming language python: Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements. Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements shou...
```python n = int(input()) a = list(map(int, input().split())) l = len(a) b = [True] * l x = 0 d = [100] * 1001 for i in range(l): if d[a[i]] == 100: x += 1 else: b[d[a[i]]] = False d[a[i]] = i b[i] = True print(x) res = [] for i in range(l): if b[i]: res.append(a[i]) print(*res) ```
vfc_141742
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/978/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 5 5 1 6 1\n", "output": "3\n5 6 1 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/9dacc32ad062be6e2ba8f6c41aad0b2b2376397d/1
Solve the following coding problem using the programming language python: There is a row of N walls in Geeksland. The king of Geeksland ordered Alexa to color all the walls on the occasion of New Year. Alexa can color each wall with one of the K colors. The cost associated with coloring each wall with a particular col...
```python from typing import List inf = 10 ** 18 class Solution: def minCost(self, costs: List[List[int]]) -> int: (n, k) = (len(costs), len(costs[0])) if k == 1 and n > 1: return -1 nmin = [[0, -1], [0, -1]] for i in range(1, n + 1): min1 = nmin[:] nmin = [] for j in range(1, k + 1): mini = ...
vfc_141762
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/9dacc32ad062be6e2ba8f6c41aad0b2b2376397d/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4, K = 3\r\ncosts[][] = {{1, 5, 7},\r\n {5, 8, 4},\r\n {3, 2, 9},\r\n {1, 2, 4}}", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5,...
taco
verifiable_code
https://www.codechef.com/DEC15/problems/ORACLCS
Solve the following coding problem using the programming language python: Devu is a disastrous oracle: his predictions about various events of your life are horrifying. Instead of providing good luck, he "blesses" you with bad luck. The secret behind his wickedness is a hidden omen which is a string of length m. On yo...
```python t = int(input()) for j in range(0, t): n = int(input()) m = 100 for i in range(0, n): str = input() p = min(str.count('a', 0, len(str)), str.count('b', 0, len(str))) if m > p: m = p print(m) t = t - 1 ```
vfc_141764
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/DEC15/problems/ORACLCS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\nab\nba\n2\naa\nbb\n3\naabb\nabab\nbaab\n", "output": "1\n0\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/549/A
Solve the following coding problem using the programming language python: The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them. In this problem an image is a rectangular ...
```python (n, m) = map(int, input().split()) a = [list(input()) for i in range(n)] d = set(['f', 'a', 'c', 'e']) k = 0 for i in range(n - 1): for j in range(m - 1): if a[i][j] in d: s = set() s.add(a[i][j]) s.add(a[i + 1][j]) s.add(a[i + 1][j + 1]) s.add(a[i][j + 1]) if s == d: k += 1 print(k) ...
vfc_141773
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/549/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\nxxxx\nxfax\nxcex\nxxxx\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\nxx\ncf\nae\nxx\n", "output": "1\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://www.codechef.com/problems/CHRL2
Solve the following coding problem using the programming language python: Read problems statements in Russian also. Chef likes playing with strings. The most interesting game are named "CHEF in string". The move of the game consists of the following: Chef takes a subsequence of string's letters that form the word "CH...
```python s = input() c1 = c2 = c3 = c4 = 0 for i in range(len(s)): if s[i] == 'C': c1 += 1 if s[i] == 'H': c2 += 1 c2 = min(c2, c1) if s[i] == 'E': c3 += 1 c3 = min(c2, c3) if s[i] == 'F': c4 += 1 c4 = min(c3, c4) print(c4) ```
vfc_141777
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHRL2", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "CHEFCHEFFFF\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "CHHHEEEFFCC", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input"...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/palindrome-string0817/1
Solve the following coding problem using the programming language python: Given a string S, check if it is palindrome or not. Example 1: Input: S = "abba" Output: 1 Explanation: S is a palindrome Example 2: Input: S = "abc" Output: 0 Explanation: S is not a palindrome Your Task: You don't need to read input or pri...
```python class Solution: def isPalindrome(self, S): return 1 if S == S[::-1] else 0 ```
vfc_141781
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/palindrome-string0817/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"abba\"", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"abc\"", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: F: Grid number problem Ebi-chan is trying to write exactly one integer from 1 to 2 \ times n in a grid with n columns horizontally and 2 rows vertically. Only one integer can be written to each cell in the grid. It's not fun just to write no...
```python from collections import Counter (N, K, mod) = map(int, input().split()) dp = [Counter() for _ in range(2 * N)] dp[0][None, (0,)] = 1 for i in range(2 * N - 1): for ((left, top), v) in dp[i].items(): if len(top) > K + 1: continue if left == None: if top and i + 1 - top[0] <= K: dp[i + 1][i + 1, ...
vfc_141782
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 11", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 0 11", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 2...
taco
verifiable_code
https://codeforces.com/problemset/problem/887/D
Solve the following coding problem using the programming language python: There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by a and after each fa...
```python from sys import stdin from collections import deque def main(): (n, a, b, c, d, st, l) = map(int, input().split()) q = deque() po = q.popleft pu = q.append mq = deque() mpop = mq.pop mpo = mq.popleft mpu = mq.append sb = [0] * (n + 1) mst = st pu((0, 0, mst, st)) pp = 0 for (i, line) in enumerat...
vfc_141786
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/887/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 1 1 1 2 0 10\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n", "output": "5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/ORACLCS
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Devu is a disastrous oracle: his predictions about various events of your life are horrifying. Instead of providing good luck, he "blesses" you with bad luck. The se...
```python t = int(input()) for i in range(t): n = int(input()) a = 100 b = 100 for j in range(n): s = input() a = min(a, s.count('a')) b = min(b, s.count('b')) print(min(a, b)) ```
vfc_141790
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ORACLCS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\nab\nba\n2\naa\nbb\n3\naabb\nabab\nbaab", "output": "1\n0\n2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/py-set-add/problem
Solve the following coding problem using the programming language python: If we want to add a single element to an existing set, we can use the .add() operation. It adds the element to the set and returns 'None'. Example >>> s = set('HackerRank') >>> s.add('H') >>> print s set(['a', 'c', 'e', 'H', 'k', 'n', 'r', '...
```python N = int(input()) stamps = set() for _ in range(N): stamps.add(input().strip()) print(len(stamps)) ```
vfc_141794
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/py-set-add/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\nUK\nChina\nUSA\nFrance\nNew Zealand\nUK\nFrance \n", "output": "5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/the-non-repetitive-string5955/1
Solve the following coding problem using the programming language python: Given a string S, the task is to check if a string is a non-repetitive or not. A non-repetitive string is defined as a string that does not contain any different character between two same characters Example 1: Input: S = "AABBCCCCC" Output: 1...
```python class Solution: def nonRepetitive(self, s): a = set() for i in range(len(s)): if s[i] not in a: a.add(s[i]) elif s[i] != s[i - 1]: return False return True ```
vfc_141798
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/the-non-repetitive-string5955/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"AABBCCCCC\"", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"ABA\"", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/460/D
Solve the following coding problem using the programming language python: Little Victor adores the sets theory. Let us remind you that a set is a group of numbers where all numbers are pairwise distinct. Today Victor wants to find a set of integers S that has the following properties: * for all x <image> the follow...
```python import random (l, r, k) = map(int, input().split(' ')) if k == 1: print(l) print(1) print(l) quit() if k == 2: if r == l + 1: a = l b = l ^ r if a <= b: print(a) print(1) print(l) quit() else: print(b) print(2) print(l, l + 1) quit() for i in range(l, r + 1): if i % 2 =...
vfc_141799
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/460/D", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "999999999996 1000000000000 5\n", "output": "0\n4\n999999999996 999999999997 999999999998 999999999999 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: The goddess of programming is reviewing a thick logbook, which is a yearly record of visitors to her holy altar of programming. The logbook also records her visits at the altar. The altar attracts programmers from all over the world because one...
```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 = [(0, -1), (1, 0), (0, 1), (-1, 0)] ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), ...
vfc_141803
{ "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": "14\n04/21 09:00 I 000\n04/21 09:00 I 001\n04/21 09:15 I 002\n04/21 09:30 O 001\n04/21 09:45 O 000\n04/21 10:00 O 002\n04/28 09:00 I 003\n04/28 09:15 I 000\n04/28 09:30 I 004\n04/28 09:45 O 004\n04/28 10:00 O 000\n04/28 10:15 O 003\...
taco
verifiable_code
Solve the following coding problem using the programming language python: Raja tranports boxes from one place to another.But the boxes are too heavy it is very diffcult for him to transport them.But he is Raja:-p he has a magical power he can choose any random number D and if sum of weight of two continuous boxes one ...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t=int(input()) while t>0: n=int(input()) a=[int(x) for x in input().split()] k=int(input()) b=[] i=0 while i<len(a)-1: if (a[i]+a[i+1])%k==0: c=a.pop(i) d=a.po...
vfc_141807
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n42\n12133 7331 4246 2396 18759 4864 6866 -2504 7115 -26955 10702 -139 -5039 -1002 14448 6955 9669 -5755 9264 -18809 -7511 12660 -10477 -20542 -18679 -5018 12720 4136 -17788 -11538 -19155 1554 21066 -10322 -4798 7915 -17641 344 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/260/C
Solve the following coding problem using the programming language python: Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right. Once Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is gua...
```python from sys import stdin, setrecursionlimit import math from collections import defaultdict, deque setrecursionlimit(15000) def transform(arr, ans): for i in range(len(arr)): arr[i] -= ans def find_index(x, arr): i = x - 1 while True: if arr[i] == 0: break arr[i] -= 1 i -= 1 if i == -1: i = ...
vfc_141812
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/260/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n4 3 1 6\n", "output": "3 2 5 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n3 2 0 2 7\n", "output": "2 1 4 1 6 ", "type": "stdin_stdout" }, { "fn_name...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/save-your-life4601/1
Solve the following coding problem using the programming language python: Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefine...
```python import sys class Solution: def maxSum(self, w, x, b, n): max_so_far = -sys.maxsize max_current = 0 i = 0 j = 0 s = 0 if n == 0: return w for cur in range(len(w)): new_asc = ord(w[cur]) if w[cur] in x: new_asc = b[x.index(w[cur])] max_current += new_asc if max_so_far < max_c...
vfc_141816
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/save-your-life4601/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "W = abcde\r\nN = 1\r\nX[] = { 'c' }\r\nB[] = { -1000 }", "output": "de", "type": "stdin_stdout" }, { "fn_name": null, "input": "W = dbfbsdbf \r\nN = 2\r\nX[] = { 'b','s' }\r\nB[] = { -100, 45 }", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/997/B
Solve the following coding problem using the programming language python: Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written...
```python n = int(input()) m = min([n, 100]) result = 50 * (n - m) + m - n + 1 my_set = set() for i in range(m + 1): for j in range(i, m + 1): for k in range(j, m + 1): tmp = 50 * i + 10 * (j - i) + 5 * (k - j) + (m - k) my_set.add(tmp) result += len(my_set) - 1 print(result) ```
vfc_141817
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/997/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n", ...
taco
verifiable_code
https://www.codechef.com/LTIME31/problems/DISTCODE
Solve the following coding problem using the programming language python: Sergey recently learned about country codes - two letter strings, denoting countries. For example, BY stands for Belarus and IN stands for India. Mesmerized by this new discovery, Sergey now looks for country codes everywhere! Sergey has recentl...
```python t = eval(input()) while t: s = input() set1 = set() j = 0 for i in s[:-1]: a = s[j:j + 2] set1.add(a) j = j + 1 print(str(len(set1)) + '\n') t = t - 1 ```
vfc_141821
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LTIME31/problems/DISTCODE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nINBY\nBYBY\n", "output": "3\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1269/B
Solve the following coding problem using the programming language python: You are given a positive integer $m$ and two integer sequence: $a=[a_1, a_2, \ldots, a_n]$ and $b=[b_1, b_2, \ldots, b_n]$. Both of these sequence have a length $n$. Permutation is a sequence of $n$ different positive integers from $1$ to $n$. ...
```python list1 = input().split() n = int(list1[0]) m = int(list1[1]) a = input().split() b = input().split() a = [int(x) for x in a] b = [int(x) for x in b] a = sorted(a) b = sorted(b) list2 = a i = 0 l = n d = 0 mind = 100000000000 while i < l: j = 0 equal = True d = (b[i] - a[0]) % m for k in range(l): if i + ...
vfc_141829
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1269/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n0 0 2 1\n2 0 1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n0 0 0\n1 1 1\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/393/C
Solve the following coding problem using the programming language python: Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A a...
```python from math import sqrt n = int(input()) if n == 0: print(1) else: print(4 * int(n * sqrt(2))) ```
vfc_141833
{ "difficulty": "unknown_difficulty", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/393/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11\n", "output": "60\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "17\n", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/490/C
Solve the following coding problem using the programming language python: Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the ...
```python (s, x, pfx) = (input(), 0, []) (a, b) = map(int, input().split()) try: for (i, c) in enumerate(s, 1): x = (x * 10 + int(c)) % a if not x and s[i] != '0': pfx.append(i) except IndexError: pass (x, p, i) = (0, 1, len(s)) for stop in reversed(pfx): for i in range(i - 1, stop - 1, -1): x = (x + int(s[...
vfc_141838
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/490/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "116401024\n97 1024\n", "output": "YES\n11640\n1024\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "284254589153928171911281811000\n1009 1000\n", "output": "YES\n2842545891539\n281719...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-primes-in-range1604/1
Solve the following coding problem using the programming language python: Given two numbers L and R(L<R). Count all the prime numbers in the range [L, R]. Example 1: Input: L=1,R=10 Output: 4 Explanation: There are 4 primes in this range, which are 2,3,5 and 7. Example 2: Input: L=5,R=10 Output: 2 Explanation: There ...
```python class Solution: def countPrimes(self, L, R): primes = [True] * (R + 1) primes[0] = False primes[1] = False for i in range(2, int(math.sqrt(R)) + 1): if primes[i] == True: for j in range(i * i, R + 1, i): primes[j] = False cnt = 0 for i in range(L, R + 1): if primes[i] == True: ...
vfc_141842
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-primes-in-range1604/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "L=1,R=10", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "L=5,R=10", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: As an English learner, sometimes you cannot remember the entire spelling of English words perfectly, but you can only remember their prefixes and suffixes. For example, you may want to use a word which begins with 'appr' and ends with 'iate', bu...
```python from bisect import bisect import sys readline = sys.stdin.readline write = sys.stdout.write def construct(N, S, base, MOD): L = 26 root = [0, 0, N - 1, [None] * L] nds = [root] for (i, s) in enumerate(S): node = root for c in s: (h, a, b, nt) = node if nt[c] is None: h1 = (h * base + c + 1)...
vfc_141843
{ "difficulty": "unknown_difficulty", "memory_limit": "536.870912 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 4\nbonnected\ndisconnected\ngraph\ndirected\ndiameter\ndistance\nminor\nc ed\ndi ed\ndis ed\ndis e", "output": "0\n2\n1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 7\nappreciate...
taco
verifiable_code
https://www.hackerrank.com/challenges/minimum-average-waiting-time/problem
Solve the following coding problem using the programming language python: Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the first-come, first-served rule, Tieu simply minimizes the average waiting time of his customers. So he gets to dec...
```python import heapq N = int(input()) Tasks = [tuple((int(_) for _ in input().split())) for _ in range(N)] Tasks.sort() TotalWaiting = 0 currentTime = 0 currentWaiting = [] i = 0 while i < len(Tasks): if not currentWaiting and Tasks[i][0] > currentTime: currentTime = Tasks[i][0] while i < len(Tasks) and Tasks[i][...
vfc_141847
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/minimum-average-waiting-time/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 3\n1 9\n2 6\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 3\n1 9\n2 5\n", "output": "8\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Given a string, S, we define some operations on the string as follows: a. reverse(S) denotes the string obtained by reversing string S. E.g.: reverse("abc") = "cba" b. shuffle(S) denotes any string that's a permutation of string S. E.g.: shuff...
```python from collections import defaultdict def solve(S): # Reverse S S = S[::-1] # Count each character in S. count = defaultdict(int) for c in S: count[c] += 1 need = {} for c in count: need[c] = count[c] / 2 solution = [] i = 0 while len(solution) < len(S) / 2: min_char_at = -1 while Tru...
vfc_141852
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "eggegg", "output": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
taco
verifiable_code
https://www.codechef.com/problems/CHNUM
Solve the following coding problem using the programming language python: Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Recently, Chef hosted a strange competition at the Byteland annual fair. There were $N$ participants in the competition (numbered $1$ throug...
```python t = int(input()) for _ in range(t): n = int(input()) l = list(map(int, input().split())) l1 = list(filter(lambda x: x >= 0, l)) l2 = list(filter(lambda x: x < 0, l)) if len(l2) == 0: print(len(l1), len(l1)) elif len(l1) == 0: print(len(l2), len(l2)) else: print(max(len(l1), len(l2)), min(len(l1),...
vfc_141856
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHNUM", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n5 2 4 6 7", "output": "5 5", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/moving-on-grid1135/1
Solve the following coding problem using the programming language python: Given a grid on XY plane with dimensions r x c, the two players (say JON and ARYA ) can move the coin over the grid satisfying the following rules: There is a coin on (1,1) cell initially. JON will move first. Both will play on alternate move...
```python class Solution: def movOnGrid(self, r, c): r = (r - 1) % 7 c = (c - 1) % 4 return ['JON', 'ARYA'][r == c] ```
vfc_141864
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/moving-on-grid1135/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "r = 1, c = 2", "output": "JON", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Miki is a high school student. She has a part time job, so she cannot take enough sleep on weekdays. She wants to take good sleep on holidays, but she doesn't know the best length of sleeping time for her. She is now trying to figure that out wi...
```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_141865
{ "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 0 2\n0.4085591484323763\n0.00000100000\n0.37500000000", "output": "0.2068873589\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 0 2\n0.14744802999270293\n0.37499999977\n1.00000000000",...
taco
verifiable_code
https://codeforces.com/problemset/problem/127/C
Solve the following coding problem using the programming language python: Bob is about to take a hot bath. There are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit any integer number of water ...
```python import math def gcd(a, b): if b == 0: return a return gcd(b, a % b) l = input().split() t1 = int(l[0]) t2 = int(l[1]) x1 = int(l[2]) x2 = int(l[3]) t0 = int(l[4]) num1 = t2 - t0 num2 = t0 - t1 if t1 == t2: print(x1, x2) quit() if num1 == 0: print(0, x2) quit() if num2 == 0: print(x1, 0) quit() z = ...
vfc_141869
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/127/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "176902 815637 847541 412251 587604\n", "output": "228033 410702\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/convert-floating-point-to-natural-number3049/1
Solve the following coding problem using the programming language python: Given a positive floating point number N, the task is to find the smallest integer k, such that when we multiply k with N, we get a natural number. Example 1: Input: N = "30.25" Output: 4 Explanation: 30.25 * 4 = 321, there is no number less ...
```python class Solution: def gcd(self, a, b): if b == 0: return a return self.gcd(b, a % b) def findMinMultiple(self, N): l = N.split('.') c = len(l[1]) d = int(l[1]) h = 10 ** c return h // self.gcd(d, h) ```
vfc_141873
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/convert-floating-point-to-natural-number3049/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = \"30.25\"", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = \"5.5\"", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Pandey needs your help. As you know, he is on the quest to save the princess. After traveling for a number of days, he has finally reached the palace, but one last battle remains to be fought. However he has only one unit of energy left in him. ...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' def solve(): n = int(input()) a, b = 1, 1 for i in range(n): line = input() if line == 'N': a, b = min(a, -b), max(-a, b) else: x = int(line.split(' ')[1]) ...
vfc_141874
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n20\nN\n+ 4\nN\nN\n+ 1\n+ 5\n+ 4\n- 3\nN\n+ 2\nN\n- 1\n+ 4\n- 3\n+ 1\n+ 1\nN\n/ 2\nN\nN\n4\n- 2\nN\n+ 4\n* 3\n7\n- 2\nN\n+ 5\n- 2\n+ 1\n/ 3\n+ 4\n1\n+ 3\n29\n- 4\n- 1\n- 2\n- 4\n- 3\n+ 3\nN\n+ 1\n+ 2\nN\nN\n+ 5\n+ 4\n+ 5\nN\n* 5...