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
862_D. Mahmoud and Ehab and the binary string
Solve the following coding problem using the programming language python: Mahmoud and Ehab are in the fourth stage now. Dr. Evil has a hidden binary string of length n. He guarantees that there is at least one '0' symbol and at least one '1' symbol in it. Now he wants Mahmoud and Ehab to find a position of any '0' sy...
vfc_71921
{ "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\n2\n1\n3\n2\n1\n0", "output": "? 000\n? 100\n? 110\n? 100\n! 1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "110\n", "output": "? 0000000000000000000000000000000000000000000000...
code_contests
verifiable_code
888_B. Buggy Robot
Solve the following coding problem using the programming language python: Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y + 1...
```python n=input() s=input() print((min(s.count('L'),s.count('R'))+min(s.count('D'),s.count('U')))*2) ```
vfc_71925
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nLDUR\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nRRRUU\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
910_C. Minimum Sum
Solve the following coding problem using the programming language python: Petya has n positive integers a1, a2, ..., an. His friend Vasya decided to joke and replaced all digits in Petya's numbers with a letters. He used the lowercase letters of the Latin alphabet from 'a' to 'j' and replaced all digits 0 with one l...
```python #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction import collections from itertools import permutations import threading from collections import defaultdict BUFSIZE = 8192 ...
vfc_71929
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nabcdef\nghij\nbdef\naccbd\ng\n", "output": "136542\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
932_E. Team Work
Solve the following coding problem using the programming language python: You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk. Output the sum of costs over all non-empty subsets of people. Input Only line of input contains ...
```python # ############################## import # def stirling2_list(n, mod=10 ** 9 + 7): # if not n: # return [0] # res = [0, 1] # for i in range(n - 1): # res = [0, 1] + [(res[j - 1] + j * res[j]) % mod for j in range(2, 2 + i)] + [1] # return res # Explain: # ans = \sum_{i=1}^{n} \...
vfc_71933
{ "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": "1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n", "output": "24\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "493 48...
code_contests
verifiable_code
959_F. Mahmoud and Ehab and yet another xor task
Solve the following coding problem using the programming language python: Ehab has an array a of n integers. He likes the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) and he likes to bother Mahmoud so he came up with a problem. He gave Mahmoud q queries. In each of them, he gave Mahmoud...
```python import sys range = xrange input = raw_input MOD = 10**9 + 7 inp = [int(x) for x in sys.stdin.read().split()]; ii = 0 n = inp[ii]; ii += 1 q = inp[ii]; ii += 1 A = inp[ii: ii + n]; ii += n zeros = [1] Abase = [] base = [] for i in range(n): a = A[i] for b in base: if a ^ b < a: ...
vfc_71937
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 1 1\n3 1\n2 0\n", "output": "4\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
986_D. Perfect Encoding
Solve the following coding problem using the programming language python: You are working as an analyst in a company working on a new system for big data storage. This system will store n different objects. Each object should have a unique ID. To create the system, you choose the parameters of the system — integers m...
vfc_71941
{ "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": "37\n", "output": "11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "36\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1234567...
code_contests
verifiable_code
brio-and-house-2-1
Solve the following coding problem using the programming language python: Brio got his house constructed near the National Highway. The Construction and Planning Committee has planned to construct a road near his house. Brio is worried about the Committee's plan as he fears that his house might come on the way of the ...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' from math import sqrt t=input() while t>0: t-=1 x1, y1 ,x2 ,y2 =map(int,raw_input().split()) r=input() x=(x2-x1) y=(y2-y1) if x==0 and y==0: prin...
vfc_71949
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 5 -5 5 \n4\n1 2 3 4\n5\n\nSAMPLE", "output": "SAFE\nREPLANNING\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 3 -5 5 \n4\n1 2 3 4\n5\n\nSAMPLE", "output": "REPLANNING\nREP...
code_contests
verifiable_code
darshak-and-networks
Solve the following coding problem using the programming language python: Darshak (Dark) completed with his studies and became a engineer, now to earn his bread he decided to start a company, being a son of rich men he need not to think about investors. He came up with a idea of bringing up a company so as to star...
```python t = int(raw_input()) for i in range(t): x = long(raw_input()) print (x*(x-1))/2 ```
vfc_71953
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n\nSAMPLE", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5000\n1\n931733\n694459\n638630\n749751\n238760\n886106\n762142\n517246\n642611\n203388\n491378\n369474\n52116...
code_contests
verifiable_code
game-of-bots
Solve the following coding problem using the programming language python: There are two kind of bots in the game BOT A and BOT B. Both are designed so as to move only in one direction in a 1-D array. Bot A can move towards left whereas bot B is constrained to move rightwards. Both are constrained to move only to the e...
```python import sys testCase = int(raw_input()) def findOccurences(s, ch): return [i for i, letter in enumerate(s) if letter == ch] while (testCase>0): try: line = raw_input() except KeyboardInterrupt: break if not line: break else: temp = line.split(" ") ...
vfc_71957
{ "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#A#B#B# A###B#B\n#A#B# #B#A#\n\nSAMPLE", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n#A#B#A# A###B#B\n#A#B# #B#A#\n\nSAMPLE", "output": "No\nNo\n", ...
code_contests
verifiable_code
karan-and-his-sticker-collection
Solve the following coding problem using the programming language python: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input d...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' n = int(raw_input()) a = map(int,raw_input().split()) cnt=0 for i in range(n): if a[i] < 300000000: cnt+=1 print cnt ```
vfc_71961
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n18 400000000\n\nSAMPLE", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n18 757482671\n\nSAMPLE", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
missing-alphabets-1
Solve the following coding problem using the programming language python: Adriana was playing with the English alphabet. When she was done playing with the alphabet, she realised that she had jumbled up the positions of the letters. Now, given a set of words, she wondered what would be the dictionary ordering of these...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' def convertAlphabet(s, fromAlphabet, toAlphabet): newWord = [] fromAlphaList = dict(zip(list(fromAlphabet), [i for i in range(26)])) toAlphaList = dict(zip([i for i in rang...
vfc_71965
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nabcdefghijklmnopqrstuvwxyz\n2\naa\nbb\nbacdefghijklmnopqrstuvwxyz\n2\naa\nbb\n\nSAMPLE", "output": "aa\nbb\nbb\naa\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\neklpyqrbgjdwtcaxzsn...
code_contests
verifiable_code
palindromic-revenge
Solve the following coding problem using the programming language python: Mike lost in a coding contest just because he was not aware with the concept of palindrome properly. So finally he learnt about it and decided to mess up with the Winners name of the contest as he will now meddle with letters of their names. He ...
```python for i in range(input()): a=raw_input() c=0 for j in range(0,len(a)/2): c+=abs(ord(a[j])-ord(a[len(a)-1-j])) print(c) ```
vfc_71969
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nada\nacda\ndceb\n\nSAMPLE", "output": "0\n1\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\ngulrdbmnfdahexaqfcarewrstjtxonnwhbonccchfcqmcqchuebyassvblsraioilexpgzymeoyggapahqyhir...
code_contests
verifiable_code
robot-challenge
Solve the following coding problem using the programming language python: All Indian Robotic Challenge (AIRC) is going to be held in NIT Raipur.Ajeet a student of nitrr want to participate in it and win it. In airc person whose robots will reach faster to end point will win .speed of bot is 20meters/Min.Ajeet want to ...
```python t=input() while t: n=input() r=(n*60)/20 r=int(r) print r t-=1 ```
vfc_71973
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n30\n45\n60\n20\n40\n\nSAMPLE", "output": "90\n135\n180\n60\n120\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
starting-game-development
Solve the following coding problem using the programming language python: Every one is now a days playing games on their smartphones for passing free time. Because of which there are number of game developing companies growing in the market. Not only that, each company is now flooding the market with a lot of games. W...
```python import bisect N,M,Q = map(int,raw_input().split()) levels = [] for _ in xrange(N): levels.append(map(int,raw_input().split())) for _ in xrange(Q): q=map(int,raw_input().split()) m=M for i in xrange(N): m = min(m,bisect.bisect_right(levels[i],q[i])) print m ```
vfc_71977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3 3\n10 20 30\n7 14 100\n11 7\n35 13\n100 1002\n\nSAMPLE", "output": "1\n1\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
turing-and-the-magic-board
Solve the following coding problem using the programming language python: Turing loves playing board games. Recently he played a game on the internet, that he found interesting. You are given a square board of length N. Each unit box in the board is to be filled with a gold coin. All the players have infinite gold co...
```python rr=raw_input for testcase in xrange(int(rr())): N,K = map(int,rr().split()) X = N*N-K print int(X%(N+1)!=0) ```
vfc_71981
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "388\n519 72054\n276 24593\n48 586\n445 65349\n634 214562\n564 216338\n328 48675\n539 22361\n715 421522\n705 213461\n837 463587\n766 254594\n583 13882\n348 58915\n396 38345\n135 7722\n315 26519\n480 121393\n297 38722\n599 235477\n78...
code_contests
verifiable_code
p00005 GCD and LCM
Solve the following coding problem using the programming language python: Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b. Constraints * 0 < a, b ≤ 2,000,000,000 * LCM(a, b) ≤ 2,000,000,000 * The number of data sets ≤ 50 Input Input consists of ...
```python def gcd(a,b): a,b=max(a,b),min(a,b) while b!=0: a,b=b,a%b return a def lcm(a,b): return a*b//gcd(a,b) while True: try: x,y=map(int,input().split()) print(gcd(x,y),lcm(x,y)) except EOFError: break ```
vfc_72025
{ "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": "8 6\n50000000 30000000", "output": "2 24\n10000000 150000000", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 6\n50000000 24597532", "output": "2 24\n4 307469150000000\n", "type...
code_contests
verifiable_code
p00137 Middle-Square Method
Solve the following coding problem using the programming language python: Create a program of the square picking method, which is one of the classical random number generation methods. The square harvesting method was proposed by von Neumann in the mid-1940s. In the square picking method, when the number of digits of...
```python def method(s): count=0 ans=[] while count!=10: s=str(s**2).zfill(8) s=int(s[2]+s[3]+s[4]+s[5]) ans.append(s) count +=1 return ans N=int(input()) for i in range(N): s=int(input()) print("Case %d:"%(i+1)) for j in range(10): print(method(s)[j])...
vfc_72029
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n123\n567", "output": "Case 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
p00270 Railroad
Solve the following coding problem using the programming language python: We have decided to introduce an automatic ticket gate to the railway network of a certain country. One of the difficult issues to implement is determining whether a given ticket can move between designated stations. Each ticket has a boarding st...
```python from heapq import heappush, heappop s, r = map(int, input().split()) edges = [[] for _ in range(s)] for _ in range(r): u, v, w = map(int, input().split()) u -= 1 v -= 1 edges[u].append((v, w)) edges[v].append((u, w)) a, b, q = map(int, input().split()) a -= 1 b -= 1 def dijkstra(start)...
vfc_72033
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 7\n1 2 3\n1 4 1\n2 3 5\n4 3 1\n3 6 2\n4 5 2\n5 6 1\n1 6 6\n1 6\n4 3\n4 6\n5 6\n2 6\n2 5", "output": "Yes\nYes\nYes\nYes\nNo\nNo", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n1 2 3\n...
code_contests
verifiable_code
p00648 Watchin' TVA
Solve the following coding problem using the programming language python: Animation is one of methods for making movies and in Japan, it is popular to broadcast as a television program or perform as a movie. Many people, especially the young, love one. And here is an anime lover called Jack. We say he is an mysterious...
```python # AOJ 1063: Watchin' TVA # Python3 2018.7.8 bal4u while True: n = int(input()) if n == 0: break dic, tbl = {}, [] for i in range(n): nm, w, s = input().split() w, s = int(w), int(s) h, m = s//100, s%100 s = (1440*w + h*60 + m) % 10080 e = s + 30; tbl.append([s, e, 0, nm]) dic[nm] = i for i...
vfc_72041
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\ngalaxy_angel 0 600\n1\ngalaxy_angel\n11\nA 0 600\nB 0 610\nC 0 610\nD 0 610\nE 0 640\nEE 0 700\nF 0 710\nG 0 710\nH 0 710\nI 0 740\nJ 0 750\n2\nB\nH\n42\nnchj 6 2620\nanhnnnmewbktthsrn 4 2515\ngntmdsh 1 1800\nachnnl 4 2540\nhnsk...
code_contests
verifiable_code
p00792 Mirror Illusion
Solve the following coding problem using the programming language python: A rich man has a square room with mirrors for security or just for fun. Each side of the room is eight meters wide. The floor, the ceiling and the walls are not special; however, the room can be equipped with a lot of mirrors on the walls or as ...
vfc_72045
{ "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": "0\n1\ny 8 7\n4\ny 8 7\nx 7 8\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 2\ny 0 0\nx 0 0\n-1", "output": "800 750\n750 800\n75 25\n75 25", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00924 Bit String Reordering
Solve the following coding problem using the programming language python: Example Input 6 3 1 0 0 1 0 1 1 3 2 Output 1 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x i...
vfc_72049
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n1 0 0 1 0 1\n1 3 2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3\n1 0 0 1 0 1\n1 3 2", "output": "0\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
p01189 Roads in a City
Solve the following coding problem using the programming language python: Roads in a city play important roles in development of the city. Once a road is built, people start their living around the road. A broader road has a bigger capacity, that is, people can live on a wider area around the road. Interstellar Congl...
vfc_72057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n0 -12 0 0 2\n0 0 12 0 2\n0", "output": "39.14159", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01326 UTF-8
Solve the following coding problem using the programming language python: UTF-8 is one of the methods for coding multibyte characters. Characters are treated as bytes on the computer. If it is only English, it can be expressed in 1 byte even if the Latin alphabet, numbers and symbols are combined, but unfortunately i...
```python UTF8pattern = [ ['0xxxxxxx'], \ ['110yyyyx','10xxxxxx'], \ ['1110yyyy','10yxxxxx','10xxxxxx'], \ ['11110yyy','10yyxxxx', '10xxxxxx', '10xxxxxx'] \ ] def func(linelist, pattern): mother=UTF8pattern[pattern-1] ret=1 rety=1 y_hasone=0 y_allzero=1 for i in range(pattern)...
vfc_72061
{ "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\nxxxxxxxx", "output": "128", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\nxxxxxxxx\n3\n11100000\n10x00000\n10111111\n3\n11100000\n10000000\n10111111\n4\nxxxxxxxx\nxxxxxxxx\nxxxxxxxx\nx...
code_contests
verifiable_code
p01494 ThreeRooks
Solve the following coding problem using the programming language python: Example Input 3 3 1 0 0 Output 4 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_72065
{ "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": "3 3 1\n0 0", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5 1\n0 0", "output": "48\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
p01660 Sugoroku
Solve the following coding problem using the programming language python: E-Sugoroku Bob, a fox with no friends, decided to spend his time playing sugoroku alone today. A 6-sided die with integers a_1, a_2, a_3, a_4, a_5, a_6 written on each side, a piece, and M squares on a straight line, and numbers from 1 to M are...
vfc_72069
{ "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": "", "output": "", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01807 Stamp Rally
Solve the following coding problem using the programming language python: Stamp Rally Stamp Rally The Japan Amusement Group (JAG) is planning an event at a theme park that imitates an island country. In this event, each time a participant crosses a bridge, the stamps decided for each bridge are stamped in order on t...
vfc_72073
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5 1 4\n1 2 (\n1 3 a\n2 4 a\n3 4 )\n3 2 +\n4 4 1 2\n1 3 (\n3 4 a\n4 1 +\n3 2 a\n3 4 1 1\n1 2 a\n2 2 +\n2 3 a\n3 1 a\n5 8 1 5\n1 1 [\n1 2 (\n2 1 *\n2 2 a\n2 3 a\n3 3 )\n3 4 ]\n4 5 )\n2 14 1 1\n1 2 a\n1 2 (\n1 2 )\n1 2 [\n1 2 ]\n1 2...
code_contests
verifiable_code
p01942 Taiyaki-Master and Eater
Solve the following coding problem using the programming language python: E: Taiyaki-Master and Eater story Tsuta is very good at making Taiyaki. Ebi-chan loves Taiyaki made by Tsuta-san. The two are happy to make and eat Taiyaki every week, but Tsuta-san's recent worries are that Ebi-chan, who is in the middle of e...
```python from heapq import heappush, heappop H, W, T, Q = map(int, input().split()) que = [] state = [[0]*(W+1) for i in range(H+1)] data1 = [[0]*(W+1) for i in range(H+1)] data2 = [[0]*(W+1) for i in range(H+1)] def get(data, h, w): s = 0 while h: w0 = w el = data[h] while w0: ...
vfc_72077
{ "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 3 3 6\n1 0 1 1\n2 2 1 1 2 2\n3 1 1 1\n4 0 2 1\n5 2 1 1 2 2\n6 2 2 1 3 3", "output": "0 1\n1 1\n0 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 3 6\n1 0 1 1\n2 2 1 1 2 2\n3 1 1 1\n4...
code_contests
verifiable_code
p02091 XORANDORBAN
Solve the following coding problem using the programming language python: D: XORANDORBAN Problem Statement You are given a positive integer N. Your task is to determine a set S of 2^N integers satisfying the following conditions: * All the integers in S are at least 0 and less than 2^{N+1}. * All the integers in S...
vfc_72081
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 6 1 5", "output": "Yes\n0 3 4 7", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 6 0 5", "output": "Yes\n2 3 6 7\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
cds002
Solve the following coding problem using the programming language python: There are n children who have landed up in an unknown place where they find just some jar of cookies to eat. They also have a dog with them. The children gather all the cookies and put them in a big jar. Exhausted, they agree to go and wait unti...
```python t=int(input()) while t>0: t=t-1 n=0 m=0 n=int(input()) if n == 2: print (15) else: m=n+1 ans=pow(n,m)-n+1 print (ans) ```
vfc_72093
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n6", "output": "15621\n279931", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
cw5
Solve the following coding problem using the programming language python: With her new hair-style, Penny has to listen to all the comments of Sheldon Cooper. She (God knows why) challenged Sheldon Cooper for a match of Chess. Penny wants to defeat Dr. Sheldon Cooper in the game of chess. Although, she tried very hard,...
```python #!/usr/local/bin/python2.7 print "NOT YET!"; ```
vfc_72097
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "____B___\n________\n__Q_____\n________\n____P_S_\n_R______\n________\n________", "output": "NOT YET!", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
icq2
Solve the following coding problem using the programming language python: Prats is learning to count.But this is not a usual counting.He has been given the task to count number of trailing 0s in a binary representation of a number.   Input First line of input contains T, number of test cases. Each of the next T lines...
```python exec(input()*"print bin(input())[::-1].find('1');") ```
vfc_72101
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n7", "output": "2\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
uaseq
Solve the following coding problem using the programming language python: You are given an array that consists of n integer numbers. You have to change at most K elements of this array, so that the resulting array will be a arithmetic progression. From all the possible arithmetic progressions, you should choose most b...
```python array_len, allowed_changes = map(int, raw_input().split()) array = map(int, raw_input().split()) MAX = 10 ** 9 + 1 best_a = MAX best_d = MAX for start in xrange(allowed_changes + 1): rem = allowed_changes - start for end in xrange(max(start + 1, array_len - rem - 1), array_len): d = (array[e...
vfc_72113
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n1 2 1 4", "output": "-5 -2 1 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n1 0 1 4", "output": "-5 -2 1 4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1042_B. Vitamins
Solve the following coding problem using the programming language python: Berland shop sells n kinds of juices. Each juice has its price c_i. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin "A", vitamin "B" and vitamin "C". Each juice can contain one, two or all three types o...
```python n = int(input()) a = [1000000,1000000,1000000,1000000,1000000,1000000,1000000] for i in range(n): s = input() k = s.split(" ") q = int(k[0]) p = k[1] p = sorted(p) p = "".join(p) if(p=='A' or p=='B' or p=='C'): a[int(ord(p[0])-ord('A'))] = min(a[int(ord(p[0])-ord...
vfc_72121
{ "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\n10 A\n9 BC\n11 CA\n4 A\n5 B\n", "output": "13", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1065_A. Vasya and Chocolate
Solve the following coding problem using the programming language python: There is a special offer in Vasya's favourite supermarket: if the customer buys a chocolate bars, he or she may take b additional bars for free. This special offer can be used any number of times. Vasya currently has s roubles, and he wants to ...
```python n = int(input()) for i in range(n): a,b,c,d = map(int,input().split()) z = a//d x = z//b v = x*c print(z+v) ```
vfc_72125
{ "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\n10 3 1 1\n1000000000 1 1000000000 1\n", "output": "13\n1000000001000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 19260817 1 1\n", "output": "1\n", "type": "st...
code_contests
verifiable_code
1086_E. Beautiful Matrix
Solve the following coding problem using the programming language python: Petya collects beautiful matrix. A matrix of size n × n is beautiful if: * All elements of the matrix are integers between 1 and n; * For every row of the matrix, all elements of this row are different; * For every pair of vertically ...
vfc_72129
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 1\n1 2\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1106_E. Lunar New Year and Red Envelopes
Solve the following coding problem using the programming language python: Lunar New Year is approaching, and Bob is going to receive some red envelopes with countless money! But collecting money from red envelopes is a time-consuming process itself. Let's describe this problem in a mathematical way. Consider a timeli...
vfc_72133
{ "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": "12 2 6\n1 5 5 4\n4 6 6 2\n3 8 8 3\n2 9 9 5\n6 10 10 7\n8 12 12 9\n", "output": "11", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 1 6\n1 1 2 4\n2 2 6 2\n3 3 3 3\n4 4 4 5\n5 5 5 7\n6 6 6 ...
code_contests
verifiable_code
1133_F1. Spanning Tree with Maximum Degree
Solve the following coding problem using the programming language python: You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph. Your task is to find any spanning tree of this graph such that the ...
```python def dfs(s): stk,cnt=[],[] stk.append(s) cnt.append(0) while (len(stk)>0): s=stk[-1] ll=cnt[-1] visit[s]=1 flag=1 for j in range(ll,len(adj[s]),1): if visit[adj[s][j]]==0: cnt[-1]=j+1 stk.append(adj[s][j]) cnt.append(0) flag=0 break if flag: stk.pop() cnt.pop() n,m...
vfc_72137
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "1 2\n1 3\n1 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 9\n1 2\n2 3\n2 5\n1 6\n3 4\n6 5\n4 5\n2 7\n5 8\n", "output": "2 1\n2 ...
code_contests
verifiable_code
1154_C. Gourmet Cat
Solve the following coding problem using the programming language python: Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food: * on Mondays, Thursdays and Sundays he eats fish food; * on Tuesdays and Saturdays he eats rabbit stew; * on other days of we...
```python import copy nums = [0, 1, 2, 0, 2, 1, 0] asdf = [3, 2, 2] things = list(map(int, input().split(' '))) max_idx = 0 for i in range(7): stuff = copy.deepcopy(things) idx = i while stuff[0] >= 0 and stuff[1] >= 0 and stuff[2] >= 0 and idx < 7: stuff[nums[idx % 7]] -= 1 idx += 1 num...
vfc_72141
{ "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": "30 20 10\n", "output": "39\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1194_G. Another Meme Problem
Solve the following coding problem using the programming language python: Let's call a fraction x/y good if there exists at least one another fraction (x')/(y') such that x/y = (x')/(y'), 1 ≤ x', y' ≤ 9, the digit denoting x' is contained in the decimal representation of x, and the digit denoting y' is contained in th...
vfc_72149
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "42\n", "output": "150\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3141592653589793238462643383279\n", "output": "459925407\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
1211_D. Teams
Solve the following coding problem using the programming language python: There are n table bowling players, the rating of the i-th player equals r_i. Compose a maximum number of teams in a such way that: * each player belongs to at most one team; * each team contains exactly a+b players; * each team contains...
vfc_72153
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "12 1 2 2\n1 1 2 2 2 2 2 3 3 4 6 6\n", "output": "\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "14 1 1 3\n3 3 1 1 9 9 2 3 6 6 3 18 3 18\n", "output": "\n6\n", "type": "std...
code_contests
verifiable_code
1234_B2. Social Network (hard version)
Solve the following coding problem using the programming language python: The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Initiall...
```python #!/usr/bin/env python3 ''' https://github.com/dhruvildave http://codeforces.com/contest/1234/problem/B1 ''' from collections import deque def soln() -> None: '''Driver code''' def logic() -> None: '''Logic''' n, k = [int(x) for x in input().split()] arr = [int(x) for x in in...
vfc_72157
{ "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": "7 2\n1 2 3 2 1 3 2\n", "output": "2\n2 1 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1276_F. Asterisk Substrings
Solve the following coding problem using the programming language python: Consider a string s of n lowercase English letters. Let t_i be the string obtained by replacing the i-th character of s with an asterisk character *. For example, when s = abc, we have t_1 = \tt{*bc}, t_2 = \tt{a*c}, and t_3 = \tt{ab*}. Given a...
vfc_72165
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abc\n", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "e\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "wym\n", ...
code_contests
verifiable_code
1296_F. Berland Beauty
Solve the following coding problem using the programming language python: There are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree. You have a map of that network, so for each railway section you ...
```python import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ from collections import deque n = int(input()) G = [[] for i in range(n)] edges = [] for i in range(n-1): a,b = map(int, input().split()) a,b = a-1,b-1 G[a].append(b) G[b].append(a) edges.append((a,b)) dep = [0]...
vfc_72169
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 2\n1 6\n3 1\n1 5\n4 1\n4\n6 1 1\n3 4 3\n6 5 3\n1 2 4\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 2\n1 6\n3 1\n1 5\n4 1\n4\n6 1 3\n3 4 1\n6 5 2\n1 2 5\n", ...
code_contests
verifiable_code
1320_A. Journey Planning
Solve the following coding problem using the programming language python: Tanya wants to go on a journey across the cities of Berland. There are n cities situated along the main railroad line of Berland, and these cities are numbered from 1 to n. Tanya plans her journey as follows. First of all, she will choose some...
```python n = int(input()) a = input().split() a = [int(x) for x in a] a = [a[i]-i for i in range(n)] d = {} for i in range(n): if (a[i] not in d): d[a[i]] = 0 d[a[i]] += a[i]+i m = 0 for k in d: m = max(m,d[k]) print(m) ```
vfc_72173
{ "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": "7\n8 9 26 11 12 29 14\n", "output": "55\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n10 7 1 9 10 15\n", "output": "26\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
1360_H. Binary Median
Solve the following coding problem using the programming language python: Consider all binary strings of length m (1 ≤ m ≤ 60). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly 2^m such strings in total. The...
```python for nt in range(int(input())): n,m = map(int,input().split()) r = [] for i in range(n): r.append(int(input(),2)) r.sort() left = 2**m-n med = (left-1)//2 for i in range(n): if r[i]<=med: med+=1 ans = bin(med)[2:] ans = "0"*(m-len(ans))+ans print (ans) ```
vfc_72181
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 3\n010\n001\n111\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n3 3\n010\n001\n110\n4 3...
code_contests
verifiable_code
1401_B. Ternary Sequence
Solve the following coding problem using the programming language python: You are given two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respectively, and the number of elements 0, 1, 2 in the ...
```python def checkKey(dict, key): if key in dict: return True return False # def helper(s): # l=len(s) # if (l==1): # l=[] # l.append(s) # return l # ch=s[0] # recresult=helper(s[1:]) # myresult=[] # myresult.append(ch) # for st in recresult: # myresult.append(st) # ts=ch+st # myresult.append(t...
vfc_72189
{ "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\n2 3 2\n3 3 1\n4 0 1\n2 3 0\n0 0 1\n0 0 1\n", "output": "4\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n45094381 58629867 47778466\n33028864 48902149 69571701\n", "outp...
code_contests
verifiable_code
1424_I. Bubble Cup hypothesis
Solve the following coding problem using the programming language python: The Bubble Cup hypothesis stood unsolved for 130 years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis to this problem: Given ...
```python # =============================================================================================== # importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import BytesIO, IOBase from itertools import * import bisect from hea...
vfc_72193
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 4\n", "output": "2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4 1 8 3 9\n", "output": "4\n1\n9\n2\n9\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
146_E. Lucky Subsequence
Solve the following coding problem using the programming language python: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence a co...
```python MOD = 1000000007 n, m = map(int, raw_input().split()) arr = map(int, raw_input().split()) def check(num): return set(str(num)) <= set(['4', '7']) ct = {} nonlucky = 0 for num in arr: if not check(num): nonlucky += 1 continue if num not in ct: ct[num] = 0 ct[num] +=...
vfc_72201
{ "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 2\n4 4 7 7\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n10 10 10\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1496_A. Split it!
Solve the following coding problem using the programming language python: Kawashiro Nitori is a girl who loves competitive programming. One day she found a string and an integer. As an advanced problem setter, she quickly thought of a problem. Given a string s and a parameter k, you need to check if there exist k+1 ...
```python from os import path import sys,time # mod = int(1e9 + 7) # import re from math import ceil, floor,gcd,log,log2 ,factorial,sqrt from collections import defaultdict ,Counter , OrderedDict , deque from itertools import combinations ,accumulate # from string import ascii_lowercase ,ascii_uppercase from bisect imp...
vfc_72205
{ "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": "7\n5 1\nqwqwq\n2 1\nab\n3 1\nioi\n4 2\nicpc\n22 0\ndokidokiliteratureclub\n19 8\nimteamshanghaialice\n6 3\naaaaaa\n", "output": "\nYES\nNO\nYES\nNO\nYES\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
173_E. Camping Groups
Solve the following coding problem using the programming language python: A club wants to take its members camping. In order to organize the event better the club directors decided to partition the members into several groups. Club member i has a responsibility value ri and an age value ai. A group is a non-empty su...
vfc_72217
{ "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 1\n1 5 4 1 2\n4 4 3 2 2\n4\n5 3\n2 3\n2 5\n4 1\n", "output": "4\n3\n-1\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20 1000\n14978 51012 24266 26753 21674 21363 14717 36618 6337 11...
code_contests
verifiable_code
194_A. Exams
Solve the following coding problem using the programming language python: One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2. The author would need to spend too much time and ...
```python n, k = map(int, input().split()) q = k // n r = k % n if q > 2: print(0) else: print(n - r) ```
vfc_72221
{ "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 3\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
218_A. Mountain Scenery
Solve the following coding problem using the programming language python: Little Bolek has found a picture with n mountain peaks painted on it. The n painted peaks are represented by a non-closed polyline, consisting of 2n segments. The segments go through 2n + 1 points with coordinates (1, y1), (2, y2), ..., (2n + 1,...
```python n, k = map(int, input().split()) tab = [int(x) for x in input().split()] i = 1 while k > 0: if tab[i - 1] < tab[i] - 1 and tab[i + 1] < tab[i] - 1: tab[i] -= 1 k -= 1 i += 2 print(' '.join(map(str, tab))) ```
vfc_72225
{ "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 2\n0 5 3 5 1 5 2\n", "output": "0 4 3 4 1 5 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n0 2 0\n", "output": "0 1 0\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
266_D. BerDonalds
Solve the following coding problem using the programming language python: BerDonalds, a well-known fast food restaurant, is going to open a cafe in Bertown. The important thing is to choose the new restaurant's location so that it would be easy to get there. The Bertown road system is represented by n junctions, conne...
vfc_72233
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 2 100\n2 3 1\n", "output": "50.5000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2 1\n2 3 1\n1 3 1\n", "output": "1.0000000000\n", "type": "stdin_stdout"...
code_contests
verifiable_code
28_D. Don't fear, DravDe is kind
Solve the following coding problem using the programming language python: A motorcade of n trucks, driving from city «Z» to city «З», has approached a tunnel, known as Tunnel of Horror. Among truck drivers there were rumours about monster DravDe, who hunts for drivers in that tunnel. Some drivers fear to go first, oth...
```python n = int(input()) v = n*[-1] c = n*[-1] L = n*[-1] R = n*[-1] for i in range(n): v[i], c[i], L[i], R[i] = map(int, input().split()) index = [i for i in range(n)] index.sort(key = lambda i: (c[i]+L[i]+R[i], i)) prev = n*[-1] best_res = 0 best_last = -1 ii = 0 while ii < n: i = index[ii] jj = ii ...
vfc_72237
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 1 0 3\n10 1 2 1\n2 2 1 1\n10 1 1 2\n3 1 3 0\n", "output": "3\n1 3 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 0 3\n1 1 1 2\n1 1 2 1\n1 1 3 0\n2 1 3 0\n", "output": ...
code_contests
verifiable_code
315_D. Sereja and Periods
Solve the following coding problem using the programming language python: Let's introduce the designation <image>, where x is a string, n is a positive integer and operation " + " is the string concatenation operation. For example, [abc, 2] = abcabc. We'll say that string s can be obtained from string t, if we can re...
```python b, p = map(int, input().split()) s1 = input() s2 = input() cnt = [0] * len(s2) nxt = [0] * len(s2) for i in range(len(s2)): pos = i for j in range(len(s1)): if s1[j] == s2[pos]: pos += 1 if pos == len(s2): cnt[i] += 1 pos = 0 ...
vfc_72241
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3\nabab\nbab\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
338_A. Quiz
Solve the following coding problem using the programming language python: Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on...
```python def chk(x): d = (m - x) // (k - 1) * k if (m - x) % (k - 1): d += 1 + (m - x) % (k - 1) if d <= n - x: return True else: return False def calc(e): if e == 1: return 2 if e & 1: d = 2 else: d = 1 f = calc(e >> 1) d = d * f % D...
vfc_72245
{ "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 3 2\n", "output": " 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4 2\n", "output": " ...
code_contests
verifiable_code
360_C. Levko and Strings
Solve the following coding problem using the programming language python: Levko loves strings of length n, consisting of lowercase English letters, very much. He has one such string s. For each string t of length n, Levko defines its beauty relative to s as the number of pairs of indexes i, j (1 ≤ i ≤ j ≤ n), such tha...
vfc_72249
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 7\nabcd\n", "output": "21962\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\nyz\n", "output": "26\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
384_A. Coder
Solve the following coding problem using the programming language python: Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x...
```python """ ██╗ ██████╗ ██╗ ██████╗ ██████╗ ██╗ █████╗ ██║██╔═══██╗██║ ╚════██╗██╔═████╗███║██╔══██╗ ██║██║ ██║██║ █████╔╝██║██╔██║╚██║╚██████║ ██║██║ ██║██║ ██╔═══╝ ████╔╝██║ ██║ ╚═══██║ ██║╚██████╔╝██║ ███████╗╚██████╔╝ ██║ █████╔╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚════╝ """ ...
vfc_72253
{ "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\n", "output": "2\nC.\n.C\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15\n", "output": "113\nC.C.C.C.C.C.C.C\n.C.C.C.C.C.C.C.\nC.C.C.C.C.C.C.C\n.C.C.C.C.C.C.C.\nC.C.C.C.C.C.C.C\...
code_contests
verifiable_code
404_E. Maze 1D
Solve the following coding problem using the programming language python: Valera has a strip infinite in both directions and consisting of cells. The cells are numbered by integers. The cell number 0 has a robot. The robot has instructions — the sequence of moves that he must perform. In one move, the robot moves one...
vfc_72257
{ "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": "RRL\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "RR\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "RRRRLRLR...
code_contests
verifiable_code
432_A. Choosing Teams
Solve the following coding problem using the programming language python: The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, e...
```python n, k = [int(x) for x in input().split()] pros = [int(x) for x in input().split()] teams=0 for i in range(n): z = pros[i]+k if z <= 5: teams+=1 print(int(teams/3)) ```
vfc_72261
{ "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": "6 4\n0 1 2 3 4 5\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 5\n0 0 0 0 0 0\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
454_C. Little Pony and Expected Maximum
Solve the following coding problem using the programming language python: Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice has m faces: th...
```python n,m = map(int, input().split()) s=0 for i in range(n): s+=(i+1)*(pow((i+1)/n,m)-pow(i/n,m)) print(s) ```
vfc_72265
{ "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": "6 1\n", "output": "3.500000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n", "output": "1.750000000000\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
477_A. Dreamoon and Sums
Solve the following coding problem using the programming language python: Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where k is some integer number...
```python import sys import math MAXNUM = math.inf MINNUM = -1 * math.inf ASCIILOWER = 97 ASCIIUPPER = 65 MODMAX = 1000000007 def getInt(): return int(sys.stdin.readline().rstrip()) def getInts(): return map(int, sys.stdin.readline().rstrip().split(" ")) def getString(): return sys.stdin.readline().r...
vfc_72269
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n", "output": "8\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
4_B. Before an Exam
Solve the following coding problem using the programming language python: Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less tha...
```python def print_arr(arr): for a in arr: print(a, end=' ') def solution(): d, hr = input().split() d, hr = int(d), int(hr) intervals = [] first = [] for _ in range(d): vmin, vmax = input().split() vmin, vmax = int(vmin), int(vmax) intervals.append((vmin, vm...
vfc_72273
{ "difficulty": "8", "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 5\n0 1\n3 5\n", "output": "YES\n1\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 48\n5 7\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
525_A. Vitaliy and Pie
Solve the following coding problem using the programming language python: After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go f...
```python n = int(input()) knowledge = input() count = 0 keyHash = {} for i in range((2*n) -2): if i%2 == 0: key = knowledge[i] if key in keyHash: keyHash[key]+=1 else: keyHash[key] = 1 else: door = knowledge[i] reqKey = chr(ord(door)+ 32) if reqKey i...
vfc_72277
{ "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\naAbB\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\naBaCaB\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
550_B. Preparing Olympiad
Solve the following coding problem using the programming language python: You have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems...
```python vet = [] aux = [] cont = 0 def fa(i, f): global aux, cont if i<=f: aux.append(vet[i]) #print(aux, menor, sum(aux), maior, max(aux), min(aux), diff) if len(aux) >=2 and menor<=sum(aux)<=maior and max(aux) - min(aux)>=diff: #print('Entrei', aux) cont+=1 ...
vfc_72281
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 40 50 10\n10 20 30 25\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 25 35 10\n10 10 20 10 20\n", "output": "6\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
577_C. Vasya and Petya's Game
Solve the following coding problem using the programming language python: Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. Petya can ask questions like: "Is the unknown number divisible by number y?". The game is played by the following rules:...
```python def get_primes(n): numbers = set(range(n, 1, -1)) primes = [] while numbers: p = numbers.pop() primes.append(p) numbers.difference_update(set(range(p*2, n+1, p))) return primes n = int(input()) l = get_primes(n+1) ans = [] for x in l: p = x while(p<=n): ...
vfc_72285
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "3\n2 4 3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": "4\n2 4 3 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
59_A. Word
Solve the following coding problem using the programming language python: Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only c...
```python n = input() a=0 b=0 for i in n: if(i.isupper()): a+=1 else: b+=1 if(a>b): print(n.upper()) else: print(n.lower()) ```
vfc_72289
{ "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": "ViP\n", "output": "VIP", "type": "stdin_stdout" }, { "fn_name": null, "input": "maTRIx\n", "output": "matrix", "type": "stdin_stdout" }, { "fn_name": null, "input": "H...
code_contests
verifiable_code
641_D. Little Artem and Random Variable
Solve the following coding problem using the programming language python: Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Consider two dices. When thrown each dice shows some integer from 1 to n inclusive. For each dice th...
```python n = int(input()) M = list(map(float, input().split())) m = list(map(float, input().split())) a = [] sa = [0] b = [] sb = [0] for i in range(0, n): p = sa[i] - sb[i] - M[i] - m[i] q = M[i] - sa[i]*(M[i] + m[i]) d = p*p - 4*q if d < 0: d = -d a.append((-p + (d ** 0.5))/2) b.appe...
vfc_72297
{ "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\n0.125 0.25 0.625\n0.625 0.25 0.125\n", "output": "0.25000000 0.25000000 0.50000000 \n0.50000000 0.25000000 0.25000000 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
66_B. Petya and Countryside
Solve the following coding problem using the programming language python: Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The gard...
```python num = input() sec = list(map(int, input().split(' '))) ans = 0 def check(index): total = 1 #print(sec[index]) for i in range(len(sec)): #print(i) if index-i-1 < 0: break if sec[index-i-1] <= sec[index-i]: #print(i) total = total +1 ...
vfc_72301
{ "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": "8\n1 2 1 1 1 3 3 4\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
690_F2. Tree of Life (medium)
Solve the following coding problem using the programming language python: Heidi got tired of deciphering the prophecy hidden in the Tree of Life and decided to go back to her headquarters, rest a little and try there. Of course, she cannot uproot the Tree and take it with her, so she made a drawing of the Tree on a pi...
vfc_72305
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 5\n2\n4 1\n2 1\n1\n3 1\n3\n4 1\n4 3\n2 1\n3\n3 1\n3 2\n4 1\n3\n2 1\n3 2\n4 2\n", "output": "YES\n1 2\n1 4\n3 4\n1 5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
715_D. Create a Maze
Solve the following coding problem using the programming language python: ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n × m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom starting from 1) and m columns (numbered from the left to ...
```python corr = lambda x, y: 1 <= x <= n and 1 <= y <= m T = int(input()) a = [] while T: a.append(T % 6) T //= 6 L = len(a) n = m = L * 2 + 2 ans = [(1, 2, 2, 2), (2, 1, 2, 2)] f = [[1] * 9 for i in range(7)] f[1][2] = f[2][2] = f[2][6] = f[3][5] = 0 f[4][5] = f[4][6] = f[5][2] = f[5][5] = f[5][6] = 0 p = [0...
vfc_72309
{ "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\n", "output": "4 4\n4\n1 2 2 2\n2 1 2 2\n3 1 3 2\n4 1 4 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "5 5\n9\n1 3 1 4\n1 4 2 4\n2 4 2 5\n3 1 4 1\n3 4 3 5\n4 1 ...
code_contests
verifiable_code
736_A. Tennis Championship
Solve the following coding problem using the programming language python: Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. That means, that if some...
```python n = int(input()) an = 0 a = 1 b = 0 c = 2 while(n >= c): b = a a = c c = a + b an+=1 print(an) ```
vfc_72313
{ "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\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", ...
code_contests
verifiable_code
760_A. Petr and a calendar
Solve the following coding problem using the programming language python: Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a...
```python def read_input(): line = input().strip().split() m = int(line[0]) week = int(line[1]) days31 = {1,3,5,7,8,10,12} if m == 2: days = 28 elif m in days31: days = 31 else: days = 30 z = (days + week - 1) return z//7 if z % 7 == 0 else z//7 + 1 if __name...
vfc_72317
{ "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 7\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
804_B. Minimum number of steps
Solve the following coding problem using the programming language python: We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the mi...
```python MOD = 10**9 + 7 s = input() bcount, count = 0, 0 for c in reversed(s): if c == 'b': bcount += 1 else: count += bcount bcount *= 2 if bcount > 2**62: bcount %= MOD print(count % MOD) ```
vfc_72325
{ "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": "ab\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aab\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abbbbaba...
code_contests
verifiable_code
82_A. Double Cola
Solve the following coding problem using the programming language python: Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go ...
```python n=int(input()) #L=["Sheldon","Leonard","Penny","Rajesh","Howard"] i=1 val=5 while n>val: if i%2==0 or i==1: n=n-5*i val=2*val i=2*i if 1<=n<=i: print("Sheldon") elif i<=n<=2*i: print("Leonard") elif 2*i<=n<=3*i: print("Penny") elif 3*i<=n<=4*i: print("Rajesh") elif 4*i<=n<=5*i: print("Howard") ...
vfc_72329
{ "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": "6\n", "output": "Sheldon", "type": "stdin_stdout" }, { "fn_name": null, "input": "1802\n", "output": "Penny", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
850_C. Arpa and a game with Mojtaba
Solve the following coding problem using the programming language python: Mojtaba and Arpa are playing a game. They have a list of n numbers in the game. In a player's turn, he chooses a number pk (where p is a prime number and k is a positive integer) such that pk divides at least one number in the list. For each nu...
```python import sys input = sys.stdin.buffer.readline from collections import Counter games = Counter() # prime : bitmask of if that power of the prime exists def add_primes(a): i = 2 while i*i <= a: cnt = 0 while a % i == 0: a //= i cnt += 1 if cnt: ...
vfc_72333
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1 17 17\n", "output": "Mojtaba\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 1 1\n", "output": "Arpa\n", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
873_E. Awards For Contestants
Solve the following coding problem using the programming language python: Alexey recently held a programming contest for students from Berland. n students participated in a contest, i-th of them solved ai problems. Now he wants to award some contestants. Alexey can award the students with diplomas of three different d...
vfc_72337
{ "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": "4\n1 2 3 4\n", "output": "-1 3 2 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 4 3 1 1 2\n", "output": "-1 1 2 -1 -1 3 ", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
899_D. Shovel Sale
Solve the following coding problem using the programming language python: There are n shovels in Polycarp's shop. The i-th shovel costs i burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovels in pairs. Visitors ar...
```python n = int(input()) if n < 5: print((n*(n-1))//2) else: x = n+n-1 if str(x).count('9') == len(str(x)): print(1) else: ans = 0 x = len(str(x)) x = x-1 z = 10**x y = int('9'*x) while y <= (n+(n-1)): if n >= y: ans +...
vfc_72341
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "50\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "14\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n", ...
code_contests
verifiable_code
91_E. Igloo Skyscraper
Solve the following coding problem using the programming language python: Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building! There are n walruses taking part in the contest. Each walrus is given a unique number from 1 to n. After start each walrus begins to build his own iglo...
vfc_72345
{ "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": "5 4\n6 1\n5 1\n2 5\n4 3\n6 1\n2 4 1\n3 4 5\n1 4 5\n1 2 0\n", "output": "3\n3\n3\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n4 1\n3 5\n6 2\n3 5\n6 5\n1 5 2\n1 3 5\n1 1 0\n1 5 0\...
code_contests
verifiable_code
948_C. Producing Snow
Solve the following coding problem using the programming language python: Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a ...
```python import heapq heap = [] n = int(input()) V = list(map(int, input().split())) T = list(map(int, input().split())) tmp = 0 for i in range(n): ans = 0 heapq.heappush(heap, tmp+V[i]) while len(heap) and heap[0]<=tmp+T[i]: ans += heapq.heappop(heap)-tmp tmp += T[i] ans += T[i]*len(heap) ...
vfc_72349
{ "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\n10 10 5\n5 7 2\n", "output": "5 12 4 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
976_C. Nested Segments
Solve the following coding problem using the programming language python: You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 ≥ l2 ...
```python n = int(input()) otr = [tuple(map(int, input().split())) for i in range(n)] left = sorted(otr, key=lambda x: (x[0], x[1])) for i, el in enumerate(left[1:]): one, two = left[i], el if one[0] == two[0]: print(f'{otr.index(one) + 1} {n - otr[::-1].index(two)}') exit() elif one[1] ...
vfc_72353
{ "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\n1 5\n2 6\n6 20\n", "output": "-1 -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 10\n2 9\n3 9\n2 3\n2 9\n", "output": "2 1\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
996_A. Hit the Lottery
Solve the following coding problem using the programming language python: Allen has a LOT of money. He has n dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are 1, 5, 10, 20, 100. What is the minimum number of bills ...
```python money=int(input()) number=0 alist=[100,20,10,5,1] for i in alist: number+=money//i money=money%i print(int(number)) ```
vfc_72357
{ "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": "43\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "125\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10000000...
code_contests
verifiable_code
balanced-weights
Solve the following coding problem using the programming language python: Today RK has to transport his N items of different weights(in calories) to a near city but before that he wants to make sure that the weights of all items are balanced. In order to check this he puts all items on the weight scale and found that ...
```python gcd = lambda a,b: gcd(b, a%b) if a%b else b for _ in range(int(raw_input())): n = int(raw_input()) num = map(int, raw_input().split()) ans = num[0] for i in num[1:]: ans = gcd(i, ans) if ans == 1: break print ans*n ```
vfc_72361
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n3 6 9\n2\n2 2\n\nSAMPLE", "output": "9\n4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
circles-in-rectangles
Solve the following coding problem using the programming language python: This question is straight-forward. Given length L cm and breadth B cm of a rectangular cardboard. You need to cut out the circles of diameter D cm from it. Find out the maximum number of circles you can cut out from it. Since the value can be v...
```python from math import pi,floor t=int(raw_input()) for qq in xrange(t): l,b,d=map(long,raw_input().split()) print ((l/d) * (b/d)) % (10**9+7) ```
vfc_72365
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n20 10 30\n30 20 10\n\nSAMPLE", "output": "0\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 10 100\n999999999999999999 999999999999999999 100", "output": "0\n105700001\n",...
code_contests
verifiable_code
end-game
Solve the following coding problem using the programming language python: Problem: Black and White are playing a game of chess on a chess board of n X n dimensions. The game is nearing its end. White has his King and a Pawn left. Black has only his King left. So, definitely Black cannot win the game. However, Black c...
```python tc = int(raw_input()) while tc: n,a,b,c,d,move = map(int,raw_input().split()) if c + move < a or abs (d - b) > n + move - a: print "White Wins" else: print "Draw" """ if a<=n and b<=n and c<=n and d<=n: while 1: if move == 0: if c==a and d==b: print"Draw" break if a<n: a = a +...
vfc_72369
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 6 2 10 2 0\n10 5 2 1 3 0\n\nSAMPLE", "output": "Draw\nWhite Wins", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
help-ashu-1
Solve the following coding problem using the programming language python: Ashu and Shanu are best buddies. One day Shanu gives Ashu a problem to test his intelligence.He gives him an array of N natural numbers and asks him to solve the following queries:- Query 0:- modify the element present at index i to x. Query 1:...
```python import math n = int(raw_input()) arr = map(int,raw_input().split()) q = int(raw_input()) #tree stores count of odd number height = int(math.ceil(math.log(n,2))) tn = int(math.pow(2,height)) tree = [0]*(2*tn) # print 2*tn def buildSegTree(node,l,r,arr): if l==r: tree[node] = arr[l]%2 else: mid = (l+r)/...
vfc_72373
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 2 3 4 5 6\n4\n1 2 5\n2 1 4\n0 5 4\n1 1 6\n\nSAMPLE", "output": "2\n2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 2 3 4 5 6\n4\n1 2 5\n2 1 3\n0 5 4\n1 1 6\n\nSAMPLE", ...
code_contests
verifiable_code
lucky-string-1
Solve the following coding problem using the programming language python: Lucky numbers are those numbers which contain only "4" and/or "5". For example 4, 5, 44, 54,55,444 are lucky numbers while 457, 987 ,154 are not. Lucky number sequence is one in which all lucky numbers exist in increasing order for example 4...
```python from itertools import product import sys data = sys.stdin.read().splitlines() def main(): global data test_cases = int(data.pop(0).strip()) digit_tot = [] index = 1 prev_val = 2 digit_tot.append(prev_val) while prev_val < 1000000000000000: index += 1 cur_val = ...
vfc_72377
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1\n2\n3\n9\n\nSAMPLE", "output": "Hacker\nEarth\nHacker\nEarth\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
navi-and-his-company-3
Solve the following coding problem using the programming language python: Navi is a CEO of a famous IT based software company. He is hiring some new developers to work in his company. He already know the number of new projects and number of hirings at particular timestamp. He will assign one project to one developer a...
```python t = input() for _ in range(t): n = input() developers = 0 answer = 0 for _ in range(n): i = raw_input().strip() if len(i) > 1 and developers == 0: answer += 1 elif len(i) > 1 and developers: developers -= 1 else: developers +=...
vfc_72381
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n1\nNew Project\nNew Project\n\nSAMPLE", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3\n2\nNew Project\nNew Project\n\nSAMPLE", "output": "0\n", "type"...
code_contests
verifiable_code
product-divisors-6
Solve the following coding problem using the programming language python: Oz is in love with number theory, so he expects you to love it too and solve his problems. The current problem which has been given by Oz to you is in the form of an array. So, he has given you N integers i.e a1,a2,..,aN to deal with. You have t...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' from math import sqrt N=int(raw_input()) ip=[int(i) for i in raw_input().strip().split()] mdic={} for i in ip: q=i try: mdic[i][0]+=1 continue except: pass dic={} w...
vfc_72385
{ "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 3\n\nSAMPLE", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n204 188 114 382 862 941 149 900 904 129 10 845 454 531 993 444 917 639 190 917 462 585 504 946 637 121...
code_contests
verifiable_code
sharpen-the-pencils-2
Solve the following coding problem using the programming language python: Madhav and Riya were getting bored. So they decided to play a game. They placed N pencils in a line. Madhav starts to sharpen pencil from left to right, and Riya from right to left. For each pencil, its length is known. Madhav sharpens with sp...
```python t=int(raw_input()) for s in range(0,t): no=int(raw_input()) l=map(int,raw_input().split()) if no==1: print "1 0" else: m=0 n=0 x=0 y=0 for i in xrange(0,no): if m<=n: m+=l[x]/2.0 x+=1 else: n+=l[no-1-y] y+=1 print x,y ```
vfc_72389
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n2 9 8 2 7\n\nSAMPLE", "output": "3 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5\n2 9 8 2 7\n\nSAMPLD", "output": "3 2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
the-blessing-1
Solve the following coding problem using the programming language python: In a village far far away, lived a farmer named Zico. He was finding it difficult to make his two ends meet and hence, approached the god of grains, Azure. Azure granted him a blessing: "I shall grant thou P units of food initially . After ev...
```python t=int(raw_input()) for i in range(t): p,m=map(int,raw_input().split()) print 2*(p+m) ```
vfc_72393
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 1 \n0 3\n2 9\n\nSAMPLE", "output": "2\n6\n22\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00069 Drawing Lots II
Solve the following coding problem using the programming language python: There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizo...
```python # AOJ 0069: Drawing Lots II # Python3 2018.6.28 bal4u while True: n = int(input()) if n == 0: break m, p, d = [int(input()) for i in range(3)] m -= 1 p -= 1 a = [[] for i in range(d+1)] for i in range(d): a[i] = list(map(int, input())) s = [[0 for j in range(n)] for i in range(d+1)] s[d] = [i for i ...
vfc_72441
{ "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": "5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0100\n0101\n1010\n0", "output": "6 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0000\n010...
code_contests
verifiable_code
p00201 Wrought Gold Master
Solve the following coding problem using the programming language python: You finally got a magic pot, an alchemy pot. You can create a new item by putting multiple items in the alchemy pot. Newly created items can also be placed in alchemy pots to make other items. A list of items needed to make an item will be calle...
```python # from pprint import pprint as pprint import copy def findrecipe(rec,ite,obj): # pprint(rec) # print("obj: ",obj) # print("=-") try: mat = rec[obj] rec2 = copy.copy(rec) del rec2[obj] price = min(ite[obj],sum([findrecipe(rec2,ite,m) for m in mat])) # pr...
vfc_72445
{ "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": "8\nwood 3000\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophone 9800\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 racket microphone onigiri\nguitar\n1\ncomputer 300000\n0\ncomputer\n0", ...
code_contests
verifiable_code
p00562 Soccer
Solve the following coding problem using the programming language python: You are a manager of a prestigious soccer team in the JOI league. The team has $N$ players numbered from 1 to $N$. The players are practicing hard in order to win the tournament game. The field is a rectangle whose height is $H$ meters and widt...
vfc_72453
{ "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": "6 5\n1 3 6\n3\n1 1\n0 4\n6 5", "output": "26", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 5\n1 3 6\n3\n1 1\n0 4\n2 5", "output": "13\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p00715 Name the Crossing
Solve the following coding problem using the programming language python: The city of Kyoto is well-known for its Chinese plan: streets are either North-South or East-West. Some streets are numbered, but most of them have real names. Crossings are named after the two streets crossing there, e.g. Kawaramachi-Sanjo is t...
```python from collections import deque import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) if N == 0: return False L = 0 n_map = {} def get(s): nonlocal L if s in n_map: return n_map[s] n_map[s] = L ...
vfc_72457
{ "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": "7\nShijo-Kawaramachi\nKarasuma-Imadegawa\nKawaramachi-Imadegawa\nNishioji-Shijo\nKarasuma-Gojo\nTorimaru-Rokujo\nRokujo-Karasuma\n6\nShijo-Karasuma\nImadegawa-Nishioji\nNishioji-Gojo\nShijo-Torimaru\nTorimaru-Gojo\nShijo-Kawabata\n...
code_contests
verifiable_code
p00855 Prime Gap
Solve the following coding problem using the programming language python: The sequence of n - 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a prime gap of length n. For example, (24, 25, 26, 27, 28) between 23 ...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split...
vfc_72461
{ "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": "10\n11\n27\n2\n492170\n0", "output": "4\n0\n6\n0\n114", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n11\n27\n2\n296421\n0", "output": "4\n0\n6\n0\n60\n", "type": "stdin_stdo...
code_contests
verifiable_code
p01256 Time Trial
Solve the following coding problem using the programming language python: Some people like finishing computer games in an extremely short time. Terry A. Smith is one of such and prefers role playing games particularly. He is now trying to find a shorter play for one of the key events in a role playing game. In this e...
vfc_72473
{ "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": "7 6\n\n.._..#\n.*.*.#\n.@.*.#\n_..._#\n\n10 13\n\n___###\n...###\n...###\n.####\n.....#..#\n.#*.*.*.#\n...###..#\n.#.#.##\n.#.#.##\n.....##\n..@..##\n\n0 0", "output": "15\n118", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p01417 Calender Colors
Solve the following coding problem using the programming language python: Taro is a member of a programming contest circle. In this circle, the members manage their schedules in the system called Great Web Calender. Taro has just added some of his friends to his calendar so that he can browse their schedule on his ca...
```python import itertools N,M = map(int,input().split()) src = [tuple(map(float,input().split())) for i in range(N)] if M <= 1: print(0) exit() dists = [[None for j in range(N)] for i in range(N)] for i in range(N-1): for j in range(i+1,N): l1,a1,b1 = src[i] l2,a2,b2 = src[j] dist =...
vfc_72477
{ "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": "2 1\n1.0 1.0 1.0\n0.0 0.0 0.0", "output": "0.00000000000000000000", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01571 Adhoc Translation
Solve the following coding problem using the programming language python: One day, during daily web surfing, you encountered a web page which was written in a language you've never seen. The character set of the language was the same as your native language; moreover, the grammar and words seemed almost the same. Exci...
vfc_72481
{ "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 5\nqwerty asdf zxcv\nqwert\nasf\ntyui\nzxcvb\nghjk", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 10\nqwerty asdf zxcv\nqwert\nasf\ntyui\nzxcvb\nghjk", "output": "3...
code_contests
verifiable_code
p01733 Fox Observation
Solve the following coding problem using the programming language python: Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. With her previous research, foxes in the forest are k...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x in ...
vfc_72485
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1 2\n2 2 3", "output": "5 / 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1 4\n2 2 3", "output": "7 / 1\n", "type": "stdin_stdout" }, { "fn_name": nul...