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
code_contests
verifiable_code
seavote
Solve the following coding problem using the programming language python: Sereja conducted a voting about N of his opinions. Ai percent of people voted for opinion number i. This statistics is called valid if sum of all Ai is equal to 100. Now let us define rounding up of a statistics A. If Ai is not an integer, ...
```python from pprint import pprint as pp def GI(): return int(raw_input()) def GIS(): return map(int, raw_input().split()) def main(): T = GI() for t in xrange(T): N = GI() B = GIS() excess = sum(B) - 100 if excess < 0: print 'NO' elif excess < N - B.count(0...
vfc_33805
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n30 30 30\n4\n25 25 25 25\n2\n50 51", "output": "NO\nYES\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3\n30 30 30\n4\n25 40 25 25\n2\n50 51", "output": "NO\nNO\nYES\n...
code_contests
verifiable_code
1003_C. Intense Heat
Solve the following coding problem using the programming language python: The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonab...
```python n, k = map(int, input().split()) ar = list(map(int, input().split())) average = M = 0 for i in range(n): s = 0 for j in range(i,n): s += ar[j] if (j-i+1) >= k: average = s / (j-i+1) M = max(M, average) print(M) ```
vfc_33809
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n3 4 1 2\n", "output": "2.666666666666667", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n4 6 6 6 2\n", "output": "4.8", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
1046_C. Space Formula
Solve the following coding problem using the programming language python: Formula 1 officials decided to introduce new competition. Cars are replaced by space ships and number of points awarded can differ per race. Given the current ranking in the competition and points distribution for the next race, your task is to...
```python n,k=map(int,input().strip().split()) cr = list(map(int,input().strip().split())) pa = list(map(int,input().strip().split())) x = cr[k-1]+pa[0] p = 0 if k==1: print(1) else: for i in range(k-1): if cr[i]+pa[-1]<=x: p +=1 del pa[-1] print(k-p) ```
vfc_33817
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n50 30 20 10\n15 10 7 3\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n29 25 13 10\n20 9 3 0\n", "output": "1", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1070_B. Berkomnadzor
Solve the following coding problem using the programming language python: Berkomnadzor — Federal Service for Supervision of Communications, Information Technology and Mass Media — is a Berland federal executive body that protects ordinary residents of Berland from the threats of modern internet. Berkomnadzor maintain...
```python #!/usr/bin/env python3 # Copied solution import collections import sys import traceback class Input(object): def __init__(self): self.fh = sys.stdin def next_line(self): while True: line = sys.stdin.readline() if line == '\n': continue ...
vfc_33821
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n-127.0.0.4/31\n+127.0.0.8\n+127.0.0.0/30\n-195.82.146.208/29\n-127.0.0.6/31\n", "output": "2\n127.0.0.4/30\n128.0.0.0/1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n-149.154.167.9...
code_contests
verifiable_code
1091_F. New Year and the Mallard Expedition
Solve the following coding problem using the programming language python: Bob is a duck. He wants to get to Alice's nest, so that those two can duck! <image> Duck is the ultimate animal! (Image courtesy of See Bang) The journey can be represented as a straight line, consisting of n segments. Bob is located to the le...
```python from heapq import heappush, heappop n = int(input()) L = list(map(int, input().split())) T = input() # fly -> walk, time cost: +4s, stamina: +2 # walk in place, time cost: +5s, stamina: +1 #fly -> swim, time cost: +2s, stamina: +2 #swim in place, time cost: +3s, stamina:+1 ans = sum(L) Q = [] for l, t in...
vfc_33825
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\nWL\n", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n10 10 10\nGLW\n", "output": "80", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1110_D. Jongmah
Solve the following coding problem using the programming language python: You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Eac...
```python from collections import Counter n, m = map(int, input().split()) B = list(map(int, input().split())) cnt = Counter(B) A = sorted(cnt.keys()) n = len(A) dp = [[0] * 3 for _ in range(3)] for i, a in enumerate(A): dp2 = [[0] * 3 for _ in range(3)] for x in range(1 if i >= 2 and a - 2 != A[i - 2] else 3):...
vfc_33829
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 6\n2 3 3 3 4 4 4 5 5 6\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 5\n1 1 5 1 2 3 3 2 4 2 3 4 5\n", "output": "4\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
1140_A. Detective Book
Solve the following coding problem using the programming language python: Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The i-th page contains some mystery that will be explained on page a_i (a_i ≥ i). Iv...
```python import sys #p = [[] for i in range(N)] #for i in range(N): # p[i] += map(int, sys.stdin.readline().split()) #Q = input() #for i in range(Q): # print(list(map(int, sys.stdin.readline().split()))) n = int(input()) a = [int(c) for c in sys.stdin.readline().split()] aktmax, d = 0, 0 for i, c in enumerate(a...
vfc_33833
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\n1 3 3 6 7 6 8 8 9\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1158_E. Strange device
Solve the following coding problem using the programming language python: It is an interactive problem. Vasya enjoys solving quizzes. He found a strange device and wants to know how it works. This device encrypted with the tree (connected undirected graph without cycles) with n vertices, numbered with integers from ...
vfc_33837
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n00000\n11011\n11100\n10010\n", "output": "\n? 0 0 0 0 0\n? 1 1 2 0 2\n? 0 0 0 1 0\n? 0 1 0 0 1\n!\n4 2\n1 5\n3 4\n4 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n11 13\n20 16\n1...
code_contests
verifiable_code
1180_D. Tolik and His Uncle
Solve the following coding problem using the programming language python: This morning Tolik has understood that while he was sleeping he had invented an incredible problem which will be a perfect fit for Codeforces! But, as a "Discuss tasks" project hasn't been born yet (in English, well), he decides to test a proble...
```python # [0,0,0] # [0,0,0] # [1,0,0] # [0,0,0] # [0,0,0] # [1,0,1] # [0,0,0] # [0,0,0] # [1,1,1] # [0,0,0] # [0,0,0] # [1,1,1] # [0,0,1] # [0,0,0] # [0,0,0] 3,2 # # 0,0 3,2 # 0,1 3,1 # 0,2 3,0 # 1,0 2,2 # 1,1 2,1 # 1,2 2,0 n, m = map(int, input().split()) ans = [] if n % 2 == 0: for i in range(int(n / 2))...
vfc_33841
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n", "output": "1 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1199_D. Welfare State
Solve the following coding problem using the programming language python: There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services...
```python import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def main(): n = int(input()) A = list(map(int, input().split())) q = int(input()) Q = [] for i in range(q): temp = list(map(int, input().split())) t = temp[0] if t == 1: ...
vfc_33845
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 50 2 1 10\n3\n1 2 0\n2 8\n1 3 20\n", "output": "8 8 20 8 10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 3 4\n3\n2 3\n1 2 2\n2 1\n", "output": "3 2 3 4\n", "type...
code_contests
verifiable_code
1216_C. White Sheet
Solve the following coding problem using the programming language python: There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates (0, 0)...
```python a=list(map(int,input().split())) x1,y1,x2,y2=a[0],a[1],a[2],a[3] a=list(map(int,input().split())) x3,y3,x4,y4=a[0],a[1],a[2],a[3] a=list(map(int,input().split())) x5,y5,x6,y6=a[0],a[1],a[2],a[3] l1=l2=l3=l4=1 if (x1>=x5 and x2<=x6 and y1>=y5 and y1<=y6) or (x1>=x3 and x2<=x4 and y1>=y3 and y1<=y4) or (y1>=y5 ...
vfc_33849
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0 1000000 1000000\n0 0 499999 1000000\n500000 0 1000000 1000000\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 7 5\n0 0 4 6\n0 0 7 4\n", "output": "YES\n", ...
code_contests
verifiable_code
1257_F. Make Them Similar
Solve the following coding problem using the programming language python: Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example: * 2 and 4 are similar (binary representations are 10 and 100); * 1337 and 4213 are similar (binary representations ar...
```python def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) dic1 = {} dic2 = {} A1 = [0] * N for i, a in enumerate(A): A1[i] = a>>15 for i in range(2**15): tmp = [0] * N for j, a in enumerate(A1): ...
vfc_33857
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 17 6 0\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1281_A. Suffix Three
Solve the following coding problem using the programming language python: We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It...
```python n = int(input()) for _ in range(n): s = input().split("_")[-1:][0] if s[-2:] == "po": print("FILIPINO") elif s[-4:] == "desu" or s[-4:] == "masu": print("JAPANESE") else: print("KOREAN") ```
vfc_33861
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\nkamusta_po\ngenki_desu\nohayou_gozaimasu\nannyeong_hashimnida\nhajime_no_ippo\nbensamu_no_sentou_houhou_ga_okama_kenpo\nang_halaman_doon_ay_sarisari_singkamasu\nsi_roy_mustang_ay_namamasu\n", "output": "FILIPINO\nJAPANESE\...
code_contests
verifiable_code
1301_A. Three Strings
Solve the following coding problem using the programming language python: You are given three strings a, b and c of the same length n. The strings consist of lowercase English letters only. The i-th letter of a is a_i, the i-th letter of b is b_i, the i-th letter of c is c_i. For every i (1 ≤ i ≤ n) you must swap (i....
```python t = int(input()) for T in range(t): a = input() b = input() c = input() n = len(a) count = 0 for i in range(n): if a[i] == c[i] or b[i] == c[i]: count += 1 if count == n: print("YES") else: print("NO") ```
vfc_33865
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim\n", "output": "NO\nYES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\nab\nab\nbb\n", "output": "NO\n", ...
code_contests
verifiable_code
1325_A. EhAb AnD gCd
Solve the following coding problem using the programming language python: You are given a positive integer x. Find any such 2 positive integers a and b such that GCD(a,b)+LCM(a,b)=x. As a reminder, GCD(a,b) is the greatest integer that divides both a and b. Similarly, LCM(a,b) is the smallest integer such that both a...
```python # your code goes here for _ in range(int(input())): x=int(input()) print(1,end=" ") print(x-1) ```
vfc_33869
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n14\n", "output": "1 1\n1 13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n...
code_contests
verifiable_code
1365_G. Secure Password
Solve the following coding problem using the programming language python: This is an interactive problem. Ayush devised yet another scheme to set the password of his lock. The lock has n slots where each slot can hold any non-negative integer. The password P is a sequence of n integers, i-th element of which goes int...
vfc_33877
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n\n1\n\n2\n\n4\n\n", "output": "? 3 1 2 3\n? 3 1 2 3\n? 3 1 2 3\n? 3 1 2 3\n? 2 1 2\n? 2 1 3\n? 2 2 3\n! 0 0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n", "output"...
code_contests
verifiable_code
1407_E. Egor in the Republic of Dagestan
Solve the following coding problem using the programming language python: Egor is a famous Russian singer, rapper, actor and blogger, and finally he decided to give a concert in the sunny Republic of Dagestan. There are n cities in the republic, some of them are connected by m directed roads without any additional co...
```python import sys input = sys.stdin.readline from collections import deque n, m = map(int, input().split()) back = [[] for i in range(n)] for _ in range(m): u, v, w = map(int, input().split()) u -= 1 v -= 1 back[v].append((u,w)) out = [2] * n outl = [-1] * n outl[-1] = 0 q = deque([n - 1])...
vfc_33885
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n1 2 0\n1 3 1\n2 3 0\n2 3 1\n", "output": "2\n010\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 10\n1 2 0\n1 3 1\n1 4 0\n2 3 0\n2 3 1\n2 5 0\n3 4 0\n3 4 1\n4 2 1\n4 5 0\n", "...
code_contests
verifiable_code
1428_C. ABBB
Solve the following coding problem using the programming language python: Zookeeper is playing a game. In this game, Zookeeper must use bombs to bomb a string that consists of letters 'A' and 'B'. He can use bombs to bomb a substring which is either "AB" or "BB". When he bombs such a substring, the substring gets dele...
```python # from debug import * import sys;input = sys.stdin.readline for _ in range(int(input())): s = input().strip() stack = [] for i in s: if stack and i == 'B': stack.pop() else: stack.append(i) print(len(stack)) ```
vfc_33889
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nAAA\nBABA\nAABBBABBBB\n", "output": "3\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nAAA\nAABA\nAABBBABBBB\n", "output": "3\n2\n0\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
1500_A. Going Home
Solve the following coding problem using the programming language python: It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours a...
```python def show(x, y, z, w): print("YES") print(x+1, y+1, z+1, w+1) exit(0) n=int(input()) ara=list(int(x) for x in input().split()) n=min(n, 2000) found={} for i in range(0, n): for j in range(i+1, n): cur_sm=ara[i]+ara[j] if cur_sm in found.keys() and found[cur_sm][0]!=i and found[cur_sm][1]!=j and found...
vfc_33901
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 1 9 20\n", "output": "\nNO", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 1 5 2 7 4\n", "output": "\nYES\n2 3 1 6 ", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
1525_C. Robot Collisions
Solve the following coding problem using the programming language python: There are n robots driving along an OX axis. There are also two walls: one is at coordinate 0 and one is at coordinate m. The i-th robot starts at an integer coordinate x_i~(0 < x_i < m) and moves either left (towards the 0) or right with the s...
```python from collections import deque def main(): t=int(input()) allans=[] for _ in range(t): n,m=readIntArr() xes=readIntArr() direction=input().split() ans=[-1]*n # moving to each other will collide first, followed by moving in same directi...
vfc_33905
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L\n", "output": "\n1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3 \n", "type": "stdin_stdout" ...
code_contests
verifiable_code
156_E. Mrs. Hudson's Pancakes
Solve the following coding problem using the programming language python: Mrs. Hudson hasn't made her famous pancakes for quite a while and finally she decided to make them again. She has learned m new recipes recently and she can't wait to try them. Those recipes are based on n special spices. Mrs. Hudson has these s...
vfc_33909
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n1\n2 ? 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1000000000000000000\n1\n16 ?????????????? 1\n", "output": "-1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
177_G2. Fibonacci Strings
Solve the following coding problem using the programming language python: Fibonacci strings are defined as follows: * f1 = «a» * f2 = «b» * fn = fn - 1 fn - 2, n > 2 Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba". You are given a Fibonacci string and m strings si. For each str...
```python F = ['', 'a', 'b', 'ba', 'bab', 'babba', 'babbabab', 'babbababbabba', 'babbababbabbababbabab', 'babbababbabbababbababbabbababbabba', 'babbababbabbababbababbabbababbabbababbababbabbababbabab', 'babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabba', 'babbababbabbababbababbab...
vfc_33913
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 5\na\nb\nab\nba\naba\n", "output": "3\n5\n3\n3\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 14\na\nb\naa\nab\nba\nbb\naaa\naab\naba\nabb\nbaa\nbab\nbba\nbbb\n", "output": "...
code_contests
verifiable_code
19_A. World Football Cup
Solve the following coding problem using the programming language python: Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations: * the final...
```python import sys # from itertools import product import logging logging.root.setLevel(level=logging.INFO) team_size = int(sys.stdin.readline()) teams = {} for _ in range(team_size): name = sys.stdin.readline().strip() teams[name] = { "point":0, "delta":0, "score":0 } contest_si...
vfc_33917
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nA\nB\nC\nD\nA-B 1:1\nA-C 2:2\nA-D 1:0\nB-C 1:0\nB-D 0:3\nC-D 0:3\n", "output": "A\nD\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
223_B. Two Strings
Solve the following coding problem using the programming language python: A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|). You've got two strings — s and t. Let's consider all subsequences of string s, coinci...
```python import bisect import string s = input() t = input() max_match = [0 for i in range(len(s))] min_match = [0 for i in range(len(s))] char_idx = [0 for i in range(30)] char_occur = [ [] for i in range(30) ] for (i, ch) in enumerate(t): idx = ord(ch) - ord('a') char_occur[idx].append(i) for ch in strin...
vfc_33921
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abc\nba\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abacaba\naba\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
272_A. Dima and Friends
Solve the following coding problem using the programming language python: Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place. To decide who exactly would clean the apartment, the friends wan...
```python def solve(n,d): other = 0 for i in d: other += i ways = 0 for i in range(1,6): if (other + i) % (n + 1) != 1: ways += 1 print(ways) def main(): n = int(input()) d = input() d = [int(i) for i in d.split()] solve(n,d) main() ```
vfc_33929
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
295_C. Greg and Friends
Solve the following coding problem using the programming language python: One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river...
```python from collections import deque n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] c50 = sum([1 for i in a if i == 50]) c100 = sum([1 for i in a if i == 100]) c = [[0] * 51 for i in range(51)] c[0][0] = 1 c[1][0] = 1 c[1][1] = 1 for x in range(2, 51): for y in range(x + 1): ...
vfc_33933
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 100\n50 50 100\n", "output": "5\n 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 50\n50\n", "output": "1\n ...
code_contests
verifiable_code
319_A. Malek Dance Club
Solve the following coding problem using the programming language python: As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2n members and coincidentally Natalia Fan Club also has 2n members. Each member of MDC i...
```python s = input() res = pow(2, len(s)-1)*(int(s, 2)) print (res%1000000007) ```
vfc_33937
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "01\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "11\n", ...
code_contests
verifiable_code
343_A. Rational Resistance
Solve the following coding problem using the programming language python: Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value. However, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with other resi...
```python I = lambda : list(map(int, input().split(' '))) a, b = I() ans = 0 while a > 0 and b > 0 and a//b > 0 or b//a > 0: ans += a//b a, b = b, a%b print(ans) ```
vfc_33941
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "199 200...
code_contests
verifiable_code
366_C. Dima and Salad
Solve the following coding problem using the programming language python: Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something. Dima and Seryozha have n fruits in the fridge. Each fruit has two paramete...
```python from bisect import bisect_right n, k = map(int, input().split()) t = sorted((u - k * v, v) for u, v in zip(*(map(int, input().split()), map(int, input().split())))) m = n - bisect_right(t, (0, 0)) l, p, t = 0, [0] * 100001, t[:: -1] for d, v in t[: m]: for j in range(l, 0, -1): if p[j]: p[j + d] =...
vfc_33945
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n4 4 4 4 4\n2 2 2 2 2\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n10 8 1\n2 7 1\n", "output": "18\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
40_A. Find Color
Solve the following coding problem using the programming language python: Not so long ago as a result of combat operations the main Berland place of interest — the magic clock — was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can...
```python # _ ##################################################################################################################### from math import sqrt, ceil def colorOfDamagedArea(x, y): location = sqrt(x*x+y*y) area_sBorder = ceil(location) if location == area_sBorder: return 'black' are...
vfc_33953
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "-2 1\n", "output": "white\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n", "output": "black\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
437_E. The Child and Polygon
Solve the following coding problem using the programming language python: This time our child has a simple polygon. He has to find the number of ways to split the polygon into non-degenerate triangles, each way must satisfy the following requirements: * each vertex of each triangle is one of the polygon vertex; ...
vfc_33957
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0\n1 0\n0 1\n-1 0\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 0\n1 0\n1 1\n0 1\n-2 -1\n", "output": "3\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
45_G. Prime Problem
Solve the following coding problem using the programming language python: In Berland prime numbers are fashionable — the respectable citizens dwell only on the floors with numbers that are prime numbers. The numismatists value particularly high the coins with prime nominal values. All the prime days are announced holi...
vfc_33961
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8", "output": "1 1 1 1 2 1 1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "1 1 2 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
483_A. Counterexample
Solve the following coding problem using the programming language python: Your friend has recently learned about coprime numbers. A pair of numbers {a, b} is called coprime if the maximum number that divides both a and b is equal to one. Your friend often comes up with different statements. He has recently supposed ...
```python s, e = [int(num) for num in input().split()] def GCD(a, b): return GCD(b, a % b) if b else a result = -1 for i in range(s, e + 1): for j in range(i + 1, e + 1): if GCD(i, j) == 1: for k in range(j + 1, e + 1): if GCD(j, k) == 1 and GCD(i, k) != 1: ...
vfc_33965
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "900000000000000009 900000000000000029\n", "output": "900000000000000010 900000000000000011 900000000000000012\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
507_A. Amr and Music
Solve the following coding problem using the programming language python: Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to...
```python I = lambda: map(int, input().split()) n, k = I() l = sorted(zip(I(), range(1, n+1))) h = [] for i, j in l: k -= i if k>=0: h.append(j) print(len(h));print(*h) ```
vfc_33969
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 6\n4 3 1 1 2\n", "output": "3\n3 4 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3\n4\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
530_B. String inside out
Solve the following coding problem using the programming language python: You are given a string S of even length s1..s2n . Perform the following manipulations: * divide it into two halves s1..sn and sn + 1..s2n * reverse each of them sn..s1 and s2n..sn + 1 * concatenate the resulting strings into sn..s1s2n..sn...
vfc_33973
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "codeforces\n", "output": "fedocsecro\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "qwertyasdfgh\n", "output": "ytrewqhgfdsa\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
556_B. Case of Fake Numbers
Solve the following coding problem using the programming language python: Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was. Its most important components are a button an...
```python import functools as ft if __name__ == '__main__': n = int(input()) a = list(map(int, input().split())) b = [i for i in range(n)] for i in range(1, n + 1): a = [(a[j] + 1) % n if not j % 2 else (a[j] - 1) % n for j in range(n)] cnt = ft.reduce(lambda x, y: x + y, [a[j] == b[j]...
vfc_33977
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 2 3 1\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4 2 1 4 3\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
603_E. Pastoral Oddities
Solve the following coding problem using the programming language python: In the land of Bovinia there are n pastures, but no paths connecting the pastures. Of course, this is a terrible situation, so Kevin Sun is planning to rectify it by constructing m undirected paths connecting pairs of distinct pastures. To make ...
vfc_33985
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n1 3 4\n2 4 8\n1 2 2\n3 4 3\n", "output": "-1\n8\n8\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
626_C. Block Towers
Solve the following coding problem using the programming language python: Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. Th...
```python n, m = map(int, input().split()) x = max(n*2, m*3) while x//2+x//3-x//6 < m+n: x += 1 print(x) ```
vfc_33989
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n", "output": "8\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
650_A. Watchmen
Solve the following coding problem using the programming language python: Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi). They need to arrange a plan, but there...
```python import collections r=0;a,b,c=[collections.Counter() for _ in [0,0,0]] for _ in range(int(input())): x,y=map(int, input().split()) r+=a[x]+b[y]-c[(x,y)] a[x]+=1;b[y]+=1;c[(x,y)]+=1 print(r) ```
vfc_33993
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n7 5\n1 5\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n0 0\n0 1\n0 2\n-1 1\n0 1\n1 1\n", "output": "11", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
675_D. Tree Construction
Solve the following coding problem using the programming language python: During the programming classes Vasya was assigned a difficult problem. However, he doesn't know how to code and was unable to find the solution in the Internet, so he asks you to help. You are given a sequence a, consisting of n distinct intege...
```python __author__ = "House" import bisect if __name__ == "__main__": n = int(input()) s = [int(i) for i in input().split()] f = [[s[0], 0]] outp = list() for i in range(1, n): now = [s[i], i] idx = bisect.bisect_left(f, now) ans = 0 if idx == 0: ans =...
vfc_33997
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 2 3 1 6\n", "output": "4 2 2 4 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
720_B. Cactusophobia
Solve the following coding problem using the programming language python: Tree is a connected undirected graph that has no cycles. Edge cactus is a connected undirected graph without loops and parallel edges, such that each edge belongs to at most one cycle. Vasya has an edge cactus, each edge of this graph has some ...
vfc_34005
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n1 2 4\n2 3 1\n3 4 2\n4 2 3\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
741_D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths
Solve the following coding problem using the programming language python: Just in case somebody missed it: we have wonderful girls in Arpa’s land. Arpa has a rooted tree (connected acyclic graph) consisting of n vertices. The vertices are numbered 1 through n, the vertex 1 is the root. There is a letter written on ea...
vfc_34009
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 s\n2 a\n3 s\n", "output": "3 1 1 0 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 a\n2 h\n1 a\n4 h\n", "output": "4 1 0 1 0 \n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
765_C. Table Tennis Game 2
Solve the following coding problem using the programming language python: Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score...
```python """ Created by Henrikh Kantuni on 2/14/17 """ if __name__ == '__main__': k, a, b = [int(x) for x in input().split()] score_a = 0 if a >= k: score_a = a // k score_b = 0 if b >= k: score_b = b // k if score_a == 0 and score_b == 0: print(-1) else: ...
vfc_34013
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11 2 3\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "11 11 5\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "18 ...
code_contests
verifiable_code
788_E. New task
Solve the following coding problem using the programming language python: On the 228-th international Uzhlyandian Wars strategic game tournament teams from each country are called. The teams should consist of 5 participants. The team of Uzhlyandia will consist of soldiers, because there are no gamers. Masha is a new...
vfc_34017
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 1 1 1 1 1\n2\n1 3\n2 3\n", "output": "1\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n3 4 4 2 4 5 4 1\n3\n1 5\n2 5\n1 2\n", "output": "1\n6\n2\n", "type": "stdin_s...
code_contests
verifiable_code
80_B. Depression
Solve the following coding problem using the programming language python: Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels! There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After tha...
```python # # solving: # from: https://vjudge.net/contest/417235#problem/D def main(): inlist = input().split(":") hh, mm = int(inlist[0]), int(inlist[1]) deg_per_h = 360/12 deg_per_m = 360/60 print("{} {}".format(((hh+mm/60) * deg_per_h) % 360, (mm * deg_per_m) % 360)) main() ...
vfc_34021
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "04:30\n", "output": "135 180\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "08:17\n", "output": "248.5 102\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
834_E. Ever-Hungry Krakozyabra
Solve the following coding problem using the programming language python: <image> Recently, a wild Krakozyabra appeared at Jelly Castle. It is, truth to be said, always eager to have something for dinner. Its favorite meal is natural numbers (typically served with honey sauce), or, to be more precise, the zeros in t...
vfc_34025
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 10\n", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input": "40 57\n", "output": "17", "type": "stdin_stdout" }, { "fn_name": null, "input": "157 165...
code_contests
verifiable_code
855_C. Helga Hufflepuff's Cup
Solve the following coding problem using the programming language python: Harry, Ron and Hermione have figured out that Helga Hufflepuff's cup is a horcrux. Through her encounter with Bellatrix Lestrange, Hermione came to know that the cup is present in Bellatrix's family vault in Gringott's Wizarding Bank. The Wiza...
```python import os import sys from atexit import register from io import BytesIO sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size)) sys.stdout = BytesIO() register(lambda: os.write(1, sys.stdout.getvalue())) input = lambda: sys.stdin.readline().rstrip('\r\n') raw_input = lambda: sys.stdin.readline().rstrip('\r\n') ...
vfc_34029
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n1 2\n1 3\n1 1\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2\n1 3\n2 1\n", "output": "13", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
87_A. Trains
Solve the following coding problem using the programming language python: Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free time, h...
```python a,b=map(int,input().split()) if(a==b): print('Equal') exit() import math lcm=(a*b)//(math.gcd(a,b)) if(a<b): da=(lcm//a)-1 ma=lcm//b if(da>ma): print('Dasha') elif(da<ma): print('Masha') else: print('Equal') else: da=(lcm//a) ma=(lcm//b)-1 if(da...
vfc_34033
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n", "output": "Equal\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
903_C. Boxes Packing
Solve the following coding problem using the programming language python: Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai. Mishka can put a box i into another box j if the following conditions are met: * i-th box is not put into another box; * j-th box doesn't conta...
```python from sys import stdin,stdout from collections import Counter def ai(): return list(map(int, stdin.readline().split())) def ei(): return map(int, stdin.readline().split()) def ip(): return int(stdin.readline().strip()) def op(ans): return stdout.write(str(ans) + '\n') t = ip() li = ai() x = max(li) c = Count...
vfc_34037
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n4 2 4 3\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
925_D. Aztec Catacombs
Solve the following coding problem using the programming language python: Indiana Jones found ancient Aztec catacombs containing a golden idol. The catacombs consists of n caves. Each pair of caves is connected with a two-way corridor that can be opened or closed. The entrance to the catacombs is in the cave 1, the id...
vfc_34041
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n1 2\n2 3\n", "output": "4\n1 2 3 1 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 2\n2 3\n1 3\n3 4\n", "output": "2\n1 3 4 ", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
980_D. Perfect Groups
Solve the following coding problem using the programming language python: SaMer has written the greatest test case of all time for one of his problems. For a given array of integers, the problem asks to find the minimum number of groups the array can be divided into, such that the product of any pair of integers in th...
```python #!/usr/bin/env python3 from math import sqrt primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 2...
vfc_34049
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 5\n", "output": "3 0 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0\n", "output": "1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n...
code_contests
verifiable_code
9_D. How many trees?
Solve the following coding problem using the programming language python: In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phong — the oldest among the inhabitants of Mainframe. But still he managed to get some information from there. For example, h...
```python n,h=map(int,input().split()) L=[] for i in range(n+1): g=[] for j in range(n+1): g.append(0) L.append(g) L[0][0]=1 for i in range(1,n+1): for j in range(1,n+1): sumu=0 for m in range(1,i+1): t1=L[m-1][j-1] tot=0 for k in range(0,j): ...
vfc_34053
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "21 12\n...
code_contests
verifiable_code
bhargav-and-gre
Solve the following coding problem using the programming language python: bhargav has dream to study his MS is foreign country. So, He started his preparation for GRE. There are huge number of words that he has to prepare for. So, firs he wanted to group all synonyms and antonyms. As there are huge number of words tha...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' s=raw_input() n=input() a=0 sy=0 for i in range(n): s1=raw_input() if s1[0]==s[0] and len(s1)==len(s): sy+=1 if chr(ord(s[0])+3)==s1[0] and len(s1)==len(s)...
vfc_34057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "hasrfk\n4\nheyfgs\njhajyrbf\nkayufs\nhetinf\n\nSAMPLE", "output": "2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ashtrick\n25\namberhed\ndouglasb\nashmartin\nroogle\neglownasht\ndutt...
code_contests
verifiable_code
converter
Solve the following coding problem using the programming language python: Raghu wants to design a converter such that when a user inputs a binary number it gets converted to Octal number & also the correspond alphabet to it. Example- if a user inputs- 10101101 then the output is 255 BEE Note : for decimal places the...
```python bindict = {'000':0,'001':1,'010':2,'100':4,'101':5,'110':6,'111':7,'011':3} binary = raw_input().split('.') for index,value in enumerate(binary): arr = [] if(index==0): while(len(value)%3!=0): value='0'+value j = 1 i = 0 while(j<=len(value)): ...
vfc_34061
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10101101\n\nSAMPLE", "output": "255 BEE", "type": "stdin_stdout" }, { "fn_name": null, "input": "10101101", "output": "255 BEE", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
find-the-hub
Solve the following coding problem using the programming language python: After decrypting the code Enigma crew came to know that there are N locations where bombs has been planted. X1, X2 …. Xn are the N locations. Among this locations, one X location is the central hub which control all the other Xn-1 location. 1 or...
```python def isPrime(num): if num == 0 or num == 1: return False if num == 2: return True if num % 2 == 0: return False i = 3 while i <= num**0.5+1: if num%i == 0: return False i = i+2 return True t = int(raw_input()) Arr = map(int, raw_input().strip().split(' ')) mx = -1 for i in Arr: #print...
vfc_34065
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n1 3 5 17 21 17 5 11 10 40\n\nSAMPLE", "output": "17\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1 3 5 17 21 17 5 11 7 40\n\nSAMPLE", "output": "17\n2\n", "type":...
code_contests
verifiable_code
indexing-the-palindrome
Solve the following coding problem using the programming language python: You are given a string of lower case letters. Your task is to figure out the index of the character on whose removal it will make the string a palindrome. There will always be a valid solution. In case the string is already a palindrome, then -...
```python for _ in range(input()): strn = raw_input().strip() le = len(strn) if le < 3: print "0" continue index = 0 f = 1 while index < le / 2: if strn[index] == strn[-1-index]: index+=1 else: f = 0 break if f == 1: ...
vfc_34069
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naaab\nbaa\naaa\n\nSAMPLE", "output": "3\n0\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\naaab\nbaa\naaa", "output": "3\n0\n-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
mattey-multiplication-6
Solve the following coding problem using the programming language python: Mattey has an assignment that he should submit tomorrow. The assignment has one question which asks to write a program to multiply two numbers without using ''* operator. As Mattey finds no interest in this subject, he never listens to classes a...
```python T=int(raw_input()) while T>0: sd=list() n=list(raw_input().split()) pro=int(n[0])*int(n[1]) c=0 x=int(n[0]) y=int(n[1]) s=x rem=1 # c=num-1 while y!=0: te=y%2 sd.extend(str(te)) y=y/2 c=c+1 # print sd[0] me=0 c=c-1 whi...
vfc_34073
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 1\n2 3\n\nSAMPLE", "output": "(2<<0)\n(2<<1) + (2<<0)\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 1\n2 3\n\nSAMPLE", "output": "(3<<0)\n(2<<1) + (2<<0)\n", "type"...
code_contests
verifiable_code
om-nom-and-candies
Solve the following coding problem using the programming language python: There are N boxes .The i^th box contains ai candies . The frog Om Nom is sitting in box number 1 .Om Nom wants to collect as many candies as he can . However , Om Nom jumps in a peculiar fashion . Om Nom can jump from box number j to box number ...
```python import math n=input() alist=map(int,raw_input().split()) track=[alist[i]+alist[0] for i in range(n)] track[0]-=alist[0] for i in range(2,int(n/2)+2): x=i+i while x<=n: track[x-1]=max(track[x-1],track[i-1]+alist[x-1]) x+=i for i in track: print i, ```
vfc_34077
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 3 1 4 6\n\nSAMPLE", "output": "2 5 3 9 8", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
ram-in-the-hostel-mess-3
Solve the following coding problem using the programming language python: Codex is about to start and Ram has not done dinner yet. So, he quickly goes to hostel mess and finds a long queue in front of food counter. But somehow he manages to take the food plate and reaches in front of the queue. The plates are divided...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' from math import factorial def ncr(n,r): if(n<0 or r<0): return 0 elif(n<r): return 0 else: return factorial(n)/(factorial(r)*factorial(n-r)) t = input() for i in ran...
vfc_34081
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n3\n\nSAMPLE", "output": "4\n25\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "19\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19", "output": "4\n9\n25\n64\n...
code_contests
verifiable_code
simple-maths
Solve the following coding problem using the programming language python: PROBLEM SPECIFICATION: You are given three positive integers 'n' , 'a' and 'b' . In the given range from 1 to 'n' how many distinct numbers are completely divisible by 'a' or 'b' or both? NOTE: The range includes both 1 and 'n'. INPUT SPECIFIC...
```python def lcm(x, y): if x > y: greater = x else: greater = y while(True): if((greater % x == 0) and (greater % y == 0)): lcm = greater break greater += 1 return lcm t = int(raw_input()) for j in range(t): c = 0 n,a,b = tuple(map(int,raw_input().s...
vfc_34085
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n24 5 3\n\nSAMPLE", "output": "11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "11\n24 5 3\n1000000000 1 4\n978654 5467 378\n100000008 2 87965\n989 3 78\n2571 23 890\n12345678 765 987\...
code_contests
verifiable_code
the-string-monster-july-easy
Solve the following coding problem using the programming language python: As Gudi escapes the room and moves onto to the next floor, the Wizard of UD receives her at the gate! The wizard questions her intelligence and does not allow her to move ahead unless she answers his puzzle correctly. The wizard says : Imagine ...
```python #!/usr/bin/env python #-*- coding:utf-8 -*- import sys, math, random, operator #from string import ascii_lowercase #from string import ascii_uppercase from fractions import Fraction, gcd from decimal import Decimal, getcontext from itertools import product, permutations, combinations from Queue import Queue,...
vfc_34089
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\nhey\nrain\nday\nwet\ndraaxiny\n4\nbump\nud\nbish\nchau\nbichhusa\n\nSAMPLE", "output": "NO\nYES", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n12\nwaqacryrawvqtwvvrrrtuwbqcawerb\n...
code_contests
verifiable_code
p00231 Dangerous Bridge
Solve the following coding problem using the programming language python: In Aizuwakamatsu Village, which is located far north of Aizuwakamatsu City, a bridge called "Yabashi" is the only way to move to the surrounding villages. Despite the large number of passers-by, the bridge is so old that it is almost broken. <i...
```python # coding: utf-8 # Your code here! class Sch: def __init__(self, m, t): self.m = m self.t = t def __lt__(self,other): if self.t == other.t: return self.m < other.m else: return self.t < other.t while True: N = int(input()) ...
vfc_34141
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n80 0 30\n50 5 25\n90 27 50\n3\n80 0 30\n70 5 25\n71 30 50\n0", "output": "NG\nOK", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n80 0 30\n50 5 25\n90 27 50\n3\n80 0 30\n70 5 25\n71 30 ...
code_contests
verifiable_code
p00609 Amazing Graze
Solve the following coding problem using the programming language python: In 2215 A.D., a war between two planets, ACM and ICPC, is being more and more intense. ACM introduced new combat planes. These planes have a special system that is called Graze, and fighting power of a plane increases when it is close to energy...
vfc_34149
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 1\n0 0\n0 4\n2 2\n2 8\n0 0 0", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 1\n0 0\n0 5\n2 2\n2 8\n0 0 0", "output": "3\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
p00746 Pablo Squarson's Headache
Solve the following coding problem using the programming language python: Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth. At the center of his studio, there is a huuuuuge table and beside it ...
```python while True: N = int(input()) w=[0]*N h=[0]*N wx=[-1,0,1,0] hy=[0,-1,0,1] if N == 0: break for i in range(1,N): n,d = map(int,input().split()) w[i] = w[n]+wx[d] h[i] = h[n]+hy[d] print(max(w)-min(w)+1,max(h)-min(h)+1) ```
vfc_34153
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n0 0\n0 1\n0 2\n0 3\n12\n0 0\n1 0\n2 0\n3 1\n4 1\n5 1\n6 2\n7 2\n8 2\n9 3\n10 3\n10\n0 2\n1 2\n2 2\n3 2\n2 1\n5 1\n6 1\n7 1\n8 1\n0", "output": "1 1\n3 3\n4 4\n5 6", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
p00885 Balloon Collecting
Solve the following coding problem using the programming language python: "Balloons should be captured efficiently", the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipulates a robot vehicle on th...
```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),(-1,1)] def LI(): return [int(x) for x in ...
vfc_34157
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 100\n100 270\n2\n10 100\n100 280\n3\n100 150\n10 360\n40 450\n3\n100 150\n10 360\n40 440\n2\n100 10\n50 200\n2\n100 100\n50 110\n1\n15 10\n4\n1 10\n2 20\n3 100\n90 200\n0", "output": "OK 220\nOK 200\nOK 260\nOK 280\nNG ...
code_contests
verifiable_code
p01016 Password
Solve the following coding problem using the programming language python: Taro had his own personal computer and set a password for login. However, Taro inadvertently forgot the password. Then, remembering that there was a piece of paper with the password written down, Taro found the paper and was surprised to see it....
```python a = input() b = input() length_a = len(a) length_b = len(b) def check(): for i in range(length_a - length_b + 1): for j in range(length_b): if b[j] == "_" or a[i + j] == b[j]:continue else:break else: print("Yes") return print("No") ...
vfc_34161
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "KUSATSU\nKSATSU", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, "input": "ABCABC\nACBA_B", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01149 Blackjack
Solve the following coding problem using the programming language python: Brian Jones is an undergraduate student at Advanced College of Metropolitan. Recently he was given an assignment in his class of Computer Science to write a program that plays a dealer of blackjack. Blackjack is a game played with one or more d...
```python N=int(raw_input()) for i in range(N): hand=raw_input().split() deck=raw_input().split() #defaulthand d=0 points=0 for i in range(len(hand)): if hand[i] in ['T','J','Q','K']: hand[i]=10 elif hand[i]=='A': hand[i]=11 else: hand[i...
vfc_34165
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n5 4\n9 2 8 3 7 4 6 5\nA J\nK Q J T 9 8 7 6\nT 4\n7 J A 6 Q T K 7\n2 2\n2 3 4 K 2 3 4 K", "output": "18\nblackjack\n21\nbust", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 4\n9 2 8 3...
code_contests
verifiable_code
p01288 Marked Ancestor
Solve the following coding problem using the programming language python: You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T: * M v: (Mark) Mark node v. * Q v: (Query) Print the index of the nearest ma...
```python def root(x): while P[x] != x: x = P[x] return x def mark(x): P[x-1] = x-1 def query(x): v = root(x-1) +1 return v while True: N,Q = map(int,input().strip().split(" ")) if N == Q == 0: break P = [] P.append(0) for i in range(N-1): p_i = int(input...
vfc_34169
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n1\n1\n2\n3\n3\nQ 5\nM 3\nQ 5\n0 0", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n2\n1\n2\n3\n3\nQ 5\nM 3\nQ 5\n0 0", "output": "4\n", "type": "stdin_std...
code_contests
verifiable_code
p01457 Carpenters' Language
Solve the following coding problem using the programming language python: International Carpenters Professionals Company (ICPC) is a top construction company with a lot of expert carpenters. What makes ICPC a top company is their original language. The syntax of the language is simply given in CFG as follows: S -> ...
```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 = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split...
vfc_34173
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 ( 10\n10 ) 20\n0 ( 10", "output": "No\nNo\nYes", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 ( 10\n10 ) 5\n10 ) 5", "output": "No\nNo\nYes", "type": "stdin_stdout" ...
code_contests
verifiable_code
p01608 1
Solve the following coding problem using the programming language python: 1 Problem Statement There is a bit string of length n. When the i-th bit from the left is 1, the score is a_i points. The number of 1s within the distance w around the i-th bit from the left (= | \\ {j \ in \\ {1, ..., n \\} ∩ \\ {iw, ..., i ...
vfc_34177
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n3 1 2 7\n13 8 25 9", "output": "1001", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01903 Overflow of Furo
Solve the following coding problem using the programming language python: F: Bath overflows --Overflow of Furo - story The hot spring inn Paro is passionate about the hot springs that it is proud of, and is attracting professional bathers. Bath professionals mainly manage the plumbing of hot springs, and manage and ...
vfc_34185
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 4\n1 3 4\n2 4 2\n0 3 3\n4 0 5", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 4\n1 3 4\n2 4 2\n0 3 3\n4 0 5", "output": "8\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
p02041 LISum
Solve the following coding problem using the programming language python: problem Given the sequence $ A $ of length $ N $. Find the maximum value of $ \ sum B_i $, where $ B $ is one of the longest increasing subsequences of the sequence $ A $. The longest increasing subsequence of the sequence $ A $ is the longest...
```python import bisect N = int(input()) A = list(map(int,input().split())) lis = [] hist = [] for a in A: i = bisect.bisect_left(lis,a) if i == len(lis): lis.append(a) hist.append([a]) else: lis[i] = a hist[i].append(a) ans = last = hist[-1][0] for row in reversed(hist[:-...
vfc_34189
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6 4 7 8", "output": "21", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n7 4 7 8", "output": "19\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
p02184 Canisar Cipher
Solve the following coding problem using the programming language python: C: Canisal cryptography problem Ebi-chan was given the string C obtained by encrypting a non-negative integer D with "canisal cipher". This cipher replaces each number in decimal notation with a fixed number (not necessarily different from the...
```python # 半分全列挙 from itertools import permutations, combinations M = int(input()) C = list(map(int, input())) if len(C)==1 and M==0: print(0) exit() mod = 10**9 + 7 L = [0] * 10 b = 1 for c in C[::-1]: L[c] += b b = b * 10 % mod for t_half1 in combinations(range(10), 5): L1, L2 = L[:5], L[5:] ...
vfc_34193
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1000000007", "output": "1000000009", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1036219253", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
aou
Solve the following coding problem using the programming language python: For Turbo C++ Users : Read the following document before attempting the question : Problem Description Hank Pym is an aspiring student at IIITD. He has almost completed his work on Ultron, the ultimate artificial intelligence. However, one t...
```python max = 10**5 a = [True]*max prime = [] for i in range(2,max): if a[i]: prime.append(i) j = 2*i while j < max: a[j] = False j += i n = input() for z in range(n): k = input() count = 0 track = 0 while track < len(prime) and k!=1: while k...
vfc_34205
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n9\n100\n17", "output": "1\n2\n4\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2\n9\n100\n28", "output": "1\n2\n4\n3\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
cielab
Solve the following coding problem using the programming language python: In Ciel's restaurant, a waiter is training. Since the waiter isn't good at arithmetic, sometimes he gives guests wrong change. Ciel gives him a simple problem. What is A-B (A minus B) ? Surprisingly, his answer is wrong. To be more precise, hi...
```python test = map(int,raw_input().split()) count = str(abs(test[0] - test[1])) l = ['1','2','3','4','5','6','7','8','9'] l.remove(count[0]) string = '' string += l[0] string += count[1:len(count)+1] print int(string) ```
vfc_34209
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5858 1234", "output": "1624\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5858 2439", "output": "1419\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
etmx06
Solve the following coding problem using the programming language python: Common Integer Andy wants to prove his practical programming knowledge to his old pal. He will get two numbers both in the range 10 to 99. if there exists a comon integer in both the numbers, he has to write TRUE or else FALSE. For Example: ...
```python x=raw_input() a,b=x.split() d=0 for i in a: if i in b: print "TRUE" d=1 break if d==0: print "FALSE" ```
vfc_34213
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11 34", "output": "FALSE", "type": "stdin_stdout" }, { "fn_name": null, "input": "12 24", "output": "TRUE", "type": "stdin_stdout" }, { "fn_name": null, "input": "19 3...
code_contests
verifiable_code
ladybug1
Solve the following coding problem using the programming language python: Mrs. Verma has decided to sell his car. N people have offered to buy the car. Instead of selling to the highest bidder, Mrs. Verma decides to sell his company to the Kth lowest bidder. How much money will Mrs. Verma get? Input The first line of...
```python n, k = map(int, raw_input().split()); a = [int(i) for i in raw_input().split()]; a.sort(); print a[k - 1]; ```
vfc_34217
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4\n1 2 1 3 3", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
pcsc2
Solve the following coding problem using the programming language python: Phillip has become fascinated with sequences lately. He looks for sequences all the time. His favorite sequence is the Fibonacci sequence, where any element is equal to the sum of the two previous elements. However, he isn't able to figure ou...
```python fib=[] i1,i2,i3=map(int, raw_input().split()) y=i3 p=i1 fib.append(p) r=i2 fib.append(r) while(y): n=p+r fib.append(n) p=r r=n y-=1 print fib.pop((i3-1)) ```
vfc_34221
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 5 7", "output": "45", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
start01
Solve the following coding problem using the programming language python: Problem Statement Write a program that accepts a number and outputs the same. Sample Input 123 Sample Output 123 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing...
```python num=int(raw_input()) print num ```
vfc_34225
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "123", "output": "123\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1008_A. Romaji
Solve the following coding problem using the programming language python: Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant. In Berlanese, there has to be a vowel after every consonant, but...
```python s=input() a=['a','e','i','o','u'] c=0 for i in range(len(s)): if(i==len(s)-1): if s[i] in a or s[i]=='n': c+=1 continue elif s[i] in a: c+=1 continue elif(s[i]=='n'): c+=1 continue else: if s[i+1] in a: ...
vfc_34229
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "codeforces\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ninja\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1030_F. Putting Boxes Together
Solve the following coding problem using the programming language python: There is an infinite line consisting of cells. There are n boxes in some cells of this line. The i-th box stands in the cell a_i and has weight w_i. All a_i are distinct, moreover, a_{i - 1} < a_i holds for all valid i. You would like to put to...
vfc_34233
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 8\n1 2 6 7 10\n1 1 1 1 2\n1 1\n1 5\n1 3\n3 5\n-3 5\n-1 10\n1 4\n2 5\n", "output": "0\n10\n3\n4\n18\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10\n4 5 6 7 8 11 14 15 17 19\n1 4...
code_contests
verifiable_code
1053_D. Linear Congruential Generator
Solve the following coding problem using the programming language python: You are given a tuple generator f^{(k)} = (f_1^{(k)}, f_2^{(k)}, ..., f_n^{(k)}), where f_i^{(k)} = (a_i ⋅ f_i^{(k - 1)} + b_i) mod p_i and f^{(0)} = (x_1, x_2, ..., x_n). Here x mod y denotes the remainder of x when divided by y. All p_i are pr...
vfc_34237
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 3 5 7\n", "output": "210\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1075_E. Optimal Polygon Perimeter
Solve the following coding problem using the programming language python: You are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from 1 to n...
```python n = int(input()) north = -100000000 south = 100000000 east = -100000000 west = 100000000 ne = -200000000 nw = -200000000 se = -200000000 sw = -200000000 for i in range(n): x,y = map(int,input().split()) north = max(north,y) east = max(east,x) south = min(south,y) west = min(west,x) ne ...
vfc_34241
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 4\n4 3\n3 0\n1 3\n", "output": "12 14 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 0\n0 2\n2 0\n", "output": "8 ", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
1096_F. Inversion Expectation
Solve the following coding problem using the programming language python: A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_i < a_j. For example, a permutation [4, 1, 3, 2...
```python base=998244353; def power(x, y): if(y==0): return 1 t=power(x, y//2) t=(t*t)%base if(y%2): t=(t*x)%base return t; def inverse(x): return power(x, base-2) ft=[0] for i in range(0, 200000): ft.append(0) def get(i): res=0 while(i<=200000): res+=ft[i] ...
vfc_34245
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\n", "output": " 0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1117_G. Recursive Queries
Solve the following coding problem using the programming language python: You are given a permutation p_1, p_2, ..., p_n. You should answer q queries. Each query is a pair (l_i, r_i), and you should calculate f(l_i, r_i). Let's denote m_{l, r} as the position of the maximum in subsegment p_l, p_{l+1}, ..., p_r. Then...
vfc_34249
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5\n3 1 4 2\n2 1 1 2 1\n2 3 4 4 1\n", "output": "1 6 8 5 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n3 1 4 2\n2 2 1 2 1\n2 3 4 4 1\n", "output": " ...
code_contests
verifiable_code
1144_C. Two Shuffled Sequences
Solve the following coding problem using the programming language python: Two integer sequences existed initially — one of them was strictly increasing, and the other one — strictly decreasing. Strictly increasing sequence is a sequence of integers [x_1 < x_2 < ... < x_k]. And strictly decreasing sequence is a sequen...
```python n = int(input()) a = [int(s) for s in input().split()] d = dict() for i in a: x = d.get(i,0) if x == 0: d[i] = 1 else: d[i] += 1 up = [] down = [] for i in d.keys(): k = d[i] if k == 1: up.append(i) elif k == 2: up.append(i) down.append(i) el...
vfc_34253
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 3 1 5 3\n", "output": "YES\n4\n1 3 4 5\n1\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1165_B. Polycarp Training
Solve the following coding problem using the programming language python: Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly 1 problem, during the second day — exactly 2 problems, during the third day — exactly 3 problems, and so on. During the ...
```python a = int(input()) b = [int(x) for x in input().split()] b.sort() s = 1 q = 0 for i in b: if i >= s: s += 1 q += 1 print(q) ```
vfc_34257
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 1 4 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 1 2 2\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1219_I. The Light Square
Solve the following coding problem using the programming language python: For her birthday Alice received an interesting gift from her friends – The Light Square. The Light Square game is played on an N × N lightbulbs square board with a magical lightbulb bar of size N × 1 that has magical properties. At the start of ...
```python N = input() a, b = [], [] for n in range(N) : a.append(raw_input()) for n in range(N) : b.append(raw_input()) wand = raw_input() piv = -1 if wand.count('1') == 0 else wand.index('1') def getVar(ca, row, col) : v = int(a[row][col]) ^ (int(wand[row])*ca[col]) if v == v ^ int(wand[col]) : if v =...
vfc_34269
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n110\n011\n100\n100\n011\n100\n100\n", "output": "1\ncol 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n11\n11\n00\n01\n11\n", "output": "-1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
1244_D. Paint the Tree
Solve the following coding problem using the programming language python: You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph. <image> Example of a tree. You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every color...
```python import sys from collections import defaultdict,deque def getcost(ind,col1,col2,col3,count): #print(ind,'ind',count,'count') if count==1: #print(col1[ind-1],'collooorr') return col1[ind-1] if count==2: #print(col2[ind-1],'colllllooorrr') return col2[ind-1] #print...
vfc_34273
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 4 2 1 2\n4 2 1 5 4\n5 3 2 1 1\n1 2\n3 2\n4 3\n5 3\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n3 4 2 1 2\n4 2 1 5 4\n5 3 2 1 1\n1 2\n3 2\n4 3\n5 4\n", "o...
code_contests
verifiable_code
1264_B. Beautiful Sequence
Solve the following coding problem using the programming language python: An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to 1. More formally, a sequence s_1, s_2, …, s_{n} is beautiful if |s_i - s_{i+1}| = 1 for all 1 ≤ i ≤ n - 1. Trans has a numbers 0, b number...
```python import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter # from itertools import permutations,combinations d...
vfc_34277
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 3 4\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 2 3\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
1285_D. Dr. Evil Underscores
Solve the following coding problem using the programming language python: Today, as a friendship gift, Bakry gave Badawy n integers a_1, a_2, ..., a_n and challenged him to choose an integer X such that the value \underset{1 ≤ i ≤ n}{max} (a_i ⊕ X) is minimum possible, where ⊕ denotes the [bitwise XOR operation](https...
```python def solve(nums, bit): if bit < 0: return 0 l = [] r = [] for el in nums: if ((el >> bit) & 1): r.append(el) else: l.append(el) if len(l) == 0: return solve(r, bit - 1) if len(r) == 0: return solve(l, bit - 1) return min(solve(l, bit - 1), solve(r, bit - 1)) + (1 << bit) n = int(input()) nums = map(...
vfc_34281
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 5\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n...
code_contests
verifiable_code
1329_A. Dreamoon Likes Coloring
Solve the following coding problem using the programming language python: Dreamoon likes coloring cells very much. There is a row of n cells. Initially, all cells are empty (don't contain any color). Cells are numbered from 1 to n. You are given an integer m and m integers l_1, l_2, …, l_m (1 ≤ l_i ≤ n) Dreamoon wi...
```python n,m=map(int,input().split()) b=list(map(int,input().split())) if sum(b)<n:print(-1) else: s=n+1;r=[-1]*m;i=0 for j in b[::-1]: s=max(s-j,m-i) if s+j-1>n:print(-1);break r[i]=s;i+=1 else:print(*r[::-1]) ```
vfc_34289
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 1\n1\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n3 2 2\n", "output": "1 2 4 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1349_A. Orac and LCM
Solve the following coding problem using the programming language python: For the multiset of positive integers s=\\{s_1,s_2,...,s_k\}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow: * \gcd(s) is the maximum positive integer x, such that all integers in s are divisible on x...
```python from collections import Counter from math import floor, sqrt try: long except NameError: long = int def fac(n): step = lambda x: 1 + (x<<2) - ((x>>1)<<1) maxq = long(floor(sqrt(n))) d = 1 q = 2 if n % 2 == 0 else 3 while q <= maxq and n % q != 0: q = step(d) d...
vfc_34293
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n540 648 810 648 720 540 594 864 972 648\n", "output": "54\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1391_D. 505
Solve the following coding problem using the programming language python: A binary matrix is called good if every even length square sub-matrix has an odd number of ones. Given a binary matrix a consisting of n rows and m columns, determine the minimum number of cells you need to change to make it good, or report th...
```python def f( l, a): i, count = 0,0 for x in l: count += x not in a[i] #print( x, a[i], count ) i = (i+1) %2 return count def g( l, mx ): return min( [ f(l,mx[i]) for i in range(len(mx)) ] ) def two(): l = [ x[0]+x[1] for x in zip(input(),input())] mx =...
vfc_34301
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n101\n001\n110\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 15\n000100001010010\n100111010110001\n101101111100100\n010000111111010\n111010010100001\n0000110011111...
code_contests
verifiable_code
1431_J. Zero-XOR Array
Solve the following coding problem using the programming language python: You are given an array of integers a of size n. This array is non-decreasing, i. e. a_1 ≤ a_2 ≤ ... ≤ a_n. You have to find arrays of integers b of size 2n - 1, such that: * b_{2i-1} = a_i (1 ≤ i ≤ n); * array b is non-decreasing; * b_...
vfc_34309
{ "difficulty": "16", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 1 3\n", "output": "\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 3 6 7\n", "output": "\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
1455_G. Forbidden Value
Solve the following coding problem using the programming language python: Polycarp is editing a complicated computer program. First, variable x is declared and assigned to 0. Then there are instructions of two types: 1. set y v — assign x a value y or spend v burles to remove that instruction (thus, not reassign x...
vfc_34313
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 1\nset 1 10\nset 2 15\nif 2\nset 1 7\nend\n", "output": "\n17\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1506_G. Maximize the Remaining String
Solve the following coding problem using the programming language python: You are given a string s, consisting of lowercase Latin letters. While there is at least one character in the string s that is repeated at least twice, you perform the following operation: * you choose the index i (1 ≤ i ≤ |s|) such that the...
```python for _ in range(int(input())): s = input(); stack = []; seen = set(); last_occurrence = {c: i for i, c in enumerate(s)} for i, c in enumerate(s): if c not in seen: while stack and c > stack[-1] and i < last_occurrence[stack[-1]]: seen.discard(...
vfc_34321
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\ncodeforces\naezakmi\nabacaba\nconvexhull\nswflldjgpaxs\nmyneeocktxpqjpz\n", "output": "\nodfrces\nezakmi\ncba\nconvexhul\nwfldjgpaxs\nmyneocktxqjpz\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1534_A. Colour the Flag
Solve the following coding problem using the programming language python: Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag). You are given an n × m grid of "R", "W", and "." characters. "R" is red, "W" is white and "." is b...
```python I=input for _ in[0]*int(I()): s=set();n,m=map(int,I().split());i=5 for _ in[0]*n: i^=5;j=5 for x in I():j^=5;s|=(s,{ord(x)^i^j})[x>'.'] if len(s)<2: c=s and s.pop()or 82 r=('YES',*(''.join(chr(c^((i^j)&1)*5)for i in range(m))for j in range(n))) else:r='NO', print(*r) ```
vfc_34325
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 6\n.R....\n......\n......\n.W....\n4 4\n.R.W\n....\n....\n....\n5 1\nR\nW\nR\nW\nR\n", "output": "\nYES\nWRWRWR\nRWRWRW\nWRWRWR\nRWRWRW\nNO\nYES\nR\nW\nR\nW\nR\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
180_E. Cubes
Solve the following coding problem using the programming language python: Let's imagine that you're playing the following simple computer game. The screen displays n lined-up cubes. Each cube is painted one of m colors. You are allowed to delete not more than k cubes (that do not necessarily go one after another). Aft...
```python # ---------------------------iye ha aam zindegi--------------------------------------------- import math import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction mod = 10 ** 9 + 7 mod1 = 998244353 # ------------------------------warmup------------------------...
vfc_34333
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1 2\n1 1 1\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 2 2\n1 2 1 2 1 1 2 1 1 2\n", "output": "5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
204_A. Little Elephant and Interval
Solve the following coding problem using the programming language python: The Little Elephant very much loves sums on intervals. This time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x equals the last one (in dec...
```python def F (x) : if (x < 10) : return x rv = 9 tmp = x len = 0 while (tmp > 0) : len += 1 tmp = tmp // 10 d = int (x // pow(10, len-1)) tmp = 1 for i in range(len - 2) : rv += 9 * tmp tmp *= 10 for i in range (1, 10) : if (...
vfc_34337
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "47 1024\n", "output": "98\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 47\n", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...