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
37_D. Lesson Timetable
Solve the following coding problem using the programming language python: When Petya has free from computer games time, he attends university classes. Every day the lessons on Petya’s faculty consist of two double classes. The floor where the lessons take place is a long corridor with M classrooms numbered from 1 to M...
vfc_78917
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 1\n1 2 3\n", "output": "36\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 1\n1 1 1\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
427_D. Match & Catch
Solve the following coding problem using the programming language python: Police headquarter is monitoring signal on different frequency levels. They have got two suspiciously encoded strings s1 and s2 from two different frequencies as signals. They are suspecting that these two strings are from two different criminal...
```python import sys import itertools import bisect import math from fractions import gcd def solve(): a = sys.stdin.readline().strip("\n\r") b = sys.stdin.readline().strip("\n\r") words = [len(a), len(a) + len(b) + 2] a += "#" + b states = [] state0 = [0, 0, {}] sz = 0 ...
vfc_78925
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "testsetses\nteeptes\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "bidhan\nroy\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
450_B. Jzzhu and Sequences
Solve the following coding problem using the programming language python: Jzzhu has invented a kind of sequences, they meet the following property: <image> You are given x and y, please calculate fn modulo 1000000007 (109 + 7). Input The first line contains two integers x and y (|x|, |y| ≤ 109). The second line co...
```python n,m=map(int,input().split()) k=int(input()) l=m-n s=[n,m,l] z=(k-1)//3 if(z%2==0): print((s[k%3-1])%1000000007) else: print((-1*s[k%3-1])%1000000007) ```
vfc_78929
{ "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": "0 -1\n2\n", "output": "1000000006\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n3\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
496_D. Tennis Game
Solve the following coding problem using the programming language python: Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. ...
```python #!/usr/bin/env python3 import itertools n = int(input()) a = [int(x) for x in input().split()] winner = a[-1] looser = 3 - winner serve_win_cnt, serve_loose_cnt, win_pos, loose_pos, result = [0], [0], [-1], [-1], [] win_cnt = a.count(winner) for i in range(n): if a[i] == winner: win_pos.append...
vfc_78937
{ "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": "8\n2 1 2 1 1 1 1 1\n", "output": "3\n1 6\n2 3\n6 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 1 1\n", "output": "3\n1 4\n2 2\n4 1\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
520_A. Pangram
Solve the following coding problem using the programming language python: A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices. You are given a st...
```python import string gauge = set(string.ascii_lowercase) n = int(input()) line = set(input().lower()) if line == gauge: print("YES") else: print("NO") ```
vfc_78941
{ "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": "12\ntoosmallword\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "35\nTheQuickBrownFoxJumpsOverTheLazyDog\n", "output": "YES\n", "type": "stdin_stdout" } ...
code_contests
verifiable_code
547_C. Mike and Foam
Solve the following coding problem using the programming language python: Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's numbered from 1 to n. i-th kind of beer has ai milliliters of foam on it. <image> Maxim is Mike's boss. Today he told M...
vfc_78945
{ "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 6\n1 2 3 4 6\n1\n2\n3\n4\n5\n1\n", "output": "0\n1\n3\n5\n6\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n499590\n1\n1\n", "output": "0\n0\n", "type": "stdin_stdout...
code_contests
verifiable_code
573_E. Bear and Bowling
Solve the following coding problem using the programming language python: Limak is an old brown bear. He often goes bowling with his friends. Today he feels really good and tries to beat his own record! For rolling a ball one gets a score — an integer (maybe negative) number of points. Score for i-th roll is multipli...
vfc_78949
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n-2 -8 0 5 -3\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n-10 20 -30 40 -50 60\n", "output": "400\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
595_C. Warrior and Archer
Solve the following coding problem using the programming language python: In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and mod...
```python #!/usr/bin/env python3 n = int(input()) n_2 = n // 2 x = sorted([int(tok) for tok in input().split()]) res = min((x[j] - x[j-n_2] for j in range(n_2, n))) print(res) ```
vfc_78953
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n73 37\n", "output": "36", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n0 1 3 7 15 31\n", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
616_F. Expensive Strings
Solve the following coding problem using the programming language python: You are given n strings ti. Each string has cost ci. Let's define the function of string <image>, where ps, i is the number of occurrences of s in ti, |s| is the length of the string s. Find the maximal value of function f(s) over all strings. ...
vfc_78957
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\naa\nbb\n2 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\naa\nab\n2 1\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
637_A. Voting for Photos
Solve the following coding problem using the programming language python: After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the ph...
```python from collections import Counter n=int(input()) a=[int(i) for i in input().split(' ')] c=Counter() mx=-1 mxid=-1 for i in range(n): c[a[i]]+=1 if c[a[i]]>mx: mx=c[a[i]] mxid=a[i] print(mxid) ```
vfc_78961
{ "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": "9\n100 200 300 200 100 300 300 100 200\n", "output": "300", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 3 2 2 1\n", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
665_A. Buses Between Cities
Solve the following coding problem using the programming language python: Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a minutes and arrives to the city B in a ta minutes, and a bus from the city B departs ev...
```python def solve(a, t1, t2): l1 = t1 - (t1 - 300) % a + a if (l1 < 300): l1 = 300 l2 = t2 - (t2 - 300) % a if (l2 > 1439): l2 = 1439 if (l2 < l1): return 0 return (l2-l1) // a + 1 - (l2 == t2) def trans(h, m): return 60 * h + m data1 = [int(x) for x in in...
vfc_78965
{ "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": "10 30\n10 35\n05:20\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "60 120\n24 100\n13:00\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
689_D. Friends and Subsequences
Solve the following coding problem using the programming language python: Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows? Every one of them has an integer sequences a a...
```python from bisect import bisect HISENTINEL = 10**9 + 1 LOSENTINEL = -HISENTINEL def main(): length = int(input()) a = [int(fld) for fld in input().strip().split()] b = [int(fld) for fld in input().strip().split()] print(countmaxminsubseq(a, b)) def countmaxminsubseq(a, b): leq, lgt = getl...
vfc_78969
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3 3\n1 1 1\n", "output": "0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
732_B. Cormen — The Best Friend Of a Man
Solve the following coding problem using the programming language python: Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. Empirically Polycarp learned that the dog needs at least k walks for any two consecutive days in ...
```python import math n,k=map(int,input().split()) l2=[] a=list(map(int,input().split())) for i in a: l2.append(i) i=1 l=[a[0]] while i<=n-1: if a[i]+a[i-1]<k: a[i]=k-a[i-1] l.append(k-a[i-1]) else: l.append(a[i]) i=i+1 print(sum(l)-sum(l2)) print(*l) ```
vfc_78977
{ "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": "3 5\n2 0 1\n", "output": "4\n2 3 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6\n2 4 3 5\n", "output": "0\n2 4 3 5\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
756_C. Nikita and stack
Solve the following coding problem using the programming language python: Nikita has a stack. A stack in this problem is a data structure that supports two operations. Operation push(x) puts an integer x on the top of the stack, and operation pop() deletes the top integer from the stack, i. e. the last added. If the s...
```python def _main(): from sys import stdin, stdout def modify(x, left, right, L, R, V): if L <= left and right <= R: add[x] += V return if add[x]: add[2*x] += add[x] add[2*x+1] += add[x] add[x] = 0 mid = (left + right) / ...
vfc_78981
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 2\n2 1 3\n3 0\n", "output": "2\n3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 1 2\n1 0\n", "output": "2\n2\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
777_D. Cloud of Hashtags
Solve the following coding problem using the programming language python: Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particul...
```python def cut_to_lexicographic(word_bigger, word_smaller): for l in range(len(word_bigger)): if word_bigger[l] != word_smaller[l]: return word_bigger[:l] return word_bigger n = int(input()) array = [str(input()) for c in range(n)] b = n - 2 while b > -1: if array[b + 1] >= array[b]...
vfc_78985
{ "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#book\n#bigtown\n#big\n", "output": "#b\n#big\n#big\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n#book\n#cool\n#cold\n", "output": "#book\n#co\n#cold\n", "type": "stdi...
code_contests
verifiable_code
802_B. Heidi and Library (medium)
Solve the following coding problem using the programming language python: Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences. Input Same as the easy version, but the limits have changed: 1 ≤...
```python import sys input = sys.stdin.readline from collections import deque, defaultdict from heapq import heappush, heappop n, k = map(int, input().split()) A = list(map(int, input().split())) dic = defaultdict(deque) for i, a in enumerate(A): dic[a].append(i) hp = [] # for d in dic: # heappush(hp, (-dic[d][...
vfc_78989
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 10, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 100\n1 2 2 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n1 2 3 1\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
822_D. My pretty girl Noora
Solve the following coding problem using the programming language python: In Pavlopolis University where Noora studies it was decided to hold beauty contest "Miss Pavlopolis University". Let's describe the process of choosing the most beautiful girl in the university in more detail. The contest is held in several sta...
vfc_78993
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 4\n", "output": "19\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "844079775 8212 4470298\n", "output": "274251678\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
847_I. Noise Level
Solve the following coding problem using the programming language python: The Berland's capital has the form of a rectangle with sizes n × m quarters. All quarters are divided into three types: * regular (labeled with the character '.') — such quarters do not produce the noise but are not obstacles to the propagati...
vfc_78997
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 2 8\nB*.\nBB*\nBBB\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4 5 4\n..*B\n..**\nD...\n", "output": "7", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
869_D. The Overdosing Ubiquity
Solve the following coding problem using the programming language python: The fundamental prerequisite for justice is not to be correct, but to be strong. That's why justice is always the victor. The Cinderswarm Bee. Koyomi knows it. The bees, according to their nature, live in a tree. To be more specific, a complet...
vfc_79001
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n2 3\n", "output": "15\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4\n1 2\n2 1\n1 2\n2 1\n", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
895_C. Square Subsets
Solve the following coding problem using the programming language python: Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square of s...
```python from collections import * l = int(input()) c = Counter(map(int, input().split())) t = defaultdict(int) p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67] for k, s in c.items(): d = 0 for i, q in enumerate(p): while k % q == 0: k //= q d ^= 1 ...
vfc_79005
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1 1 1\n", "output": "15\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 2 2 2\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
916_D. Jamie and To-do List
Solve the following coding problem using the programming language python: Why I have to finish so many assignments??? Jamie is getting very busy with his school life. He starts to forget the assignments that he has to do. He decided to write the things down on a to-do list. He assigns a value priority for each of his...
vfc_79009
{ "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": "8\nset physicsexercise 2\nset chinesemockexam 3\nset physicsexercise 1\nquery physicsexercise\nquery chinesemockexam\nundo 4\nquery physicsexercise\nquery chinesemockexam\n", "output": "0\n1\n0\n-1\n", "type": "stdin_st...
code_contests
verifiable_code
939_E. Maximize!
Solve the following coding problem using the programming language python: You are given a multiset S consisting of positive integers (initially empty). There are two kind of queries: 1. Add a positive integer to S, the newly added integer is not less than any number in it. 2. Find a subset s of the set S such t...
```python import sys import math from collections import defaultdict #n=int(sys.stdin.readline().split()) arr=[] q=int(sys.stdin.readline()) a,b=map(int,sys.stdin.readline().split()) l,r=0,0 mean=b num=1 arr.append(b) for _ in range(1,q): lis=list(map(int,sys.stdin.readline().split())) if lis[0]==1: b=l...
vfc_79013
{ "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": "4\n1 1\n1 4\n1 5\n2\n", "output": "2.000000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 3\n2\n1 4\n2\n1 8\n2\n", "output": "0.000000000000\n0.500000000000\n3.000000000...
code_contests
verifiable_code
965_B. Battleship
Solve the following coding problem using the programming language python: Arkady is playing Battleship. The rules of this game aren't really important. There is a field of n × n cells. There should be exactly one k-decker on the field, i. e. a ship that is k cells long oriented either horizontally or vertically. Howe...
```python n, k = [int(x) for x in input().split()] p = [0]*n for x in range(n): p[x] = [x for x in input()] res = [[0]*n for x in range(n)] for y in range(n): for x in range(n): if x + k <= n: a = True for b in range(k): if p[y][x + b] == "#": ...
vfc_79017
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 4\n#....##...\n.#...#....\n..#..#..#.\n...#.#....\n.#..##.#..\n.....#...#\n...#.##...\n.#...#.#..\n.....#..#.\n...#.#...#\n", "output": "6 1", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
992_B. Nastya Studies Informatics
Solve the following coding problem using the programming language python: Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well. We define a pair of integers (a, b) good, if G...
```python from collections import defaultdict l, r, x, y = map(int, input().split()) if x == y == 1: if l == 1: print(1) exit() print(0) exit() if y % x != 0: print(0) exit() c = x * y c_ = y // x i = 2 del_ = defaultdict(int) while c_ > 1: while c_ % i == 0: c_ //=...
vfc_79021
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 1 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "50 100 3 30\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
artsy-lulu-1
Solve the following coding problem using the programming language python: Problem Description Lulu says "I love triangles. I love the alphabet, too. Today, I am feeling artsy and I want to mix up these two. Write me a program that draws left-aligned triangles using consecutive letters of the alphabet." Input Forma...
```python while True: try: s = raw_input() except: break if len(s.rstrip().lstrip())==0: break si = s.split() startCh = ord(si[0]) offset = int(si[1]) if offset == 1: print "INVALID" print continue endChi = startCh + (offs...
vfc_79025
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "f 1\nA 3\nn 5\nw 7\nv 5\n\nSAMPLE", "output": "INVALID\n\nA \nB B \nC C C \n\nn \no o \np p p \nq q q q \nr r r r r \n\nINVALID\n\nv \nw w \nx x x \ny y y y \nz z z z z", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
chef-and-prime-tree
Solve the following coding problem using the programming language python: Darshak (Dark) likes to get fruits from trees a lot,he always like to eat those natural fruits directly from the tree. Today he has an infinite full binary tree (each node has exactly two child's) with special properties. Dark's tree has the fo...
```python def is_prime(n): if n == 2 or n == 3: return True elif n < 2: return False elif n%2 == 0: return False limit = int(n**0.5) + 1 for i in xrange(3, limit, 2): if n%i == 0: return False return True def main(): for _ in xrange(in...
vfc_79029
{ "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 5\n4 4\n\nSAMPLE", "output": "-6\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1500\n4289384 87\n1692778 16\n2747794 36\n4885387 93\n1516650 22\n202363 28\n3368691 60\n4897764 27...
code_contests
verifiable_code
double-factorial-1
Solve the following coding problem using the programming language python: Kuldeep is tired from all the fun he's having with Christie, so now all he needs is a good night's sleep to get some rest. Being a math nerd, he even dreams about maths. But in this dreamland some mathematical entities have slightly differen...
```python import math for t in range(input()): n,m = map(int,raw_input().split()) if n > 4: print 0 else: f = math.factorial ans = f(f(n))%(10 ** m) print ans ```
vfc_79033
{ "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 4\n1 2\n\nSAMPLE", "output": "1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1\n1 2\n\nSAMPLE", "output": "1\n1\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
greater-bigger
Solve the following coding problem using the programming language python: Given a word w, rearrange the letters of w to construct another word s in such a way that s is lexicographic-ally greater than w. In case of multiple possible answers, find the lexicographic-ally smallest one. Input Format The first line of in...
```python def NextPerm(s): Len = len(s) EndChar = s[Len-1] for i in range (Len-2,-1,-1): c = s[i] if(c < EndChar): buff = s[:i] for j in range(Len-1,i,-1): if(s[j] > c): break buff = buff + s[j] ind...
vfc_79037
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nab\nbb\nhefg\ndhck\ndkhc\n\nSAMPLE", "output": "ba\nno answer\nhegf\ndhkc\nhcdk\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nab\nbb\nhefg\ndhck\ndkhc\n\nSAPMLE", "output": "...
code_contests
verifiable_code
little-jhool-and-the-magical-jewels
Solve the following coding problem using the programming language python: Little Jhool is still out of his mind - exploring all his happy childhood memories. And one of his favorite memory is when he found a magical ghost, who promised to fulfill one of Little Jhool's wish. Now, Little Jhool was a kid back then, and...
```python t=int(input()) while t>0: r,u,b,y=0,0,0,0 s=raw_input() for c in s: if c=='r': r+=1 if c=='u': u+=1 if c=='b': b+=1 if c=='y': y+=1 print(min(r,u,b,y)) t-=1 ```
vfc_79041
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nrrrruubbbyy\nrubrubrubrubrubrubrubrubrubrubrubrubrubrb\n\nSAMPLE", "output": "2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "73\naclnbkbzqtvjvtvxdahhimirlsk\nxdcraywfygqxzctmtqsxq...
code_contests
verifiable_code
my-girlfriend-and-her-love-for-cats-1
Solve the following coding problem using the programming language python: Ashima has brought home n cats. Now, being a cat lover, she is taking care of the cats and has asked me to bring cat food for them. Being a guy with no idea what to buy, I brought some n packets of cat food (I atleast knew that each and every ca...
```python n=input() s=map(int,raw_input().split()) c=map(int,raw_input().split()) s=sorted(s) c=sorted(c) total=0 for i in range(n): total+=c[i]*s[i] print total ```
vfc_79045
{ "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 1\n4 3\n\nSAMPLE", "output": "15\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 1\n4 3\n\nSLMPAE", "output": "15\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
precedence-rule
Solve the following coding problem using the programming language python: In the Mathematical world of Dr. Ramanujam, every new student must have to pass a exam to take the classes of Advance mathematics from Dr. Ramanujam. One day Ram wants to have classes of Advance mathematics, so he arrived at class of Dr. Ramanuj...
```python t=input() i=0 while i<t: x=raw_input() j=len(x)-1 sm=int(x[j]) j=j-1 while j>=0: c=x[j] j=j-1 a=int(x[j]) if c=='*': sm=sm*a elif c=='+': sm=sm+a else: sm=sm-a j=j-1 print sm i=i+1 ```
vfc_79049
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2+3*5\n1*2*3\n\nSAMPLE", "output": "17\n6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
samu-and-shopping
Solve the following coding problem using the programming language python: Samu is in super market and in a mood to do a lot of shopping. She needs to buy shirts, pants and shoes for herself and her family. There are N different shops. Each shop contains all these three items but at different prices. Now Samu has a str...
```python def minCostIter(): # Here i is the current i, j is the lastColumn selected dp = [[0] * (3) for i in xrange(N)] for j in xrange(3): dp[N - 1][j] = L[N - 1][j] for i in xrange(N - 2, -1, -1): for j in xrange(3): minVal = 10**9 for k in filter(lambda x: x ...
vfc_79053
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n1 50 50\n50 50 50\n1 50 50\n\nSAMPLE", "output": "52\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n82\n9414 595 5212\n2756 7474 3494\n787 9298 9010\n1897 4914 3531\n2321 8057 2...
code_contests
verifiable_code
super-string
Solve the following coding problem using the programming language python: A string is said to be "SUPER STRING" if the number of times the character appeared in the string is equal to its ASCII value. Given the conditions that the ASCII value of ‘a’ is 26 and z is ‘1’. Input First line takes number of test cases ‘N...
```python tc = int(raw_input()) while tc>0: tc = tc - 1 s = raw_input() flag = True s = list(s) # print s for i in s: # print ord(i) x = ord('Z') - ord(i) + 1 # print x if s.count(i)==x: pass else: flag = False break if flag == False: print "No" else: print "Yes" ```
vfc_79057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nZYY\nZYYZ\n\nSAMPLE", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nAAAAAAAAAAAAAAAAAAAAAAAAAA\nGGGGGVVVVVGGGGGWWWWGGGGGZGGGGGXXX\nIIIIIIIIIIIIIIIII", "out...
code_contests
verifiable_code
what-is-the-string-made-of-2
Solve the following coding problem using the programming language python: You are given a string, which contains entirely of decimal digits (0-9). Each digit is made of a certain number of dashes, as shown in the image below. For instance 1 is made of 2 dashes, 8 is made of 7 dashes and so on. You have to write a fun...
```python dashes={'0':6,'1':2,'2':5,'3':5,'4':4,'5':5,'6':6,'7':3,'8':7,'9':6} n = raw_input() s=0 for e in n: s+=dashes[e] print s ```
vfc_79061
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "12134\n\nSAMPLE", "output": "18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "73254370932875002027963295052175", "output": "157\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p00515 Average Score
Solve the following coding problem using the programming language python: problem Five students, Taro, Jiro, Saburo, Shiro, and Hanako, participated in the JOI High School class. In this class, a final exam was conducted. All five people took the final exam. For students with a final exam score of 40 or higher, the ...
```python data = [] kekka = [] for i in range(5): n = int(input()) data.append(n) for i in range(5): if data[i]<40: kekka.append(40) else: kekka.append(data[i]) print(int(sum(kekka)/5)) ```
vfc_79117
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n65\n100\n30\n95", "output": "68", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n65\n101\n30\n95", "output": "68\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
p00691 Fermat's Last Theorem
Solve the following coding problem using the programming language python: In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or F...
```python a=1/3 while 1: z=int(input()) if z==0:break m,zz=0,z*z*z for x in range(1,int(z/pow(2,a))+1): xx=x*x*x y=int(pow(zz-xx,a)) yy=y*y*y m=max(m,yy+xx) print(zz-m) ```
vfc_79121
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n4\n2\n0", "output": "27\n10\n6", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n6\n2\n0", "output": "27\n27\n6\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
p00963 Rendezvous on a Tetrahedron
Solve the following coding problem using the programming language python: Problem G Rendezvous on a Tetrahedron One day, you found two worms $P$ and $Q$ crawling on the surface of a regular tetrahedron with four vertices $A$, $B$, $C$ and $D$. Both worms started from the vertex $A$, went straight ahead, and stopped c...
```python from math import cos, sin, pi, sqrt B = ["BC", "CD", "DB"] XY0, d0, l0, XY1, d1, l1 = open(0).read().split() d0, l0, d1, l1 = map(int, [d0, l0, d1, l1]) def calc(XY, d, l): angle = B.index(XY) * 60 + d x = l * cos(pi*angle/180) y = l * sin(pi*angle/180) x = x + y/sqrt(3) y = y * 2/sqrt(3)...
vfc_79129
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "CD 30 1\nDB 30 1", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "CD 51 1\nDB 30 1", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
p01096 Daruma Otoshi
Solve the following coding problem using the programming language python: Daruma Otoshi You are playing a variant of a game called "Daruma Otoshi (Dharma Block Striking)". At the start of a game, several wooden blocks of the same size but with varying weights are stacked on top of each other, forming a tower. Anothe...
```python n=int(input()) while n!=0: w=list(map(int,input().split())) check=[[False]*n for i in range(n)] for i in range(n-1): if abs(w[i+1]-w[i])<=1: check[i][i+1]=True for i in range(3,n,2): for j in range(n-i): for k in range(j+1,j+i): if check[...
vfc_79133
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 3 4\n4\n1 2 3 1\n5\n5 1 2 3 6\n14\n8 7 1 4 3 5 4 1 6 8 10 4 6 5\n5\n1 3 5 1 3\n0", "output": "4\n4\n2\n12\n0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 3 4\n4\n1 2 3 1\n5\...
code_contests
verifiable_code
p01232 Ancient Expression
Solve the following coding problem using the programming language python: Your friend's archaeologist was excavating the ruins. One day he found a large number of slate engraved with a series of dubious symbols. He was delighted with this great discovery and immediately began to decipher the symbols engraved on the sl...
vfc_79137
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\nR 1 =\nL 2 + -\nL 2 * /\n6\na+b*c-d\n(p-q)/q/d\na+b*c=d-e\nt+t+t+t+t\ns=s=s=s=s\n(((((z)))))\n3\nR 3 = < >\nL 3 & | ^\nL 4 + - * /\n1\na>b*c=d<e|f+g^h&i<j>k", "output": "((a+(b*c))-d)\n(((p-q)/q)/d)\n((a+(b*c))=(d-e))\n...
code_contests
verifiable_code
p01704 Flowers
Solve the following coding problem using the programming language python: Problem Statement We have planted $N$ flower seeds, all of which come into different flowers. We want to make all the flowers come out together. Each plant has a value called vitality, which is initially zero. Watering and spreading fertilizer...
```python import sys def main(): readline = sys.stdin.readline write = sys.stdout.write def gcd(m, n): while n: m, n = n, m % n return m def init(p, q=1): g = gcd(p, q) return p//g, q//g def add(A, B): pa, qa = A pb, qb = B if pa ...
vfc_79149
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10\n4 3 4 10\n5 4 5 20\n6 5 6 30\n3\n7\n-4 3 4 -10\n5 4 5 20\n6 5 6 30\n3\n1\n-4 3 4 -10\n-5 4 5 -20\n6 5 6 30\n3\n10\n-4 3 4 -10\n-5 4 5 -20\n-6 5 6 -30\n0", "output": "43.5\n36\n13.5\n0", "type": "stdin_stdout" ...
code_contests
verifiable_code
p01848 Early Morning Work at Summer Camp
Solve the following coding problem using the programming language python: Early morning in summer camp The morning of JAG summer training camp is early. To be exact, it is not so fast, but many participants feel that it is fast. At the facility that is the venue for the training camp every year, participants must co...
```python def dfs(s): for t in G[s]: if not used[t]: used[t] = 1 dfs(t) res.append(s) def rdfs(s, l): for t in RG[s]: if label[t] is None: label[t] = l rdfs(t, l) while 1: n = int(input()) if n == 0: break G = [[] for i in...
vfc_79153
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n0.60 1 2\n0.60 0\n2\n0.60 1 2\n0.60 1 1\n5\n0.10 1 2\n0.20 1 3\n0.30 1 4\n0.40 1 5\n0.50 1 1\n5\n0.10 0\n0.20 1 1\n0.30 1 1\n0.40 1 1\n0.50 1 1\n5\n0.10 4 2 3 4 5\n0.20 0\n0.30 0\n0.40 0\n0.50 0\n4\n0.10 1 2\n0.20 0\n0.30 1 4\n0...
code_contests
verifiable_code
p01984 Tanka Number
Solve the following coding problem using the programming language python: Number of tanka Wishing to die in the spring under the flowers This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases ...
```python def solve(N): k = 0 rng = 0 for i in range(54): if cl[i] < N <= cl[i+1]: k = i + 2 rng2 = cl[i] rng = cl[i+1] - cl[i] # print(k) posrng = (N-rng2)%(rng//9) perrng = (N-rng2)//(rng//9)+1 if posrng == 0: posrng = rng//9 perr...
vfc_79157
{ "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": "1\n2\n3\n390\n1124\n1546\n314159265358979323\n0", "output": "10\n12\n13\n2020\n25252\n57577\n7744444777744474777777774774744777747477444774744744", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
p02271 Exhaustive Search
Solve the following coding problem using the programming language python: Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once. You are given the sequence A and q questions where each ques...
```python n=int(input()) A=list(map(int,input().split())) q=int(input()) M=list(map(int,input().split())) pattern=[] for i in range(2**n): s=0 for j in range(n): if i >> j & 1: s+=A[j] pattern.append(s) P=set(pattern) for m in M: print('yes' if m in P else 'no') ```
vfc_79165
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35", "output": "no\nno\nyes\nyes\nyes\nyes\nno\nno", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 5 7 10 21\n8\n2 4 17 10 22 21 100 35", "ou...
code_contests
verifiable_code
p02418 Ring
Solve the following coding problem using the programming language python: Write a program which finds a pattern $p$ in a ring shaped text $s$. <image> Constraints * $1 \leq $ length of $p \leq $ length of $s \leq 100$ * $s$ and $p$ consists of lower-case letters Input In the first line, the text $s$ is given. In...
```python s = input() p = input() print("Yes" if p in (s + s) else "No") ```
vfc_79169
{ "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": "vanceknowledgetoad\nadvance", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "vanceknowledgetoad\nadvanced", "output": "No", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
cn03
Solve the following coding problem using the programming language python: So, as you all know free WiFis are being installed in our institute. These are a special type of WiFi and they start to interfere when there is a signal coming from two different WiFis at a single location. The WiFi installation task is giv...
```python def f(d, N, C, X): cows_placed = 1 last_pos = X[0] for i in xrange(1, N): if X[i] - last_pos >= d: cows_placed += 1 last_pos = X[i] if cows_placed == C: return 1 return 0 N, C = map(int, raw_input().split()) X = [] for i in xrange(N): X.append(input()) X.sort() start = 0 end = X[N-1]...
vfc_79177
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n1\n2\n8\n4\n9", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
forestga
Solve the following coding problem using the programming language python: Chef is the head of commercial logging industry that recently bought a farm containing N trees. You are given initial height of the i-th tree by Hi and the rate of growth of height as Ri meters per month. For simplicity, you can assume that all ...
```python def possible(x,l,w): sm=0 for i in range(n): if((ini[i]+rate[i]*x)>=l): sm=sm+ini[i]+rate[i]*x if sm>=w: return 1 else: return 0 n,w,l=map(int,raw_input().split()) ini=[] rate=[] for i in range(n): cur=map(int,raw_input().split()) ini....
vfc_79181
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 74 51\n2 2\n5 7\n2 9", "output": "7\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
linnum
Solve the following coding problem using the programming language python: Stuart is obsessed to numbers. He like all type of numbers in fact he is having a great collection of numbers in his room. His collection includes N different large numbers. But today he is searching for a number which is having maximum frequenc...
```python for _ in range(input()): n=input() a=raw_input().split() x=raw_input() b=[0]*n #n=a[0].count(x) #print n for i in range(n): c=a[i].count(x) b[i]=c m=max(b) #print b for i in range(n): if b[i]==m: print a[i] break ```
vfc_79185
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n345 1323 165 98 456\n3\n5\n335 876 98 1323 349\n3", "output": "1323\n335", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5\n345 1323 165 98 456\n3\n5\n335 876 98 1323 349\n4", ...
code_contests
verifiable_code
pree02
Solve the following coding problem using the programming language python: Problem Statement You have a number N and you want to calculate how many divisors of N are special. A number is said to be special if it is possible to remove some digits from it to get a number having 3, 5 or 6 only.For exemple number 38597 ...
```python from math import sqrt t=input() while t!=0: n=input() c=0 for i in range(2,int(sqrt(n))+1): if n%i==0: if str(i).find('5')!=-1 or str(i).find('3')!=-1 or str(i).find('6')!=-1: c+=1 # p...
vfc_79189
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n15\n75", "output": "3\n5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
tadelive
Solve the following coding problem using the programming language python: Andy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders. It's known that the amount of tips may be different when handled by different delivery man. More specifically, if Andy takes the i^th order, he w...
```python n,x,y = map(int,raw_input().split()) n1 = [int(i) for i in raw_input().split()] n2 = [int(i) for i in raw_input().split()] num = [n1[i]-n2[i] for i in xrange(n) ] num.sort(reverse=True) mx = max(0,n-y) Mx = min(n,x) xy = sum(n2) for i in xrange(mx): xy += num[i] ans = xy for i in xrange(mx,Mx): xy += ...
vfc_79193
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 3\n1 2 3 4 5\n5 4 3 2 1", "output": "21\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3 3\n1 2 3 4 5\n5 4 3 0 1", "output": "21\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1010_E. Store
Solve the following coding problem using the programming language python: Natasha was already going to fly back to Earth when she remembered that she needs to go to the Martian store to buy Martian souvenirs for her friends. It is known, that the Martian year lasts x_{max} months, month lasts y_{max} days, day lasts ...
vfc_79197
{ "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": "10 10 10 3 1 3\n2 6 2\n4 2 4\n6 4 6\n9 9 9\n3 3 3\n10 10 10\n8 8 8\n", "output": "CORRECT\nOPEN\nCLOSED\nUNKNOWN\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10 10 1 1 1\n2 5 7\n2 5 ...
code_contests
verifiable_code
1034_E. Little C Loves 3 III
Solve the following coding problem using the programming language python: Little C loves number «3» very much. He loves all things about it. Now he is interested in the following problem: There are two arrays of 2^n intergers a_0,a_1,...,a_{2^n-1} and b_0,b_1,...,b_{2^n-1}. The task is for each i (0 ≤ i ≤ 2^n-1), t...
vfc_79201
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n11\n11\n", "output": "12", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0123\n3210\n", "output": "0322", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1057_B. DDoS
Solve the following coding problem using the programming language python: We get more and more news about DDoS-attacks of popular websites. Arseny is an admin and he thinks that a website is under a DDoS-attack if the total number of requests for a some period of time exceeds 100 ⋅ t, where t — the number of seconds ...
```python from itertools import accumulate as ac from collections import Counter as cc from bisect import bisect_left as bsl from bisect import bisect as bs from math import factorial as f from collections import * from itertools import * from string import * from bisect import * from queue import * from heapq import *...
vfc_79205
{ "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\n100 200 1 1 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1080_A. Petya and Origami
Solve the following coding problem using the programming language python: Petya is having a party soon, and he has decided to invite his n friends. He wants to make invitations in the form of origami. For each invitation, he needs two red sheets, five green sheets, and eight blue sheets. The store sells an infinite n...
```python data=[int(i) for i in input().split()] n=data.pop(0) k=data.pop(0) red=n*2 green=n*5 blue=n*8 answer=0 if red%k==0: answer+=red//k else: answer+=red//k+1 if blue%k==0: answer+=blue//k else: answer+=blue//k+1 if green%k==0: answer+=green//k else: answer+=green//k+1 print(int...
vfc_79209
{ "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 5\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15 6\n", "output": "38\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3093...
code_contests
verifiable_code
109_E. Lucky Interval
Solve the following coding problem using the programming language python: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya came across...
```python import sys d0 = [0,0,0,0,1,-1,0,1,-1,0,0] oo = 1000000000000 def clucky(x): cnt = 0 while x!=0: if x%10 in [4,7]: cnt+=1 x/=10 return cnt def solve1(a,add): des = clucky(a)+add if des<0: return oo b = a+1 step = 1 nfree = 0 while 1: whi...
vfc_79213
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 4\n", "output": "17\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 7\n", "output": "14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 100...
code_contests
verifiable_code
1120_E. The very same Munchhausen
Solve the following coding problem using the programming language python: A positive integer a is given. Baron Munchausen claims that he knows such a positive integer n that if one multiplies n by a, the sum of its digits decreases a times. In other words, S(an) = S(n)/a, where S(x) denotes the sum of digits of the nu...
```python tabela = """ 3 11 1 1 2 1 2 6 1 4 2 11 3 20 7 2 7 9 1 7 6 9 11 40 1 2 40 0 11 1 7 6 1 6 3 12 2 13 2 11 12 1 13 1 9 15 1 8 30 14 1 10 12 11 9 36 15 11 14 2 2 14 4 17 2 14 9 2 13 27 18 1 34 4 1 33 1 19 1 15 18 1 14 9 21 1 17 10 2 14 8 22 1 12 6 1 10 3 23 1 11 3 11 9 27 24 1 39 6 1 38 0 26 1 16 18 2 15 36 27 11 ...
vfc_79217
{ "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\n", "output": "26667", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1148_A. Another One Bites The Dust
Solve the following coding problem using the programming language python: Let's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string. You have a strings "a", b st...
```python a,b,c=map(int,input().split()) dif=abs(a-b) if dif <=1: print(a+b+c*2) else: print(min(a,b)*2+1+c*2) ```
vfc_79221
{ "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 2 1\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1...
code_contests
verifiable_code
1169_C. Increasing by Modulo
Solve the following coding problem using the programming language python: Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n. In one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≤ i_1 < i_2 < … < i_k ≤ n. He should th...
```python n, m = map(int, input().split()) a = list(map(int, input().split())) l, r = 0, m-1 while r > l: mid = (l + r) >> 1 p = 0 f = False for i in a: if i <= p <= i+mid or i <= p+m <= i+mid: continue if i < p: f = True break p = max(p, i) ...
vfc_79225
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n0 0 0 1 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n0 6 1 3 2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1206_D. Shortest Cycle
Solve the following coding problem using the programming language python: You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation...
```python import sys, os, re, datetime, copy from collections import * from bisect import * def mat(v, *dims): def dim(i): return [copy.copy(v) for _ in range(dims[-1])] if i == len(dims)-1 else [dim(i+1) for _ in range(dims[i])] return dim(0) __cin__ = None def cin(): global __cin__ if __cin__ is None: __cin__ = i...
vfc_79233
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 6 28 9\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1223_G. Wooden Raft
Solve the following coding problem using the programming language python: Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've already cut several trees and prepared it to the poi...
vfc_79237
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n9\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n9 10 9 18 9 9 9 28 9\n", "output": "90\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1249_C1. Good Numbers (easy version)
Solve the following coding problem using the programming language python: The only difference between easy and hard versions is the maximum value of n. You are given a positive integer number n. You really love good numbers so you want to find the smallest good number greater than or equal to n. The positive integer...
```python def ternary (n): if n == 0: return '0' nums = [] while n: n, r = divmod(n, 3) nums.append(str(r)) return ''.join(reversed(nums)) for xyz in range(0,int(input())): n=int(input()) s=ternary(n) f=0 for i in range(0,len(s)): if s[i]=='2': ...
vfc_79241
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1\n2\n6\n13\n14\n3620\n10000\n", "output": "1\n3\n9\n13\n27\n6561\n19683\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n450283905890997363\n", "output": "450283905890997363\n"...
code_contests
verifiable_code
1267_J. Just Arrange the Icons
Solve the following coding problem using the programming language python: BerPhone X is almost ready for release with n applications being preinstalled on the phone. A category of an application characterizes a genre or a theme of this application (like "game", "business", or "education"). The categories are given as ...
```python t = int(input()) for i in range(t): n = int(input()) c =[int(x) for x in input().split()] dt = [0]*n for j in c: dt[j-1]+=1 # print('dt: ', dt) dt = sorted(dt) # print ('dt: ',dt) for i in range(len(dt)): if dt[i]!=0: dt=dt[i:] break ...
vfc_79245
{ "difficulty": "16", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n11\n1 5 1 5 1 5 1 1 1 1 5\n6\n1 2 2 2 2 1\n5\n4 3 3 1 2\n", "output": "3\n3\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n11\n1 5 1 3 1 5 1 1 1 1 5\n6\n1 2 2 2 2 1\n5\n4 3 3 1 2...
code_contests
verifiable_code
128_D. Numbers
Solve the following coding problem using the programming language python: One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to ...
```python n=int(input()) g={} for i in list(map(int,input().split())):g[i]=g.get(i,0)+2 mx=max(g) for i in sorted(g)[:-1]: if i+1 not in g:exit(print('NO')) g[i+1]-=g[i] if g[i+1]<0:exit(print('NO')) print('YES'if g[mx]==0 and list(g.values()).count(0)==1else'NO') ```
vfc_79249
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 1 2 2 2 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 3 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
130_J. Date calculation
Solve the following coding problem using the programming language python: In Gregorian calendar a typical year consists of 365 days and 12 months. The numbers of days in the months are: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31. If year index is divisible by 400, or divisible by 4 but not by 100, the year becomes...
vfc_79253
{ "difficulty": "16", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2011\n324\n", "output": "20 11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2012\n274\n", "output": "30 9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1332_E. Height All the Same
Solve the following coding problem using the programming language python: Alice has got addicted to a game called Sirtet recently. In Sirtet, player is given an n × m grid. Initially a_{i,j} cubes are stacked up in the cell (i,j). Two cells are called adjacent if they share a side. Player can perform the following op...
```python import io import os from collections import Counter, defaultdict, deque DEBUG = False def modInverse(a, p): # Fermat's little theorem, a**(p-1) = 1 mod p return pow(a, p - 2, p) def solve(N, M, L, R): MOD = 998244353 num = R - L + 1 numCells = N * M # Answer doesn't have to lie...
vfc_79257
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 1 2\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1353_A. Most Unstable Array
Solve the following coding problem using the programming language python: You are given two integers n and m. You have to construct the array a of length n consisting of non-negative integers (i.e. integers greater than or equal to zero) such that the sum of elements of this array is exactly m and the value ∑_{i=1}^{n...
```python t = int(input()) for i in range(t): n, m = map(int, input().split()) if n >= 3: print(2 * m) if n == 2: print(m) if n == 1: print(0) ```
vfc_79261
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 100\n2 2\n5 5\n2 1000000000\n1000000000 1000000000\n", "output": "0\n2\n10\n1000000000\n2000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n9041 222\n", "output": "444...
code_contests
verifiable_code
1372_F. Omkar and Modes
Solve the following coding problem using the programming language python: Ray lost his array and needs to find it by asking Omkar. Omkar is willing to disclose that the array has the following qualities: 1. The array has n (1 ≤ n ≤ 2 ⋅ 10^5) elements. 2. Every element in the array a_i is an integer in the range ...
vfc_79265
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n\n2 2\n\n2 2\n\n3 2\n\n2 1\n", "output": "? 1 1\n? 6 6\n! 2 2 2 2 2 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n1 1 1 2 3 3 3 3\n", "output": "? 1 1\n? 8 8\n! 1 1 1 1 1 1...
code_contests
verifiable_code
141_A. Amusing Joke
Solve the following coding problem using the programming language python: So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name i...
```python a = input() b = input() n = list(a) + list(b) n = sorted(n) p = sorted(list(input())) if n == p: print("YES") else: print("NO") ```
vfc_79273
{ "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": "BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS\n", "output": "YES"...
code_contests
verifiable_code
1438_A. Specific Tastes of Andre
Solve the following coding problem using the programming language python: Andre has very specific tastes. Recently he started falling in love with arrays. Andre calls an nonempty array b good, if sum of its elements is divisible by the length of this array. For example, array [2, 3, 1] is good, as sum of its elements...
```python t=int(input()) for i in range(t): n= int(input()) l=[1]*n print(*l) ```
vfc_79277
{ "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\n1\n2\n4\n", "output": "1\n1 1\n1 1 1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26...
code_contests
verifiable_code
1462_F. The Treasure of The Segments
Solve the following coding problem using the programming language python: Polycarp found n segments on the street. A segment with the index i is described by two integers l_i and r_i — coordinates of the beginning and end of the segment, respectively. Polycarp realized that he didn't need all the segments, so he wante...
```python import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self....
vfc_79281
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3\n1 4\n2 3\n3 6\n4\n1 2\n2 3\n3 5\n4 5\n5\n1 2\n3 8\n4 5\n6 7\n9 10\n5\n1 5\n2 4\n3 5\n3 8\n4 8\n", "output": "\n0\n1\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1\n1 2\n1...
code_contests
verifiable_code
186_E. Clever Fat Rat
Solve the following coding problem using the programming language python: The Fat Rat and his friend Сerealguy have had a bet whether at least a few oats are going to descend to them by some clever construction. The figure below shows the clever construction. <image> A more formal description of the clever construct...
vfc_79301
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n1 2\n5\n", "output": "Fat Rat", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1\n2\n", "output": "Fat Rat", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
207_D7. The Beaver's Problem - 3
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem: Y...
vfc_79305
{ "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": "32000\nU.S. M-1 MONEY SUPPLY FALLS TWO BILLION DLRS\nNEW YORK, April 9 - U.S. M-1 money supply fell two billion\ndlrs to a seasonally adjusted 738.9 billion dlrs in the March\n30 week, the Federal Reserve said.\nThe previous week's...
code_contests
verifiable_code
233_A. Perfect Permutation
Solve the following coding problem using the programming language python: A permutation is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. Let's denote the i-th element of permutation p as pi. We'll call number n the size of permutation p1, p2, ..., pn...
```python n=int(input()) if n%2==1: print(-1) else: arr1=[2*int(x) for x in range(1,int((n+2)/2))] arr2=[x-1 for x in arr1] for i in range(n//2): print(arr1[i],end=" ") print(arr2[i],end=" ") ```
vfc_79309
{ "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\n", "output": "2 1 4 3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", ...
code_contests
verifiable_code
258_E. Little Elephant and Tree
Solve the following coding problem using the programming language python: The Little Elephant loves trees very much, he especially loves root trees. He's got a tree consisting of n nodes (the nodes are numbered from 1 to n), with root at node number 1. Each node of the tree contains some list of numbers which initial...
vfc_79313
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 1\n1 2\n1 3\n3 5\n3 4\n2 3\n", "output": "0 3 3 3 3 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
304_D. Rectangle Puzzle II
Solve the following coding problem using the programming language python: You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m). Your task is to find a maximum sub-r...
```python #!/usr/bin/python3 def gcd(a, b): while a: a, b = b % a, a return b n, m, x, y, a, b = tuple(map(int, input().strip().split())) g = gcd(a, b) a //= g b //= g k = min(n // a, m // b) w = k * a h = k * b ans = [x - w + w // 2, y - h + h // 2, x + w // 2, y + h // 2] if ans[0] < 0: ans[2] -...
vfc_79321
{ "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": "100 100 52 50 46 56\n", "output": "17 8 86 92\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 9 5 5 2 1\n", "output": "1 3 9 7\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
352_C. Jeff and Rounding
Solve the following coding problem using the programming language python: Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: * cho...
```python n = int(input()) As = list(map(float, input().split())) B = list(x - int(x) for x in As if x - int(x) > 0.000) l = len(B) if l == 0: print('{:.3f}'.format(0)) exit(0) S = sum(x for x in B) ll = l if l % 2 == 0 else l + 1 ans = 1e10 for i in range(max(0, l - n), (n if l > n else l) + 1): ans = min(ans, ...
vfc_79329
{ "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\n0.000 0.500 0.750 1.000 2.000 3.000\n", "output": "0.250\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4469.000 6526.000 4864.000 9356.383 7490.000 995.896\n", "output": "0.2...
code_contests
verifiable_code
376_D. Maximum Submatrix 2
Solve the following coding problem using the programming language python: You are given a matrix consisting of digits zero and one, its size is n × m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the described op...
vfc_79333
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n100\n011\n000\n101\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n10\n11\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
399_A. Pages
Solve the following coding problem using the programming language python: User ainta is making a web site. This time he is going to make a navigation of the pages. In his site, there are n pages numbered by integers from 1 to n. Assume that somebody is on the p-th page now. The navigation will look like this: << p - ...
```python n, p, k = map(int, input().split()) x = 0 close_symbol = True pages = "" if((p-k) > 1): pages += "<< " if(k<=p): for x in range (k): if(p-k+x == 0): continue #means that p == k and need to ommit first navigation number pages += str(p-k+x) + " " else: for x in range(1,...
vfc_79337
{ "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 5 2\n", "output": "<< 3 4 (5) 6 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 1 2\n", "output": "(1) 2 3 >>\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
421_B. Start Up
Solve the following coding problem using the programming language python: Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it? The market analysts came up with a very smart plan: the name of the company should ...
```python def main(): s = input() print(("NO", "YES")[s == s[::-1] and all(c in "AHIMOTUVWXY" for c in s)]) if __name__ == '__main__': main() ```
vfc_79341
{ "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": "XO\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
447_E. DZY Loves Fibonacci Numbers
Solve the following coding problem using the programming language python: In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 = 1; Fn = Fn - 1 + Fn - 2 (n > 2). DZY loves Fibonacci numbers very much. Today DZY gives you an array consisting of n integers: a1, ...
vfc_79345
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n1 2 3 4\n1 1 4\n2 1 4\n1 2 4\n2 1 3\n", "output": "17\n12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n1 2\n2 1 2\n2 1 2\n", "output": "3\n3\n", "type": "stdin_std...
code_contests
verifiable_code
46_A. Ball Game
Solve the following coding problem using the programming language python: A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count. The game goes as follows. Kids stand in circle. Let's agree to think of the children...
```python #----Kuzlyaev-Nikita-Codeforces----- #------------03.04.2020------------- alph="abcdefghijklmnopqrstuvwxyz" #----------------------------------- n=int(input()) now_child=1 for i in range(1,n): now_child+=i if now_child>n: now_child=now_child%n print(now_child,end=" ") ```
vfc_79349
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n", "output": "2 4 7 1 6 2 9 7 6 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "2 1 ", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
516_A. Drazil and Factorial
Solve the following coding problem using the programming language python: Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit...
```python def add(x, i): if i == 1: pass if i == 2: x.append(2) if i == 3: x.append(3) if i == 4: x.append(2) x.append(2) x.append(3) if i == 5: x.append(5) if i == 6: x.append(5) x.append(3) if i == 7: x.append...
vfc_79357
{ "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\n1234\n", "output": "33222\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n555\n", "output": "555\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
543_A. Writing Code
Solve the following coding problem using the programming language python: Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly ai bugs in every line of code that he writes. Let's call a sequence...
```python import sys import copy input=sys.stdin.readline n,m,b,mod=map(int,input().split()) a=list(map(int,input().split())) dp=[[0]*(m+1) for i in range(b+1)] dp[0][0]=1 for i in range(n): for j in range(a[i],b+1): for k in range(1,m+1): dp[j][k]=(dp[j][k]+dp[j-a[i]][k-1])%mod ans=0 for i in range(b+1): ...
vfc_79361
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 6 5 1000000007\n1 2 3\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
56_C. Corporation Mail
Solve the following coding problem using the programming language python: The Beroil corporation structure is hierarchical, that is it can be represented as a tree. Let's examine the presentation of this structure as follows: * employee ::= name. | name:employee1,employee2, ... ,employeek. * name ::= name of an e...
```python #!/usr/bin/env python3 tree = input().strip() def get_answer(tree, start_index = 0, prev = []): colon_index = tree.find(':', start_index) period_index = tree.find('.', start_index) name_end_index = colon_index if ((colon_index != -1) and (colon_index < period_index)) else period_index name = tree[s...
vfc_79365
{ "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": "MIKE:MAX.,ARTEM:MIKE..,DMITRY:DMITRY.,DMITRY...\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "A:C:C:C:C.....\n", "output": "6\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
612_E. Square Root of Permutation
Solve the following coding problem using the programming language python: A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i = 1......
```python import sys #import random from bisect import bisect_right as rb from collections import deque #sys.setrecursionlimit(10**8) from queue import PriorityQueue from math import * input_ = lambda: sys.stdin.readline().strip("\r\n") ii = lambda : int(input_()) il = lambda : list(map(int, input_().split())) ilf = la...
vfc_79373
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 1 3 4\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 1 4 3\n", "output": "3 4 2 1 ", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
632_E. Thief in a Shop
Solve the following coding problem using the programming language python: A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the shop and an infinite number of products of each kind. The cost of one product of kind i is ai....
```python def main(): _, k = map(int, raw_input().split()) aa = set(map(int, raw_input().split())) mi = min(aa) aa = sorted(i - mi for i in aa) le = aa[-1] * k + 1 dp = [k + 1] * le dp[0] = 0 for a in aa: if a: for i in xrange(a, le): x = dp[i - a] + 1...
vfc_79377
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n3 5 11\n", "output": "9 11 13 15 17 19 21 25 27 33 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 2 3\n", "output": "2 3 4 5 6 ", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
661_B. Seasons
Solve the following coding problem using the programming language python: You are given a name of a month. Output the season of the year to which it belongs (based on Northern hemisphere). Input The input consists of a single string containing the name of one of the twelve months (January, February, March, April, Ma...
vfc_79381
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "April\n", "output": "spring\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "November\n", "output": "autumn\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
685_B. Kay and Snowflake
Solve the following coding problem using the programming language python: After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes. Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) c...
```python import operator import bisect n, q = [int(s) for s in input().split()] ps = [int(s) for s in input().split()] childs = [[] for _ in range(n)] for (c,pa) in enumerate(ps): childs[pa-1].append(c+1) toposort = [] this_level = [0] next_level = [] while len(this_level) > 0: for this_n in this_level: ...
vfc_79385
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 4\n1 1 3 3 5 3\n1\n2\n3\n5\n", "output": "3\n2\n3\n5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n1\n1\n2\n", "output": "1\n2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
708_A. Letters Cyclic Shift
Solve the following coding problem using the programming language python: You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each cha...
```python import sys n=input() i=0 n=n+'a' m="" while n[i]=='a' and len(n)>i+1: i+=1 m=m+'a' if i+1==len(n): w=m[0:len(m)-1]+'z' print(w) sys.exit() while n[i]!='a' and len(n)>i: m=m+chr(ord(n[i])-1) i+=1 m=m+n[i:len(n)-1] print(m) ```
vfc_79389
{ "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": "codeforces\n", "output": "bncdenqbdr", "type": "stdin_stdout" }, { "fn_name": null, "input": "abacaba\n", "output": "aaacaba", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
72_G. Fibonacci army
Solve the following coding problem using the programming language python: King Cambyses loves Fibonacci numbers. He has several armies. Today he wants to make a new army for himself and he wants the number of men in this army to be the n-th Fibonacci number. Given n you should find n-th Fibonacci number. The set of F...
vfc_79393
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
750_D. New Year and Fireworks
Solve the following coding problem using the programming language python: One tradition of welcoming the New Year is launching fireworks into the sky. Usually a launched firework flies vertically upward for some period of time, then explodes, splitting into several parts flying in different directions. Sometimes those...
```python import sys plane = set() crackers = {((0, -1), (0, 1))} n = int(input()) a = [int(x) for x in input().split()] crack_dict = { (1, 0): ((1, -1), (1, 1)), (1, 1): ((1, 0), (0, 1)), (0, 1): ((1, 1), (-1, 1)), (-1, 1): ((0, 1), (-1, 0)), (-1, 0): ((-1, 1), (-1, -1)), (-1, -1): ((-1, 0),...
vfc_79397
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 1 1 1 1 3\n", "output": "85\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
774_B. Significant Cups
Solve the following coding problem using the programming language python: Stepan is a very experienced olympiad participant. He has n cups for Physics olympiads and m cups for Informatics olympiads. Each cup is characterized by two parameters — its significance ci and width wi. Stepan decided to expose some of his cu...
```python n, m, d = map(int, input().split()) ph = [[int(j) for j in input().split()] for i in range(n)] inf = [[int(j) for j in input().split()] for i in range(m)] for i in range(n): ph[i][1] = -ph[i][1] for i in range(m): inf[i][1] = -inf[i][1] ph.sort(reverse=True) inf.sort(reverse=True) sw, sc = 0, 0 for p ...
vfc_79401
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1 8\n4 2\n5 5\n4 2\n3 2\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 2\n5 3\n6 3\n4 2\n8 1\n", "output": "0\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
799_B. T-shirt buying
Solve the following coding problem using the programming language python: A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers pi, ai and bi, where pi is the price of the i-th t-shirt, ai is front color of the i-th t-shirt and bi is back color of the i-th t-shirt. All values...
```python n = int(input()) p = map(int,input().split()) a = map(int,input().split()) b = map(int,input().split()) m = int(input()) pos = map(int,input().split()) fut = zip(p,a,b) fut=list(fut) def sravni(elem): return elem[0] fut.sort(key=sravni) vz = [] for i in range(n): vz.append(False) lastc = [0,0,0] re...
vfc_79405
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n300 200 400 500 911\n1 2 1 2 3\n2 1 3 2 1\n6\n2 3 1 2 1 1\n", "output": "200 400 300 500 911 -1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1000000000 1\n1 1\n1 2\n2\n2 1\n", ...
code_contests
verifiable_code
819_B. Mister B and PR Shifts
Solve the following coding problem using the programming language python: Some time ago Mister B detected a strange signal from the space, which he started to study. After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some ...
```python def main(): n = int(input()) data = input().split() #print(str(n) + " " + str(data)) data = list(map(lambda x: int(x), data)) res = 0 ires = 0 neg = 0 when = [0] * n for i in range(n): data[i] = i + 1 - data[i] res += abs(data[i]) if data[i] <= 0: neg += 1 a = -data[i] if a < 0: a ...
vfc_79409
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n", "output": "0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 2 1\n", "output": "2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
865_B. Ordering Pizza
Solve the following coding problem using the programming language python: It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices. It ...
```python def solve(ls): ls.sort(key=lambda q: q[1] - q[0]) m = sum(si for a, b, si in ls) k = s * (m // s) n = m - k x = y = z = 0 for a, b, si in ls: if k >= si: k -= si z += si * a elif k: z += k * a x = (si - k) * a ...
vfc_79417
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 12\n3 5 7\n4 6 7\n5 9 5\n", "output": "84\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 10\n7 4 7\n5 8 8\n12 5 8\n6 11 6\n3 3 7\n5 9 6\n", "output": "314\n", "type": "std...
code_contests
verifiable_code
891_B. Gluttony
Solve the following coding problem using the programming language python: You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≤ xi ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different,...
```python import sys input() a = list(map(int, input().split())) b = sorted(a) for i in a: sys.stdout.write(str(b[b.index(i)-1])) sys.stdout.write(" ") sys.stdout.write("\n") ```
vfc_79421
{ "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\n1000 100 10 1\n", "output": "1 1000 100 10 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2\n", "output": "2 1 ", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
913_E. Logical Expression
Solve the following coding problem using the programming language python: You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of: * Operation AND ('&', ASCII code 38) * ...
```python answers = [ '!x&x', 'x&y&z', '!z&x&y', 'x&y', '!y&x&z', 'x&z', '!y&x&z|!z&x&y', '(y|z)&x', '!y&!z&x', '!y&!z&x|x&y&z', '!z&x', '!z&x|x&y', '!y&x', '!y&x|x&z', '!(y&z)&x', 'x', '!x&y&z', 'y&z', '!x&y&z|!z&x&y', '(x|z)&y', '!x&y&z|!y&x&z', '(x|y)&z', '!x&y&z|!y&x&z|!z&x&y', '(x|y)&z|x&y', '!x&y&z|!y&!z&x', '!y&...
vfc_79425
{ "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": "4\n00110011\n00000111\n11110000\n00011111\n", "output": "y\n(y|z)&x\n!x\nx|y&z\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n11000010\n11000010\n11001110\n10001001\n", "output":...
code_contests
verifiable_code
935_E. Fafa and Ancient Mathematics
Solve the following coding problem using the programming language python: Ancient Egyptians are known to have understood difficult concepts in mathematics. The ancient Egyptian mathematician Ahmes liked to write a kind of arithmetic expressions on papyrus paper which he called as Ahmes arithmetic expression. An Ahmes...
```python from math import inf class Node: def __init__(self, parent = None, leftExp = None, rightExp = None, signQ = 0): self.parent, self.leftExp, self.rightExp, self.signQ = parent, leftExp, rightExp, signQ def __str__(self): return "Node" memo = {} def Memoize(node, p, maxValue, minValue)...
vfc_79429
{ "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?(5?7))?((6?2)?7))\n3 2\n", "output": "18", "type": "stdin_stdout" }, { "fn_name": null, "input": "(1?1)\n1 0\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
961_D. Pair Of Lines
Solve the following coding problem using the programming language python: You are given n points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are distinct. You may draw two straight lines (not necessarily distinct). Is it possible to do this in such a...
```python n = int(input()) lst = [] for x in range(n): (a, b) = map(int, input().split()) lst.append((a, b)) def scal(x1, y1, x2, y2, x3, y3): if (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1) == 0: return True return False def check(): for x in range(n - 2): if len(s2) >= 3: ...
vfc_79433
{ "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\n0 0\n0 1\n1 1\n1 -1\n2 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 0\n1 0\n2 1\n1 1\n2 3\n", "output": "NO\n", "type": "stdin_stdout" } ]...
code_contests
verifiable_code
989_C. A Mist of Florescence
Solve the following coding problem using the programming language python: As the boat drifts down the river, a wood full of blossoms shows up on the riverfront. "I've been here once," Mino exclaims with delight, "it's breathtakingly amazing." "What is it like?" "Look, Kanno, you've got your paintbrush, and I've got...
```python import sys A, B, C, D = map(int, sys.stdin.readline().split()) cols = 49 rows = 50 res = [['.' for i in range(cols)] for j in range (rows)] A -= 1 B -= 1 for r in range (rows // 2): for c in range (cols): if r % 2 == 0 or c % 2 == 0: res[r][c] = 'A' elif B > 0: res[r][c] = 'B' B -=...
vfc_79437
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 2 1\n", "output": "50 50\nAAAAAAAAAAAAAAAAAAAAAAAAACBBBBBBBBBBBBBBBBBBBBBBBB\nAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBB\nAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBB\nAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBB...
code_contests
verifiable_code
amit-chahals-love-for-juices-and-dhruv-katyals-astrology
Solve the following coding problem using the programming language python: Amit Chahal has a pious love for all kind of fruit juices. Almost every day ,he buys One litre pack of juice. For past one month , Amit Chahal is having a very bad time. One day while he was on a date, he Reverse Peristalsis . Amit Chahal guess...
```python def isprime(number): if number==2: return 1 if number%2==0: return 0 N=number**0.5 i=3 while i<=N: if number%i==0: return 0 i=i+2 return 1 def main(): for t in range(input()): number=long(raw_input()) summ=0 while number>0: summ=summ+number%10 number=number/10 if isprime(summ...
vfc_79441
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n22\n3\n7\n\nSAMPLE", "output": "NO\nYES\nYES", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n22\n5\n7\n\nSAMPLE", "output": "NO\nYES\nYES\n", "type": "stdin_stdout" }, ...