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
337_B. Routine Problem
Solve the following coding problem using the programming language python: Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio c:d. Manao adjusts the view in such a way that the movie pres...
```python import sys from fractions import gcd my_file = sys.stdin #my_file = open("input.txt", "r") line = [int(i) for i in my_file.readline().split()] a, b, c, d = line[0], line[1], line[2], line[3] if a/b < c/d: N = (b*c) - (a*d) D = b*c else: N = (a*d)-(b*c) D = a*d dec = gcd(N,D) print(N//dec, en...
vfc_54757
{ "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 1 3 2\n", "output": "1/3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3 2 2\n", "output": "1/4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
35_D. Animals
Solve the following coding problem using the programming language python: Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse storing Ogudar-Olok, a magical but non-alcoholic drink) came home after a hard day. That day he had to drink 9...
vfc_54761
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n1 1 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 6\n1 1 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
404_A. Valera and X
Solve the following coding problem using the programming language python: Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today...
```python n = int(input()) data = [] ghotr = set() other = set() for i in range(n): text = input() for index in range(len(text)): if index == i: ghotr.add(text[index]) elif index == n - i - 1: ghotr.add(text[n-1-i]) else: other....
vfc_54769
{ "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\nxooox\noxoxo\nsoxoo\noxoxo\nxooox\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nwsw\nsws\nwsw\n", "output": "YES\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
453_D. Little Pony and Elements of Harmony
Solve the following coding problem using the programming language python: The Elements of Harmony are six supernatural artifacts representing subjective aspects of harmony. They are arguably the most powerful force in Equestria. The inside of Elements of Harmony can be seen as a complete graph with n vertices labeled ...
vfc_54777
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 10000\n4 1 2 3\n0 1 0\n", "output": "14\n6\n6\n14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 276447232 3214567\n583583455 627533935 611750460 726535241 270420970 520570962 76038...
code_contests
verifiable_code
476_B. Dreamoon and WiFi
Solve the following coding problem using the programming language python: Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them. Each command is one of the following two types: 1. Go 1 unit towards the positiv...
```python import math s1=input() s2=input() c1=0 c2=0 c3=0 for items in s1: if items=="+": c1+=1 if items=="-": c2+=1 for items in s2: if items=="+": c1-=1 if items=="-": c2-=1 if items=="?": c3+=1 if (c2<0): print(0.000) elif (c2>c3): print(0.000)...
vfc_54781
{ "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": "++-+-\n+-+-+\n", "output": "1.000000000\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
49_C. Disposition
Solve the following coding problem using the programming language python: Vasya bought the collected works of a well-known Berland poet Petya in n volumes. The volumes are numbered from 1 to n. He thinks that it does not do to arrange the book simply according to their order. Vasya wants to minimize the number of the ...
```python print(*range(2, int(input())+1), end=' ') print(1) ```
vfc_54785
{ "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\n", "output": "2 3 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "2 1 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
524_C. The Art of Dealing with ATM
Solve the following coding problem using the programming language python: ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiar...
```python # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq,bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(1...
vfc_54789
{ "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 2\n1 2 3 5 8\n8\n1\n3\n5\n7\n9\n11\n13\n15\n", "output": "1\n1\n1\n2\n2\n2\n2\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 20\n10 50 100 500 1000 5000\n8\n4200\n100000\n95000\n9...
code_contests
verifiable_code
54_C. First Digit Law
Solve the following coding problem using the programming language python: In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's the ...
```python def num_ones(a,b): '''returns how many nums start with digit 1 in [a,b]''' if a==0: if b==0: return 0 ans=0 b=str(b) for i in range(1,len(b)): ans+=10**(i-1) if b[0]=='1': x=b[1:] if x=='': x=0 ...
vfc_54793
{ "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": "2\n1 2\n9 11\n50\n", "output": "0.833333333333333\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 2\n50\n", "output": "0.500000000", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
576_D. Flights for Regular Customers
Solve the following coding problem using the programming language python: In the country there are exactly n cities numbered with positive integers from 1 to n. In each city there is an airport is located. Also, there is the only one airline, which makes m flights. Unfortunately, to use them, you need to be a regular...
vfc_54797
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 2 0\n2 3 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1 2 100500\n", "output": "Impossible\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
620_A. Professor GukiZ's Robot
Solve the following coding problem using the programming language python: Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the ...
```python x2,y2=map(int,input().split()) x1,y1=map(int,input().split()) m=min(abs(x1-x2),abs(y2-y1) ) d=max(abs(x1-x2),abs(y2-y1) ) ans = m+d-m print(ans ) ```
vfc_54805
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0\n4 5\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n6 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
63_E. Sweets Game
Solve the following coding problem using the programming language python: Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a ga...
```python import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') lines = [ [0, 1, 2], [3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18], [0, 3, 7], [1, 4, 8, 12], [2, 5, 9, 13, 16], [6, 10, 14, 17], [...
vfc_54809
{ "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": ". . .\n . . . O\n. . . O .\n O . O .\n . O .\n", "output": "Karlsson\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ". . .\n . . O .\n. . O O .\n . . . .\n . . .\n", "output": "Lil...
code_contests
verifiable_code
669_C. Little Artem and Matrix
Solve the following coding problem using the programming language python: Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it. That ele...
```python a, b, c = map(int, input().split()) arr = [] mat = [[0 for j in range(b)] for i in range(a)] for i in range(c): arr.append(input()) arr = arr[::-1] for command in arr: arra = [int(i) for i in command.split()] if arra[0] == 1: swp = mat[arra[1] - 1][b - 1] for i in range(b): ...
vfc_54813
{ "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": "2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8\n", "output": "8 2\n1 8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 2\n1 2\n3 2 2 5\n", "output": "0 0 0\n0 0 5\n0 0 0\n",...
code_contests
verifiable_code
690_D3. The Wall (hard)
Solve the following coding problem using the programming language python: So many wall designs to choose from! Even modulo 106 + 3, it's an enormous number. Given that recently Heidi acquired an unlimited supply of bricks, her choices are endless! She really needs to do something to narrow them down. Heidi is quick t...
```python mod = 10 ** 6 + 3 def prod(a, b): return [[sum([a[i][k] * b[k][j] for k in range(len(b))]) % mod for j in range(len(b[0]))] for i in range(len(a))] c, w, h = map(int, input().split()) a = [[0] * (w + 1) for _ in range(w + 1)] for i in range(w): a[i][i + 1] = 1 for cnt in range(0, w + 1): a...
vfc_54817
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 15, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4 9\n", "output": "40951\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "40 37 65\n", "output": "933869\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
714_E. Sonya and Problem Wihtout a Legend
Solve the following coding problem using the programming language python: Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the...
```python N=int(input()) s=list(map(int,input().split())) for i in range(N):s[i]-=i X=sorted(s) dp=[0]*N for i in s: mi = 7e77 for j in range(N): mi = min(mi, dp[j]) dp[j] = mi + abs(i-X[j]) print(min(dp)) ```
vfc_54821
{ "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": "5\n5 4 3 2 1\n", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n2 1 5 11 5 9 11\n", "output": "9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
75_B. Facetook Priority Wall
Solve the following coding problem using the programming language python: Facetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sort all posts from your friends according to the priority factor (it will be described). This priority factor wi...
```python from collections import defaultdict u, p = input(), defaultdict(int) for i in range(int(input())): t = input().split() a, k = t[0], t[1][0] if k == 'p': b, d = t[3][: -2], 15 elif k == 'c': b, d = t[3][: -2], 10 else: b, d = t[2][: -2], 5 if a == u: p[b] += d elif b == u: p[a] += d...
vfc_54829
{ "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": "aba\n1\nlikes likes posted's post\n", "output": "likes\nposted\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ahmed\n3\nahmed posted on fatma's wall\nfatma commented on ahmed's post\nmona...
code_contests
verifiable_code
780_A. Andryusha and Socks
Solve the following coding problem using the programming language python: Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants t...
```python NumOfSocks = int(input()) Socks = [int(x) for x in input().split()] OnTable, maxSocks, tmpMaxSocks = [0] * (NumOfSocks+1), 0, 0 for i in Socks: if not OnTable[i]: OnTable[i] = 1 tmpMaxSocks += 1 else: OnTable[i] = 0 tmpMaxSocks -= 1 if tmpMaxSocks > maxSocks: maxSo...
vfc_54833
{ "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\n1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 1 1 3 2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
803_E. Roma and Poker
Solve the following coding problem using the programming language python: Each evening Roma plays online poker on his favourite website. The rules of poker on this website are a bit strange: there are always two players in a hand, there are no bets, and the winner takes 1 virtual bourle from the loser. Last evening R...
```python n, k = [int(i) for i in input().split()] s = input() dp = [[False] * 2010 for i in range(1001)] dp[0][0] = True for i in range(n): l = -k + 1 r = k if i == n - 1: l -= 1 r += 1 for b in range(l, r): if s[i] == 'L': dp[i + 1][b] = dp[i][b + 1] elif ...
vfc_54837
{ "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 1\nW??\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\nL??\n", "output": "LDL\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
828_C. String Reconstruction
Solve the following coding problem using the programming language python: Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the string s. Namely...
```python from sys import stdin, stdout sze = 10 ** 6 + 1 n = int(stdin.readline()) challengers = [] strings = [] sze = 10 ** 6 + 1 cnt = [[] for i in range(sze)] for i in range(n): s = stdin.readline().strip().split() num = int(s[1]) values = list(map(int, s[2:])) strings.append(s[0]) ...
vfc_54841
{ "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\nab 1 1\naba 1 3\nab 2 3 5\n", "output": "ababab\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\na 4 1 3 5 7\nab 2 1 5\nca 1 4\n", "output": "abacaba\n", "type": "stdin_st...
code_contests
verifiable_code
84_D. Doctor
Solve the following coding problem using the programming language python: There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore...
```python import sys from array import array # noqa: F401 from collections import deque def input(): return sys.stdin.buffer.readline().decode('utf-8') n, k = map(int, input().split()) a = list(map(int, input().split())) if sum(a) < k: print(-1) exit() ok, ng = 0, 10**9 + 10 while abs(ok - ng) > 1: ...
vfc_54845
{ "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": "7 10\n1 3 3 1 2 3 1\n", "output": "6 2 3 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2 1\n", "output": "2 \n", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
873_A. Chores
Solve the following coding problem using the programming language python: Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai ≥ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not...
```python n, k, x = map(int, input().split()) a = [int(x) for x in input().split()] res = k*x n-=k res+=sum(a[:n]) print(res) ```
vfc_54849
{ "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": "4 2 2\n3 6 7 10\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2 1\n100 100 100 100 100\n", "output": "302\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
898_F. Restoring the Expression
Solve the following coding problem using the programming language python: A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' an...
```python def modgroup(M = 10**9+7, invn = 0) : exec(f'''class mod{M} : inv = [None] * {invn+1} if {invn+1} >= 2 : inv[1] = 1 for i in range(2, {invn+1}) : inv[i] = (({M} - {M}//i) * inv[{M}%i]) %{M} def __init__(self, n = 0) : self.n = n % {M} __repr__ = lambda self : str(self.n) + '%{M}' __int__ = lambda sel...
vfc_54853
{ "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": "12345168\n", "output": "123+45=168", "type": "stdin_stdout" }, { "fn_name": null, "input": "099\n", "output": "0+9=9", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
91_A. Newspaper Headline
Solve the following coding problem using the programming language python: A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. Aft...
```python import math a, b = input(), input() na = len(a) nb = len(b) dp = [[-1 for _ in range(26)] for _ in range(na+1)] # dp = ([-1 for _ in range(26)],) * (na + 1) for i in range(na - 1, -1, -1): for j in range(26): dp[i][j] = dp[i+1][j] dp[i][ord(a[i]) - 97] = i cp = 0 ans = 1 i = 0 while i < nb: ...
vfc_54857
{ "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": "abc\nxyz\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "abcd\ndabc\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
946_F. Fibonacci String Subsequences
Solve the following coding problem using the programming language python: You are given a binary string s (each character of this string is either 0 or 1). Let's denote the cost of string t as the number of occurences of s in t. For example, if s is 11 and t is 111011, then the cost of t is 3. Let's also denote the ...
vfc_54861
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4\n11\n", "output": "14\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
975_D. Ghosts
Solve the following coding problem using the programming language python: Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way. There are n ghosts in the universe, they move in the OXY plane, each one of them has its own velocity that does not change...
```python import atexit import io import sys # Buffering IO _INPUT_LINES = sys.stdin.read().splitlines() input = iter(_INPUT_LINES).__next__ _OUTPUT_BUFFER = io.StringIO() sys.stdout = _OUTPUT_BUFFER @atexit.register def write(): sys.__stdout__.write(_OUTPUT_BUFFER.getvalue()) def main(): n, a, b = [int...
vfc_54865
{ "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 1 1\n1 -1 -1\n2 1 1\n3 1 1\n4 -1 -1\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 0\n0 0 0\n1 0 0\n2 0 0\n", "output": "0\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
995_C. Leaving the Bar
Solve the following coding problem using the programming language python: For a vector \vec{v} = (x, y), define |v| = √{x^2 + y^2}. Allen had a bit too much to drink at the bar, which is at the origin. There are n vectors \vec{v_1}, \vec{v_2}, ⋅⋅⋅, \vec{v_n}. Allen will make n moves. As Allen's sense of direction is ...
```python import random n = int(input()) V = [tuple(map(int,input().split())) for i in range(n)] dist = lambda x,y:x*x+y*y indices = sorted((dist(*v),i) for i,v in enumerate(V)) result = [0]*n vx,vy = 0,0 for d,i in reversed(indices): x,y = V[i] _,c = min(((dist(vx+x,vy+y),1),(dist(vx-x,vy-y),-1))) vx += c*...
vfc_54869
{ "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": "1\n-824590 246031\n", "output": "1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n-67761 603277\n640586 -396671\n46147 -122580\n569609 -2112\n400 914208\n131792 309779\n-850150 -486293\...
code_contests
verifiable_code
bajirao-returns
Solve the following coding problem using the programming language python: Bajirao's city has N X N police stations P(i,j) (1 ≤ i ≤ N, 1 ≤ j ≤ N) arranged in an N X N square matrix format. Bajirao is a really hardworking police officer and wants to solve all the pending cases of all the police stations in his city. How...
```python n=input() casearray=[] for i in range(n): casearray.append(map(int,raw_input().split())) maxcase=[] maxcaseperlevel=[] directconnect=[] for i in range(n): directconnect.append(-1) maxcase.append([]) maxcaseperlevel.append([]) for j in range(n): maxcase[i].append(0) maxcasep...
vfc_54873
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n3 1 2\n1 4 1\n\nSAMPLE", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 0 3\n3 1 2\n1 4 1\n\nSAMPLE", "output": "10\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
chris-angle
Solve the following coding problem using the programming language python: Chris always struggle in converting angles from degree to radian or vice-verse. You being his best friend whom he trusts so much, decided to help him out. Sam has T angles you need to convert them in radian and represent them in fraction(i.e P/Q...
```python from fractions import gcd t=int(raw_input()) while(t): angle=int(raw_input()) if angle>=360: angle=angle-360*(angle//360) g=gcd(angle,180) rad=180 while(g!=1): angle=angle/g rad/=g g=gcd(angle,rad) if angle==1 and rad!=1: print "$"+"/"+str(rad) elif angle!=1 and rad==1: print str(an...
vfc_54877
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n90\n180\n87\n720\n4\n\nSAMPLE", "output": "$/2\n$\n29$/60\n0$\n$/45", "type": "stdin_stdout" }, { "fn_name": null, "input": "500\n3\n87\n90\n180\n123\n3029383\n46370886\n80572777\n13446915\n564177...
code_contests
verifiable_code
eggs-and-building
Solve the following coding problem using the programming language python: You are given 'k' eggs and a 'n' storey building. The eggs MIGHT break if thrown down from a specific height (Note: It is NOT necessary that the eggs have to break; they might not even break from the topmost floor). What is the minimum number of...
```python ht = {} def floors(e, s): if e == 0 or s == 0: return 0 elif e == 1: return s elif s == 1: return 1 elif e > s: return floors(s, s) if not ht.has_key((e, s)): ht[(e, s)] = floors(e-1, s-1) + floors(e, s-1) + 1 return ht[(e, s)] noc = input() whi...
vfc_54881
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10 1\n10 2\n100 2\n104 3\n\nSAMPLE", "output": "10\n4\n14\n9", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n42 8\n335 1\n170 5\n479 9\n963 5\n706 6\n282 8\n962 2\n996 3\n828 7", ...
code_contests
verifiable_code
have-a-nice-day
Solve the following coding problem using the programming language python: A fashion show rates participants according to their level of hotness. Two different fashion shows were organized, one for men and the other for women. A date for the third is yet to be decided ;) . Now the results of both fashion shows are out...
```python T=input() while(T): T-=1 N=input() H=map(int,raw_input().split()) M=map(int,raw_input().split()) H.sort() M.sort() s=0 for x in xrange(N): s+=H[x]*M[x] print s ```
vfc_54885
{ "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\n1 1\n3 2\n3\n2 3 2\n1 3 2\n\nSAMPLE", "output": "5\n15\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n1 1\n3 2\n3\n2 3 2\n1 6 2\n\nSAMPLE", "output": "5\n24\n", "t...
code_contests
verifiable_code
lucky-kitties
Solve the following coding problem using the programming language python: It’s well know fact among kitties that digits 4 and 7 are lucky digits. Today, N boxes of fish bites arrived. Each box has a unique integer label on it, ranged between 1 and N, inclusive. The boxes are going to be given away to the kitties in in...
```python k = input() n = input() i=1 a=0 b=0 cnt=0 while(i<=n): a+=str(i).count('4') b+=str(i).count('7') if(a+b>k): cnt+=1 a=0 b=0 i+=1 print cnt ```
vfc_54889
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n74\n\nSAMPLE", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n49503", "output": "6684\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
name-string-1
Solve the following coding problem using the programming language python: Description: Name string is a string consisting of letters "R","K" and "V". Today Oz wants to design a name string in a beautiful manner. Actually Oz cannot insert these three letters arbitrary anywhere ,he has to follow some rules to make the n...
```python for _ in xrange(input()): r,k,v=sorted(map(int,raw_input().split())) if k==v: print k+v else: print 2*k+1 ```
vfc_54893
{ "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 2 5\n0 0 2\n\nSAMPLE", "output": "5\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "21\n0 0 0\n3 0 0\n5 1 2\n7 7 4\n0 0 1\n0 1 0\n1 0 0\n50 50 50\n4 10 42\n11 49 20\n30 21 44\n3 7 ...
code_contests
verifiable_code
problem-7
Solve the following coding problem using the programming language python: The main building of the nation is developing complex patterns as each day progresses. The task is to find the number of three sided closed figures on the nth day. (Input – n Output – number of triangles) SAMPLE INPUT 2 SAMPLE OUTPUT 5 The ...
```python n=int(raw_input()) print n*n+(n-1)**2 ```
vfc_54897
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n\nSAMPLE", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
seven-segment-display
Solve the following coding problem using the programming language python: Kancha wants to participate in a new event of Technobyte. Event says that you have to write a number in seven segment display using matchsticks. Please refer to the diagram below for how many sticks are used for each digit !! Now, event coordin...
```python A=[6,2,5,5,4,5,6,3,7,6] t=input() for i in range(0,t): s=raw_input() S=0 for j in range(0,len(s)): ch=ord(s[j])-48 S=S+A[ch] print(S) ```
vfc_54901
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n4523521178603692869044796170148349853679689223589819975621633677282235231443204731632537466129523854\n1302325049960398304982582357280685122562102438321157305518841538649586388982800700181595650321563194\n25129573327868305223086...
code_contests
verifiable_code
the-art-of-security-4
Solve the following coding problem using the programming language python: Fatal Eagle has finally teamed up with Arjit to take on this weird army of zombies and vampires. And they are coming up with strategies to beat these guys on a roll. The simple thing they figured out is that these creatures attack everything by ...
```python # Awesome Recursion Problem. # TODO(hapie): Learn iterative permutation generation algorithms. # 2^n recursions. doors = [0, 0] powers_sum = 0 arrangement_sum = 0 def recurse(item, idx): if idx == len(item): global arrangement_sum arrangement_sum += 1 return for i in range(2): if i == 0 and doo...
vfc_54905
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 13\n\nSAMPLE", "output": "15 16\nGot no way out!\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n32 68 6 93 25 61", "output": "10473 285\nWe will win!\n", "type": "st...
code_contests
verifiable_code
xenny-and-bitsums
Solve the following coding problem using the programming language python: Let f(x) represent the number of set bits (i.e. bit = 1) in the binary representation of non-negative integer x. For e.g. f(3) = 2, since 3 is represented as '11' in binary. Xenny's friend Xynazog gave him the following task: Given two non-neg...
```python from math import floor,log def f(n): if n<1:return 0 x=floor(log(n)/log(2)) return int(x*pow(2,x-1)+f(n-pow(2,x))+n-pow(2,x)+1) t=input() for _ in xrange(t): a,b=map(int,raw_input().split()) print f(b)-f(a-1) ```
vfc_54909
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1 3\n\nSAMPLE", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 1\n\nSAMPLE", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00065 Trading
Solve the following coding problem using the programming language python: There is data that records the customer number of the business partner and the trading date on a monthly basis. Please create a program that reads this month's data and last month's data and outputs the customer number of the company with which ...
```python flag = False cli = [0] * 1001 sen = set() kon = set() while True: try: c, d = map(int, input().split(",")) except: if flag: break flag = True continue if flag: kon.add(c) else: sen.add(c) cli[c] += 1 for i in range(1,1001): ...
vfc_54953
{ "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": "123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5", "output": "56 2\n123 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "123,10\n56,12\n35,14\n\n123,3\n56,4\n123,5", "output": "56 2\n123 3\...
code_contests
verifiable_code
p00197 Greatest Common Divisor: Euclidean Algorithm
Solve the following coding problem using the programming language python: The greatest common divisor is an indispensable element in mathematics handled on a computer. Using the greatest common divisor can make a big difference in the efficiency of the calculation. One of the algorithms to find the greatest common div...
```python def solve(): from sys import stdin f_i = stdin ans = "" while True: a, b = map(int, f_i.readline().split()) if a == 0 and b == 0: break if a < b: a, b = b, a # Euclidean Algorithm cnt = 1 ...
vfc_54957
{ "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": "1071 1029\n5 5\n0 0", "output": "21 3\n5 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1071 1029\n5 3\n0 0", "output": "21 3\n1 3\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p00547 Food stalls
Solve the following coding problem using the programming language python: problem The city of IOI, where JOI lives, has a rectangular shape with H sections in the north-south direction and W sections in the east-west direction, and is divided into H x W sections. The i-th section from the north and the j-th section f...
vfc_54965
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n..483\n.59.9\n3.866\n79...\n4.8..", "output": "20", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n..483\n.59/9\n3.866\n79...\n4.8..", "output": "20\n", "type": "stdin_s...
code_contests
verifiable_code
p00711 Red and Black
Solve the following coding problem using the programming language python: There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on blac...
```python from collections import deque y = [-1,0,1,0] x = [0,-1,0,1] def main(): h,w = 0,0 c = [] def check(i,j): return 0<=i and i<h and 0<=j and j<w def bfs(a,b): res = 0 d = deque() d.append([a,b]) f = [[False]*w for _ in range(h)] while len(d): ...
vfc_54969
{ "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": "6 9\n....#.\n.....#\n......\n......\n......\n......\n......\n@...#\n.#..#.\n11 9\n.#.........\n.#.#######.\n.#.#.....#.\n.#.#.###.#.\n.#.#..@#.#.\n.#.#####.#.\n.#.......#.\n.#########.\n...........\n11 6\n..#..#..#..\n..#..#..#..\n...
code_contests
verifiable_code
p00850 Power Calculus
Solve the following coding problem using the programming language python: Starting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications: x2 = x × x, x3 = x2 × x, x4 = x3 × x, ... , x31 = x30 × x. The operation of squaring can appreciably shorten the sequence of multiplications. The ...
vfc_54973
{ "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\n31\n70\n91\n473\n512\n811\n953\n0", "output": "0\n6\n8\n9\n11\n9\n13\n12", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00982 Twin Trees Bros.
Solve the following coding problem using the programming language python: Twin Trees Bros. To meet the demand of ICPC (International Cacao Plantation Consortium), you have to check whether two given trees are twins or not. <image> Example of two trees in the three-dimensional space. The term tree in the graph theor...
vfc_54977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 0 0\n1 0 0\n3 0 0\n1 2\n2 3\n0 0 0\n0 2 2\n0 3 3\n4 5\n5 6", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 0 0\n1 0 0\n3 0 0\n1 2\n2 3\n0 0 0\n1 2 2\n0 3 3\n4 5\n5 6...
code_contests
verifiable_code
p01114 Equilateral Triangular Fence
Solve the following coding problem using the programming language python: Equilateral Triangular Fence Ms. Misumi owns an orchard along a straight road. Recently, wild boars have been witnessed strolling around the orchard aiming at pears, and she plans to construct a fence around many of the pear trees. The orchard...
vfc_54981
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 15, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1\n0 1\n1 2\n-1 2\n2 1\n4\n1\n1 1\n2 2\n1 3\n1 4\n4\n1\n1 1\n2 2\n3 1\n4 1\n4\n1\n1 2\n2 1\n3 2\n4 2\n5\n2\n0 1\n0 2\n0 3\n0 4\n0 5\n6\n3\n0 2\n2 2\n1 1\n0 3\n2 3\n1 4\n0", "output": "6.000000000000\n6.928203230276\n6.0000...
code_contests
verifiable_code
p01252 Alice and Bob
Solve the following coding problem using the programming language python: Alice and Bob are in love with each other, but they have difficulty going out on a date - Alice is a very busy graduate student at the ACM university. For this reason, Bob came to the ACM university to meet her on a day. He tried to reach the m...
vfc_54985
{ "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\n3 3 7 7\n2 2 8 2\n2\n2 5 5 9\n6 1 9 5\n1 5 10 5\n2\n2 1 3 2\n2 3 3 4\n1 1 4 4\n1\n3 3 7 7\n1 5 9 5\n1\n3 3 7 7\n1 5 8 5\n1\n3 3 7 7\n1 5 10 5\n0", "output": "0.000\n0.000\n0.000\n5.657\n6.406\n4.992", "type": "stdin_...
code_contests
verifiable_code
p01413 Quest of Merchant
Solve the following coding problem using the programming language python: Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well. Today's training is to gain the power of business by running around the city and conducting trade. I want to ea...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N, M, W, T = map(int, readline().split()) cur = 0 n_map = {} ws = [0]*M; P = [0]*M for i in range(M): s, v, p = readline().split() n_map[s] = i ws[i] = int(v) P[i] = int(p) ...
vfc_54989
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3 100 20\nvim 10 10\nemacs 5 10\nvstudio 65 100\n2 1 6\nemacs 4\nvstudio 13\n3 -3 0\nvim 5\nemacs 9\nvstudio 62", "output": "183", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 100 20\...
code_contests
verifiable_code
p01567 Presentation
Solve the following coding problem using the programming language python: You are a researcher investigating algorithms on binary trees. Binary tree is a data structure composed of branch nodes and leaf nodes. Every branch nodes have left child and right child, and each child is either a branch node or a leaf node. Th...
vfc_54993
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "((()(()()))((()(()()))()))", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "(()())", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01867 AddMul
Solve the following coding problem using the programming language python: Problem statement Jota knows only the characters from `a` to` z` and the addition symbol `+`. Jota has an older sister, Tachiko. In addition to that, Tatsuko knows multiplication `*`, parentheses `(`, `)`, and integers (numbers) between `1` and...
```python # -*- coding: utf-8 -*- from collections import Counter N = input() S = input().split('+') dic_chr_num = Counter(S) dic_num_kind = Counter(dic_chr_num.values()) ans = 4 * len(dic_chr_num) - 1 for num, kind in dic_num_kind.items(): if num == 1: ans -= 2 * kind elif kind >= 2: ans -=...
vfc_55001
{ "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": "5\na+a+a", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nb+a+a", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n...
code_contests
verifiable_code
p02004 GuruGuru
Solve the following coding problem using the programming language python: You are playing a game called Guru Guru Gururin. In this game, you can move with the vehicle called Gururin. There are two commands you can give to Gururin: 'R' and 'L'. When 'R' is sent, Gururin rotates clockwise by 90 degrees. Otherwise, when ...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): S = readline().strip() ans = 0 d = 0; cur = 0 for c in S: if c == "R": if d == cur: cur += 1 d = (d + 1) % 4 if d == 0 and cur == 4: ans +=...
vfc_55005
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "LR", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "RRRRLLLLRRRR", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "RLLRLLL...
code_contests
verifiable_code
p02289 Priority Queue
Solve the following coding problem using the programming language python: A priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations: * $insert(S, k)$: insert an element $k$ into the set $S$ * $extractMax(S)$: remove and re...
```python #coding:utf-8 #1_9_C import heapq h = [] while True: cmd = input().split() if cmd[0] == "end": break elif cmd[0] == "insert": heapq.heappush(h, -int(cmd[1])) else: print(-heapq.heappop(h)) ```
vfc_55013
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend", "output": "8\n10\n11\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "insert 8\ninsert 1\nextract\ninser...
code_contests
verifiable_code
approx
Solve the following coding problem using the programming language python: Chef has recently learnt some new facts about the famous number π. For example, he was surprised that ordinary fractions are sometimes used to represent this number approximately. For example, 22/7, 355/113 or even 103993/33102. Soon, by calcula...
```python def main(): cases = int(raw_input()) repetition='415926530119026040722614947737296840070086399613316' for i in range(cases): k = int(raw_input()) if(k == 0): print "3" elif(k==1): print "3...
vfc_55021
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0\n6\n20", "output": "3\n3.141592\n3.14159265301190260407\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1\n6\n20", "output": "3.1\n3.141592\n3.14159265301190260407\n", ...
code_contests
verifiable_code
cieldist
Solve the following coding problem using the programming language python: In Wolf town there are 2 big markets S and T. The distance between these markets is D. Chef Ciel would like to run 2 restaurants in Wolf town, where the first restaurant will be supplied by the market S and the second one will be supplied by the...
```python def solve(da, db, d): if(da + db <= d): return d - da - db elif(da + d <= db): return db - d - da elif(db + d <= da): return da - d - db else: return 0 # main test = int(raw_input()) for i in range(test): # apply the function(int) to all items in the raw_input().split() da, db, d...
vfc_55025
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n15 15 50\n15 15 18\n43 88 200\n2013 2013 2013", "output": "20.0\n0\n69.0\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n15 15 50\n15 15 18\n43 88 200\n2013 1560 2013", "out...
code_contests
verifiable_code
etmx07
Solve the following coding problem using the programming language python: Mirrored Strings Davy Jones needs to conquer a ship for his pirates. But the only rule he has to follow is to conquer only those ships whose names are partially mirrored at the end. For Example: If a ship's name is 'abxyzba' then he can conquer...
```python x=raw_input() l=len(x) s="" for i in range(0,l): if x[i]==x[l-i-1]: s=s+x[i] else: break print s ```
vfc_55029
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abXYZba", "output": "ab", "type": "stdin_stdout" }, { "fn_name": null, "input": "codechefdoc", "output": "cod", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
lapin
Solve the following coding problem using the programming language python: Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check for...
```python q=int(raw_input()) while(q>0): a=raw_input() a1=a[0:len(a)//2] if(len(a)%2==0): a2=a[(len(a)//2):len(a)] else: a2=a[(len(a)//2)+1:len(a)] a1=list(a1) a1.sort() a2=list(a2) a2.sort() cnt=0 for x, y in zip(a1, a2): if(x==y): cnt+=1 if(cnt==len(a)//2): print 'YES' else: print 'NO' q-=1 ...
vfc_55033
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\ngaga\nabcde\nrotor\nxyzxy\nabbaab\nababc", "output": "YES\nNO\nYES\nYES\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\ngaga\nabcde\nrotor\nxyzxy\nabbbab\nababc", "outp...
code_contests
verifiable_code
pcsc7
Solve the following coding problem using the programming language python: Yesterday, the CS Club hosted a massive party that put all the frat parties to shame. Today, they have to clean up everything. They also have to restock the strategic supply of Mountain Dew. Phillip hates cleaning and wants to pick up the dew...
```python import sys def josephus(n,k): if n==1: return 1 else: return (josephus(n-1,k)+k-1)%n+1 n,k=map(int,sys.stdin.readline().split()) sys.stdout.write("%d"%josephus(n,k)) ```
vfc_55037
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "41 3", "output": "31", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
stem
Solve the following coding problem using the programming language python: Given n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring that occurs in al...
```python ''' Created on 24-Oct-2015 @author: Venkatesh ''' def read_str_list(): return [x for x in raw_input().split()] def read_int(): return int(raw_input()) def get_stem(s_lst, n): fst_str = s_lst[0] m = len(fst_str) ans = "" all_stems = set() for k in xrange(1, m+1): for ...
vfc_55041
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\ngrace graceful disgraceful gracefully", "output": "grace\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n4\necarg graceful disgraceful gracefully", "output": "a\n", "t...
code_contests
verifiable_code
1008_B. Turn the Rectangles
Solve the following coding problem using the programming language python: There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also ...
```python n=int(input()) l=[] for i in range(n): l.append(list(map(int,input().split()))) val=0 check=1 for j in range(n-1,-1,-1): if(l[j][0]<l[j][1]): if(l[j][0]>=val): val=l[j][0] elif(l[j][1]>=val): val=l[j][1] else: check=0 else: if(l[j][1]>=val): val=l[j][1] elif(l[j][0]>=val): val=l[j]...
vfc_55045
{ "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": "3\n3 4\n4 6\n3 5\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 4\n5 5\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
1030_G. 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_55049
{ "difficulty": "13", "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" }, { "fn_name": null, "input": "3\n5 3 3\n", "output": "30\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
1053_E. Euler tour
Solve the following coding problem using the programming language python: Euler is a little, cute squirrel. When the autumn comes, he collects some reserves for winter. The interesting fact is that Euler likes to collect acorns in a specific way. A tree can be described as n acorns connected by n - 1 branches, such th...
vfc_55053
{ "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": "2\n1 0 0\n", "output": "yes\n1 2 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 1 2 3 4 1 0 0 0\n", "output": "no\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
1096_G. Lucky Tickets
Solve the following coding problem using the programming language python: All bus tickets in Berland have their numbers. A number consists of n digits (n is even). Only k decimal digits d_1, d_2, ..., d_k can be used to form ticket numbers. If 0 is among these digits, then numbers may have leading zeroes. For example,...
```python from math import trunc MOD = 998244353 MODF = float(MOD) SHRT = float(1 << 16) # Using pajenegod's crazy method for multiplication using floating point fmod = lambda x: x - MODF * trunc(x / MODF) mod_prod = lambda a, b: fmod(trunc(a / SHRT) * fmod(b * SHRT) + (a - SHRT * trunc(a / SHRT)) * b) def fpow(a, b)...
vfc_55061
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n1 8\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20 1\n6\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
1118_A. Water Buying
Solve the following coding problem using the programming language python: Polycarp wants to cook a soup. To do it, he needs to buy exactly n liters of water. There are only two types of water bottles in the nearby shop — 1-liter bottles and 2-liter bottles. There are infinitely many bottles of these two types in the ...
```python q=int(input()) for i in range(q): n,a,b=map(int,input().split()) b=min(b,2*a) if(n%2==1): print(((n//2)*b)+a) else: print((n//2)*b) ```
vfc_55065
{ "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\n10 1 3\n7 3 2\n1 1000 1\n1000000000000 42 88\n", "output": "10\n9\n1000\n42000000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n32 4 7\n", "output": "112\n", "typ...
code_contests
verifiable_code
1165_C. Good String
Solve the following coding problem using the programming language python: Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different from the fourth, and so...
```python n = int(input()) s = input() i,p=0,1 ans = '' while i<(n-1): if p%2 == 1: if s[i] != s[i+1]: ans = ans + s[i] p += 1 else: ans = ans + s[i] p += 1 i += 1 if len(ans)%2 == 1: ans += s[-1] print(len(s)-len(ans)) print(ans) ```
vfc_55073
{ "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\n", "output": "3\n\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\ngood\n", "output": "0\ngood\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
1184_C2. Heidi and the Turing Test (Medium)
Solve the following coding problem using the programming language python: The Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen. After the fighting stopped, Heidi gave them another task to waste their time on. There...
```python import sys NORM = 2000000 LIMIT = NORM * 2 + 1 class segmentTree: def __init__(self, n): self.n = n self.t = [0] * (n * 2) self.lazy = [0] * n def apply(self, p, value): self.t[p] += value if p < self.n: self.lazy[p] += value def build(self, p): while p > 1: p >>= 1 self.t[p] = m...
vfc_55077
{ "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 2\n1 1\n1 -1\n-1 1\n-1 -1\n2 0\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n1 1\n1 -1\n-1 1\n-1 -1\n2 0\n", "output": "3\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
1202_E. You Are Given Some Strings...
Solve the following coding problem using the programming language python: You are given a string t and n strings s_1, s_2, ..., s_n. All strings consist of lowercase Latin letters. Let f(t, s) be the number of occurences of string s in string t. For example, f('aaabacaa', 'aa') = 3, and f('ababa', 'aba') = 2. Calcul...
```python class Node(object): def __init__(self): super(Node, self).__init__() self.next = [-1] * 26 self.trans = [] self.matches = 0 self.leaf = 0 self.link = 0 class AhoCorasick(object): def __init__(self): super(AhoCorasick, self).__init__() se...
vfc_55081
{ "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": "aaabacaa\n4\na\na\na\nb\n", "output": "33\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aaabacaa\n2\na\naa\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
121_A. Lucky Sum
Solve the following coding problem using the programming language python: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Let next(x) be the minimu...
```python n = (input()).split() l = int(n[0]) r = int(n[1]) a = [] x = [] a.append([]) a[0].append('4') a[0].append('7') for i in range(1,10): a.append([]) for j in a[i-1]: a[i].append('4'+j) a[i].append('7'+j) for j in a[i]: x.append(int(j)) x.append(4) x.append(7) x.sort...
vfc_55085
{ "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 7\n", "output": "33", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 7\n", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "input": "47 47\n", ...
code_contests
verifiable_code
1264_C. Beautiful Mirrors with queries
Solve the following coding problem using the programming language python: Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Some mirrors are called checkpoint...
```python import sys input = sys.stdin.readline mod = 998244353 #出力の制限 #互いに素なa,bについて、a*x+b*y=1の一つの解 def extgcd(a,b): r = [1,0,a] w = [0,1,b] while w[2]!=1: q = r[2]//w[2] r2 = w w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]] r = r2 w = w2 #[x,y] return [w[0],w[1]...
vfc_55093
{ "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": "2 2\n50 50\n2\n2\n", "output": "4\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n10 20 30 40 50\n2\n3\n4\n5\n3\n", "output": "117\n665496274\n332748143\n831870317\n499122211...
code_contests
verifiable_code
1329_B. Dreamoon Likes Sequences
Solve the following coding problem using the programming language python: Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS: You are given two integers d, m, find the number of arrays a, satisfying the following constraints: * The length of a is n, n ≥ 1 ...
```python #------------------------------warmup---------------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file...
vfc_55105
{ "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": "10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n6 99995\n7 9994\n8 993\n9 92\n10 1\n", "output": "1\n3\n5\n11\n17\n23\n29\n59\n89\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
1456_E. XOR-ranges
Solve the following coding problem using the programming language python: Given integers c_{0}, c_{1}, …, c_{k-1} we can define the cost of a number 0 ≤ x < 2^{k} as p(x) = ∑_{i=0}^{k-1} \left( \left⌊ \frac{x}{2^{i}} \right⌋ mod 2 \right) ⋅ c_{i}. In other words, the cost of number x is the sum of c_{i} over the bits ...
vfc_55129
{ "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 3\n2 2\n3 4\n4 6\n1 10 100\n", "output": "\n102\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n3 3\n5 5\n6 6\n1 1\n5 2 7\n", "output": "\n30\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
180_F. Mathematical Analysis Rocks!
Solve the following coding problem using the programming language python: Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to n. Each student i (1 ≤ i ≤ n) ...
```python n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) d={} for i in range(n): d[a[i]]=b[i] for i in range(1,n+1): print(d[i],end=" ") print() ```
vfc_55149
{ "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": "4\n2 1 4 3\n3 4 2 1\n", "output": "4 3 1 2 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5 2 3 1 4\n1 3 2 4 5\n", "output": "4 3 2 5 1 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
204_B. Little Elephant and Cards
Solve the following coding problem using the programming language python: The Little Elephant loves to play with color cards. He has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Litt...
```python from collections import defaultdict import math n=int(input()) d=defaultdict(int) o=defaultdict(int) for i in range(n): x,y=map(int,input().split()) o[x]+=1 d[x]+=1 if y!=x: d[y]+=1 mi=10**5+1 for i in d: ## print(d[i]) if d[i]>=math.ceil(n/2): mi=min(mi,max(math.ceil(n/...
vfc_55153
{ "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": "5\n4 7\n7 4\n2 11\n9 7\n1 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 7\n4 7\n7 4\n", "output": "0\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
229_A. Shifts
Solve the following coding problem using the programming language python: You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right. T...
```python import sys n, m = map(int, input().split()) mp = ['' for i in range(n)] f = [[0 for j in range(m)] for i in range(n)] for i in range(n): mp[i] = input() if mp[i].find('1') == -1: print(-1) sys.exit() tmp = mp[i][::-1].find('1') + 1 for j in range(m): if mp[i][j] == '1': f[i][j] = 0 else: f[i...
vfc_55157
{ "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": "3 6\n101010\n000100\n100000\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
252_D. Playing with Permutations
Solve the following coding problem using the programming language python: Little Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n. A permutation a of length n is a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ n), all integers there are distinct. There is o...
```python def Solve(x,L): if(x==k[0]): return L==S if((x,tuple(L)) in Mem): return False if(L==S): return False E=[] for i in range(len(L)): E.append(L[Q[i]-1]) if(Solve(x+1,E)): return True E=[0]*len(L) for i in range(len(L)): E[Q[i]-...
vfc_55161
{ "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 3\n4 3 1 2\n3 4 2 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1\n4 3 1 2\n2 1 4 3\n", "output": "NO\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
325_B. Stadium and Games
Solve the following coding problem using the programming language python: Daniel is organizing a football tournament. He has come up with the following tournament format: 1. In the first several (possibly zero) stages, while the number of teams is even, they split in pairs and play one game for each pair. At each ...
```python import sys def isqrt(n): l = -1 h = n while l + 1 < h: m = (l + h) // 2 if m * m <= n: l = m else: h = m return l with sys.stdin as fin, sys.stdout as fout: n = int(next(fin)) ans = [] for i in range(64 + 1): a = 2 ** i -...
vfc_55173
{ "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": "25\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "3\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", ...
code_contests
verifiable_code
348_C. Subset Sums
Solve the following coding problem using the programming language python: You are given an array a1, a2, ..., an and m sets S1, S2, ..., Sm of indices of elements of this array. Let's denote Sk = {Sk, i} (1 ≤ i ≤ |Sk|). In other words, Sk, i is some element from set Sk. In this problem you have to answer q queries of...
vfc_55177
{ "difficulty": "9", "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 3 5\n5 -5 5 1 -4\n2 1 2\n4 2 1 4 5\n2 2 5\n? 2\n+ 3 4\n? 1\n+ 2 1\n? 2\n", "output": "-3\n4\n9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10 10\n0 0 0 1 -5 8 7 2 9 -2\n8 1 9 7 8 ...
code_contests
verifiable_code
371_D. Vessels
Solve the following coding problem using the programming language python: There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. <image> Initia...
```python n=int(input()) a=list(map(int,input().split())) vessels=[] ans=[] index=[] for i in range(n): vessels.append([0,a[i]]) index.append(i+1) m=int(input()) for i in range(m): a=input() if a[0]=='1': a,p,x=list(map(int,a.split())) p-=1 tt=set() while p<n and x>0:...
vfc_55181
{ "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": "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3\n", "output": "7\n10\n5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2\n", "output":...
code_contests
verifiable_code
393_A. Nineteen
Solve the following coding problem using the programming language python: Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string. For example, if she has string "xiineteenppnnnewtnee", she ca...
```python a=input() n=int(0) ii=int(0) t=int(0) e=int(0) for i in range(len(a)): if a[i] == "n": n+=1 if a[i] == "i": ii+=1 if a[i] == "e": e+=1 if a[i] == "t": t+=1 if n >3: n=int(((n-3)/2))+1 else: n=int(n/3) print(min(n,int(e/3),ii,t)) ```
vfc_55185
{ "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": "nniinneetteeeenn\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n", "output": "2\n", "type": "stdin_stdou...
code_contests
verifiable_code
416_B. Art Union
Solve the following coding problem using the programming language python: A well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of n painters who decided to organize their work as follows. Each painter uses only the color that was assigned to him. The colors are ...
```python m,n=map(int,input().split()) a=[] for i in range(m): p=[int(j) for j in input().split()] a.append(p) for j in range(1,m): a[j][0]+=a[j-1][0] for i in range(1,n): a[0][i]+=a[0][i-1] #print(a) for j in range(1,m): a[j][i]+=max(a[j-1][i],a[j][i-1]) #print(a) for i in...
vfc_55189
{ "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": "5 1\n1\n2\n3\n4\n5\n", "output": "1 3 6 10 15 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
442_E. Gena and Second Distance
Solve the following coding problem using the programming language python: Gena doesn't like geometry, so he asks you to solve this problem for him. A rectangle with sides parallel to coordinate axes contains n dots. Let's consider some point of the plane. Let's count the distances from this point to the given n point...
vfc_55193
{ "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": "5 5 3\n4 0\n2 5\n4 1\n", "output": "5.656854249432\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 4\n0 0\n5 0\n0 5\n5 5\n", "output": "4.999999999936\n", "type": "stdin_st...
code_contests
verifiable_code
465_A. inc ARG
Solve the following coding problem using the programming language python: Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of n bits. These bits are numbered from 1 to n. An integer is stored in the cell in the following way: the least significant bit is ...
```python n = int(input()) s = input() swaps = 0 k = 0 for i in range(len(s)): if int(s[i]) == 0: k += 1 break k += 1 print(k) ```
vfc_55197
{ "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\n1100\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1111\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
488_E. Prefix Product Sequence
Solve the following coding problem using the programming language python: Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence <image>. Now given n, find a permutation of [1, 2, ..., n], such that its prefix product sequence is a permutation of [0, 1, ..., n - 1]. Input The only input line con...
```python #!/usr/bin/python # coding: utf-8 def isPrime(n): if n == 2: return True if n % 2 == 0: return False for i in xrange(3, (int)(n ** 0.5) + 1, 2): if n % i == 0: return False return True n = input() if n == 1: print 'YES\n1' elif n == 4: print 'YES\n1\n3\n2\n4' elif not isPrime(n)...
vfc_55201
{ "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": "6\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n", "output": "YES\n1\n2\n5\n6\n3\n4\n7\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
536_E. Tavas on the Path
Solve the following coding problem using the programming language python: Tavas lives in Tavaspolis. Tavaspolis has n cities numbered from 1 to n connected by n - 1 bidirectional roads. There exists a path between any two cities. Also each road has a length. <image> Tavas' favorite strings are binary strings (they c...
vfc_55209
{ "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 6\n-5 0 0 2 10\n1 2 1\n2 3 2\n3 4 5\n4 5 1\n5 6 5\n1 6 1\n1 6 2\n1 6 5\n3 6 5\n4 6 4\n1 4 2\n", "output": "10\n-5\n-10\n-10\n-5\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n10...
code_contests
verifiable_code
566_A. Matching Names
Solve the following coding problem using the programming language python: Teachers of one programming summer school decided to make a surprise for the students by giving them names in the style of the "Hobbit" movie. Each student must get a pseudonym maximally similar to his own name. The pseudonym must be a name of s...
```python import sys class Node: def __init__(self, d): global nodes self.ch = {} self.a = [[], []] self.d = d nodes += [self] nodes = [] pairs = [] res = 0 N = int(sys.stdin.readline()) _input = sys.stdin.readlines() _input = [s[:-1] for s in _input] A = [_input[:N], _inp...
vfc_55213
{ "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\ngennady\ngalya\nboris\nbill\ntoshik\nbilbo\ntorin\ngendalf\nsmaug\ngaladriel\n", "output": "11\n1 3\n2 5\n3 4\n4 1\n5 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\na\nb\na\na\n",...
code_contests
verifiable_code
587_B. Duff in Beach
Solve the following coding problem using the programming language python: While Duff was resting in the beach, she accidentally found a strange array b0, b1, ..., bl - 1 consisting of l positive integers. This array was strange because it was extremely long, but there was another (maybe shorter) array, a0, ..., an - 1...
```python from collections import Counter mod = 1000000007 n, l, k = map(int, raw_input().split()) a = map(int, raw_input().split()) b = [] count_a = Counter(a) count_a_keys = sorted(count_a.keys()) rev_map = {} for i, key in enumerate(count_a_keys): rev_map[key] = i b.append(count_a[key]) m = l / n rest = l %...
vfc_55217
{ "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": "3 5 3\n5 9 1\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 10 3\n1 2 3 4 5\n", "output": "25\n", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
609_D. Gadgets for dollars and pounds
Solve the following coding problem using the programming language python: Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing. Nura ...
```python from sys import stdin, stdout def ints(): return [int(x) for x in stdin.readline().split()] n, m, k, s = ints() a = ints() b = ints() d_gad = []; p_gad = []; for i in range(m): t, c = ints() if t == 1: d_gad.append([c, i + 1]) else: p_gad.append([c, i + 1]) d_gad.sort() p_gad.sort() mn_dol =...
vfc_55221
{ "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 3 1 1000000000\n900000 910000 940000 990000\n990000 999000 999900 999990\n1 87654\n2 76543\n1 65432\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4 2 2\n1 2 3 2 1\n...
code_contests
verifiable_code
630_C. Lucky Numbers
Solve the following coding problem using the programming language python: The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers. Lucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office given t...
```python x=input() print((2**(int(x)+1))-2) ```
vfc_55225
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n", "output": "8190\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "55\n", ...
code_contests
verifiable_code
656_G. You're a Professional
Solve the following coding problem using the programming language python: A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system. You are given user's friends' opinions about a list of items. You are also given ...
```python from functools import reduce f,o,t = map(int, input().split(' ')) res = [0 for i in range(o)] for i in range(f): s = input() for j in range(o): res[j]+=(s[j]=='Y') print(reduce(lambda x,y: x+(y>=t), res,0)) #kitten ```
vfc_55229
{ "difficulty": "13", "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 4 1\nNNNY\nNNYN\nNYNN\nYNNN\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 2\nYYY\nNNN\nYNY\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
680_B. Bear and Finding Criminals
Solve the following coding problem using the programming language python: There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|. Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard becaus...
```python from sys import stdin, stdout cnt, number = map(int, stdin.readline().split()) labels = list(map(int, stdin.readline().split())) if labels[number - 1]: ans = 1 else: ans = 0 for i in range(1, min(cnt - number, number - 1) + 1): if labels[number - 1 + i] and labels[number - 1 - i]: ans...
vfc_55233
{ "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": "5 2\n0 0 0 1 0\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n1 1 1 0 1 0\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
703_A. Mishka and Game
Solve the following coding problem using the programming language python: Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game. R...
```python n = int(input()) k = 0 l = 0 for i in range(n): m,c = map(int,input().split()) if m > c: k +=1 elif c > m: l +=1 if k > l: print("Mishka") elif l > k: print("Chris") else: print("Friendship is magic!^^") ```
vfc_55237
{ "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\n6 1\n1 6\n", "output": "Friendship is magic!^^\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 5\n3 3\n2 2\n", "output": "Chris\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
725_A. Jumping Ball
Solve the following coding problem using the programming language python: In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by...
```python n=int(input()) s=input() k=s[0] res=i=0 while i<=n-1 and s[i]==k: i+=1 else: if k=='<': res+=i k='>' i=n-1 while i>=0 and s[i]==k: i-=1 else: res+=n-i-1 print(res) ```
vfc_55241
{ "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\n&gt;&gt;&gt;&gt;&gt;\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n&lt;&lt;&gt;&lt;\n", "output": "0", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
747_A. Display Size
Solve the following coding problem using the programming language python: A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels a and the numbe...
```python import math num = int(input()) s = math.sqrt(num) s = int(float(s)) for i in range (s, 0, -1) : if num % i == 0 : print(i) print(int(float(num / i))) break ```
vfc_55245
{ "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\n", "output": "2 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n", "output": "1 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "999999\...
code_contests
verifiable_code
76_D. Plus and xor
Solve the following coding problem using the programming language python: Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit o...
```python a, b = int(input()), int(input()) x, y = (a - b) >> 1, (a - b) // 2 + b if a < b or (a + b) & 1 or x & (a - x) != x: print("-1") else: print(x, y) ```
vfc_55249
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "142\n76\n", "output": "33 109", "type": "stdin_stdout" }, { "fn_name": null, "input": "9992164445234764941\n8162963574901971597\n", "output": "914600435166396672 9077564010068368269", "ty...
code_contests
verifiable_code
794_A. Bank Robbery
Solve the following coding problem using the programming language python: A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes. Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from ...
```python # Method 1a: Using a list comprehension # a, b, c, d = [int(x) for x in input().split()] # print(a*b*c*d) # Method 1b: Using the map function # a, b, c, d = map(int, input().split()) # print(a*b*c*d) # Method 2a: List comprehension with stdin and stdout # from sys import stdin, stdout # a, b, c, d = [int(x...
vfc_55253
{ "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 3 7\n8\n4 7 5 5 3 6 2 8\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 5 7\n5\n1 5 7 92 3\n", "output": "0", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
83_E. Two Subsequences
Solve the following coding problem using the programming language python: On an IT lesson Valera studied data compression. The teacher told about a new method, which we shall now describe to you. Let {a1, a2, ..., an} be the given sequence of lines needed to be compressed. Here and below we shall assume that all line...
vfc_55261
{ "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\n000\n111\n110\n001\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n10101\n01010\n11111\n01000\n10010\n", "output": "17\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
860_A. Did you mean...
Solve the following coding problem using the programming language python: Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from ...
```python s = input() n = len(s) if n==1 or n==2: print(s) else: a = ['a','e','i','o','u'] q,w = '','' if s[0] not in a: q = s[0] if s[1] not in a: w = s[1] res = s[:2] for i in range(2,n): e = s[i] if e not in a: if q!='' and w!='': ...
vfc_55265
{ "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": "asdfasdf\n", "output": "asd fasd f \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "hellno\n", "output": "hell no \n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
886_F. Symmetric Projections
Solve the following coding problem using the programming language python: You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines. Multiset is a set where equal elem...
```python from fractions import Fraction import time class Point: def __init__(self, x, y): self.x = x self.y = y def to_tuple(self): return (self.x, self.y) def __repr__(self): return "Point({}, {})".format(self.x, self.y) def __eq__(self, other): return sel...
vfc_55269
{ "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": "3\n1 2\n2 1\n3 3\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
909_F. AND-permutations
Solve the following coding problem using the programming language python: Given an integer N, find two permutations: 1. Permutation p of numbers from 1 to N such that pi ≠ i and pi & i = 0 for all i = 1, 2, ..., N. 2. Permutation q of numbers from 1 to N such that qi ≠ i and qi & i ≠ 0 for all i = 1, 2, ..., N. ...
```python def test(x, i): i = list(i) ok = True for j in range(x): if (i[j] == j+1 or (i[j]&(j+1) != 0)): ok = False if ok: print(i) def comp(n): return 2**len(bin(n)[2:])-1-n n = int(input()) nn = n if (n%2 == 0): x = [] while (n != 0): #add n to comp(n) to the front of x for i in range(comp(n), n+...
vfc_55273
{ "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": "3\n", "output": "NO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
931_C. Laboratory Work
Solve the following coding problem using the programming language python: Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error. Kirill has already made his measurements, and has got the following integer...
```python R = lambda : map(int, input().split()) n = int(input()) v = list(R()) mn = min(v); mx = max(v); from collections import Counter c = Counter(v) if mn==mx or mn==mx-1: print(len(v)); print(" ".join(map(str,v))); exit(); if mn==mx-2 and len(c)==2: c[mn+1]=0 k = sorted(list(c.keys())) ck0 = c[k[0]]; ck...
vfc_55277
{ "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\n100 100 101\n", "output": "3\n100 100 101\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n-1 1 1 0 0 -1\n", "output": "2\n0 0 0 0 0 0\n", "type": "stdin_stdout" } ]...
code_contests
verifiable_code
958_F1. Lightsabers (easy)
Solve the following coding problem using the programming language python: There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-kno...
```python import sys n, m = map(int, input().split()) a = list(map(int, input().split())) k = list(map(int, input().split())) c = 0 s = sum(k) if m==1: if a.count(1)==k[0] or k[0] in a: print("YES") else: print("NO") sys.exit(0) for i in range(n): if i+s-1<=n-1: k0 = [0]*m for j in a[i:i+s]: k0[...
vfc_55281
{ "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": "5 2\n1 1 2 2 1\n1 2\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
985_C. Liebig's Barrels
Solve the following coding problem using the programming language python: You have m = n·k wooden staves. The i-th stave has length ai. You have to assemble n barrels consisting of k staves each, you can use any k staves to construct a barrel. Each stave must belong to exactly one barrel. Let volume vj of barrel j be...
```python n, k, l = map(int, input().split()) sl = [int(i) for i in input().split()] vx = min(sl) vy = vx + l fl = sorted([i for i in sl if vx <= i <= vy]) if len(fl) < n: print('0') else: ans = 0 i = 0 um = n while um > 0: ans += fl[i] um -= 1 i = min(i + k, len(fl) - um) ...
vfc_55285
{ "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 1\n1 2 3 4 5 6\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 1\n2 2 1 2 3 2 2 3\n", "output": "7", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
abed-and-timelines
Solve the following coding problem using the programming language python: Those of you who are familiar with the TV Show Community and it's 'lovable' character, Abed, who likes to travel around dimensions, parallel universes, and various other parallel time lines, would know that Abed needs your help. And if you aren'...
```python t=input() while t: n,m=map(int,raw_input().split()) x1,y1=map(int,raw_input().split()) x2,y2=map(int,raw_input().split()) p=input() r=abs(x1-x2) c=abs(y1-y2) h=min(r,n-r) v=min(c,m-c) ans = (h+v)*p print ans if ans>1000: print 'Let go of the group.' else: print 'You saved the group.' t=t-1 ``...
vfc_55289
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 4\n3 0\n2 2\n9\n\nSAMPLE", "output": "27\nYou saved the group.\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n227 147\n36 84\n100 62\n9\n143 19\n34 4\n73 13\n9\n241 63\n21 57\n94...
code_contests
verifiable_code
bomb-defusal-4
Solve the following coding problem using the programming language python: Exams are over !! Everyone is now in the mood to play the multiplayer game Counter-Strike 1.6. 12 players decide to play Counter-Strike 1.6, each one playing from his own room via LAN on his own laptop. The 12 players (6 on 6) : Counter Terrori...
```python from collections import * from heapq import * from bisect import * from math import * from itertools import * inf=float('inf') if __name__=="__main__": tcase=int(raw_input()) while tcase>0: tcase-=1 p,a,b,c,d=map(int,raw_input().split()) if abs(a+b)%2==abs(c+d)%2: t=0 if a==c and b==d: t=0...
vfc_55293
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n2 1 2 3 4 \n1 1 2 3 4\n2 1 2 4 3\n1 1 2 4 3\n3 1 2 4 3\n1 1 2 1 2\n\nSAMPLE", "output": "Counter-Terrorists Win !\nTerrorists Win !\nTerrorists Win !\nTerrorists Win !\nCounter-Terrorists Win !\nCounter-Terrorists Win !\n"...
code_contests
verifiable_code
cupcake-challenge-1
Solve the following coding problem using the programming language python: Hansa did not have enough money to pay the bill of the party. Now she loves cupcakes (and can also eat any amount of it apparently), so she came up with a cupcake challenge. She challenges t people individually every time for the challenge. The...
```python t=input() while t: a,b,c=map(int,raw_input().split()) x=a^b^c; if(x!=0): print "NO BILL" else: print "BILL" t-=1 ```
vfc_55297
{ "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 1 1\n1 2 3\n\nSAMPLE", "output": "NO BILL\nBILL\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2 1\n1 2 3\n\nSAMPLE", "output": "NO BILL\nBILL\n", "type": "stdin_std...