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
1132_A. Regular Bracket Sequence
Solve the following coding problem using the programming language python: A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this seq...
```python a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a == d: if a > 0 or c == 0: print(1) else: print(0) else: print(0) ```
vfc_52569
{ "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\n2\n3\n4\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1\n4\n3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
1152_D. Neko and Aki's Prank
Solve the following coding problem using the programming language python: Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys... It took Neko an ent...
```python l=[1, 2, 6, 18, 57, 186, 622, 2120, 7338, 25724, 91144, 325878, 1174281, 4260282, 15548694, 57048048, 210295326, 778483932, 892818230, 786724318, 347919346, 355845955, 274146173, 336110626, 508416482, 521006399, 214448866, 997593411, 238896999, 849258736, 819525514, 53182350, 202970081, 945166442, 598349475, ...
vfc_52573
{ "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\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1192_A. Building Skyscrapers
Solve the following coding problem using the programming language python: We are going to build a new city: the Metropolis. The city is going to be built on an infinite square grid. The finished city will consist of n skyscrapers, each occupying a different cell of the grid. At any moment during the construction, the ...
vfc_52581
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n0 0\n1 1\n2 2\n", "output": "YES\n1\n2\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
120_J. Minimum Sum
Solve the following coding problem using the programming language python: You are given a set of n vectors on a plane. For each vector you are allowed to multiply any of its coordinates by -1. Thus, each vector vi = (xi, yi) can be transformed into one of the following four vectors: * vi1 = (xi, yi), * vi2 = ( -...
vfc_52585
{ "difficulty": "16", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 2\n-4 7\n-6 0\n-8 4\n5 1\n", "output": "3 4 5 4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1230_D. Marcin and Training Camp
Solve the following coding problem using the programming language python: Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other. Let's focus on the students. They are indexed wit...
```python n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) v = [] for i in range(n): v.append([a[i],b[i]]) v.sort() prev = -1 big = [] flag = True for i in v: if prev == i[0] and (flag or big[-1]!=i[0]): big.append(i[0]) flag = False prev = i[0] answer = 0 counter = 0 big.so...
vfc_52589
{ "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": "3\n1 2 3\n1 2 3\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0\n1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
1252_A. Copying Homework
Solve the following coding problem using the programming language python: Danang and Darto are classmates. They are given homework to create a permutation of N integers from 1 to N. Danang has completed the homework and created a permutation A of N integers. Darto wants to copy Danang's homework, but Danang asks Darto...
vfc_52593
{ "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\n1 3 2 4\n", "output": "\n4 2 3 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 1\n", "output": "\n1 2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1271_F. Divide The Students
Solve the following coding problem using the programming language python: Recently a lot of students were enrolled in Berland State University. All students were divided into groups according to their education program. Some groups turned out to be too large to attend lessons in the same auditorium, so these groups sh...
vfc_52597
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n9 4 13\n1 10 3\n1 2 3 4 5 6 7\n9 4 13\n1 10 3\n2 1 3 4 5 6 7\n1 2 3\n4 5 6\n0 0 0 0 0 0 0\n", "output": "1 1 3 4 2 0 7 \n-1\n0 0 0 0 0 0 0 \n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
1316_A. Grade Allocation
Solve the following coding problem using the programming language python: n students are taking an exam. The highest possible score at this exam is m. Let a_{i} be the score of the i-th student. You have access to the school database which stores the results of all students. You can change each student's score as lon...
```python for i in range(int(input())): print(min(list(map(int, input().split()))[1], sum(list(map(int, input().split()))))) ```
vfc_52605
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 10\n1 2 3 4\n4 5\n1 2 3 4\n", "output": "10\n5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "27\n1 1\n0\n1 2\n0\n1 5\n0\n1 10\n0\n1 50\n0\n1 100\n0\n1 500\n0\n1 1000\n0\n1 5000\n0\n...
code_contests
verifiable_code
1337_C. Linova and Kingdom
Solve the following coding problem using the programming language python: Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it. <image> Th...
```python from sys import * input = stdin.readline n,k = map(int,input().split()) graph = [set([]) for _ in range(n+1)] for _ in range(n-1): x,y = map(int,input().split()) graph[x].add(y) graph[y].add(x) dep,par,cn = [0]*(n+1),[0]*(n+1),0 q,p = [1],[] vis = [0]*(n+1) vis[1] = 1 while(q): x = q.pop()...
vfc_52609
{ "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": "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7\n", "output": "7\n", "type": "stdin_st...
code_contests
verifiable_code
135_A. Replacement
Solve the following coding problem using the programming language python: Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exac...
```python n = int(input()) a = sorted(map(int, input().split())) ans = [0]*n ans[0] = 1 f = ans[0] != a[0] for i in range(1, n): ans[i] = a[i-1] if ans[i] != a[i]: f = True m = 10**9 if not f: for i in range(n-1, -1, -1): if ans[i] < m: ans[i] += 1 break print(' '....
vfc_52613
{ "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 1 2 3 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 3 4 5 6\n", "output": "1 2 3 4 5\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
137_B. Permutation
Solve the following coding problem using the programming language python: "Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerabl...
```python n = int(input()) l = list(map(int,input().split())) cnt=0 for i in range(1,n+1): if i not in l: cnt+=1 print(cnt) ```
vfc_52617
{ "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\n2 2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 1 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
13_B. Letter A
Solve the following coding problem using the programming language python: Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A. You are given three segments on the plane. They form the lett...
```python __author__ = 'Darren' def solve(): t = int(input()) while t: run() t -= 1 def run(): def check_condition_1(): record = {} common, first, second = None, -1, -1 found = False for i in range(3): for j in range(2): if segm...
vfc_52621
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 4 6 0\n4 1 5 2\n4 0 4 4\n0 0 0 6\n0 6 2 -4\n1 1 0 1\n0 0 0 5\n0 5 2 -1\n1 2 0 1\n", "output": "YES\nNO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 4 6 0\n4 1 5 2\n4 0 4 ...
code_contests
verifiable_code
1423_K. Lonely Numbers
Solve the following coding problem using the programming language python: In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks. More precisely, two different numbers a and b are friends if gcd(a,b), (a)/(gcd(a,b)), (b)/(gcd(a,b)) can form sides of a trian...
```python # This code is contributed by Siddharth import os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline # setrecursionlimit(10**6) # from sys import * import random from bisect import * import math from collections import * import operator from heapq import * from itertools import * inf=10**18 m...
vfc_52625
{ "difficulty": "17", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 5 10\n", "output": "1\n3\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n791 303 765 671 210 999 106 489 243 635 807 104 558 628 545 926 35 3 75 196 35 460 523 621 748 45 501 ...
code_contests
verifiable_code
1468_M. Similar Sets
Solve the following coding problem using the programming language python: You are given n sets of integers. The i-th set contains k_i integers. Two sets are called similar if they share at least two common elements, i. e. there exist two integers x and y such that x ≠ y, and they both belong to each of the two sets. ...
```python def solve(n, debug=False): global curr; global seen; global last; big = []; small = [] for i in range(1,1+n): l = list(map(int, input().split())) if l[0] > 600: big.append((i,l[1:])) else: small.append((i,l[1:])) s1 = len(big); s2 = len(...
vfc_52633
{ "difficulty": "20", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n2 1 10\n3 1 3 5\n5 5 4 3 2 1\n3 10 20 30\n3\n4 1 2 3 4\n4 2 3 4 5\n4 3 4 5 6\n2\n3 1 3 5\n3 4 3 2\n", "output": "\n2 3 \n1 2 \n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n2...
code_contests
verifiable_code
1494_A. ABC String
Solve the following coding problem using the programming language python: You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'. A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that ...
```python from typing import Callable, Iterator, TypeVar, cast _F = TypeVar("_F", bound=Callable[[], None]) def repeater(func: _F) -> _F: def wrapper(): for _ in range(int(input())): func() return cast(_F, wrapper) def get_num_input() -> Iterator[int]: return map(int, input().split...
vfc_52637
{ "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\nAABBAC\nCACA\nBBBBAC\nABCA\n", "output": "\nYES\nYES\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\nCA\nBA\nCC\nAC\nCA\nCB\nAC\nBB\nAB\nCB\nBA\nCA\n", "output": "YES\...
code_contests
verifiable_code
1516_D. Cut
Solve the following coding problem using the programming language python: This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following: * he picks a range (l, r) and cuts the subsegment a_l, a_{l + 1}, …, a_r out, removing...
```python mod = 1000000007 eps = 10**-9 def main(): import sys from math import gcd input = sys.stdin.buffer.readline V = 10**5 minfactor = list(range(V+1)) for d in range(2, V+1): for x in range(2, V+1): if d*x > V: break if minfactor[d*x] == d...
vfc_52641
{ "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": "6 3\n2 3 10 7 5 14\n1 6\n2 4\n3 5\n", "output": "\n3\n1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n100000\n1 1\n", "output": "1\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
171_F. ucyhf
Solve the following coding problem using the programming language python: qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf. Input jxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1 ≤ d ≤ 11184) — jxu edu-rqiut ydtun ev jxu ucyhf je vydt. Output ekjfkj q iydwbu dkcru...
```python #!/usr/bin/env python from __future__ import division, print_function import math import os import sys from fractions import * from sys import * from io import BytesIO, IOBase from itertools import * from collections import * # sys.setrecursionlimit(10**5) if sys.version_info[0] < 3: from __builtin__ i...
vfc_52649
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5273\n", "output": "340573\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "22...
code_contests
verifiable_code
215_D. Hot Days
Solve the following coding problem using the programming language python: The official capital and the cultural capital of Berland are connected by a single road running through n regions. Each region has a unique climate, so the i-th (1 ≤ i ≤ n) region has a stable temperature of ti degrees in summer. This summer a ...
```python import sys n, m = map(int, sys.stdin.readline().split()) ans = 0 for _ in range(n): ti, Ti, xi, ci = map(int, sys.stdin.readline().split()) cost = xi * m * (ti + m > Ti) + ci if ti < Ti: cost2 = ci * ((m - 1) // (Ti - ti) + 1) cost = min(cost, cost2) ans += cost print...
vfc_52657
{ "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 100\n10 30 1000 1\n5 10 1000 3\n10 40 1000 100000\n", "output": "200065\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
239_D. Boring Partition
Solve the following coding problem using the programming language python: This problem is the most boring one you've ever seen. Given a sequence of integers a1, a2, ..., an and a non-negative integer h, our goal is to partition the sequence into two subsequences (not necessarily consist of continuous elements). Each...
```python from sys import stdin rints = lambda: [int(x) for x in stdin.readline().split()] n, m = rints() a = rints() mi = a.index(min(a)) if n == 2: print('%d\n%s' % (0, '1 1')) else: a.sort() ans = ['1'] * n diff1 = (a[-1] + a[-2]) - (a[0] + a[1]) diff2 = max(a[-1] + a[-2], a[-1] + a[0] + m) - m...
vfc_52661
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 10\n0 1 0 2 1\n", "output": "3\n1 1 1 1 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 2 3\n", "output": "1\n1 2 2\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
264_B. Good Sequences
Solve the following coding problem using the programming language python: Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a1, a2, ..., an are good. Now she is interested in good sequences. A sequence x1, x2, ..., xk is called good if it satisfies the following thr...
```python ###### ### ####### ####### ## # ##### ### ##### # # # # # # # # # # # # # ### # # # # # # # # # # # # # ### ###### ######### # # # # ...
vfc_52665
{ "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\n2 3 4 6 9\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n1 2 3 5 6 7 8 9 10\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
288_B. Polo the Penguin and Houses
Solve the following coding problem using the programming language python: Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n). Little penguin Polo loves walk...
```python import sys,math,heapq,copy from collections import defaultdict,deque from bisect import bisect_left,bisect_right from functools import cmp_to_key from itertools import permutations,combinations,combinations_with_replacement # sys.setrecursionlimit(10**6) # sys.stdin=open('Input.txt','r') # sys.stdout=open('Ou...
vfc_52669
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 4\n", "output": "1728\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n", "output": "54\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 5...
code_contests
verifiable_code
313_B. Ilya and Queries
Solve the following coding problem using the programming language python: Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam. You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m quer...
```python s=input() n=len(s) m=int(input()) a=[0]*(n+1) for i in range(n-1): a[i+1]=a[i]+(s[i]==s[i+1]) ans="" for i in range(m): l,r=map(int,input().split()) ans+=str(a[r-1]-a[l-1])+" " print(*ans.split(),sep="\n") ```
vfc_52673
{ "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": "......\n4\n3 4\n2 3\n1 6\n2 6\n", "output": "1\n1\n5\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4\n", "output": "1\n1\n2\n2\n0\n", "typ...
code_contests
verifiable_code
381_D. Sereja and Tree
Solve the following coding problem using the programming language python: Sereja adores trees. Today he came up with a revolutionary new type of binary root trees. His new tree consists of n levels, each vertex is indexed by two integers: the number of the level and the number of the vertex on the current level. The ...
vfc_52685
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5\n1 4 4 7 1\n1 3 1 2 2\n2 1 1\n2 4 1\n2 3 3\n", "output": "2\n0\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
42_D. Strange town
Solve the following coding problem using the programming language python: Volodya has recently visited a very odd town. There are N tourist attractions in the town and every two of them are connected by a bidirectional road. Each road has some travel price (natural number) assigned to it and all prices are distinct. B...
```python #codeforces 42d: strange town: math, constructive algorithm def readGen(trans): while 1: for x in input().split(): yield(trans(x)) readint=readGen(int) n=next(readint) def constructRow(n): can=[1 for i in range(1001)] b=[0 for i in range(n+1)] b[2]=1 b[3]=2 can[1]=0 can[2]=0 for k in range(4,n...
vfc_52693
{ "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\n", "output": "0 3 4\n3 0 5\n4 5 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "17\n", "output": "0 3 4 6 9 14 22 31 40 54 75 96 129 153 183 213 259\n3 0 5 7 10 15 23 32 41 55 7...
code_contests
verifiable_code
452_B. 4-point polyline
Solve the following coding problem using the programming language python: You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as possible...
```python n, m = map(int, input().split()) a = ([[0, 1], [0, m], [0, 0], [0, m - 1]], [[1, 0], [n, 0], [0, 0], [n - 1, 0]], \ [[0, 1], [n, m], [0, 0], [n, m - 1]], [[1, 0], [n, m], [0, 0], [n - 1, m]], \ [[0, 0], [n, m], [0, m], [n, 0]], [[0, 0], [n, m], [n, 0], [0, m]]) for x in max(a, key = lambda a: (len(s...
vfc_52697
{ "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": "0 10\n", "output": "0 1\n0 10\n0 0\n0 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n", "output": "0 0\n1 1\n0 1\n1 0\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
474_F. Ant colony
Solve the following coding problem using the programming language python: Mole is hungry again. He found one ant colony, consisting of n ants, ordered in a row. Each ant i (1 ≤ i ≤ n) has a strength si. In order to make his dinner more interesting, Mole organizes a version of «Hunger Games» for the ants. He chooses t...
```python from math import gcd class SegTree: def __init__(self, arr = None, length = None): """ Creates a segment tree. If arr (a list) is given, length is ignored, and we build a segment tree with underlying array arr. If no list is given, length (an int) must be given, and we bui...
vfc_52701
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 2 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "output": "4\n4\n1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 5 2 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "output": "4\n4\n1\n1\n", ...
code_contests
verifiable_code
498_E. Stairs and Lines
Solve the following coding problem using the programming language python: You are given a figure on a grid representing stairs consisting of 7 steps. The width of the stair on height i is wi squares. Formally, the figure is created by consecutively joining rectangles of size wi × i so that the wi sides lie on one stra...
vfc_52705
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1 0 0 0 0\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 0 3 0 0 1\n", "output": "411199181\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
522_A. Reposts
Solve the following coding problem using the programming language python: One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on. These events are ...
```python leng = int(input()) names = ["POLYCARP", 1] others = [] max = 1 for i in range(leng): x, y= map(str, input().split(' reposted ')) others.append(x.upper()) others.append(y.upper()) for i in range(0, leng*2, 2): if others[i+1] in names: num = names[names.index(others[i+1]) + 1] + 1 names.append(others[...
vfc_52709
{ "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\nMike reposted Polycarp\nMax reposted Polycarp\nEveryOne reposted Polycarp\n111 reposted Polycarp\nVkCup reposted Polycarp\nCodeforces reposted Polycarp\n", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
549_C. The Game Of Parity
Solve the following coding problem using the programming language python: There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis st...
```python n,k=[int(i) for i in input().split()] l=[int(i) for i in input().split()] no=0 for i in l: no+=i%2 ne=n-no if n==k: if no%2: print("Stannis") else: print("Daenerys") else: if no<=(n-k)//2: print("Daenerys") else: if no%2: if (n-k)%2 and ne<=(n-k)//...
vfc_52713
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n1 2 1\n", "output": "Stannis\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n5 20 12 7 14 101\n", "output": "Stannis\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
575_E. Spectator Riots
Solve the following coding problem using the programming language python: It’s riot time on football stadium Ramacana! Raging fans have entered the field and the police find themselves in a difficult situation. The field can be represented as a square in the coordinate system defined by two diagonal vertices in (0,0) ...
vfc_52717
{ "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 1 1\n1 1 1\n1 2 1\n", "output": "1 0\n2 1\n2 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 3 3\n55 65 1\n100 0 0\n", "output": "55 66\n54 65\n0 4\n", "type": "std...
code_contests
verifiable_code
597_C. Subsequences
Solve the following coding problem using the programming language python: For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018. Input First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤...
```python # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase def update(tree,pos,diff,si): pos += si-1 while pos: tree[pos] += diff pos >>= 1 def query(tree,l,r,si): ans,l,r = 0,l+si-1,r+si-1 while l < r: if l&1: ...
vfc_52721
{ "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 2\n1\n2\n3\n5\n4\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 2\n6\n10\n9\n7\n1\n2\n8\n5\n4\n3\n", "output": "5\n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
639_C. Bear and Polynomials
Solve the following coding problem using the programming language python: Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials. He considers a polynomial valid if its degree is n and its coefficients are integers not exceeding k by the absolute value. More formally: Let a0...
vfc_52729
{ "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 12\n10 -9 -3 5\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1000000000\n10 -9 -3 5\n", "output": "3", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
666_E. Forensic Examination
Solve the following coding problem using the programming language python: The country of Reberland is the archenemy of Berland. Recently the authorities of Berland arrested a Reberlandian spy who tried to bring the leaflets intended for agitational propaganda to Berland illegally . The most leaflets contain substrings...
vfc_52733
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 768000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "suffixtree\n3\nsuffixtreesareawesome\ncartesiantreeisworsethansegmenttree\nnyeeheeheee\n2\n1 2 1 10\n1 3 9 10\n", "output": "1 1\n3 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "cxunrv...
code_contests
verifiable_code
690_B1. Recover Polygon (easy)
Solve the following coding problem using the programming language python: The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good. Heidi ...
```python n = int(input()) aux = [] grid = [] flag = True ans = -1 um = 0 dois = 0 quatro = 0 while(n): n-=1 x = str(int(input())) if(x!='0'): aux.append(x) for i in aux: txt = '' for j in i: if(j!='0'): txt+=j grid....
vfc_52737
{ "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": "6\n000000\n000000\n012100\n024200\n012100\n000000\n", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n00000000\n00001210\n00002420\n00002020\n00001210\n00000000\n00000000\n...
code_contests
verifiable_code
713_B. Searching Rectangles
Solve the following coding problem using the programming language python: Filya just learned new geometry object — rectangle. He is given a field consisting of n × n unit cells. Rows are numbered from bottom to top with integer from 1 to n. Columns are numbered from left to right with integers from 1 to n. Cell, locat...
vfc_52741
{ "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\n2\n1\n0\n1\n1\n1\n0\n1\n", "output": "? 1 1 3 5\n? 4 1 5 5\n? 1 1 1 5\n? 2 1 5 5\n? 1 1 2 5\n? 3 1 5 5\n? 1 1 2 3\n? 1 1 2 5\n? 1 1 2 4\n? 1 4 2 5\n? 1 5 2 5\n? 2 1 2 5\n? 1 1 1 5\n? 3 1 5 3\n? 3 1 5 1\n? 3 4 5 5\n? 3 5 5 ...
code_contests
verifiable_code
757_G. Can Bash Save the Day?
Solve the following coding problem using the programming language python: Whoa! You did a great job helping Team Rocket who managed to capture all the Pokemons sent by Bash. Meowth, part of Team Rocket, having already mastered the human language, now wants to become a master in programming as well. He agrees to free t...
vfc_52749
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 768000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n4 5 1 3 2\n4 2 4\n1 3 9\n4 1 4\n4 5 2\n1\n1 5 4\n1\n22 20 20\n2\n38\n2\n39\n1\n36 38 38\n", "output": " 23\n ...
code_contests
verifiable_code
779_D. String Game
Solve the following coding problem using the programming language python: Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t ...
```python s = input() t = input() a = list(map(int, input().split())) def ok(n): bad = set() for i in range(n): bad.add(a[i] - 1) pt = 0 ps = 0 while pt < len(t) and ps < len(s): if ps in bad: ps += 1 else: if t[pt] == s[ps]: ps += 1 ...
vfc_52753
{ "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": "bbbabb\nbb\n1 6 3 4 2 5\n", "output": "4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
802_L. Send the Fool Further! (hard)
Solve the following coding problem using the programming language python: Heidi is terrified by your estimate and she found it unrealistic that her friends would collaborate to drive her into debt. She expects that, actually, each person will just pick a random friend to send Heidi to. (This randomness assumption impl...
vfc_52757
{ "difficulty": "19", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11\n1 0 6646\n2 0 8816\n3 2 9375\n4 2 5950\n5 1 8702\n6 2 2657\n7 2 885\n8 7 2660\n9 2 5369\n10 6 3798\n", "output": "153869806\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 1 3\n0 ...
code_contests
verifiable_code
827_A. String Reconstruction
Solve the following coding problem using the programming language python: Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the string s. Namely...
```python from sys import stdin, stdout sze = 10 ** 6 + 1 n = int(stdin.readline()) challengers = [] strings = [] sze = 10 ** 6 + 1 cnt = [[] for i in range(sze)] for i in range(n): s = stdin.readline().strip().split() num = int(s[1]) values = list(map(int, s[2:])) strings.append(s[0]) ...
vfc_52761
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\na 4 1 3 5 7\nab 2 1 5\nca 1 4\n", "output": "abacaba\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nab 1 1\naba 1 3\nab 2 3 5\n", "output": "ababab\n", "type": "stdin_st...
code_contests
verifiable_code
849_A. Odds and Ends
Solve the following coding problem using the programming language python: Where do odds begin, and where do they end? Where does hope emerge, and will they ever break? Given an integer sequence a1, a2, ..., an of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the eac...
```python n = int(input()) a = list(map(int,input().split())) if n % 2 == 0 or a[0] % 2 == 0 or a[-1] % 2 == 0: print("NO") else: print("YES") ```
vfc_52765
{ "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\n3 9 9 3\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 3 1\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
897_C. Nephren gives a riddle
Solve the following coding problem using the programming language python: What are you doing at the end of the world? Are you busy? Will you save us? <image> Nephren is playing a game with little leprechauns. She gives them an infinite array of strings, f0... ∞. f0 is "What are you doing at the end of the world? A...
```python import sys sys.setrecursionlimit(1500) s1 = "What are you doing at the end of the world? Are you busy? Will you save us?" a = "What are you doing while sending \"" b = "\"? Are you busy? Will you send \"" c = "\"?" ans = "" def solve(n, k): if n == 0: if k >= len(s1): return "." ...
vfc_52773
{ "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": "10\n4 1825\n3 75\n3 530\n4 1829\n4 1651\n3 187\n4 584\n4 255\n4 774\n2 474\n", "output": "Areyoubusy", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1\n1 2\n1 111111111111\n", "ou...
code_contests
verifiable_code
918_D. MADMAX
Solve the following coding problem using the programming language python: As we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed acyclic graph (a DAG) wit...
```python # int(input()) # [int(i) for i in input().split()] import sys sys.setrecursionlimit(20000) def go(v,w,last): if game[v][w][last] >= 0: return(game[v][w][last]) flag = 0 move = 0 for p in edges_out[v]: if p[1] >= last: move = 1 if not go(w,p[0],p[1]): ...
vfc_52777
{ "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": "5 8\n5 3 h\n1 2 c\n3 1 c\n3 2 r\n5 1 r\n4 3 z\n5 4 r\n5 2 h\n", "output": "BABBB\nBBBBB\nAABBB\nAAABA\nAAAAB\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 2 b\n1 3 a\n2 4 c\n3 4 b...
code_contests
verifiable_code
940_D. Alena And The Heater
Solve the following coding problem using the programming language python: "We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme." "Little Alena got an array as a birthday present..." The array b of length n is obtained from the array a of length n an...
```python import sys n = int(input()) A = input().split() A = [int(i) for i in A] S = input() L = -1000000000 R = 1000000000 for i in range(4, n): if S[i - 1] == S[i - 2] == S[i - 3] == S[i - 4] == '0' and S[i] == '1': L = max(max(A[i], A[i - 1], A[i - 2], A[i - 3], A[i - 4]) + 1, L) elif S[i - 1] ==...
vfc_52781
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n00001\n", "output": "6 1000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n-10 -9 -8 -7 -6 6 7 8 9 10\n0000111110\n", "output": "-5 5\n", "type": "stdi...
code_contests
verifiable_code
96_A. Football
Solve the following coding problem using the programming language python: Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero correspon...
```python entrada = input() vez = -1 total = 0 perigo = False for i in range(len(entrada)): aux = int(entrada[i]) if(vez == aux): total += 1 if(total == 7): perigo = True else: total = 1 vez = aux if(perigo): print("YES") else: print("NO") ```
vfc_52785
{ "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": "1000000001\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "001001\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
994_A. Fingerprints
Solve the following coding problem using the programming language python: You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits. Some keys on the keypad have fingerprints. Y...
```python n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = '' for i in a: if i in b: ans = ans + str(i) + ' ' print(ans) ```
vfc_52789
{ "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 4\n3 4 1 0\n0 1 7 9\n", "output": "1 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 3\n3 5 7 1 6 2 8\n1 2 7\n", "output": "7 1 2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
average-sequence-4
Solve the following coding problem using the programming language python: Today Oz is playing with two lists A and B. List A contains N elements. List B is formed by replacing every element of List A by average value of all elements before current element including current one. For example : If list A is like : a, b, ...
```python z = input() li = list(map(int,raw_input().split())) y=[] s=0 y.append(li[0]) print li[0], for i in range(1,z): num = li[i]*(i+1)-sum(y) y.append(num) print y[i], ```
vfc_52793
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 2 3 5\n\nSAMPLE", "output": "3 1 5 11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n339546 373623 375182 495006 517640 468617 457351 516663 562646 583308", "output": "3395...
code_contests
verifiable_code
chocolates-boxes-1
Solve the following coding problem using the programming language python: Alice has N boxes, and each box has certain non zero number of chocolates. These boxes are numbered from 1 to N. Alice is planning to go to wonderland. She wants to carry exactly K number of chocolates and she can carry only 2 boxes. So she w...
```python for t in range(int(raw_input())): n = int(raw_input()) xs = [int(i) for i in raw_input().split()] k = int(raw_input()) counts = [0] * 101 for x in xs: counts[x] += 1 total = 0 for i in range(1, k): if k-i < 0 or i > 100 or k-i > 100: continue tot...
vfc_52797
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n1 2 3 4 3\n6\n5\n1 1 1 1 1\n2\n5\n1 5 3 3 3\n6\n\nSAMPLE", "output": "2\n10\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5\n1 2 3 4 3\n6\n5\n1 1 2 1 1\n2\n5\n1 5 3 3 3\n6\n\...
code_contests
verifiable_code
dummy2
Solve the following coding problem using the programming language python: After getting their Registration IDs, now the students were curious to know the names of the various events. So, this time, the volunteers told the participants that they would be given a Special Compressed String which they are supposed to Deco...
```python for t in range(input()): s=raw_input() ch="" l=len(s) for i in range(0,l,1): if (s[i]>='a' and s[i]<='z') or (s[i]>='A' and s[i]<='Z'): ch=ch+s[i] else: x=ch limit=int(s[i])-1 for j in range(0,limit,1): ch=ch+x print ch ```
vfc_52801
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\na3\na2b3\n\nSAMPLE", "output": "aaa\naabaabaab\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
haaaave-you-met-ted
Solve the following coding problem using the programming language python: The Wingman gains the attention of a prospective partner for their friend, by tapping them on the shoulder, and then stating only the line "Haaaaave you met Ted?" (substituting the name of "Ted", the main protagonist of the show, with the name o...
```python for i in range(int(raw_input())): n = int(raw_input()) lis = [int(i) for i in raw_input().split()] ans = 10**10 for li in lis: x=bin(li).count('1') ans=min(ans,x) print ans ```
vfc_52805
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 2 3\n7\n1 2 3 4 5 6 7 \n\n\nSAMPLE", "output": "1\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
logically-correct
Solve the following coding problem using the programming language python: Tired of playing Counter strike at every fest, well we can't do anything about it but we can sure give you a new game to play regardless of the fact that it ain't anything like GTA V or Mad Max but it sure can get you one step closer to glory yo...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' a,b,c=map(int,raw_input().split()) for i in range(2,c): d=pow(b,2)+a a=b b=d print d ```
vfc_52809
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 1 5\n\nSAMPLE", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
mystery-2
Solve the following coding problem using the programming language python: We have an unsolved mystery this time too! Input: First line of input contains T – the number of test cases. Each of the next T lines contain two integers a and b separated by a space. Output: Output T lines, each containing a single intege...
```python T = input() for t in xrange(T): a,b = map(int,raw_input().split()) if a < b: print a #break else: V = [] #C = a while a >= b: V.append(a%b) a = a/b V.append(a) V.reverse() S = map(str,V) print "".join(S) ```
vfc_52813
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n5 5\n10 6\n2 7\n90 6\n5 6\n2 8\n\nSAMPLE", "output": "10\n14\n2\n230\n5\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
problem-1-39
Solve the following coding problem using the programming language python: One day Patrik met a magician.He asked magician for his magic pencil.So magician decided to give him magic pencil only if he correctely answers to his question. Magician gave him 3 numbers a, b and c and asked him to find the multiple of c whi...
```python n=int(raw_input()) for i in range(1,n+1): lt=map(int,raw_input().split()) d=int(pow(lt[0],lt[1])) e=int((d/lt[2])*lt[2]) f=int((d/lt[2]+1)*lt[2]) g=int(d-e) h=int(f-d) if g<h: print e else: print f ```
vfc_52817
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5000\n825441599 1 632760006\n231 -1 978701520\n183 3 555414050\n95 -4 430024021\n515 -2 428491756\n462 0 696109446\n889 -3 167435393\n238 1 823399163\n577346704 0 623872735\n234 -0 927925538\n51373708 0 361761674\n866 2 574719260\n...
code_contests
verifiable_code
scoring-in-exam-1
Solve the following coding problem using the programming language python: Milly is at the examination hall where she is reading a question paper. She checked the question paper and discovered that there are N questions in that paper. Each question has some score value. Ideally it's like questions requiring more time h...
```python N, Q = map(int, raw_input().split(" ")) l1 = map(int, raw_input().split(" ")) #time l2 = map(int, raw_input().split(" ")) #scores srt = zip(*sorted(zip(l2, l1), reverse=True))[1] reuse = {0 : 0} #reuse already calculated #ntime for i in range(0, N): if i==0: reuse[0] = srt[0]; else: reuse[i] = reuse[i-1...
vfc_52821
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n2 3 9 4 5\n3 5 11 6 7\n5\n3\n\nSAMPLE", "output": "23\n18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000 1000\n3181 31998 4632 1363 7992 5436 19660 27448 19149 7410 12169 2465 3...
code_contests
verifiable_code
technicalities
Solve the following coding problem using the programming language python: Bimal decided to join a non Hill'ffair club because he is not interested in cultural activities at all. He thought that joining a technical club would help him in gaining technical prowess. However, on joining the most technical club that he cou...
```python t=input() for _ in range(0,t): input() n=input() print n%1000000007 ```
vfc_52825
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n121\n10\n1000000008\n\nSAMPLE", "output": "121\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n121\n10\n1000000008\n\nSAMPLE", "output": "121\n1\n", "type": "std...
code_contests
verifiable_code
witch-the-great-and-powerful-17
Solve the following coding problem using the programming language python: A witch of magic-land captured three prisoners who were trying to enter in magic-land without the permission of witch. The prisoners have distinct integral height. She gave them punishment called "Painful height change". In this punishment witch...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' '''''' def get_moves(h): return max(h[2]-h[1],h[1]-h[0])-1 T = int(raw_input()) for i in xrange(T): h = map(int, raw_input().split(" ")) print get_moves(h) #print 'Hello ...
vfc_52829
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2 4\n2 4 8\n\nSAMPLE", "output": "1\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00057 The Number of Area
Solve the following coding problem using the programming language python: If you draw a few infinitely long straight lines on an infinitely wide plane, this plane will be divided into several areas. For example, if you draw a straight line, the plane will be divided into two areas. Even if you draw the same number of ...
```python while 1: try: n = int(input()) except:break ans = (0.5 * n * n) + (0.5 * n) + 1 print(round(ans)) ```
vfc_52873
{ "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\n3", "output": "2\n7", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5", "output": "2\n16\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00188 Search
Solve the following coding problem using the programming language python: "Search" is an operation to obtain the desired information from a large amount of information. Familiar examples include "finding your own exam number from a large number of exam numbers" when announcing your success, or "finding Taro Aizu's pho...
```python while True: n = int(input()) if n == 0: break a = [int(input()) for _ in range(n)] k = int(input()) l, r, c = 0, n-1, 0 while l <= r: c += 1 m = (l+r) >> 1 if k == a[m]: break elif k < a[m]: r = m-1 else: l = m...
vfc_52877
{ "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": "7\n11\n15\n23\n36\n51\n61\n86\n51\n4\n1\n2\n3\n5\n4\n0", "output": "3\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n11\n15\n0\n36\n51\n61\n86\n51\n4\n1\n2\n3\n5\n4\n0", "output...
code_contests
verifiable_code
p00539 JOI Park
Solve the following coding problem using the programming language python: JOI Park In preparation for the Olympic Games in IOI in 20XX, the JOI Park in IOI will be developed. There are N squares in JOI Park, and the squares are numbered from 1 to N. There are M roads connecting the squares, and the roads are numbered...
```python from heapq import heappush, heappop INF = 10 ** 20 n, m, c = map(int, input().split()) edges = [[] for _ in range(n)] edges_dict = {} d_cost = 0 for _ in range(m): a, b, d = map(int, input().split()) a -= 1 b -= 1 edges[a].append((b, d)) edges[b].append((a, d)) edges_dict[(a, b)] = d d_cost += ...
vfc_52885
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5 2\n2 3 1\n3 1 2\n2 4 3\n1 2 4\n2 5 5", "output": "14", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 2\n2 3 1\n3 1 2\n1 4 3\n1 2 4\n2 5 5", "output": "11\n", "type": "std...
code_contests
verifiable_code
p00701 Pile Up!
Solve the following coding problem using the programming language python: There are cubes of the same size and a simple robot named Masato. Initially, all cubes are on the floor. Masato can be instructed to pick up a cube and put it on another cube, to make piles of cubes. Each instruction is of the form `pick up cube...
```python while(1): m=int(input()) if m==0: break #root, before, next, top, rank A=[[i for i in range(m+1)],[0 for i in range(m+1)],[0 for i in range(m+1)],[i for i in range(m+1)],[1 for i in range(m+1)]] while(1): I,J=map(int, input().split()) if I==0: break if I=...
vfc_52889
{ "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\n1 3\n2 0\n0 0\n4\n4 1\n3 1\n1 2\n0 0\n5\n2 1\n3 1\n4 1\n3 2\n1 1\n0 0\n0", "output": "1\n2\nend\n1\n1\n2\nend\n1\n4\nend", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 3\n2 0\n0 0\n...
code_contests
verifiable_code
p00974 What Goes Up Must Come Down
Solve the following coding problem using the programming language python: What Goes Up Must Come Down Several cards with numbers printed on them are lined up on the table. We'd like to change their order so that first some are in non-decreasing order of the numbers on them, and the rest are in non-increasing order. ...
vfc_52897
{ "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": "7\n3 1 4 1 5 9 2", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01106 Folding a Ribbon
Solve the following coding problem using the programming language python: Folding a Ribbon Think of repetitively folding a very long and thin ribbon. First, the ribbon is spread out from left to right, then it is creased at its center, and one half of the ribbon is laid over the other. You can either fold it from the...
```python #!/usr/bin/env python3 # -*- coding: utf-8 -*- def rdp_trace(n: int, i: int) -> list: def loop(n: int, i: int) -> list: if n == 1: return [] if i <= n // 2: rval = loop(n // 2, (n // 2) - i + 1) rval.append(i) return rval else: ...
vfc_52901
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 2\n12 578 2214\n59 471605241352156968 431565444592236940\n0 0 0", "output": "LRR\nRLLLRRRLRRLL\nLRRRLRRLLRRRRLLLLRLLRRRLRRLLRLLLLLLRLRLLRLRLLLRLRLLRLLRRRLL", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
p01244 Divisor Function
Solve the following coding problem using the programming language python: Teiji is a number theory lover. All numbers are his friends - so long as they are integers. One day, while preparing for the next class as a teaching assistant, he is interested in a number-theoretical function called the divisor function. The d...
vfc_52905
{ "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\n2\n3\n10\n50\n0", "output": "1.000000\n1.500000\n1.500000\n2.000000\n2.583333", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2\n3\n10\n26\n0", "output": "1.000000000\n1.50000000...
code_contests
verifiable_code
p01405 Oh
Solve the following coding problem using the programming language python: Problem H: Oh, My Goat! Taro borrowed an ancient notebook from Jiro. This is to copy tomorrow's ancient Chinese homework. Taro has a cautious personality, so just in case, he took a copy of Jiro's notebook at a convenience store in the neighbor...
vfc_52909
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 1\n0 1 a\n2 2\n0 1 a\n0 1 b\n5 5\n0 1 a\n0 2 b\n1 3 a\n2 3 c\n3 4 e\n3 3\n0 1 aa\n0 2 bce\n1 2 a\n2 4\n0 1 abc\n0 1 def\n0 1 ghi\n0 1 jkl\n2 4\n0 1 ghi\n0 1 jkl\n0 1 mno\n0 1 pqr\n6 7\n0 1 haru\n0 1 natsu\n1 2 wa\n2 3 ake\n2 4...
code_contests
verifiable_code
p01559 MinimumCostPath
Solve the following coding problem using the programming language python: There is an NxN grid. <image> (Figure when N = 3) It costs 1 to move to an adjacent square. However, it cannot be moved diagonally. Also, there are M squares with obstacles, and you are not allowed to enter those squares. How many ways are the...
vfc_52913
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 0", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n2 2", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000 10\n1...
code_contests
verifiable_code
p01859 Match Peas War
Solve the following coding problem using the programming language python: B: Nakajima, let's do that! --Match Peas War - problem Nakajima "Uhh ..." Isono "Nakajima, are you okay?" Nakajima "... I feel like I was having an unpleasant dream." Isono "What kind of dream do you have?" Nakajima "Dream to play infinite...
```python li, ri = map(int, input().split()) ln, rn = map(int, input().split()) ISONO = True NAKAJIMA = False def search(li, ri, ln, rn, turn): if li == None and ri == None: return False if ln == None and rn == None: return True if turn == ISONO: ret = False if li and ln: ret = ret or sear...
vfc_52921
{ "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 2\n2 2", "output": "NAKAJIMA", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n2 3", "output": "ISONO\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
anumla
Solve the following coding problem using the programming language python: Mahesh got a beautiful array named A as a birthday gift from his beautiful girlfriend Namratha. There are N positive integers in that array. Mahesh loved the array so much that he started to spend a lot of time on it everyday. One day, he wrote ...
```python import heapq def func(pq,sum,res,n,flag): if n==0: if flag: heapq.heappush(pq, sum) return func(pq, sum+res[n-1], res, n-1, True) func(pq, sum, res, n-1, flag) t=int(raw_input()) for i in range(t): res=[] pq=[] n=int(raw_input()) x=raw_input(...
vfc_52941
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n0 10\n2\n0 1 1 2", "output": "10\n1 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n0 10\n2\n1 1 1 2", "output": "10 \n1 1 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
chrl1
Solve the following coding problem using the programming language python: Chef likes shopping, and especially he likes to buy oranges. But right now he is short of money. He has only k rubles. There are n oranges. The i-th one costs costi rubles and has weight equal to weighti. Chef wants to buy a set of oranges with ...
```python test = input() from itertools import combinations while test: test-=1 n,k = map(int,raw_input().split()) weights = [] costs = [] index = [] for i in range(n): c,w = map(int,raw_input().split()) costs.append(c) weights.append(w) index.append(i) max = ...
vfc_52945
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 3\n2 2\n3 4\n2 1\n2 2\n3 5", "output": "2\n5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
equation
Solve the following coding problem using the programming language python: Statement Given N,A,B,C, find how many solutions exist to the equation : a + b + c ≤ N, such that 0 ≤ a ≤ A, 0 ≤ b ≤ B, 0 ≤ c ≤ C. Input The first line contains the number of test cases T. Each test case contains 4 integers, N,A,B,C. 0 ≤ N...
```python T=input() while T: count=0 T-=1 n,a,b,c=[int(x) for x in raw_input().split()] if a+b+c<=n: count=(a+1)*(b+1)*(c+1) else: for i in range(0,min(a,n)+1): if (b+c<=n-i): count+=(b+1)*(c+1) elif (b>=n-...
vfc_52949
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 3 2 1\n1 1 1 1", "output": "20\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n6 3 2 1\n1 1 1 1", "output": "24\n4\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
kprime
Solve the following coding problem using the programming language python: Alice and Bob are studying for their class test together. The topic of the test is Prime Numbers. The preparation is getting too boring for their liking. To make it interesting, they turn it into a game. The winner will get an ice-cream treat fr...
```python import sys max_num = 100001 def count_primes(num_lines): is_prime = [1] * max_num counts = [0] * max_num #print "is_prime: ", is_prime for p in range(2, max_num): if is_prime[p]: counts[p] = 1 j = 2 while p * j < max_num: #pr...
vfc_52953
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 5 1\n4 10 2\n14 15 2\n2 20 3", "output": "4\n2\n2\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
panstack
Solve the following coding problem using the programming language python: Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once. He serves them in the form of a stack. A pancake can be treated as a circular disk with some radius. Chef needs to take care that when he places a pancake o...
```python test=int(raw_input()) dp=[[0 for _ in range(0,1002)] for _ in range(0,1002)] mod=1e9+7 for i in range(1,1001): dp[i][i]=1 for i in range(1,1001): for j in range(1,i): dp[i][j]=(dp[i-1][j]*j+dp[i-1][j-1])%mod for _ in range(0,test): n=int(raw_input()) ans=0 for i in range(0,n+1): ans=(ans+dp[n][i])%mo...
vfc_52957
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n2", "output": "1\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0\n2", "output": "0\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
sswap
Solve the following coding problem using the programming language python: In this problem, you are given a string of N characters(1-indexed), and an integer D. You perform multiple operations on this string. In the first operation you select the first D characters of the string, ie. the substring S[1...D] and reverse ...
```python # cook your code here # your code goes here from sys import stdin, stdout t = int(stdin.readline()) #t = int(raw_input()) while t: t -= 1 s = stdin.readline().strip() d = int(stdin.readline()) temp = s[:d-1] choice = len(s)-d+1 j = s[d-1:] if choice%2 == 0: j += temp el...
vfc_52961
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nhello\n3", "output": "lloeh\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\nhlelo\n3", "output": "elolh\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1007_B. Pave the Parallelepiped
Solve the following coding problem using the programming language python: You are given a rectangular parallelepiped with sides of positive integer lengths A, B and C. Find the number of different groups of three integers (a, b, c) such that 1≤ a≤ b≤ c and parallelepiped A× B× C can be paved with parallelepipeds a× ...
```python from sys import stdin from math import gcd def main(): input() l = stdin.read().splitlines() d = [3., 1., 2., 2., 2., 1.] * 16667 for i in range(4, 100001): for j in range(i, 100001, i): d[j] += 1. for i, s in enumerate(l): a, b, c = map(int, s.split()) ...
vfc_52965
{ "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\n1 1 1\n1 6 1\n2 2 2\n100 100 100\n", "output": "1\n4\n4\n165\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1051_G. Distinctification
Solve the following coding problem using the programming language python: Suppose you are given a sequence S of k pairs of integers (a_1, b_1), (a_2, b_2), ..., (a_k, b_k). You can perform the following operations on it: 1. Choose some position i and increase a_i by 1. That can be performed only if there exists at...
vfc_52973
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 1\n3 3\n5 5\n4 2\n2 4\n", "output": "0\n0\n0\n-5\n-16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 4\n2 3\n2 2\n1 1\n", "output": "0\n3\n7\n1\n", "type": "stdin_st...
code_contests
verifiable_code
1075_A. The King's Race
Solve the following coding problem using the programming language python: On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), where r...
```python a=int(input()) n, m=map(int, input().split()) mh=min(abs(1-n),abs(1-m)) mb=min(abs(a-n),abs(a-m)) if mh<=mb: print("White") else: print("Black") ```
vfc_52977
{ "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\n2 3\n", "output": "White", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n3 5\n", "output": "Black", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1117_C. Magic Ship
Solve the following coding problem using the programming language python: You a captain of a ship. Initially you are standing in a point (x_1, y_1) (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point (x_2, y_2). You know the weather forecast — the string s of l...
```python #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction import collections from itertools import permutations from collections import defaultdict from collections import deque impo...
vfc_52985
{ "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": "0 3\n0 0\n3\nUDD\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0\n4 6\n3\nUUU\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
1163_D. Mysterious Code
Solve the following coding problem using the programming language python: During a normal walk in the forest, Katie has stumbled upon a mysterious code! However, the mysterious code had some characters unreadable. She has written down this code as a string c consisting of lowercase English characters and asterisks ("*...
```python import sys from array import array # noqa: F401 from typing import List, Tuple, TypeVar, Generic, Sequence, Union # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') def build_next_table(s): s = '*' + s + '*' n = len(s) - 1 kmp = [0] * (n + 1) next_table = [[...
vfc_52993
{ "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": "***\ncc\nz\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "*****\nkatie\nshiro\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1184_A3. Heidi Learns Hashing (Hard)
Solve the following coding problem using the programming language python: Now Heidi is ready to crack Madame Kovarian's hashing function. Madame Kovarian has a very strict set of rules for name changes. Two names can be interchanged only if using the following hashing function on them results in a collision. However,...
vfc_52997
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 100\nmelodypond\nriversongg\n", "output": "181 59\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 5\nbgcbaaaaaa\ncccaaaaaaa\n", "output": "281 153\n", "type": "stdin_stdo...
code_contests
verifiable_code
1201_E2. Knightmare (hard)
Solve the following coding problem using the programming language python: This is an interactive problem. Alice and Bob are playing a game on the chessboard of size n × m where n and m are even. The rows are numbered from 1 to n and the columns are numbered from 1 to m. There are two knights on the chessboard. A whit...
vfc_53001
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 6\n4 4 2 2\n6 3", "output": "BLACK\n4 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 8\n2 3 1 8\n", "output": "WHITE\n4 4\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
1219_E. Jumping Transformers
Solve the following coding problem using the programming language python: You, the mighty Blackout, are standing in the upper-left (0,0) corner of NxM matrix. You must move either right or down each second. There are K transformers jumping around the matrix in the following way. Each transformer starts jumping from ...
vfc_53005
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 128000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 5\n0 1 1 0 7\n1 1 1 0 10\n1 1 1 1 2\n1 1 1 2 2\n0 1 1 2 3\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5 6\n0 2 2 2 3\n1 2 2 3 4\n0 3 1 2 1\n0 1 1 0 6\n0 2 1 0 6\...
code_contests
verifiable_code
1243_E. Sum Balance
Solve the following coding problem using the programming language python: Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers. There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers are d...
```python import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ k = int(input()) d = {} aa = [] sa = [] for i in range(k): ni, *a = map(int, input().split()) for ai in a: d[ai] = i aa.append(a) sa.append(sum(a)) s = sum(sa) if s%k != 0: print("No") exit() s //= k ...
vfc_53009
{ "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": "2\n2 -10 10\n2 0 -20\n", "output": "Yes\n-10 2\n-20 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 3 -2\n2 -1 5\n", "output": "No\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
1263_D. Secret Passwords
Solve the following coding problem using the programming language python: One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of n passwords — strings, ...
```python from sys import stdin inp = lambda: stdin.readline().strip() n = int(inp()) def dfs(visited, graph, node): if not visited[node]: visited[node] = True for neighbour in graph[node]: dfs(visited, graph, neighbour) adj = [set() for x in range(26)] visited = [True]*26 for i in ...
vfc_53013
{ "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\ncodeforces\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1284_G. Seollal
Solve the following coding problem using the programming language python: It is only a few days until Seollal (Korean Lunar New Year), and Jaehyun has invited his family to his garden. There are kids among the guests. To make the gathering more fun for the kids, Jaehyun is going to run a game of hide-and-seek. The ga...
vfc_53017
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 2\nOO\nOO\n3 3\nOOO\nXOO\nOOO\n4 4\nOOOX\nXOOX\nOOXO\nOOOO\n5 6\nOOOOOO\nOOOOOO\nOOOOOO\nOOOOOO\nOOOOOO\n", "output": "YES\nOOO\n O\nOOO\nNO\nYES\nOOOOO X\n O O \nX O O X\n O \nOOO X O\nO O O\nO OOOOO\nYES\nOOOO...
code_contests
verifiable_code
1304_B. Longest Palindrome
Solve the following coding problem using the programming language python: Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings "pop", "noon", "x", and "kkkkkk" are palindromes, while strings "moon", ...
```python n,m=map(int,input().split()) a=[input() for x in range(n)] z=[] p=[] for x in range(n): for y in range(x+1,n): if a[x]==a[y][::-1]: z.append((x,y)) if a[x]==a[x][::-1]: p.append(x) if x==n-1: if a[x]==a[x][::-1]: p.append(x) ans='' for x in z...
vfc_53021
{ "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": "4 2\noo\nox\nxo\nxx\n", "output": "6\noxooxo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\nhello\ncodef\norces\n", "output": "0\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1369_A. FashionabLee
Solve the following coding problem using the programming language python: Lee is going to fashionably decorate his house for a party, using some regular convex polygons... Lee thinks a regular n-sided (convex) polygon is beautiful if and only if he can rotate it in such a way that at least one of its edges is paralle...
```python t= int(input()) for i in range (t): g= int(input()) if(g%4==0): print("YES") else: print("NO") ```
vfc_53033
{ "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\n3\n4\n12\n1000000000\n", "output": "NO\nYES\nYES\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n3\n4\n12\n1010000000\n", "output": "NO\nYES\nYES\nYES\n", "type": "s...
code_contests
verifiable_code
138_E. Hellish Constraints
Solve the following coding problem using the programming language python: Katya recently started to invent programming tasks and prepare her own contests. What she does not like is boring and simple constraints. Katya is fed up with all those "N does not exceed a thousand" and "the sum of ai does not exceed a million"...
vfc_53037
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "codeforces\n2 0 0\no 1 2\ne 1 2\n", "output": " 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "codeforces\n2 1 1\no 1 2\no ...
code_contests
verifiable_code
1413_C. Perform Easily
Solve the following coding problem using the programming language python: After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret number j on the i-th string produces the note ...
```python import sys input=sys.stdin.readline a=list(map(int,input().split())) a.sort() n=int(input()) b=list(map(int,input().split())) b.sort() res=[] for i in range(6): for j in range(n): res.append([b[j]-a[i],j]) res.sort() ans=10**18 r=0 c=0 cnt=[0]*n for l in range(n*6): while c!=n and r<6*n: ...
vfc_53041
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 4 100 10 30 5\n6\n101 104 105 110 130 200\n", "output": "0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1431_F. Neural Network Problem
Solve the following coding problem using the programming language python: You want to train a neural network model for your graduation work. There are n images in the dataset, the i-th image's size is a_i bytes. You don't have any powerful remote servers to train this model so you have to do it on your local machine....
vfc_53045
{ "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": "5 5 4\n1 1 5 4 5\n", "output": "\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2 4\n6 1 5 5 6\n", "output": "\n11\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1455_C. Ping-pong
Solve the following coding problem using the programming language python: Alice and Bob play ping-pong with simplified rules. During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must a...
```python import sys import math from collections import defaultdict,deque input = sys.stdin.readline def inar(): return [int(el) for el in input().split()] def main(): t=int(input()) for _ in range(t): alice,bob=inar() print(alice-1,bob) if __name__ == '__main__': main() ```
vfc_53049
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n2 1\n1 7\n", "output": "\n0 1\n1 1\n0 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1\n2 1\n96342 7\n", "output": "0 1\n1 1\n96341 7\n", "type": "stdin_stdout"...
code_contests
verifiable_code
1506_C. Double-ended Strings
Solve the following coding problem using the programming language python: You are given the strings a and b, consisting of lowercase Latin letters. You can do any number of the following operations in any order: * if |a| > 0 (the length of the string a is greater than zero), delete the first character of the strin...
```python rn=lambda:int(input()) rns=lambda:map(int,input().split()) rl=lambda:list(map(int,input().split())) rs=lambda:input() YN=lambda x:print('YES') if x else print('NO') mod=10**9+7 for _ in range(rn()): a=rs() b=rs() aset=set() aset.add('') for i in range(len(a)): for j in range(i,len...
vfc_53057
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\na\na\nabcd\nbc\nhello\ncodeforces\nhello\nhelo\ndhjakjsnasjhfksafasd\nadjsnasjhfksvdafdser\n", "output": "\n0\n2\n13\n3\n20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\na\na\nabcc...
code_contests
verifiable_code
152_B. Steps
Solve the following coding problem using the programming language python: One day Vasya went out for a walk in the yard but there weren't any of his friends outside and he had no one to play touch and run. But the boy didn't lose the high spirits and decided to play touch and run with himself. You may ask: "How did he...
```python n, m = [int(z) for z in input().split()] x, y = [int(z) for z in input().split()] k = int(input()) res = 0 i = 0 while i < k: dx, dy = [int(z) for z in input().split()] if dx == 0: s = (m - y) // dy if dy > 0 else (1 - y) // dy elif dy == 0: s = (n - x) // dx if dx > 0 else (1 - x...
vfc_53061
{ "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": "10 10\n1 2\n1\n-1 0\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n1 1\n3\n1 1\n1 1\n0 -2\n", "output": "4\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
160_D. Edges in MST
Solve the following coding problem using the programming language python: You are given a connected weighted undirected graph without any loops and multiple edges. Let us remind you that a graph's spanning tree is defined as an acyclic connected subgraph of the given graph that includes all of the graph's vertexes. ...
```python import sys from math import inf from collections import defaultdict class disjoinSet(object): def __init__(self,n): self.father = [x for x in range(0,n+1)] self.rank = [0 for x in range(0,n+1)] def setOf(self, x): if(self.father[x] != x): self.father[x] = sel...
vfc_53065
{ "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 3\n1 2 1\n2 3 1\n1 3 2\n", "output": "any\nany\nnone\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n1 2 101\n1 3 100\n2 3 2\n2 4 2\n3 4 1\n", "output": "none\nany\nat least o...
code_contests
verifiable_code
180_A. Defragmentation
Solve the following coding problem using the programming language python: In this problem you have to implement an algorithm to defragment your hard disk. The hard disk consists of a sequence of clusters, numbered by integers from 1 to n. The disk has m recorded files, the i-th file occupies clusters with numbers ai, ...
```python import sys n, m, *inp = map(int, sys.stdin.read().split()) inp.reverse() f = [[0 for x in range(201)] for y in range(201)] #2D Array c = [(0,0)]*201 f_size = [0]*201 def putData(f_id, s_id, c_id): global f, c f[f_id][s_id] = c_id c[c_id] = (f_id, s_id) for f_id in range(1, m+1): f_size[...
vfc_53069
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2\n2 1 3\n3 2 4 5\n", "output": "3\n2 6\n3 2\n6 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 2\n2 1 2\n3 3 4 5\n", "output": "0\n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
203_B. Game on Paper
Solve the following coding problem using the programming language python: One not particularly beautiful evening Valera got very bored. To amuse himself a little bit, he found the following game. He took a checkered white square piece of paper, consisting of n × n cells. After that, he started to paint the white cell...
```python import math from sys import stdin from math import ceil import sys if __name__ == '__main__': numbers = list(map(int, input().split())) n = numbers[0] m = numbers[1] moves = [[0] * (n + 4) for _ in range(n + 4)] for i in range(m): listOfMoves = list(map(int, input().split())) ...
vfc_53073
{ "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 11\n1 1\n1 2\n1 3\n2 2\n2 3\n1 4\n2 4\n3 4\n3 2\n3 3\n4 1\n", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 12\n1 1\n1 2\n1 3\n2 2\n2 3\n1 4\n2 4\n3 4\n3 2\n4 2\n4 1\n3 1...
code_contests
verifiable_code
228_A. Is your horseshoe on the other hoof?
Solve the following coding problem using the programming language python: Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, bu...
```python l=list(map(int,input().split())) i=list(set(l)) print(abs(len(i)-len(l))) ```
vfc_53077
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 7 7 7\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 7 3 3\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
29_B. Traffic Lights
Solve the following coding problem using the programming language python: A car moves from point A to point B at speed v meters per second. The action takes place on the X-axis. At the distance d meters from A there are traffic lights. Starting from time 0, for the first g seconds the green light is on, then for the f...
```python # n=int(input()) l,d,v,g,r=map(int,input().split()) z=d/v y=(l-d)/v temp=z light=True x=0 # print(z,y) while(1): if(x%2==0): if(temp>=g): temp-=g light=False else: break else: if(temp>=r): temp-=r light=True el...
vfc_53089
{ "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 4 3 1 1\n", "output": "2.33333333333\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1 3 4 5\n", "output": "0.666666666667\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
347_C. Alice and Bob
Solve the following coding problem using the programming language python: It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, e...
```python from sys import * from math import * from string import * from operator import * from functools import * from fractions import * from collections import * setrecursionlimit(10**7) dX= [-1, 1, 0, 0,-1, 1,-1, 1] dY= [ 0, 0,-1, 1, 1,-1,-1, 1] RI=lambda: list(map(int,input().split())) RS=lambda: input().rstrip()....
vfc_53097
{ "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\n5 6 7\n", "output": "Bob\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 3\n", "output": "Alice\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
370_D. Broken Monitor
Solve the following coding problem using the programming language python: Innocentius has a problem — his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. He is recently playing the following game with his y...
```python #!/usr/bin/python3 def readln(): return list(map(int, input().split())) import sys def exit(): print(-1) sys.exit() n, m = readln() mon = [list(input()) for _ in range(n)] hor = [i for i in range(n) if mon[i] != ['.'] * m] rmon = list(zip(*mon)) ver = [j for j in range(m) if rmon[j] != ('.',) * n] m...
vfc_53101
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 8\n..w..w..\n........\n........\n..w..w..\n", "output": "..w++w..\n..+..+..\n..+..+..\n..w++w..\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6\n......\n.w....\n......\n..w...\n........
code_contests
verifiable_code
392_A. Blocked Points
Solve the following coding problem using the programming language python: Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A a...
```python from math import sqrt, floor def calc(n): if n == 0: return 1 # y = n # x = 1 # c = 0 # while x - y < 0: # if x ** 2 + y ** 2 <= n ** 2: # c += 1 # x += 1 # continue # if x ** 2 + y ** 2 > n ** 2: # y -= 1 x = fl...
vfc_53105
{ "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\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
415_B. Mashmokh and Tokens
Solve the following coding problem using the programming language python: Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tok...
```python def arr_inp(n): if n == 1: return [int(x) for x in stdin.readline().split()] elif n == 2: return [float(x) for x in stdin.readline().split()] else: return [str(x) for x in stdin.readline().split()] from sys import stdin from math import floor n, a, b = arr_inp(1) arr = a...
vfc_53109
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1\n1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 2\n1 2 3\n", "output": "1 0 1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
464_A. No to Palindromes!
Solve the following coding problem using the programming language python: Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more. Paul has found a tolerable ...
```python n, p = map(int, input().split()) s = list(ord(i) - 97 for i in input()) for i in range(n - 1, -1, -1): for j in range(s[i] + 1, p): if (i < 1 or j != s[i - 1]) and (i < 2 or j != s[i - 2]): s[i] = j for i in range(i + 1, n): for j in range(p): ...
vfc_53117
{ "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 4\ncba\n", "output": "cbd\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\nabcd\n", "output": "abda\n", "type": "stdin_stdout" }, { "fn_name": null, "...