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
510_D. Fox And Jumping
Solve the following coding problem using the programming language python: Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0. There are also n cards, each card has 2 attributes: length li ...
```python import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter # from itertools import permutations,combinations d...
vfc_53125
{ "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\n100 99 9900\n1 1 1\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
535_E. Tavas and Pashmaks
Solve the following coding problem using the programming language python: Tavas is a cheerleader in the new sports competition named "Pashmaks". <image> This competition consists of two part: swimming and then running. People will immediately start running R meters after they finished swimming exactly S meters. A wi...
vfc_53129
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3\n2 2\n3 1\n", "output": "1 2 3 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2\n1 1\n2 1\n", "output": "1 3 \n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
560_A. Currency System in Geraldion
Solve the following coding problem using the programming language python: A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with ...
```python n=int(input()) l=list(map(int,input().split()));print(1 if 1 not in l else -1) ```
vfc_53133
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n635370 154890 909382 220996 276501 716105 538714 140162 171960 271264\n", "output": "1\n", "t...
code_contests
verifiable_code
586_C. Gennady the Dentist
Solve the following coding problem using the programming language python: Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office. All children love to cry loudly at the reception at the dentist. We enumerate the children with integers f...
```python #!/usr/bin/env python # -*- coding: utf-8 -*- n = int(input()) C = [list(map(int,input().split())) for i in range(0,n)] ans = [] for i in range(n): v, d, p = C[i] if p >= 0: count = 0 d0 = 0 for j in range(i + 1, n): if C[j][2] >= 0: C[j][2] -= m...
vfc_53137
{ "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\n4 2 2\n4 1 2\n5 2 4\n3 3 5\n5 1 2\n", "output": "2\n1 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4 5 1\n5 3 9\n4 1 2\n2 1 8\n4 1 9\n", "output": "4\n1 2 4 5", "type"...
code_contests
verifiable_code
608_D. Zuma
Solve the following coding problem using the programming language python: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible. In one second, Genos is ab...
```python from sys import stdin n=int(input()) s=list(map(int,stdin.readline().strip().split())) dp=[[-1 for i in range(501)] for j in range(500)] def sol(i,j): if i>j: return 0 if i==j: return 1 if dp[i][j]!=-1: return dp[i][j] x=502 if s[i]==s[i+1]: x=min(x,sol(i+2,...
vfc_53141
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 4 4 2 3 2 1\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
62_C. Inquisition
Solve the following coding problem using the programming language python: In Medieval times existed the tradition of burning witches at steaks together with their pets, black cats. By the end of the 15-th century the population of black cats ceased to exist. The difficulty of the situation led to creating the EIC - th...
```python from math import * eps=1e-14 n = input() l = [map(int,raw_input().split()) for _ in xrange(n)] res = 0 def isect(a1,b1,c1,x1,y1,x2,y2): a2,b2,c2=y1-y2,x2-x1,x1*y2-y1*x2 d = a1*b2-a2*b1 if d==0: return None, None x = -1.0*(c1*b2-c2*b1)/d y = -1.0*(c2*a1-a2*c1)/d #print x1,y1,x2,y2,x,y ...
vfc_53145
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3 10 3 3 10\n1 1 9 4 5 6\n2 2 11 7 6 11\n", "output": "37.70440214974445325424\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 1 2 1 1 2\n", "output": "3.414213562373094923...
code_contests
verifiable_code
656_B. Scrambled
Solve the following coding problem using the programming language python: Btoh yuo adn yuor roomatme lhoate wianshg disehs, btu stlil sdmoeboy msut peorrfm tihs cohre dialy. Oen dya yuo decdie to idourtcne smoe syestm. Yuor rmmotaoe sstgegus teh fooniwllg dael. Yuo argee on tow arayrs of ientgres M adn R, nmebur upmic...
```python n = int(input()) m = list(map(int, input().split())) r = list(map(int, input().split())) days = 0 for day in range(1, 100001): for index in range(n): if day % m[index] == r[index]: days += 1 break print(days / 100000) ```
vfc_53149
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 3\n1 0\n", "output": "0.6666666666666666\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
67_B. Restoration of the Permutation
Solve the following coding problem using the programming language python: Let A = {a1, a2, ..., an} be any permutation of the first n natural numbers {1, 2, ..., n}. You are given a positive integer k and another sequence B = {b1, b2, ..., bn}, where bi is the number of elements aj in A to the left of the element at =...
```python s = input() l = s.split() n = int(l[0]) k = int(l[1]) s = input() l = s.split() b = [-1] for i in range(1, n + 1): b.append(int(l[i - 1])) for i in range(1, n + 1): j = 1 while b[j] != 0: j += 1 b[j] -= 1 print(j, end = ' ') for t in range(1, n + 1): if j - k >=...
vfc_53153
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n1 2 1 0 0\n", "output": "4 1 5 2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n1 0 0 0\n", "output": "2 3 1 4\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
702_B. Powers of Two
Solve the following coding problem using the programming language python: You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i. e. some integer x exists so that ai + aj = 2x). Input The first line contains the single positive integer n (1 ≤ n ≤ 10...
```python # @oj: codeforces # @id: hitwanyang # @email: 296866643@qq.com # @date: 2020-08-20 23:46 # @url:https://codeforc.es/problemset/problem/702/B import sys,os from io import BytesIO, IOBase import collections,itertools,bisect,heapq,math,string from decimal import * # region fastio BUFSIZE = 8192 BUFSIZE = 8192...
vfc_53157
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 1\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
769_C. Cycle In Maze
Solve the following coding problem using the programming language python: The Robot is in a rectangular maze of size n × m. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol "L"), right (the symbol "R"), up (the symbol "U") or do...
```python import math from collections import deque def main(): n, m, k = list(map(int, input().split())) grid = ["" for _ in range(n)] x, y = 0, 0 for i in range(n): grid[i] = input() if 'X' in grid[i]: x, y = i, grid[i].index('X') if k % 2 == 1: print("IMPOSSIBLE") return dx = [1, 0, 0, -1] dy ...
vfc_53169
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 15, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 4\n***\n*X*\n***\n", "output": "IMPOSSIBLE\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6 14\n..***.\n*...X.\n..*...\n..*.**\n....*.\n", "output": "DLDDLLLRRRUURU\n", ...
code_contests
verifiable_code
813_F. Bipartite Checking
Solve the following coding problem using the programming language python: You are given an undirected graph consisting of n vertices. Initially there are no edges in the graph. Also you are given q queries, each query either adds one undirected edge to the graph or removes it. After each query you have to check if the...
vfc_53177
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5\n2 3\n1 3\n1 2\n1 2\n1 2\n", "output": "YES\nYES\nNO\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "30 40\n5 15\n13 16\n12 17\n19 23\n1 27\n16 25\n20 21\n6 18\n10 17\n7 13\n2...
code_contests
verifiable_code
85_A. Domino
Solve the following coding problem using the programming language python: We all know the problem about the number of ways one can tile a 2 × n field by 1 × 2 dominoes. You probably remember that it goes down to Fibonacci numbers. We will talk about some other problem below, there you also are going to deal with tilin...
```python def computeTiling(n): if n == 1: print("a\na\nf\nf") return for tiling in generateRowTilings(n): print("".join(tiling)) def generateRowTilings(n): for (rowNum, firstTile, pattern) in generateRowTilingPatterns(n): yield makeRowTiling(rowNum, firstTile, pattern,...
vfc_53185
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "abbz\naccz\nddee\neeff\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "25\n", "output": "abbccddeeffgghhiijjkkllmm\naccddeeffgghhiijjkkllmmnn\nddeeffgghhiijjkkllmmnn...
code_contests
verifiable_code
886_A. ACM ICPC
Solve the following coding problem using the programming language python: In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams. ...
```python a = list(map(int, input().split())) summ = sum(a) res = 'NO' if summ % 2 != 1 : summ //= 2 for i in range(4) : for j in range(i + 1, 5) : for k in range(j + 1, 6) : if a[i] + a[j] + a[k] == summ : res = 'YES' print(res) ```
vfc_53189
{ "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 1 1 1 1 99\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3 2 1 2 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
909_A. Generate Login
Solve the following coding problem using the programming language python: The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there ...
```python s=input().split(" ") m=s[0] j=s[1] list=[] for x in range(len(m)): p=m[0:x+1] p=p+j[0] list.append(p) list.sort() print(list[0]) ```
vfc_53193
{ "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": "tom riddle\n", "output": "tomr\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "harry potter\n", "output": "hap\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
930_C. Teodor is not a liar!
Solve the following coding problem using the programming language python: Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;m] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that be...
```python # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import threading from collections import defaultdict #threading.stack_size...
vfc_53197
{ "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": "2 4\n1 2\n3 4\n", "output": "4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
958_D1. Hyperspace Jump (easy)
Solve the following coding problem using the programming language python: The Rebel fleet is on the run. It consists of m ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hypersp...
```python m = int(input()) esc = [eval(input()) for i in range(m)] d = {i: 0 for i in esc} for i in esc: d[i] += 1 for i in esc: print(d[i], end = ' ') ```
vfc_53201
{ "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": "4\n(99+98)/97\n(26+4)/10\n(12+33)/15\n(5+1)/7\n", "output": "1 2 2 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "30\n(89+76)/87\n(81+78)/18\n(60+97)/32\n(41+14)/48\n(55+65)/27\n(29+15...
code_contests
verifiable_code
984_C. Finite or not?
Solve the following coding problem using the programming language python: You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction. A fraction in notation with base b is finite if it contains finite numbe...
```python from sys import stdin, stdout n=int(stdin.readline()) s='' for i in range(n): p,q,b=map(int,input().split()) for i in range(6): b=(b*b)%q if((p*b)%q): s+='Infinite\n' else: s+='Finite\n' print(s) ```
vfc_53205
{ "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": "2\n6 12 10\n4 3 10\n", "output": "Finite\nInfinite\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 2\n9 36 2\n4 12 3\n3 5 4\n", "output": "Finite\nFinite\nFinite\nInfinite\n",...
code_contests
verifiable_code
bob-an-idiot-11
Solve the following coding problem using the programming language python: Andi and Bob were friends since childhood days. But, as they grew up Bob started behaving weird and this used to irritate Andi. Once, while Andi took a break after typing a large program Bob came from nowhere and swapped some alphabet keys on An...
```python no_of_replace_chars =int(raw_input()) replace_strings = list() for x in range(no_of_replace_chars): replace_strings.append(raw_input()) s = raw_input() d = dict() for key, value in enumerate(s): if d.has_key(value): d[value].append(key) else: d[value] = [key] temp = "temp" for r_str in replace_string...
vfc_53213
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nW H\nWelloHorld\n\nSAMPLE", "output": "HelloWorld\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\nW H\nWelloHoqld\n\nSAMPLE", "output": "HelloWoqld\n", "type": "stdin_std...
code_contests
verifiable_code
criminals-little-deepu-and-little-kuldeep
Solve the following coding problem using the programming language python: Little Deepu and Little Kuldeep are world renowned criminals. But, they are not bad people at heart. (Oh, they are...) Anyway, their occupation is to smuggle drugs from one place to another. And both of them are partners in this occupation of...
```python T= int(raw_input()) for _ in xrange(T): N = int(raw_input()) dic={} for __ in xrange(N): box = int(raw_input()) if box in dic: dic[box]+=1 else: dic[box]=1 key,val = max(dic.iteritems(),key=lambda x:x[1]) print val ```
vfc_53217
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n1\n2\n3\n4\n2\n2\n2\n2\n3\n11\n111\n1111\n\nSAMPLE", "output": "1\n4\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3\n0\n2\n3\n4\n2\n2\n2\n2\n3\n11\n111\n1111\n\nSAMPLE", ...
code_contests
verifiable_code
four-square-2
Solve the following coding problem using the programming language python: Rahul has recently been obsessed with mathematics, and spends most of his time reading the research notes of his equally eccentric math professor. On one of the pages of the research notes, Rahul finds a scribble that says, " the number of ways ...
```python import math def evennum(x): div= getAllDivisors(x) nfs = sum(div) print nfs*24 def oddnum(x): divisor = getAllDivisors(x) nfs = sum(divisor) print 8*nfs def getAllDivisors(x): sqrot = long(math.sqrt(x)) divi = [] for i in range(1, sqrot + 1): if n%i == 0: ...
vfc_53221
{ "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\n4\n\nSAMPLE", "output": "8\n24\n32\n24\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n999999\n999998\n999997\n999996\n999995\n999994\n999993\n999992\n999991\n999990\n999...
code_contests
verifiable_code
josh-and-hotel-2
Solve the following coding problem using the programming language python: Josh owns a hotel, there are X rooms in the hotel and every room can be allocated to maximum 1 person at a time. If a customer arrives and there are no rooms available, the customer will leave the hotel without staying, thus causing loss to his...
```python s=raw_input() while(s!='0'): x=input() #a=input() #print s list_ok=[] list_nok=[] booked_room=0 count=0 l=len(s) for i in range(0,l): if s[i] in list_ok: booked_room-=1 else: if booked_room < x: booked_room+=1 list_ok.append(s[i]) else: if s[i] in list_nok: p...
vfc_53225
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ABCBCA\n1\n0\n\nSAMPLE", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "AACBCA\n1\n0\n\nSAMPLE", "output": "1\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
milly-and-her-classmates-3
Solve the following coding problem using the programming language python: Milly and her classmates are standing in a queue to attend the morning assembly of her school. According to the rule any student should stand in his/her proper place in order to make the queue completely visible till the end. Milly being the cla...
```python def test(N): previous = 0 for i in N: if i < previous: return False else: previous = i return True tc=int(raw_input()) while tc: tc=tc-1 n=input() N=map(int,raw_input().split()) if test(N): print -1,-1 else: start=end=0 ...
vfc_53229
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n2 4 3 5\n3\n1 2 3\n3\n2 3 1\n\nSAMPLE", "output": "2 3\n-1 -1\n-1 -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4\n2 4 3 6\n3\n1 2 3\n3\n2 3 1\n\nSAMPLE", "output": "2 ...
code_contests
verifiable_code
pair-sums
Solve the following coding problem using the programming language python: You have been given an integer array A and a number K. Now, you need to find out whether any two different elements of the array A sum to the number K. Two elements are considered to be different if they lie at different positions in the array. ...
```python l=[int(x) for x in raw_input().split()] l1=[int(y) for y in raw_input().split()] l2=[] l3=[] l1.sort() for i in range(0,len(l1)): if(l1[i]>=l[1]/2.0): l2.append(l1[i]) else: l3.append(l1[i]) if(l[1]==2000000): print('NO') elif(len(l2)>1): if(l2[0]+l2[1]==l[1]): print('YES') else: try: for j in...
vfc_53233
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 9\n1 2 3 4 5\n\nSAMPLE", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 9\n1 2 3 1 5\n\nSAMPLE", "output": "NO\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
restaurant-problem-3
Solve the following coding problem using the programming language python: Kirti likes 8. Kirti's restaurant has many menus whose prices are multiples of 8. Now, Kirti has some digits written on a wooden board, and she'd like to cut the board to display prices in a new menu. In how many ways can Kirti choose consecutiv...
```python S = raw_input() #first look at 3s. if you find a hit, can do all prefixes of it N = len(S) ans = 0 for i in xrange(N-2): if int(S[i:i+3])%8 == 0: ans += i+1 - S[:i+1].count('0') #Now look at twos only for i in xrange(N-1): if int(S[i:i+2])%8 == 0 and S[i]!='0': ans += 1 ans += S.count('8')+S.count('0') prin...
vfc_53237
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5858\n\nSAMPLE", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "08648", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "64...
code_contests
verifiable_code
sorted-string
Solve the following coding problem using the programming language python: Little Ashish got a lot of strings as his birthday gift. He does not mind getting so many strings for free; in fact, he loves them. But, on noticing all the strings he received as a gift, Little Ashish, who's also a snob and a bit OCD kind of a ...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t = int(raw_input()) while t: t-=1 s = raw_input().strip() d = {} for i in s: d[i] = d.get(i, 0) + 1 l = list(d.items()) for i, v in enumerate(l): v = list...
vfc_53241
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naabbccdd\naabcc\nhackerearthSAMPLE", "output": "aabbccdd\nbaacc\nAELMPScktaaeehhrr\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
tour
Solve the following coding problem using the programming language python: Walter White is on a tour to sell meth. There are N cities. Each city has a id between 1 and N (both inclusive). You are given cost matrix. In cost matrix, the j\;th element in the i\;th row denotes the cost of travelling between cities with ...
```python di1 = {} di2 = {} ct1 = raw_input() ct = int(ct1) ct2 = int(ct1) cnt = 0 while ct!=0: ct_name = raw_input() di1[ct_name] = cnt cnt = cnt + 1 ct = ct - 1 cnt1 = 0 while ct2 !=0: st = raw_input() s = st.split(' ') di2[cnt1] = s cnt1 = cnt1 + 1 ct2 = ct2 -1 t1 = raw_input() t...
vfc_53245
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\ndelhi\nbengaluru\nhyderabad\n0 10 20\n10 0 55\n20 55 0\n4\nbengaluru\ndelhi\nhyderabad\nbengaluru\n\nSAMPLE", "output": "95\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\ndelhi\nben...
code_contests
verifiable_code
p00124 League Match Score Sheet
Solve the following coding problem using the programming language python: There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 po...
```python b=False while True: n = int(input()) if n==0:break d=dict() if b:print() b=True for _ in range(n): line = input().split() tmp = int(line[1])*3+int(line[3]*1) if tmp in d: d[tmp].append(line[0]) else: d[tmp] = [] d[tmp]...
vfc_53293
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0", "output": "Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p00257 Making Sugoroku
Solve the following coding problem using the programming language python: Taro made a sugoroku so that everyone can play at the children's association event. In order to make the game interesting, I wrote instructions such as "advance 6" and "back 5" in some of the sugoroku squares other than "Furidashi" and "Agari". ...
```python while True: m = int(input()) if not m: break n = int(input()) ds = [0] + [int(input()) for _ in range(n)] + [0] g = [[] for _ in range(n+2)] rg = [[] for _ in range(n+2)] for i in range(n+2): for j in range(min(n+1,i+1),min(n+1,i+m)+1): j = max(0,min(n+...
vfc_53297
{ "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": "3\n3\n-2\n1\n0\n2\n4\n2\n0\n-1\n-2\n2\n2\n-2\n-2\n0", "output": "OK\nNG\nNG", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00444 Change
Solve the following coding problem using the programming language python: problem Taro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smallest. Create a program to fi...
```python while True: x = int(input()) if x == 0: break else: x=1000-x a=x//500 b=(x-500*a)//100 c=(x-(500*a+100*b))//50 d=(x-(500*a+100*b+50*c))//10 e=(x-(500*a+100*b+50*c+10*d))//5 f=(x-(500*a+100*b+50*c+10*d+5*e))//1 print(a+b+c+d+e+...
vfc_53301
{ "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": "380\n1\n0", "output": "4\n15", "type": "stdin_stdout" }, { "fn_name": null, "input": "380\n0\n0", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
p00634 Provident Housewife
Solve the following coding problem using the programming language python: Kotoko, a housewife, was enthusiastic about keeping food costs down during this recession. Be sure to check the newspaper advertisement every morning. Make a good list of what to buy and the cheapest-selling shops, and go shopping by riding a bi...
vfc_53305
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 apple 100 banana 200 egg 300\n3 apple 150 banana 100 cola 200\n3 apple 100 banana 150 cola 200\n3\napple\nbanana\ncola\n5\n0 2 4\n0 1 3\n0 3 3\n1 2 3\n2 3 5\n3\n3 apple 100 banana 200 egg 300\n3 apple 150 banana 100 cola 200\n...
code_contests
verifiable_code
p00778 A Die Maker
Solve the following coding problem using the programming language python: A Die Maker The work of die makers starts early in the morning. You are a die maker. You receive orders from customers, and make various kinds of dice every day. Today, you received an order of a cubic die with six numbers t1, t2, ..., t6 on w...
vfc_53309
{ "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 1 1 1 1 1\n1 6\n1 1 1 1 1 1\n4 5\n0 0 0 0 0 2\n1 2\n0 0 2 2 2 4\n5 9\n1 2 3 4 5 6\n15 16\n0 1 2 3 5 9\n13 16\n2 13 22 27 31 91\n100 170\n0 0 0 0 0 0", "output": "EEENEE\nNE\nimpossible\nNSSNW\nEN\nEWNS\nSNSNSNSNSNSNSNSNSNSN...
code_contests
verifiable_code
p00909 Never Wait for Weights
Solve the following coding problem using the programming language python: In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the sa...
```python class Value_UnionFind(): def __init__(self,n): self.par = [i for i in range(n)] self.differ_weight = [0] * n self.rank = [0] * n def root(self,x): if x == self.par[x]: return x r = self.root(self.par[x]) self.differ_weight[x] += self.differ...
vfc_53313
{ "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 2\n! 1 2 1\n? 1 2\n2 2\n! 1 2 1\n? 2 1\n4 7\n! 1 2 100\n? 2 3\n! 2 3 100\n? 2 3\n? 1 3\n! 4 3 150\n? 4 1\n0 0", "output": "1\n-1\nUNKNOWN\n100\n200\n-50", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01312 Cat Burglar and Friday House
Solve the following coding problem using the programming language python: Natsume loves big cats. On Natsume's school road, there is a house commonly known as a cat mansion. The house is famous for having a lot of cats, and Natsume often encountered her cats in front of this house on her way to school and played with ...
vfc_53325
{ "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 0\n0 0\n15:00:00\n18:00:00\n1\n4 0 7199 1125 7199 1125 8324 0 8324\n0 0\n0 0\n15:00:00\n18:00:00\n1\n4 0 7201 1125 7201 1125 8326 0 8326", "output": "1\n17 59 59.076923\n0\n15 00 00.000000", "type": "stdin_stdout" ...
code_contests
verifiable_code
p01481 Lucky Dip
Solve the following coding problem using the programming language python: Time Limit: 8 sec / Memory Limit: 64 MB Example Input 10 10 .....#.... .....#.... .....#.... ######.... .......... ####...... ....###... t..#..#### ...##..... ....#...## 3 0 3 0 5 4 6 Output 2 The input will be given via stdin and the...
vfc_53329
{ "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 10\n.....#....\n.....#....\n.....#....\n######....\n..........\n####......\n....###...\nt..#..####\n...##.....\n....#...##\n3\n0 3\n0 5\n4 6", "output": "2", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
p01642 Reverse Game
Solve the following coding problem using the programming language python: There was a girl who had a hobby of Othello. I enjoy Othello with my family when I have time. One day, the girl tried to play Othello as usual. However, everyone was so busy that no one played. So I came up with a game that can be played by one...
vfc_53333
{ "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": "1 3\n1 1 1", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3\n2 1 0", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01794 Cost Performance Flow
Solve the following coding problem using the programming language python: Example Input 2 1 1 2 1 2 1 1 Output 1/2 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_53337
{ "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 1\n1 2\n1 2 1 1", "output": "1/2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1 2\n1 2 1 2", "output": "4/5\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
p02066 Treasure Hunter
Solve the following coding problem using the programming language python: G: Treasure Hunter problem There are N treasure trove, each of which is numbered from 1 to N. A treasure of value p_i lies in the i-th mountain, and this treasure can be obtained when you visit the mountain. Once you get the treasure, you can ...
vfc_53345
{ "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": "3 10\n6 8 2\n1 2 3\n2 3 8", "output": "14", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 10\n6 8 2\n1 2 1\n2 3 8", "output": "16\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p02362 Single Source Shortest Path (Negative Edges)
Solve the following coding problem using the programming language python: Constraints * 1 ≤ |V| ≤ 1000 * 0 ≤ |E| ≤ 2000 * -10000 ≤ di ≤ 10000 * There are no parallel edges * There are no self-loops Input An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is ...
```python import collections import sys sys.setrecursionlimit(100000) # ---- belmann-ford ----- V_num, E_num, r = [int(ele) for ele in input().split()] adjc_list = [] edges = [] for _ in range(V_num): adjc_list.append([]) for _ in range(E_num): src, dst, w = [int(ele) for ele in input().split()] adjc_list...
vfc_53353
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5 1\n0 1 2\n0 2 3\n1 2 -5\n1 3 1\n2 3 2", "output": "INF\n0\n-5\n-3", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5 0\n0 1 2\n0 2 3\n1 2 -5\n1 3 1\n2 3 2", "output": "0\n2\n-3\n-...
code_contests
verifiable_code
chcoinsg
Solve the following coding problem using the programming language python: Chef is playing a game with his friend Misha. They have a pile containg N coins. Players take alternate turns, removing some coins from the pile. On each turn, a player can remove either one coin or coins equal to some prime power (i.e. p^x coin...
```python for i in range(int(raw_input())): n = int(raw_input()) if n % 6 == 0: print "Misha" else: print "Chef" ```
vfc_53357
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n8", "output": "Chef\nChef\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
devarray
Solve the following coding problem using the programming language python: Devu has an array A consisting of N positive integers. He would like to perform following operation on array. Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same). Remo...
```python inputstr = raw_input() n,q = inputstr.split() n = int(n) q = int(q) a = map(int, raw_input().split()) minn = min(a) maxn = max(a) for i in range(q): t = int(raw_input()) if((t >= minn)&(t <= maxn)): print('Yes') else: print('No') ```
vfc_53361
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4\n1 3\n1\n2\n3\n4", "output": "Yes\nYes\nYes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n1\n1\n2", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
iitk2p02
Solve the following coding problem using the programming language python: Sumo was travelling alone at night, suddenly he saw a spaceship and out of it came an alien named KK. Obviously, the alien had a different language and thus couldn't communicate readily. After some psycho-telepathic talk, Sumo realised that KK's...
```python #Anwesh Mohanty mod=10**9+7 t=input() while t>0: n,m=map(int,raw_input().split()) if n==1: print m%mod elif n==2: print m*(m-1) else: print (m*(m-1)*pow(m-2,n-2,mod)%mod) #nPm t-=1 ```
vfc_53365
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 3\n1 4", "output": "6\n4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
ndlvote
Solve the following coding problem using the programming language python: Did you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made of noodles. It's a dish, a kind of rice noodle soup. Mr.Ping makes the best noodle soup and his son Po is eagerly waiting for the user ...
```python while 1: n = raw_input() if n == '': continue n = int(n) if n == 0: break users = 0 for i in xrange(0 , n): vote , score = raw_input().split() score = int(score) if vote == 'P': vote = 1 else: vote = -1 s...
vfc_53369
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nP 1\nP 2\n\n2\nP 2\nM -2\n\n0", "output": "1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nP 1\nP 2\n\n2\nP 0\nM -2\n\n0", "output": "1\n1\n", "type": "stdin_stdout"...
code_contests
verifiable_code
rubix4
Solve the following coding problem using the programming language python: Given an array A of N numbers, find out the minimum number of elements to be changed to ensure that the new array becomes a consecutive sequence of numbers. For example, given A = {2, 3, 6, 7, 8} where N = 5, it is obvious that we can change the...
```python times=input() while times: times-=1 n=input() l=[int(x) for x in raw_input().split()] i=0 maxi=-23 while i<n: j=i+1 count=0 while j<n: if(l[j]-l[i]-(j-i)==0): count+=1 j+=1 if(count+1>maxi): maxi=count+...
vfc_53373
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 4 5\n7\n99 8 9 102 103 16 17", "output": "1\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n1 4 5\n7\n99 7 9 102 103 16 17", "output": "1\n4\n", "type": "stdin_s...
code_contests
verifiable_code
xornuber
Solve the following coding problem using the programming language python: Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. Input The first line of input contain an integer T denoting the number of test cases. Each of the...
```python T = input() for t in range(T): N = input() if N==1: print 2 elif (N&(N+1))==0: print ((N+1)/2) - 1 else: print -1 ```
vfc_53377
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2", ...
code_contests
verifiable_code
1023_D. Array Restoration
Solve the following coding problem using the programming language python: Initially there was an array a consisting of n integers. Positions in it are numbered from 1 to n. Exactly q queries were performed on the array. During the i-th query some segment (l_i, r_i) (1 ≤ l_i ≤ r_i ≤ n) was selected and values of eleme...
```python n,q=map(int,input().split()) arr=list(map(int,input().split())) count_zero=arr.count(0) count_q=arr.count(q) if count_q ==0 and count_zero ==0: print("NO") exit() if count_q ==0: for i in range(n): if arr[i] ==0: arr[i] =q break for i in range(n): r=arr[i] i...
vfc_53381
{ "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": "4 3\n1 0 2 3\n", "output": "YES\n1 1 2 3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1044_E. Grid Sort
Solve the following coding problem using the programming language python: You are given an n × m grid. Each grid cell is filled with a unique integer from 1 to nm so that each integer appears exactly once. In one operation, you can choose an arbitrary cycle of the grid and move all integers along that cycle one space...
vfc_53385
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n4 1 2\n7 6 3\n8 5 9\n", "output": "1\n8 1 4 7 8 5 6 3 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n1 2 3 5 10\n11 6 4 14 9\n12 7 8 13 15\n", "output": "3\n4 4 14 13 8\n4...
code_contests
verifiable_code
1067_D. Computer Game
Solve the following coding problem using the programming language python: Ivan plays some computer game. There are n quests in the game. Each quest can be upgraded once, this increases the reward for its completion. Each quest has 3 parameters a_{i}, b_{i}, p_{i}: reward for completing quest before upgrade, reward for...
vfc_53389
{ "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": "2 2\n1 1000 0.1\n2 3 0.2\n", "output": "20.72000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n3 1000 0.5\n1 2 0.48\n3 20 0.3\n", "output": "252.25000000\n", "type": ...
code_contests
verifiable_code
108_B. Datatypes
Solve the following coding problem using the programming language python: Tattah's youngest brother, Tuftuf, is new to programming. Since his older brother is such a good programmer, his biggest dream is to outshine him. Tuftuf is a student at the German University in Cairo (GUC) where he learns to write programs in ...
```python n=int(input())-1 a=sorted(map(int,input().split())) ans='NO' for i in range(n): if a[i]<a[i+1]and a[i]*2>a[i+1]: ans='YES' print(ans) ```
vfc_53393
{ "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\n4 2 1 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n64 16 32\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1109_A. Sasha and a Bit of Relax
Solve the following coding problem using the programming language python: Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve uns...
```python def main(): n = int(input()) arr = list(map(int,input().split())) pref = [None]*(n+1) pref[0] = 0 pref[1] = arr[0] funny = 0 for i in range(1,n): pref[i+1] = pref[i]^arr[i] even = dict() odd = dict() even[0] = 1 for i in range(1,n+1): if i&1: ...
vfc_53397
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n42 4 2\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n3 2 2 3 7 6\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1138_D. Camp Schedule
Solve the following coding problem using the programming language python: The new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp's schedule. After some continuous discussion, they came up with a sche...
```python def kmp(s): p = [0] * len(s) idx = 0 for i in range(1, len(s)): while idx > 0 and s[idx] != s[i]: idx = p[idx - 1] if s[idx] == s[i]: idx += 1 p[i] = idx return idx def solve(s, t, pref): f = [0, 0] f[0] = s.count('0') f[1] = s.cou...
vfc_53401
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n11100\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10010110\n100011\n", "output": "10001101", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
1156_F. Card Bag
Solve the following coding problem using the programming language python: You have a bag which contains n cards. There is a number written on each card; the number on i-th card is a_i. You are playing the following game. During each turn, you choose and remove a random card from the bag (all cards that are still left...
vfc_53405
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 4 3\n", "output": "748683265", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 4 2 3\n", "output": "299473306", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
1178_H. Stock Exchange
Solve the following coding problem using the programming language python: Warning: This problem has an unusual memory limit! Bob decided that he will not waste his prime years implementing GUI forms for a large corporation and instead will earn his supper on the Stock Exchange Reykjavik. The Stock Exchange Reykjavik ...
vfc_53409
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 16000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 0\n2 1\n1 10\n1 11\n", "output": "6 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n261 261639\n92 123277\n271 131614\n320 154417\n97 258799\n246 17926\n117 222490\n110 39356\n85...
code_contests
verifiable_code
1214_C. Bad Sequence
Solve the following coding problem using the programming language python: Petya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to fix present himself. ...
```python def main(): n = int(input()) s = input() tab = [] inc = 0 if s.count("(") != s.count(")"): print("No") return for x in range(n): if s[x] == ")": inc -= 1 else: inc += 1 tab.append(inc) if min(tab) >= -1: print("Yes") else: print("No") main() ```
vfc_53417
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n)(\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n)))))(((((\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
1237_E. Balanced Binary Search Trees
Solve the following coding problem using the programming language python: Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than ...
```python # ========= /\ /| |====/| # | / \ | | / | # | /____\ | | / | # | / \ | | / | # ========= / \ ===== |/====| # code def main(): k = int(input()) s = [1,2,4,5] i = 2 while True: if s[-1] > int...
vfc_53421
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1255_E1. Send Boxes to Alice (Easy Version)
Solve the following coding problem using the programming language python: This is the easier version of the problem. In this version, 1 ≤ n ≤ 10^5 and 0 ≤ a_i ≤ 1. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for ...
```python x=int(input()) from math import ceil s=list(map(int,input().split())) id=[] for n in range(x): if s[n]: id.append(n) if len(id)==1: print(-1) exit(0) sm=len(id) res=1e9 divs=set() for n in range(2,int(sm**.5)+1): if sm%n==0: divs.add(n) divs.add(sm//n) divs.add(sm) ...
vfc_53425
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1279_D. Santa's Bot
Solve the following coding problem using the programming language python: Santa Claus has received letters from n different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the i-th kid asked Santa to give them one of k_i different items as a present. Some items coul...
```python import sys from collections import Counter from itertools import chain def input(): return sys.stdin.readline().rstrip() def input_ints(): return [int(_) for _ in input().split()] INV = {} def inv(x): if x not in INV: INV[x] = pow(x, M - 2, M) return INV[x] M = 998244353 n = int(...
vfc_53429
{ "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": "5\n2 1 2\n2 3 1\n3 2 4 3\n2 1 4\n3 4 3 2\n", "output": "798595483\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 2 1\n1 1\n", "output": "124780545\n", "type": "stdin_stdo...
code_contests
verifiable_code
1322_E. Median Mountain Range
Solve the following coding problem using the programming language python: Berland — is a huge country with diverse geography. One of the most famous natural attractions of Berland is the "Median mountain range". This mountain range is n mountain peaks, located on one straight line and numbered in order of 1 to n. The ...
vfc_53437
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 1 2 2 1 1\n", "output": "0\n1 1 2 2 1 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 3 2 5 4 6\n", "output": "1\n1 2 3 4 5 6 ", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1341_D. Nastya and Scoreboard
Solve the following coding problem using the programming language python: Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya d...
```python import sys input = sys.stdin.readline def main(): N, K = [int(x) for x in input().split()] S = [int(input().strip(), 2) for _ in range(N)] A = [119, 18, 93, 91, 58, 107, 111, 82, 127, 123] B = [[-1] * 10 for j in range(N)] for i, s in enumerate(S): for j in range(10): ...
vfc_53441
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 7\n0000000\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n0100001\n1001001\n1010011\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
1363_D. Guess The Maximums
Solve the following coding problem using the programming language python: This is an interactive problem. Ayush devised a new scheme to set the password of his lock. The lock has k slots where each slot can hold integers from 1 to n. The password P is a sequence of k integers each in the range [1, n], i-th element of...
vfc_53445
{ "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": "1\n4 2\n2 1 3\n2 2 4\n\n1\n\n2\n\n3\n\n4\n\nCorrect", "output": "? 4 1 2 3 4 \n? 2 1 2 \n? 1 3 \n? 2 1 3 \n! 1 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n5 5\n2 5 1 3 4\n1 5\n1...
code_contests
verifiable_code
1383_F. Special Edges
Solve the following coding problem using the programming language python: Koa the Koala has a directed graph G with n nodes and m edges. Each edge has a capacity associated with it. Exactly k edges of the graph, numbered from 1 to k, are special, such edges initially have a capacity equal to 0. Koa asks you q queries...
vfc_53449
{ "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": "4 4 2 5\n1 2 0\n2 3 0\n2 4 5\n3 4 2\n0 0\n1 10\n10 0\n7 1\n7 2\n", "output": "0\n1\n5\n6\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1 1 3\n1 2 0\n0\n1\n2\n", "output": "0\n...
code_contests
verifiable_code
1405_A. Permutation Forgery
Solve the following coding problem using the programming language python: A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutat...
```python # Om Namh Shivai # Jai Shree Ram # Jai Hanuman # Jai Shree Krishna # Radhe-Krishna # Jai Maa Kali # Jai Maa Durga # Jai Maa Burithakran for i in range(int(input())): n = int(input()) arr = list(map(int, input().split())) if(n%2 == 0): arr_res = list(reversed(arr)) else: arr_re...
vfc_53453
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n1 2\n6\n2 1 6 5 4 3\n5\n2 4 3 1 5\n", "output": "2 1\n3 4 5 6 1 2\n5 1 3 4 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2\n1 2\n6\n2 1 6 5 4 3\n5\n2 4 3 1 5\n", "output...
code_contests
verifiable_code
1426_C. Increase and Copy
Solve the following coding problem using the programming language python: Initially, you have the array a consisting of one element 1 (a = [1]). In one move, you can do one of the following things: * Increase some (single) element of a by 1 (choose some i from 1 to the current length of a and increase a_i by one);...
```python from math import ceil for _ in range(int(input())): n = int(input()) b = ceil(pow(n, 0.5)) a = ceil(n / b) ans = a + b - 2 print(ans) ```
vfc_53457
{ "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\n1\n5\n42\n1337\n1000000000\n", "output": "0\n3\n11\n72\n63244\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1\n5\n42\n1337\n1000001000\n", "output": "0\n3\n11\n72\n63244\n", ...
code_contests
verifiable_code
144_B. Meeting
Solve the following coding problem using the programming language python: The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose ...
```python xa, ya, xb, yb = map(int, input().split()) blankets, radiators = 0, [tuple(map(int, input().split())) for i in range(int(input()))] if xa > xb: xa, xb = xb, xa if ya > yb: ya, yb = yb, ya def distance(x1, y1, x2, y2): return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 for y in [ya, yb]: p = ...
vfc_53461
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 6 3\n2\n6 2 2\n6 5 3\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 5 4 2\n3\n3 1 2\n5 3 1\n1 3 2\n", "output": "4", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1473_B. String LCM
Solve the following coding problem using the programming language python: Let's define a multiplication operation between a string a and a positive integer x: a ⋅ x is the string that is a result of writing x copies of a one after another. For example, "abc" ⋅~2~= "abcabc", "a" ⋅~5~= "aaaaa". A string a is divisible ...
```python def gcd(a,b): if a == 0: return b return gcd(b % a, a) # Function to return LCM of two numbers def compute_lcm(a,b): return (a / gcd(a,b))* b def main(): T = int(input()) for c in range(T): s1 = input().rstrip() s2 = input().rstrip() s = s1 if le...
vfc_53465
{ "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\nbaba\nba\naa\naaa\naba\nab\n", "output": "\nbaba\naaaaaa\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\n...
code_contests
verifiable_code
1521_B. Nastia and a Good Array
Solve the following coding problem using the programming language python: Nastia has received an array of n positive integers as a gift. She calls such an array a good that for all i (2 ≤ i ≤ n) takes place gcd(a_{i - 1}, a_{i}) = 1, where gcd(u, v) denotes the [greatest common divisor (GCD)](https://en.wikipedia.org...
```python from sys import stdin """ n=int(stdin.readline().strip()) n,m=map(int,stdin.readline().strip().split()) s=list(map(int,stdin.readline().strip().split())) """ T=int(stdin.readline().strip()) for caso in range(T): n=int(stdin.readline().strip()) s=list(map(int,stdin.readline().strip().split())) mn=1...
vfc_53473
{ "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": "2\n5\n9 6 3 11 15\n3\n7 5 13\n", "output": "\n2\n1 5 11 9\n2 5 7 6\n0", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5\n9 6 3 11 15\n3\n7 5 13\n", "output": "4\n3 1 3 5\n3 2 3 4\n3...
code_contests
verifiable_code
176_E. Archaeology
Solve the following coding problem using the programming language python: This time you should help a team of researchers on an island in the Pacific Ocean. They research the culture of the ancient tribes that used to inhabit the island many years ago. Overall they've dug out n villages. Some pairs of villages were c...
vfc_53481
{ "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": "6\n1 2 1\n1 3 5\n4 1 7\n4 5 3\n6 4 2\n10\n+ 3\n+ 1\n?\n+ 6\n?\n+ 5\n?\n- 6\n- 3\n?\n", "output": "5\n14\n17\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n7 3 9\n8 3 2\n10 5 6\n9 ...
code_contests
verifiable_code
197_B. Limit
Solve the following coding problem using the programming language python: You are given two polynomials: * P(x) = a0·xn + a1·xn - 1 + ... + an - 1·x + an and * Q(x) = b0·xm + b1·xm - 1 + ... + bm - 1·x + bm. Calculate limit <image>. Input The first line contains two space-separated integers n and m (0 ≤ n,...
```python from math import gcd def polynomials(): n, m = map(int, input().strip().split()[:2]) if n > 100 or m > 100 or n < 0 or m < 0: print() else: ap1 = list(map(int, input("").split()[:n+1])) aq1 = list(map(int, input("").split()[:m+1])) if ap1[0] == 0 or aq1[0] == 0: ...
vfc_53485
{ "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": "2 1\n1 1 1\n2 5\n", "output": "Infinity\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 0\n-1 3\n2\n", "output": "-Infinity\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
220_C. Little Elephant and Shifts
Solve the following coding problem using the programming language python: The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's denote the i-th (1 ≤ i ≤ n) element of the permutation a as ai, the j-th (1 ≤ j ≤ n) element of the permutation b — as bj. The dis...
vfc_53489
{ "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": "4\n2 1 3 4\n3 4 2 1\n", "output": "2\n1\n0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2\n2 1\n", "output": "1\n0\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
244_D. Hydra
Solve the following coding problem using the programming language python: One day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph. A non-oriented graph is a hydra, if it has a structure, shown on the figure below. Namel...
vfc_53493
{ "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": "9 12 2 3\n1 2\n2 3\n1 3\n1 4\n2 5\n4 5\n4 6\n6 5\n6 7\n7 5\n8 7\n9 1\n", "output": "YES\n4 1\n5 6 \n2 3 9 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 10 3 3\n1 2\n2 3\n1 3\n1 4\n2 5...
code_contests
verifiable_code
26_B. Regular Bracket Sequence
Solve the following coding problem using the programming language python: A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))...
```python # Author : nitish420 -------------------------------------------------------------------- import os import sys from io import BytesIO, IOBase def main(): l=list(input()) # print(l) ans=0 stack=0 for item in l: if item=='(': stack+=1 else: if stack:...
vfc_53497
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "(()))(\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "((()())\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
292_D. Connected Components
Solve the following coding problem using the programming language python: We already know of the large corporation where Polycarpus works as a system administrator. The computer network there consists of n computers and m cables that connect some pairs of computers. In other words, the computer network can be represen...
vfc_53501
{ "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": "6 5\n1 2\n5 4\n2 3\n3 1\n3 6\n6\n1 3\n2 5\n1 5\n5 5\n2 4\n3 3\n", "output": "4\n5\n6\n3\n4\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 14\n7 1\n1 5\n6 4\n7 6\n2 4\n2 4\n7 2\n3 1\n...
code_contests
verifiable_code
363_D. Renting Bikes
Solve the following coding problem using the programming language python: A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them. The renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs pj rubles. In total...
```python def readn(): return map(int, input().split()) n,m,a=readn()#map(int,input().split()) b,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split())) r=min(n,m) mm=r l=0 while l<=r: mid=l+(r-l)//2 pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)]) if pri<=a: l=mid+1 ...
vfc_53513
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 10\n5 5\n7 6\n", "output": "2 3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
387_C. George and Number
Solve the following coding problem using the programming language python: George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b1, b2, ..., b|b| (record ...
```python s = input() r = len(s) c = 1 for i in range(len(s)-1, 0, -1): if s[i] != '0': if i > r-i: c += 1 r = i elif i == r-i: if s[:i] >= s[i:r]: c += 1 r = i else: break print(c) ```
vfc_53517
{ "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": "9555\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "19992000\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "10000...
code_contests
verifiable_code
408_A. Line to Cashier
Solve the following coding problem using the programming language python: Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products. There are n cashiers at the exit from the...
```python num_cashiers = int(input()) queue_sizes = list(map(lambda x: int(x) * 15, input().split())) items = [] for i in range(num_cashiers): items_list = sum(map(lambda x: int(x) * 5, input().split())) items.append(items_list) min_time = min(change + groceries for change, groceries in zip(queue_sizes, item...
vfc_53521
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n1\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 4 3 2\n100\n1 2 2 3\n1 9 1\n7 8\n", "output": "100\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
435_B. Pasha Maximizes
Solve the following coding problem using the programming language python: Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer. Help Pasha ...
```python a,k=input().split() l=list(a) k=int(k) n=len(l) for i in range(n): t=l[i] i1=0 for j in range(i+1,min(i+k+1,n)): if l[j]>t: t=l[j] i1=j while i1>i: k-=1 l[i1],l[i1-1]=l[i1-1],l[i1] i1-=1 print(''.join(l)) ```
vfc_53525
{ "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": "1990 1\n", "output": "9190\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9090000078001234 6\n", "output": "9907000008001234\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
457_D. Bingo!
Solve the following coding problem using the programming language python: The game of bingo is played on a 5 × 5 square grid filled with distinct numbers between 1 and 75. In this problem you will consider a generalized version played on an n × n grid with distinct numbers between 1 and m (m ≥ n2). A player begins b...
vfc_53529
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 1\n", "output": "2.500000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 59164 40872\n", "output": "3.141592653848\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
47_B. Coins
Solve the following coding problem using the programming language python: One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighe...
```python def R(): return map(int, input().split()) def I(): return int(input()) def S(): return str(input()) def L(): return list(R()) from collections import Counter import math import sys from itertools import permutations a=['A','B','C'] s=set() for _ in range(3): s.add(S()) l= list(permutations(a)) fo...
vfc_53533
{ "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": "A&gt;B\nC&lt;B\nA&gt;C\n", "output": "Impossible\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "A&lt;B\nB&gt;C\nC&gt;A\n", "output": "Impossible\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
504_B. Misha and Permutations Summation
Solve the following coding problem using the programming language python: Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation <image>, where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permut...
```python import sys class SegmTree(): def __init__(self, array=None): size = len(array) N = 1 while N < size: N <<= 1 self.N = N self.tree = [0] * (2*self.N) for i in range(size): self.tree[i+self.N] = array[i] self.build() def...
vfc_53537
{ "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": "2\n0 1\n0 1\n", "output": "0 1 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
553_C. Love Triangles
Solve the following coding problem using the programming language python: There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two char...
```python from sys import stdin, stdout import sys class Node(object): def __init__(self, label): self.label = label self.par = self self.rank = 0 class DisjointSet(object): def __init__(self, n): self.n = n self.nodes = [Node(i) for i in range(self.n)] def find(...
vfc_53545
{ "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": "4 4\n1 2 1\n2 3 1\n3 4 0\n4 1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 0\n", "output": " 4\n...
code_contests
verifiable_code
57_B. Martian Architecture
Solve the following coding problem using the programming language python: Chris the Rabbit found the traces of an ancient Martian civilization. The brave astronomer managed to see through a small telescope an architecture masterpiece — "A Road to the Sun". The building stands on cubical stones of the same size. The fo...
```python n, m, k = map(int, raw_input().split()) A = [] for i in xrange(m): a, b, c = map(int, raw_input().split()) A.append((a, -a + c, 1)) A.append((b + 1, a - c, -1)) A.sort() A.append((1000000000, 0, 0)) B = map(int, raw_input().split()) B.sort() add = cnt = 0 sum = j = 0 for n in B: while A[j][0] ...
vfc_53549
{ "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 2 1\n1 3 1\n1 3 1\n2\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 1\n1 3 1\n1 3 1\n3\n", "output": "6", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
601_A. The Two Routes
Solve the following coding problem using the programming language python: In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if t...
```python #created by Кама Пуля n,m=map(int,input().split()) L=[[] for i in range(n+1)] for i in range(m) : a,b=map(int,input().split()) L[a].append(b) L[b].append(a) if n not in L[1] : l=[1] D=[-1 for i in range(n+1)] D[1]=0 while len(l)>=1 : t=l[0] del(l[0]) for x i...
vfc_53553
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n1 3\n3 4\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n4 2\n3 5\n4 5\n5 1\n1 2\n", "output": "3", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
645_C. Enduring Exodus
Solve the following coding problem using the programming language python: In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. Th...
```python import sys input = sys.stdin.readline def judge(i, x): return acc[min(n, i+x+1)]-acc[max(0, i-x)]>=k+1 def binary_search(i): l, r = 0, n while l<=r: mid = (l+r)//2 if judge(i, mid): r = mid-1 else: l = mid+1 return l n, k = ...
vfc_53561
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n000\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n01010\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
672_A. Summer Camp
Solve the following coding problem using the programming language python: Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one li...
```python n = int(input()) cur = 0 s = '' for i in range(1, n + 1): s += str(i) if len(s) >= n: print(s[n - 1]) exit(0) ```
vfc_53565
{ "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": "11\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "942\n", ...
code_contests
verifiable_code
697_C. Lorenzo Von Matterhorn
Solve the following coding problem using the programming language python: Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. Y...
```python def main(): d = {} for _ in range(int(input())): c, *l = input().split() if c == "1": v, u, w = map(int, l) while u != v: if u < v: d[v] = d.get(v, 0) + w u, v = v // 2, u else: ...
vfc_53569
{ "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": "7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4\n", "output": "94\n0\n32\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2 1 343417335313797025\n", "output": "0\n", ...
code_contests
verifiable_code
718_A. Efim and Strange Grade
Solve the following coding problem using the programming language python: Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. E...
```python n, t = map(int, input().split()) tmp = input() s = [] for i in range(n): s.append(tmp[i]) ind = n perenos = 0 for i in range(n): if (s[i] == '.'): nach = i + 1 for i in range(nach, n): if (int(s[i]) > 4): ind = i break if (ind == n): print(*s, sep="") exit() while (...
vfc_53573
{ "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 2\n10.245\n", "output": "10.3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 100\n9.2\n", "output": "9.2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
73_A. The Elder Trolls IV: Oblivon
Solve the following coding problem using the programming language python: Vasya plays The Elder Trolls IV: Oblivon. Oh, those creators of computer games! What they do not come up with! Absolutely unique monsters have been added to the The Elder Trolls IV: Oblivon. One of these monsters is Unkillable Slug. Why it is "U...
```python I=lambda: map(int,input().split()) x,y,z,k=I() a1,a2,a3,q=0,0,0,0 while q<3: q=0 if a1+a2+a3==k: break if a1<x-1: a1+=1 if a1+a2+a3==k: break else: q+=1 if a2<y-1: a2+=1 if a1+a2+a3==k: break else: q+=1 if a3<z-1: a3+=1 ...
vfc_53577
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 2 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 2 3\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
762_E. Radio stations
Solve the following coding problem using the programming language python: In the lattice points of the coordinate line there are n radio stations, the i-th of which is described by three integers: * xi — the coordinate of the i-th station on the line, * ri — the broadcasting range of the i-th station, * fi — ...
vfc_53581
{ "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 3 2\n2 2 4\n3 2 1\n4 2 1\n5 3 3\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 3 10\n3 2 5\n4 10 8\n", "output": "1", "type": "stdin_stdout" }...
code_contests
verifiable_code
786_A. Berzerk
Solve the following coding problem using the programming language python: Rick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer. In this game there are n objects numbered from 1 to n arranged in...
```python f = lambda: list(map(int, input().split()))[1:] n = int(input()) s, p, q = [], [], [] for x in [0, 1]: r = f() s.append(r) t = [len(r)] * n t[0] = 0 p.append(t) q.append((x, 0)) while q: x, i = q.pop() y = 1 - x for d in s[y]: j = (i - d) % n if p[y][j] < 1:...
vfc_53585
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 3 2\n3 1 2 3\n", "output": "Lose Win Win Loop \nLoop Win Win Win \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n4 6 2 3 4\n2 3 6\n", "output": "Win Win Win Win Win Win Win ...
code_contests
verifiable_code
807_F. Perishable Roads
Solve the following coding problem using the programming language python: In the country of Never, there are n cities and a well-developed road system. There is exactly one bidirectional road between every pair of cities, thus, there are as many as <image> roads! No two roads intersect, and no road passes through inte...
vfc_53589
{ "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\n2 9 9 6 6\n7 1 9 10\n9 2 5\n4 10\n8\n", "output": "6\n5\n7\n5\n7\n11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2\n3\n", "output": "2\n2\n3\n", "type": "stdin_stdo...
code_contests
verifiable_code
832_A. Sasha and Sticks
Solve the following coding problem using the programming language python: It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with whom he shares a desk. The ...
```python n,k=map(int,input().split()) if (n//k)%2!=0: print('YES') else: print('NO') ```
vfc_53593
{ "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 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 4\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "871...
code_contests
verifiable_code
852_H. Bob and stages
Solve the following coding problem using the programming language python: The citizens of BubbleLand are celebrating their 10th anniversary so they decided to organize a big music festival. Bob got a task to invite N famous singers who would sing on the fest. He was too busy placing stages for their performances that ...
vfc_53597
{ "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 4\n0 0\n3 0\n2 1\n4 4\n1 5\n", "output": "10.00", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 6\n9556 2297\n910 7223\n1930 5926\n1509 995\n175 1098\n3538 3905\n4962 1751\n5430 6110\n5...
code_contests
verifiable_code
877_C. Slava and tanks
Solve the following coding problem using the programming language python: Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map. Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Sl...
```python n = int(input()) if n == 2: print(3) print(2, 1, 2) else: shoots = [i for i in range(2, n + 1, 2)] + [i for i in range(1, n + 1, 2)] + [i for i in range(2, n + 1, 2)] print(len(shoots)) print(" ".join(map(str, shoots))) ```
vfc_53601
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n", "output": "4\n2 1 3 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "3\n2 1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
900_D. Unusual Sequences
Solve the following coding problem using the programming language python: Count the number of distinct sequences a1, a2, ..., an (1 ≤ ai) consisting of positive integers such that gcd(a1, a2, ..., an) = x and <image>. As this number could be large, print the answer modulo 109 + 7. gcd here means the [greatest common ...
```python M=10**9+7 a,b=map(int,input().split()) if b%a:print(0) else: b//=a d=set() for i in range(1,int(pow(b,0.5)+1)): if b%i==0: d.add(i) d.add(b//i) d=sorted(list(d)) f=d[::] for i in range(len(f)): f[i]=pow(2,d[i]-1,M) for j in range(i): ...
vfc_53605
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 9\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
923_B. 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 n=int(input()) v=list(map(int,input().split())) t=list(map(int,input().split())) sumv=list() sumv.append(0) for i in range(n): sumv.append(sumv[i]+v[i]) sumt=list() sumt.append(0) for i in range(n): sumt.append(sumt[i]+t[i]) ans=[0]*(n) add=[0]*(n+1) for i in range(n): if(v[i]<=t[i]): an...
vfc_53609
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n30 25 20 15 10\n9 10 12 4 13\n", "output": "9 20 35 11 25 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n10 10 5\n5 7 2\n", "output": "5 12 4 ", "type": "stdin_stdout" ...
code_contests
verifiable_code
950_D. A Leapfrog in the Array
Solve the following coding problem using the programming language python: Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he h...
```python from collections import defaultdict, deque, Counter from sys import stdin, stdout from heapq import heappush, heappop import math import io import os import math import bisect input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline # python3 15.py<in>op\ n, m = map(int, input().split()) for i in range(...
vfc_53613
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n2\n3\n4\n", "output": "3\n2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 4\n10\n5\n4\n8\n", "output": "13\n3\n8\n9\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
978_G. Petya's Exams
Solve the following coding problem using the programming language python: Petya studies at university. The current academic year finishes with n special days. Petya needs to pass m exams in those special days. The special days in this problem are numbered from 1 to n. There are three values about each exam: * s_i ...
```python n, m = map(int, input().split()) x = [] ans = [0] * n for i in range(m): s, d, c = map(int, input().split()) x.append([d - 1, s - 1, c, i + 1]) ans[d - 1] = m + 1 x.sort() for d, s, c, i in x: cnt = 0 while cnt < c: if s == d: print(-1) exit() if ans...
vfc_53617
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 3 1\n1 2 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 3\n4 7 2\n1 10 3\n8 9 1\n", "output": "2 2 2 1 1 0 4 3 4 4\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
999_A. Mishka and Contest
Solve the following coding problem using the programming language python: Mishka started participating in a programming contest. There are n problems in the contest. Mishka's problem-solving skill is equal to k. Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only so...
```python n, k =map(int, input().split()) a=list(map(int, input().split())) i=s=0 while i<n: if a[i]<=k: s+=1 i+=1 else: if a[n-1]<=k: s+=1 n-=1 else: break print(s) ```
vfc_53621
{ "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 2\n3 1 2 1 3\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 4\n4 2 3 1 5 1 6 4\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
beginners-task-4
Solve the following coding problem using the programming language python: Naruto is a fan of numbers, he likes to play with them. This time he decided to multiply numbers and produce output. After every k elements he decides to find x^m, where x is the multiplication till k elements and m is a random number that narut...
```python def power1(x,n,MOD): if(n==0): return 1 ret=1 while(n): if(n&1): ret*=x ret%=MOD x*=x x%=MOD n>>=1 return ret T=input() while(T): T-=1 N,K,M,W=map(int,raw_input().split()) L=map(int,raw_input().split()) prod=1 for x in xrange(N): prod=prod*L[x]%W if((x+1)%K==0): prod=p...
vfc_53625
{ "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 2 2 5\n1 2 3 4 5\n5 2 2 5\n1 2 3 4 6\n\nSAMPLE", "output": "0\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 2 2 5\n1 2 3 4 9\n5 2 2 5\n1 2 3 4 6\n\nSAMPLE", "output": "1...
code_contests
verifiable_code
color-code
Solve the following coding problem using the programming language python: Our Earth is so beautiful due to the various amazing colours it contains. Now on Earth day we invited Species from Mars (called Martian) Planet to celebrate it with us and to let them know our Earth. Martians got so much attracted with the beau...
```python for t in range(input()): colors=map(int,raw_input().split()) martian=[] for color in colors: martian.append(hex(color)[2:].upper()) result=[] for mc in martian: current_clr="" if len(mc)<2: current_clr+='0' for letter in mc: if ord(letter)>=ord('A'): current_clr+=chr(ord(letter)+20) ...
vfc_53629
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n15 9 120\n255 98 174\n\nSAMPLE", "output": "Case 1: 0Z 09 78 \nCase 2: ZZ 62 UY \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n15 9 120\n255 98 110\n\nSAMPLE", "output": "Cas...
code_contests
verifiable_code
feasible-relations
Solve the following coding problem using the programming language python: As a programmer, you sometimes have to deal with some math and this is the time to do it. You are given a list of binary relations, equalities and inequalities, like a = b, a != d, b = c etc. Your task is to output YES if you can assign integers...
```python from sys import setrecursionlimit from collections import defaultdict, deque def dfs(elem, visited, Graph): cola = deque(Graph[elem]) while cola: elem = cola.pop() if visited[elem - 1]: continue visited[elem - 1] = True cola += Graph[elem] def solve(): unequal = [] positions = {} Graph = de...
vfc_53633
{ "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 2\n1 = 2\n1 != 2\n3 2\n1 = 2\n2 != 3\n\nSAMPLE", "output": "NO\nYES", "type": "stdin_stdout" } ] }