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
1155_B. Game with Telephone Numbers
Solve the following coding problem using the programming language python: A telephone number is a sequence of exactly 11 digits such that its first digit is 8. Vasya and Petya are playing a game. Initially they have a string s of length n (n is odd) consisting of digits. Vasya makes the first move, then players alter...
```python n=int(input()) s=input() # for i in range(n-10) : # if s['i']!='8' # if s[:n-10].count('8')%2==0: # print(s[:n-10]) # print("YES") # else: print("NO") c=n-10-(s[:n-10].count('8')) if c<s[:n-10].count('8'): print("YES") else: print("NO") ```
vfc_54237
{ "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": "15\n807345619350641\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13\n8380011223344\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1177_A. Digits Sequence (Easy Edition)
Solve the following coding problem using the programming language python: Let's write all the positive integer numbers one after another from 1 without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536... Your task ...
```python x = ''.join(str(i) for i in range(1, 5000)) k = int(input()) print(x[k-1]) ```
vfc_54241
{ "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": "21\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1195_E. OpenStreetMap
Solve the following coding problem using the programming language python: Seryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size n × m cells on a map (rows of grid are numbered from 1 to n from north to south, and columns are numbered from 1 t...
```python def slide_min(tl,ql,val): res=[0]*(tl-ql+1) q=[0]*tl s=0 t=0 for i in range(0,tl): while s<t and val[q[t-1]]>=val[i]: t-=1 q[t]=i t+=1 if (i-ql+1)>=0: res[i-ql+1]=val[q[s]] if q[s]==(i-ql+1): s+=1 return res def slide_min2(tl,ql,val): res=0 q=[0]*tl...
vfc_54245
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4 2 1\n1 2 3 59\n", "output": "111\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1000 1 239\n49877647 333519319 741438898 999999937\n", "output": "3303701491\n", "type": ...
code_contests
verifiable_code
1213_A. Chips Moving
Solve the following coding problem using the programming language python: You are given n chips on a number line. The i-th chip is placed at the integer coordinate x_i. Some chips can have equal coordinates. You can perform each of the two following types of moves any (possibly, zero) number of times on any chip: ...
```python n = int(input()) v = list(map(int, input().split())) a = [] b = [] for x in v: a.append(x) if x & 1 else b.append(x) print(min(len(a), len(b))) ```
vfc_54249
{ "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\n2 2 2 3 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
1236_B. Alice and the List of Presents
Solve the following coding problem using the programming language python: Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. There are n kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Present...
```python '''Author- Akshit Monga''' from sys import stdin, stdout input = stdin.readline mod=10**9+7 t = 1 for _ in range(t): n,m=map(int,input().split()) print(pow((pow(2,m,mod)-1),n,mod)) ```
vfc_54253
{ "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 3\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 6\n",...
code_contests
verifiable_code
1254_A. Feeding Chicken
Solve the following coding problem using the programming language python: Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain rice,...
```python def distribute(n, person): q, m = divmod(n, person) if m==0: return [q] * person else: return [q]*(person-m)+[q+1]*m import sys input = sys.stdin.readline T = int(input()) CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" for _ in range(T): R, C, K = map(...
vfc_54257
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 5 3\n..R..\n...R.\n....R\n6 4 6\nR..R\nR..R\nRRRR\nRRRR\nR..R\nR..R\n5 5 4\nRRR..\nR.R..\nRRR..\nR..R.\nR...R\n2 31 62\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\n", "output": "AAABB\nCCCBB\nCCCCC\...
code_contests
verifiable_code
133_E. Logo Turtle
Solve the following coding problem using the programming language python: A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands "T" ("turn around") and "F" ("move 1 unit forward"). You are given a list of commands that will...
```python import sys import math INF = -100000000 memo = dict() def func(line, r): if line in memo and r in memo[line]: return memo[line][r] if len(line) == 1: which = line[0] == 'T' if r % 2 == 1: which = not which if which: return [INF, INF, 0, 0] ...
vfc_54273
{ "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": "FT\n1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "FFFTFFF\n2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
1361_F. Johnny and New Toy
Solve the following coding problem using the programming language python: Johnny has a new toy. As you may guess, it is a little bit extraordinary. The toy is a permutation P of numbers from 1 to n, written in one row next to each other. For each i from 1 to n - 1 between P_i and P_{i + 1} there is a weight W_i writ...
vfc_54277
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 15, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 3 2 5 1\n3 2 1 4\n7\n5 4\n5 2\n1 5\n2 4\n2 4\n4 3\n3 3\n", "output": "3\n1\n2\n1\n2\n3\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1402_B. Roads
Solve the following coding problem using the programming language python: The government of Treeland wants to build a new road network. There are 2N cities in Treeland. The unfinished plan of the road network already contains N road segments, each of which connects two cities with a straight line. No two road segments...
vfc_54285
{ "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": "5\n1 3 3 6\n5 1 5 3\n3 3 6 5\n2 1 4 1\n2 3 4 2\n", "output": "\n2 1 1 3\n2 3 2 1\n3 3 2 3\n5 1 4 2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1425_A. Arena of Greed
Solve the following coding problem using the programming language python: Lately, Mr. Chanek frequently plays the game Arena of Greed. As the name implies, the game's goal is to find the greediest of them all, who will then be crowned king of Compfestnesia. The game is played by two people taking turns, where Mr. Cha...
```python #!/usr/bin/env python import os import sys from io import BytesIO, IOBase def main(): pass # 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...
vfc_54289
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n6\n", "output": "2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n6\n6\n", "output": "4\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
1446_E. Long Recovery
Solve the following coding problem using the programming language python: A patient has been infected with an unknown disease. His body can be seen as an infinite grid of triangular cells which looks as follows: <image> Two cells are neighboring if they share a side. Therefore, each cell (x, y) has exactly three nei...
vfc_54293
{ "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": "3\n1 0\n3 0\n1 1\n", "output": "SICK\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1470_F. Strange Covering
Solve the following coding problem using the programming language python: You are given n points on a plane. Please find the minimum sum of areas of two axis-aligned rectangles, such that each point is contained in at least one of these rectangles. Note that the chosen rectangles can be degenerate. Rectangle contai...
vfc_54297
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n9 1\n1 6\n2\n8 10\n0 7\n4\n0 0\n1 1\n9 9\n10 10\n", "output": "\n0\n0\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n1 5\n4 6\n8 0\n2\n8 0\n10 5\n", "output": "3\n0\n...
code_contests
verifiable_code
151_D. Quantity of Strings
Solve the following coding problem using the programming language python: Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with lengt...
```python import math def pow(a,b,p): res = 1 while(b > 0): if b%2 == 1: res = (res*a)%p a = (a*a)%p b = int(b/2) return res n,m,k = list(map(int,input().strip().split())) p = 10 ** 9 + 7 if k > n or k == 1: print(pow(m, n, p)) elif k == n: print(pow(m, ma...
vfc_54305
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2 4\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2 5\n...
code_contests
verifiable_code
1547_D. Co-growing Sequence
Solve the following coding problem using the programming language python: A sequence of non-negative integers a_1, a_2, ..., a_n is called growing if for all i from 1 to n - 1 all ones (of binary representation) in a_i are in the places of ones (of binary representation) in a_{i + 1} (in other words, a_i \:\&\: a_{i +...
```python # _ ##################################################################################################################### def minCo_growingSequenceWith(array): sequence, prevValue = [], 0 for value in array: n = prevValue&(prevValue^value) prevValue = value^n sequence.append(n...
vfc_54309
{ "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": "5\n4\n1 3 7 15\n4\n1 2 4 8\n5\n1 2 3 4 5\n4\n11 13 15 1\n1\n0\n", "output": "0 0 0 0\n0 1 3 7\n0 1 0 3 2\n0 2 0 14\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4\n1 3 7 15\n4\n1 2...
code_contests
verifiable_code
175_A. Robot Bicorn Attack
Solve the following coding problem using the programming language python: Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained po...
```python def f(t, k, s): if k == 1: if t[0] == '0' and len(t) > 1: return -1 d = int(t) if d > 1000000: return -1 return s + d if t[0] == '0': return f(t[1: ], k - 1, s) p = [(t[i: ], int(t[: i])) for i in range(1, len(t) + 2 - k)] return max(f(a, k...
vfc_54313
{ "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": "9000\n", "output": "90\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1234\n", "output": "37\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "000...
code_contests
verifiable_code
195_B. After Training
Solve the following coding problem using the programming language python: After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has n balls and m baskets. The baskets are positioned in a row from left to ...
```python n,m = map(int,input().split()) l = [] if m%2 == 1: l = [(m+1)//2] for i in range((m-1)//2,0,-1): l.append(i) l.append(m-i+1) else: l = [] for i in range(m//2,0,-1): l.append(i) l.append(m-i+1) for i in range(n): print(l[i%len(l)]) ```
vfc_54317
{ "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 1\n", "output": "1\n1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n", "output": "2\n1\n3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
219_B. Special Offer! Super Price 999 Bourles!
Solve the following coding problem using the programming language python: Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and selling such scissors. Polycaprus calculated that ...
```python p, d = input().split() p = int(p); d = int(d) ans = p = p + 1 i = 10 while i <= 1000000000000000000: if p % i <= d: ans = p - p % i i *= 10 print(ans - 1) ```
vfc_54321
{ "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": "27191 17\n", "output": "27189\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1029 102\n", "output": "999\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
242_D. Dispute
Solve the following coding problem using the programming language python: Valera has n counters numbered from 1 to n. Some of them are connected by wires, and each of the counters has a special button. Initially, all the counters contain number 0. When you press a button on a certain counter, the value it has increas...
```python from queue import Queue n,m = map(int,input().split()) e = [[]for i in range(n+1)] b = [0]*n for i in range(m): u,v = map(int,input().split()) e[u-1].append(v-1) e[v-1].append(u-1) ans = 0 q = Queue() a = input().split() ai = [-1]*n c=0 mask = [False]*n for i in a: inti = int(i) ai[c] = in...
vfc_54325
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n1 2\n3 4\n0 0 0 0\n", "output": "2\n1 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n2 3\n4 1\n1 5\n5 3\n2 1\n1 1 2 0 2\n", "output": "3\n4 1 2\n", "type": "stdin_...
code_contests
verifiable_code
268_B. Buttons
Solve the following coding problem using the programming language python: Manao is trying to open a rather challenging lock. The lock has n buttons on it and to open it, you should press the buttons in a certain order to open the lock. When you push some button, it either stays pressed into the lock (that means that y...
```python #mahade.......... n=int(input()) print((n**3+5*n)//6) ```
vfc_54329
{ "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": "2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1241\n", ...
code_contests
verifiable_code
290_E. HQ
Solve the following coding problem using the programming language python: The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ... Input The only line of the input is a string between 1 and 106 characters long. Output Output "Yes" or "No". ...
```python import sys s = input() qc = s.count('Q') qs = int(qc ** 0.5) hc = s.count('H') if qs == 0: print('Yes') sys.exit(0) if not qc == qs ** 2: print('No') sys.exit(0) if not hc % (qs + 1) == 0: print('No') sys.exit(0) t = s.split('Q') pre = len(t[0]) // 2 suf = 0 if len(t) == 1 else len(t...
vfc_54333
{ "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": "HHQHHQH\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "HHQQHHQQHH\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
316_C1. Tidying Up
Solve the following coding problem using the programming language python: Smart Beaver is careful about his appearance and pays special attention to shoes so he has a huge number of pairs of shoes from the most famous brands of the forest. He's trying to handle his shoes carefully so that each pair stood side by side....
vfc_54337
{ "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": "2 3\n1 1 2\n2 3 3\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n1 3 2 6\n2 1 5 6\n4 4 5 3\n", "output": "4", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
339_B. Xenia and Ringroad
Solve the following coding problem using the programming language python: Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise. Xenia has recently moved into the ringroad house ...
```python def main(n, m, lst): count = 0 lst = [1] + lst for i in range(1, len(lst)): if lst[i] >= lst[i-1]: count += lst[i] - lst[i-1] else: count += n - lst[i-1] + lst[i] return count n, m = [int(x) for x in input().split()] lst = list(map(int, input().split())...
vfc_54341
{ "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 3\n2 3 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n3 2 3\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
361_D. Levko and Array
Solve the following coding problem using the programming language python: Levko has an array that consists of integers: a1, a2, ... , an. But he doesn’t like this array at all. Levko thinks that the beauty of the array a directly depends on value c(a), which can be calculated by the formula: <image> The less value ...
vfc_54345
{ "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 3\n1 2 3 7 8 9\n", "output": " 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n4 7 4 7 4\n", "output": " ...
code_contests
verifiable_code
385_B. Bear and Strings
Solve the following coding problem using the programming language python: The bear has a string s = s1s2... s|s| (record |s| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices i, j (1 ≤ i ≤ j ≤ |s|), that string x(i, j) = sisi + 1... sj contain...
```python a=input() ans=0 for i in range(0,len(a)-3): b=a.find("bear",i) if b>=0: ans+=len(a)-3-b print(ans) ```
vfc_54349
{ "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": "bearaabearc\n", "output": "20\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
433_B. Kuriyama Mirai's Stones
Solve the following coding problem using the programming language python: Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: ...
```python t = int(input()) lst = list(map(int,input().split())) x = lst[:] x.sort() l_st = [0] lst1 = [0] k = 0 k1 = 0 for i in range(t): k += lst[i] l_st.append(k) k1 += x[i] lst1.append(k1) n = int(input()) for i in range(n): t_pe , l , r = map(int,input().split()) if(t_pe == 1): print...
vfc_54357
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6\n", "output": "24\n9\n28\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 ...
code_contests
verifiable_code
455_D. Serega and Fun
Solve the following coding problem using the programming language python: Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up with such a problem. You are given an array a consisting of n positive integers and queries to it. The queries can...
vfc_54361
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n8 4 2 2 7 7 8 8\n8\n1 8 8\n2 8 1 7\n1 8 1\n1 7 3\n2 8 8 3\n1 1 4\n1 2 7\n1 4 5\n", "output": "2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n6 6 2 7 4 2 5\n7\n1 3 6\n2 2 4 2\n2...
code_contests
verifiable_code
478_B. Random Teams
Solve the following coding problem using the programming language python: n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a program that wil...
```python #code n,m = map(int,input().split()) k = n//m z = n - m print(m*k*(k-1)//2+k*(n%m),(z+1)*z//2) ```
vfc_54365
{ "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 2\n", "output": "1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n", "output": "3 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1...
code_contests
verifiable_code
500_D. New Year Santa Network
Solve the following coding problem using the programming language python: New Year is coming in Tree World! In this world, as the name implies, there are n cities connected by n - 1 roads, and for any two distinct cities there always exists a path between them. The cities are numbered by integers from 1 to n, and the ...
```python from queue import Queue import sys cost = [] def readarray(): return map(int, input().split(' ')) n = int(input()) graph = [[] for i in range(n)] for i in range(n - 1): u, v, c = readarray() u, v = u - 1, v - 1 cost.append(c) graph[u].append((v, i)) graph[v].append((u, i)) order = [] used = [0] *...
vfc_54369
{ "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 5 3\n5 3 2\n6 1 7\n1 4 4\n5 2 3\n5\n1 2\n2 1\n3 5\n4 1\n5 2\n", "output": "19.600000000000\n18.600000000000\n16.600000000000\n13.600000000000\n12.600000000000\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
526_B. Om Nom and Dark Park
Solve the following coding problem using the programming language python: Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to hel...
```python # print ("Enter n") n = int(input()) alen = 2**(n+1) a = [0 for i in range(alen)] # print ("Enter all values on the same line") inp = input().split() for i in range(len(inp)): a[i+2] = int(inp[i]) answer = 0 while (n > 0): index = 2**n for i in range(index, index*2, 2): left = a[i] ...
vfc_54373
{ "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": "2\n1 2 3 4 5 6\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n87 37 91 29 58 45 51 74 70 71 47 38 91 89\n", "output": "210\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
551_C. GukiZ hates Boxes
Solve the following coding problem using the programming language python: Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, ...
```python # -*- coding: utf-8 -*- # @Time : 2021/1/15 5:25 下午 # @Author : qu # @Email : quzhenqing@zju.edu.cn # @File : C. GukiZ hates Boxes.py from sys import stdin # n, m = map(int, stdin.buffer.readline().split()) a = list(map(int, stdin.buffer.readline().split())) max_not_zero = 0 for index, value in enu...
vfc_54377
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 0 2\n", "output": " 5", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1 1\n", "output": " ...
code_contests
verifiable_code
5_B. Center Alignment
Solve the following coding problem using the programming language python: Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product. You are to implement the a...
```python import sys; lines = []; m = 0; for s in sys.stdin: lines.append(s.rstrip()); for s in lines: m = max(m, len(s)); turn_is_left = 1; sys.stdout.write('*' * (m + 2) + '\n'); for s in lines: l = len(s); p = q = (m - l) // 2; if ((m - l) % 2): if turn_is_left: q += 1; else: p += ...
vfc_54385
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "This is\n\nCodeforces\nBeta\nRound\n5\n", "output": "************\n* This is *\n* *\n*Codeforces*\n* Beta *\n* Round *\n* 5 *\n************", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
621_E. Wet Shark and Blocks
Solve the following coding problem using the programming language python: There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For exam...
```python import os from io import BytesIO #input = BytesIO(os.read(0, os.fstat(0).st_size)).readline def main(): mod = 10**9 + 7 n,b,k,x = map(int,input().split()) x2 = x + 1 ai = list(map(int,input().split())) ai2 = [0]*x2 for i in range(n): ai2[ai[i] % x] += 1 ai2[-1] = 1 de...
vfc_54389
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 1 2\n3 1 2\n", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 1 2\n6 2 2\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
670_C. Cinema
Solve the following coding problem using the programming language python: Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 1 to 1...
```python n = int(input()) d = {} for i in list(map(int, input().split())): if i in d: d[i] += 1 else: d[i] = 1 m = int(input()) res = [(0, 0)] * m b = list(map(int, input().split())) c = list(map(int, input().split())) for i in range(m): if b[i] not in d: d[b[i]] = 0 if c[i] not in d: d[c[i]] = 0 r...
vfc_54397
{ "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": "6\n6 3 1 1 3 7\n5\n1 2 3 4 5\n2 3 4 5 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 3 2\n2\n3 2\n2 3\n", "output": "2\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
691_E. Xor-sequences
Solve the following coding problem using the programming language python: You are given n integers a1, a2, ..., an. A sequence of integers x1, x2, ..., xk is called a "xor-sequence" if for every 1 ≤ i ≤ k - 1 the number of ones in the binary representation of the number xi <image> xi + 1's is a multiple of 3 and <ima...
vfc_54401
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n15 1 2 4 8\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n15 1 2 4 8\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
716_E. Digit Tree
Solve the following coding problem using the programming language python: ZS the Coder has a large tree. It can be represented as an undirected connected graph of n vertices numbered from 0 to n - 1 and n - 1 edges between them. There is a single nonzero digit written on each edge. One day, ZS the Coder was bored and...
vfc_54405
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 7\n0 1 2\n4 2 4\n2 0 1\n3 0 9\n2 5 7\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 11\n1 2 3\n2 0 3\n3 0 3\n4 3 3\n", "output": "8\n", "type": "stdin_std...
code_contests
verifiable_code
737_B. Sea Battle
Solve the following coding problem using the programming language python: Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn'...
```python n,a,b,k=map(int,input().split()) A=input() B=A.split('1') C=[] l=1 for i in B: if len(i)>=b: for j in range(b-1,len(i),b): C.append(j+l) l+=len(i)+1 C=C[:len(C)-a+1] print(len(C)) print(' '.join(list(map(str,C)))) # Made By Mostafa_Khaled ```
vfc_54409
{ "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": "13 3 2 3\n1000000010001\n", "output": "2\n3 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 2 1\n00100\n", "output": "2\n2 5 ", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
761_A. Dasha and Stairs
Solve the following coding problem using the programming language python: On her way to programming school tiger Dasha faced her first test — a huge staircase! <image> The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with...
```python string=input() a,b=map(int,string.split(' ')) if a==0 and b==0: print('NO') elif a-b==1 or b-a==1: print('YES') elif a==b: print('YES') else: print('NO') ```
vfc_54413
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0\...
code_contests
verifiable_code
784_C. INTERCALC
Solve the following coding problem using the programming language python: DO YOU EXPECT ME TO FIND THIS OUT? WHAT BASE AND/XOR LANGUAGE INCLUDES string? DON'T BYTE OF MORE THAN YOU CAN CHEW YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD THE LA...
```python input() a = list(map(int, input().split())) print(max(a) ^ a[-1]) ```
vfc_54417
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 5 3 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 6 5 3 9 5 9\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
805_B. 3-palindrome
Solve the following coding problem using the programming language python: In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick. He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' ...
```python def check(s): for i in range(len(s)//2): if s[i] != s[-(i+1)]: return(True) return(False) n = int(input()) sub = "aabb" ans = "" mod = n //4 ans += sub*mod for i in range(n%4): ans += sub[i] print(ans) # print(check(ans)) ```
vfc_54421
{ "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": "2\n", "output": "aa\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "aab\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", ...
code_contests
verifiable_code
830_B. Cards Sorting
Solve the following coding problem using the programming language python: Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the same integers on them. Vasily decided to sort the cards. To do...
```python # -*- coding: utf-8 -*- import sys # fout = open("output.txt", "w") fin = sys.stdin # fin = open("input.txt", "r") fout = sys.stdout n = int(fin.readline()) a = list(map(int, fin.readline().split())) def solution(n, a): sorted_arr = [(i, elem) for i, elem in enumerate(a)] sorted_arr.sort(key=lamb...
vfc_54425
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6 3 1 2\n", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1000\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
875_E. Delivery Club
Solve the following coding problem using the programming language python: Petya and Vasya got employed as couriers. During the working day they are to deliver packages to n different points on the line. According to the company's internal rules, the delivery of packages must be carried out strictly in a certain order....
vfc_54433
{ "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": "1 4 5\n2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 1\n3 4 5\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
89_D. Space mines
Solve the following coding problem using the programming language python: Once upon a time in the galaxy of far, far away... Darth Wader found out the location of a rebels' base. Now he is going to destroy the base (and the whole planet that the base is located at), using the Death Star. When the rebels learnt that ...
```python import sys, math def dist(a,b): return pow((a[0] - b[0])**2 + (a[1] - b[1])**2 + (a[2] - b[2])**2,0.5) def vxv(v1,v2): x = -v1[2] * v2[1] + v1[1] * v2[2] y = -v1[0] * v2[2] + v1[2] * v2[0] z = -v1[1] * v2[0] + v1[0] * v2[1] return (x,y,z) readline = sys.stdin.readline s1,s2,s3,v1,v2,v3,R ...
vfc_54437
{ "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": "30 30 2 1 2 1 20\n3\n0 0 40 5 1\n1 4 4\n-10 -40 -5 7 0\n100 200 95 8 1\n-10 0 0\n", "output": "74.6757620881\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 8 4 4 4 2 6\n1\n-2 -2 -1 3 0\...
code_contests
verifiable_code
920_F. SUM and REPLACE
Solve the following coding problem using the programming language python: Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) = 4 (6 is divisible by 1, 2, 3 and 6). You are given an array a of n integers. You have to process two types of queries...
vfc_54441
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7\n", "output": "30\n13\n4\n22\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n1 1 3 1\n1 1 4\n2 1 4\n", "output": "5...
code_contests
verifiable_code
949_D. Curfew
Solve the following coding problem using the programming language python: Instructors of Some Informatics School make students go to bed. The house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned ...
```python read = lambda: map(int, input().split()) n, d, b = read() d += 1 t, a = 0, [0] * (n + 1) for i, x in enumerate(read()): t += x a[i + 1] = t print(max(i - min(a[min(n, i * d)], (a[n] - a[max(0, n - i * d)])) // b for i in range(n + 3 >> 1))) ```
vfc_54445
{ "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": "6 1 2\n3 8 0 1 0 0\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 1\n1 0 0 0 4\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
977_C. Less or Equal
Solve the following coding problem using the programming language python: You are given a sequence of integers of length n and integer number k. You should print any integer number x in the range of [1; 10^9] (i.e. 1 ≤ x ≤ 10^9) such that exactly k elements of given sequence are less than or equal to x. Note that the...
```python # import sys # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') t = 1 # t = int(input()) while t: t -= 1 n, k = list(map(int, input().split())) a = list(map(int, input().split())) # s = input() a.sort() if k == 0: ans = a[0]-1 else: ...
vfc_54449
{ "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": "7 4\n3 7 5 1 10 3 20\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
997_A. Convert to Ones
Solve the following coding problem using the programming language python: You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones. Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a. You can apply the following operations any number of times: * ...
```python n, x, y = [int(s) for s in input().split(' ')] a = input() z = len([t for t in a.split('1') if t]) ans = max(min(z * y, y + (z - 1) * x), 0) print(ans) ```
vfc_54453
{ "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 10 1\n01000\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 2 3\n1111111\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
battle-of-two-armies
Solve the following coding problem using the programming language python: The lust for throne and power in the kingdom of Numberland has ensued a series of battles between 2 mighty armies - The Composites and The Primes. The kings decide to send their armies in waves. Both the armies consist of warriors having either ...
```python t = int(raw_input()) primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] while t>0: t -= 1 n = int(raw_input()) c = list(map(int, raw_input().split())) p = list(map(int, raw_input().split())) for i in range(0, n): if ...
vfc_54457
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n8\n5 36 8 29 89 17 22 54\n70 48 16 25 92 63 7 12\n\nSAMPLE", "output": "The Composites", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5\n56 25 14 8 8\n53 29 17 5 7\n5\n28 17 42 15 9\n...
code_contests
verifiable_code
even-odd-5
Solve the following coding problem using the programming language python: We have the following matrix 1 0 0 0 0 0 ... 2 2 0 0 0 0 ... 3 3 3 0 0 0 ... 4 4 4 4 0 0 ... 5 5 5 5 5 0 ... 6 6 6 6 6 6 ... and so on ... The matrix is created as follows, first row contains one 1 and rest 0's, second row contains 2 twos a...
```python for T in range(input()): odd = even = 0 r, c = map(int, raw_input().split()) if r <= c: if r % 2: odd = (((r+1)/2)*(1+r))/2 even = ((r/2)*(1+r))/2 else: odd = ((r/2)*(r))/2 even = ((r/2)*(2+r))/2 else: if c % 2: odd = (((c+1)/2)*(1+c))/2 + ((r-c)/2)*c even = ((c/2)*(1+c))/2 even...
vfc_54465
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3\n6 7\n10 10\n\nSAMPLE", "output": "2 1\n12 9\n30 25\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n959 933\n866 900\n831 876\n922 842\n838 936\n895 855\n919 973\n839 909\n805...
code_contests
verifiable_code
hidden-palindrome
Solve the following coding problem using the programming language python: Little Louis has recently learnt a new word in his English class which reads same from either end. He is curious to find more similar words. His naughty friend poses him a challenge which goes as follows: He gives him a long word and asks him to...
```python def check(a,i,j): while i<j: if (a[i]!=a[j]): return False i+=1 j-=1 return True t=input() while t: t-=1 s=raw_input() s=s.strip() ans=0 for i in range(len(s)): for j in range(len(s)): if (check(s,i,j)): ans=max(ans,j-i+1) print ans ```
vfc_54469
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nAfsdaydreamaerdyad \nAbcbdb\n\nSAMPLE", "output": "15\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\namacbabca\nabcdcba", "output": "7\n7", ...
code_contests
verifiable_code
magic-inversion
Solve the following coding problem using the programming language python: An inversion in an array is a pair of indices (i, j) such that A[i] > A[j] and i < j, but you are given two arrays A and B and pairs such that A[i] > B[j] and i < j is called Inversion. If total number of inversions T, is a prime number then t...
```python def isp(n): for i in range(2,int(n/2)+1): if n%i==0: return False return True n=input() a=map(int,raw_input().split()) b=map(int,raw_input().split()) c=0 i,j=0,0 while i<n-1: while i<j+1 and j<n: if a[i]>b[j]: c+=1 j+=1 i+=1 if isp(c): print "MAGIC INVERSION" else: print "SIMPLE INVERSION...
vfc_54473
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 6 7\n1 2 3\n\nSAMPLE", "output": "MAGIC INVERSION\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
next-largest-in-a-range
Solve the following coding problem using the programming language python: Given an array A(A0, A1…. An-1) of n integers. Your task is to find the smallest number larger than a given no. X in the range [l,r] inclusive. Indexing is 0 based. If there is no greater no. than X in the specified range output -1. For example...
```python t=raw_input().split() s=raw_input().split() A=[] B=[] k=0 k2=0 if len(s)==int(t[0])and int(t[0])>=1 and int(t[0])<=1000: l=int(t[1]) r=int(t[2]) n=int(t[3]) for i in range(l,r+1): if int(s[i])>=1 and int(s[i])<=pow(10,5): A.append(int(s[i])) else: k+=1 ...
vfc_54477
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 1 5 4\n1 2 3 8 15 6 7 1 8 7\n1 2 5 20\n\nSAMPLE", "output": "2\n3\n6\n-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
progression-1
Solve the following coding problem using the programming language python: NIT Raipur student 'Bhalli' have 16 numbers(non negative) which are in Arithematic Progression(Increasing AP) such that a1,a2,a3........a16(all integers). Bhalli anyhow know the value of a1+a4+a7+a10+a13+a16=n(Integer). Help Bhalli by telling hi...
```python t = input() for T in range(t): n = input() if n<45: print "INCORRECT" elif n%3 == 0: print "CORRECT" else: print "INCORRECT" ```
vfc_54481
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 \n69 \n56\n\nSAMPLE", "output": "CORRECT\nINCORRECT\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n34\n23\n45\n37\n21\n3\n22\...
code_contests
verifiable_code
sherlock-and-magic
Solve the following coding problem using the programming language python: Sherlock is following N criminals, which are right now in a 2D grid. Each criminal at t=0, decides to move in certain fixed direction. Each criminal moves with same speed. These fixed directions are North, East, West and South. Two or more crim...
```python for _ in xrange(input()): n = input() m = n D = {} C = [] i = 0 mnx, mxx, mny, mxy = 0, 0, 0, 0 for __ in xrange(n): x, y, d = raw_input().split() x = int(x) * 2 y = int(y) * 2 mxx = max(mxx, x) mxy = max(mxy, y) mnx = min(mnx, x) ...
vfc_54485
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n0 0 N\n10 10 W\n20 20 N\n30 30 E\n\nSAMPLE", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
the-confused-monk
Solve the following coding problem using the programming language python: The Monk wants to teach all its disciples a lesson about patience, since they are always in a hurry to do something crazy. To teach them this, he gives them a list of N numbers, which may or may not be distinct. The students are supposed to solv...
```python def gcd(a, b): if (b == 0): return a return gcd(b, a % b) n = int(raw_input()) l = map(int, raw_input().split()) m = reduce(lambda x, y: (x * y) % 1000000007, l) g = reduce(gcd, l) print pow(m, g, 1000000007) ```
vfc_54489
{ "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 6\n\nSAMPLE", "output": "144\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "30\n317 36 191 843 289 107 41 943 265 649 447 806 891 730 371 351 7 102 394 549 630 624 85 955 757 841 967...
code_contests
verifiable_code
xsquare-and-array-operations
Solve the following coding problem using the programming language python: Xsquare loves to play with arrays a lot. Today, he has an array A consisting of N distinct integers. He wants to perform following operation over his array A. Select a pair of consecutive integers say (Ai,Ai+1) for some 1 ≤ i < N. Replace the se...
```python test = raw_input(); test = int(test); for i in range(0, test): size = raw_input(); size = int(size); total = 0; temp_list = []; temp_list = raw_input().split(); temp_list = [int(j) for j in temp_list]; if (temp_list[0] >= temp_list[1]): total = total + temp_list[0]; ...
vfc_54493
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 2 3\n3\n1 3 2\n\nSAMPLE", "output": "5\n6", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n1 2 3\n3\n1 3 2\n\nSALPLE", "output": "5\n6\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
p00207 Block
Solve the following coding problem using the programming language python: Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1. <image> Figure 1 Mr. B is laying blocks on the board. When I asked him, "What are you making?", He replied cheerfully, "Maze !!". ...
```python import sys BLOCK_WIDTH = 4 BLOCK_HEIGHT = 2 field = [] dx = [-1, 0, 1, 0] dy = [0, 1, 0, -1] w = 0 h = 0 xg = 0 yg = 0 start_color = 0 def main(): global field, w, h, c, xg, yg, start_color while True: w, h = map(int, input().split()) if w == 0 and h == 0: break x...
vfc_54541
{ "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": "20 20\n1 1\n9 9\n7\n2 0 1 1\n5 1 1 3\n2 1 3 3\n1 1 5 2\n5 1 7 3\n2 0 2 7\n2 0 6 8\n20 20\n9 9\n1 1\n6\n2 0 1 1\n1 0 5 1\n2 1 1 3\n5 0 1 7\n3 1 5 5\n4 1 8 5\n0 0", "output": "OK\nNG", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p00721 Cleaning Robot
Solve the following coding problem using the programming language python: Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture. Consider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in ...
vfc_54553
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n...............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......
code_contests
verifiable_code
p00861 Bug Hunt
Solve the following coding problem using the programming language python: In this problem, we consider a simple programming language that has only declarations of one- dimensional integer arrays and assignment statements. The problem is to find a bug in the given program. The syntax of this language is given in BNF a...
```python import re def deref(d, expr): expr = expr.replace(']', '') symb = expr.split('[') symb[-1] = symb[-1] while len(symb) > 1: name, index = symb[-2:] if index not in d[name]: return None symb.pop() symb.pop() symb.append(d[name][index]) return symb[0] def check(s): d = ...
vfc_54557
{ "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": "a[3]\na[0]=a[1]\n.\nx[1]\nx[0]=x[0]\n.\na[0]\na[0]=1\n.\nb[2]\nb[0]=2\nb[1]=b[b[0]]\nb[0]=b[1]\n.\ng[2]\nG[10]\ng[0]=0\ng[1]=G[0]\n.\na[2147483647]\na[0]=1\nB[2]\nB[a[0]]=2\na[B[a[0]]]=3\na[2147483646]=a[2]\n.\n.", "output": ...
code_contests
verifiable_code
p01263 Reaction
Solve the following coding problem using the programming language python: You are a hero of a role playing game, asked by the king to defeat monsters threating people’s life. You have been making a long journey with your colleagues, and you are now in the town closest to the final dungeon where the head of monsters d...
vfc_54569
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n1 1\n1 1\n4\nA 10\nB 20\nC 30\nD 40\n4\n1 1 3 A A A\n1 2 2 B C\n2 1 1 D\n2 2 3 A A B\n2 2\n1 2\n2 1\n3\nScroll 50\nBastard 100\nHeal100 10\n3\n1 1 1 Scroll\n2 1 1 Bastard\n2 2 1 Heal100\n0 0", "output": "90\n200", ...
code_contests
verifiable_code
p01423 Rabbit Party
Solve the following coding problem using the programming language python: A rabbit Taro decided to hold a party and invite some friends as guests. He has n rabbit friends, and m pairs of rabbits are also friends with each other. Friendliness of each pair is expressed with a positive integer. If two rabbits are not fri...
```python #!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline(...
vfc_54573
{ "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": "3 3\n1 2 3\n2 3 1\n3 1 2", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1 2 5", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01577 Magic Walls
Solve the following coding problem using the programming language python: You are a magician and have a large farm to grow magical fruits. One day, you saw a horde of monsters, approaching your farm. They would ruin your magical farm once they reached your farm. Unfortunately, you are not strong enough to fight again...
vfc_54577
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0\n0 3\n1 1\n3 0", "output": "3.0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01739 Multi Path Story
Solve the following coding problem using the programming language python: You are a programmer who loves pretty girl games (a sub-genre of dating simulation games). A game, which is titled "Floatable Heart" and was released last Friday, has arrived at your home just now. This game has multiple stories. When you comple...
vfc_54581
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2 2\n0", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01879 About Our Effort
Solve the following coding problem using the programming language python: H: About Our Effort-About Our Effort- problem * I would appreciate it if you could consider this problem as an extra problem, and if possible, I would like you to enjoy the other problems first. I would like to challenge those who are willing ...
vfc_54585
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 1 3 2\n2\n1 3\n2 4", "output": "2\n1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02016 Twins
Solve the following coding problem using the programming language python: B: Twins One twin was angry that it was not well known which of them was the older brother and which was the younger brother. Create a program that outputs "square1001" when "ani" is entered and "e869120" when "otouto" is entered. input You ...
```python if input()=="ani": print("square1001") else: print("e869120") ```
vfc_54589
{ "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": "ani", "output": "square1001", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02299 Polygon-Point Containment
Solve the following coding problem using the programming language python: For a given polygon g and target points t, print "2" if g contains t, "1" if t is on a segment of g, "0" otherwise. g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of th...
```python def dot(c1, c2): return c1.real * c2.real + c1.imag * c2.imag def cross(c1, c2): return c1.real * c2.imag - c1.imag * c2.real def string_to_complex(s): x, y = map(int, s.split()) return x + y * 1j def contains(polygon, point): flag = False for v1, v2 in zip(polygon[0:], polygon[1:])...
vfc_54597
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0\n3 1\n2 3\n0 3\n3\n2 1\n0 2\n3 2", "output": "2\n1\n0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 0\n3 1\n2 3\n0 3\n3\n2 1\n0 2\n0 2", "output": "2\n1\n1\n", "typ...
code_contests
verifiable_code
p02446 Unique
Solve the following coding problem using the programming language python: For a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, eliminate all equivalent elements. Constraints * $1 \leq n \leq 100,000$ * $-1000,000,000 \leq a_i \leq 1,000,000,000$ * $a_0 \leq a_1 \leq ... \...
```python n = int(input()) s = { int(x) for x in input().split()} l = list(s) l.sort() print(*l) ```
vfc_54601
{ "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": "4\n1 2 2 4", "output": "1 2 4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
cd1it2
Solve the following coding problem using the programming language python: Little Chef is learning differentiation and is amazed by the function e^x as it stays the same even after differentiation. Just for fun, he tries to find out how large is the value of e^x. He is able to see only 10 digits in his calculator so he...
```python # your code goes here import math t=raw_input().split() t=int(t[0]) val = 0.4342944819032518 while(t): x=raw_input().split() x=int(x[0]) print int(x*val+1) t-=1 ```
vfc_54605
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n10\n101", "output": "1\n5\n44", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
cteams
Solve the following coding problem using the programming language python: The executive chef is trying to bring some competitive spirit into his kitchen. He wants to split the chefs into two teams based on their age - he'll form the young and the old team. To make it fair, he will split them evenly or give the young t...
```python from heapq import * def push_to_young(young, item): heappush(young, (-item[0], item[1])) def pop_from_young(young): i = heappop(young) return (-i[0], i[1]) def push_to_old(old, item): heappush(old, item) def pop_from_old(old): return heappop(old) N = int(raw_input()) young = [] old = ...
vfc_54609
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 3\n1 7\n5 5\n3 1\n8 15", "output": "3\n4\n5\n4\n9", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 3\n1 7\n4 5\n3 1\n8 15", "output": "3\n4\n5\n4\n9\n", "type": "stdin_s...
code_contests
verifiable_code
hs08test
Solve the following coding problem using the programming language python: Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each succ...
```python #!/usr/bin/python a,b=raw_input().split() a=int(a) b=float(b) if(a%5==0 and a<b-0.5): b=b-a-0.5; print "%0.2f" %b ```
vfc_54613
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "42 120.00", "output": "120.00\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
moves
Solve the following coding problem using the programming language python: Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the ...
```python import sys tokenizedInput = sys.stdin.read().split() mod=1000000007 arr=[1]*5001 for i in range(1,5001): arr[i]=(arr[i-1]*i)%mod def Power(base,expo): if(expo==0): return 1 else: if(expo&1): return(base*Power(base,expo-1)%mod) else: root=Power(bas...
vfc_54617
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n4 3\n5 3\n0 0", "output": "4\n8\n18", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
resn05
Solve the following coding problem using the programming language python: Let G(S) denote the sum of the elements of set S and F(n) be the sum of G(s) for all subsets of the set consisting of the first n natural numbers. For example, F(3) = (1) + (2) + (3) + (1 + 2) + (1 + 3) + (2 + 3) + (1 + 2 + 3) = 24. Given n...
```python def fact (a): if a==0: return 1 else: return a*fact(a-1) def f( b): sum=0 sum1=0 for i in range(b): sum=sum+ fact(b-1)/(fact(i)*fact(b-i-1)) sum1=sum1+i+1 return sum1*sum t=int(raw_input()) while(t): sum2=0 n=int(raw_input()) if(n<=22): ...
vfc_54621
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n2\n3", "output": "1\n7\n31\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1\n2\n1", "output": "1\n7\n1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
twonim
Solve the following coding problem using the programming language python: Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered 1 t...
```python t=int(raw_input()) while(t): t-=1 n=int(raw_input()) x=map(int,raw_input().split()) txor=reduce(lambda x,y:x^y,x) print "Second" if ((txor) and (n%2)) else "First" ```
vfc_54625
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 2 4 8\n3\n2 3 3\n5\n3 3 3 3 3", "output": "First\nSecond\nSecond\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4\n1 2 4 8\n3\n2 3 3\n5\n1 3 3 3 3", "output": "First\nSec...
code_contests
verifiable_code
1017_G. The Tree
Solve the following coding problem using the programming language python: Abendsen assigned a mission to Juliana. In this mission, Juliana has a rooted tree with n vertices. Vertex number 1 is the root of this tree. Each vertex can be either black or white. At first, all vertices are white. Juliana is asked to process...
vfc_54629
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 10\n1 2 1 2 5 4 5\n1 2\n3 2\n3 1\n1 1\n1 1\n3 5\n3 7\n3 4\n2 2\n3 5\n", "output": "black\nwhite\nblack\nwhite\nblack\nwhite\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 11\n1 1 2 3 ...
code_contests
verifiable_code
1041_D. Glider
Solve the following coding problem using the programming language python: A plane is flying at a constant height of h meters above the ground surface. Let's consider that it is flying from the point (-10^9, h) to the point (10^9, h) parallel with Ox axis. A glider is inside the plane, ready to start his flight at any...
```python R = lambda: map(int, input().split()) n, h = R() ps = [] for _ in range(n): l, r = R() ps.append([l, r]) l, c, res = 0, 0, 0 for r in range(n): c += (ps[r][0] - ps[r - 1][1]) if r > 0 else 0 while c >= h: c -= (ps[l + 1][0] - ps[l][1]) l += 1 res = max(res, ps[r][1] - ps[l]...
vfc_54633
{ "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 4\n2 5\n7 9\n10 11\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1000000000\n1 1000000000\n", "output": "1999999999\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
1064_C. Oh Those Palindromes
Solve the following coding problem using the programming language python: A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not. A string is called a substring of ano...
```python input() print("".join(sorted(input()))) ```
vfc_54637
{ "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": "16\ngagadbcgghhchbdf\n", "output": "aabbccddfgggghhh\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\noolol\n", "output": "llooo\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1086_A. Connect Three
Solve the following coding problem using the programming language python: The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner. Three friends, Alic...
```python s = [[int(i)for i in input().split()]for j in range(3)] s.sort() a = s[0] b = s[1] c = s[2] print(c[0] - a[0] + max(a[1], b[1], c[1]) - min(a[1], b[1], c[1]) + 1) for i in range(a[0], b[0]): print('{} {}'.format(i, a[1])) for i in range(min(a[1], b[1], c[1]), max(a[1], b[1], c[1]) + 1): print('{} {}...
vfc_54641
{ "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": "0 0\n1 1\n2 2\n", "output": "5\n0 0\n1 0\n1 1\n1 2\n2 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0\n2 0\n1 1\n", "output": "4\n0 0\n1 0\n1 1\n2 0\n", "type": "stdin_st...
code_contests
verifiable_code
1106_A. Lunar New Year and Cross Counting
Solve the following coding problem using the programming language python: Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n × n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≤ i, j ...
```python n=int(input()) a=[] for i in range(n): s=input() a.append(s) ans=0 for i in range(1,n-1): for j in range(1,n-1): if(a[i][j]=='X' and a[i-1][j-1]=='X' and a[i-1][j+1]=='X' and a[i+1][j-1]=='X' and a[i+1][j+1]=='X'): ans+=1 print(ans) ```
vfc_54645
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n.....\n.XXX.\n.XXX.\n.XXX.\n.....\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n......\nX.X.X.\n.X.X.X\nX.X.X.\n.X.X.X\n......\n", "output": "4", "type":...
code_contests
verifiable_code
1133_B. Preparation for International Women's Day
Solve the following coding problem using the programming language python: International Women's Day is coming soon! Polycarp is preparing for the holiday. There are n candy boxes in the shop for sale. The i-th box contains d_i candies. Polycarp wants to prepare the maximum number of gifts for k girls. Each gift will...
```python l=list(map(int,input().split())) n=l[0] k=l[1] l=[] b=[] for i in range (k): b.append(int(0)) l=list(map(int,input().split())) for i in l: b[i%k]+=1 sum=b[0]-b[0]%2 for i in range (1,(k+1)//2): sum+=(min(b[i],b[k-i])*2) if(k%2==0): sum+=b[k//2]-b[k//2]%2 print (sum) ```
vfc_54649
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 3\n1 2 2 3 2 4 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 2\n1 2 2 3 2 4 6 10\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
1153_E. Serval and Snake
Solve the following coding problem using the programming language python: This is an interactive problem. Now Serval is a senior high school student in Japari Middle School. However, on the way to the school, he must go across a pond, in which there is a dangerous snake. The pond can be represented as a n × n grid. T...
```python # AC import sys class Main: def __init__(self): self.buff = None self.index = 0 def next(self): if self.buff is None or self.index == len(self.buff): self.buff = sys.stdin.readline().split() self.index = 0 val = self.buff[self.index] s...
vfc_54653
{ "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\n2\n\n0\n", "output": "? 1 1 1 3\n? 2 1 2 3\n? 3 1 3 3\n? 1 1 3 1\n? 1 2 3 2\n? 1 3 3 3\n? 1 0 2 0\n! 3 0 3 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n\n1\n\n0\n\n0\n", ...
code_contests
verifiable_code
1175_D. Array Splitting
Solve the following coding problem using the programming language python: You are given an array a_1, a_2, ..., a_n and an integer k. You are asked to divide this array into k non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let f(i) be the index of subarray the ...
```python # AC import sys class Main: def __init__(self): self.buff = None self.index = 0 def next(self): if self.buff is None or self.index == len(self.buff): self.buff = self.next_line() self.index = 0 val = self.buff[self.index] self.index +=...
vfc_54657
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n3 -1 6 0\n", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 6\n-3 0 -1 -2 -2 -4 -1\n", "output": "-45", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
1210_G. Mateusz and Escape Room
Solve the following coding problem using the programming language python: Mateusz likes to travel! However, on his 42nd visit to Saint Computersburg there is not much left to sightsee. That's why he decided to go to an escape room with his friends! The team has solved all riddles flawlessly. There is only one riddle ...
vfc_54665
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 1 2\n3 0 3\n1 0 0\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 2 3\n1 2 3\n4 3 3\n4 3 3\n4 3 3\n", "output": "4\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
1231_F. Marcin and Training Camp
Solve the following coding problem using the programming language python: Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other. Let's focus on the students. They are indexed wit...
vfc_54669
{ "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": "3\n1 2 3\n1 2 3\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n3 2 3 6\n2 8 5 10\n", "output": "15\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
1252_I. Mission Possible
Solve the following coding problem using the programming language python: Allen, a government secret service, has been assigned to infiltrate a mafia secret base to uncover crucial information regarding the mafia's operations. The secret base is a rectangular bounded by (x_L,y_L), (x_L,y_R), (x_R,y_L), and (x_R,y_R) ...
vfc_54673
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 2 50 26\n4 14\n48 14\n15 13 7\n36 16 6\n46 18 3\n", "output": "\n2\n13.25 23.1234567\n36.591003 7.1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 0 0 1000 1000\n100 501\n900 501\n5...
code_contests
verifiable_code
131_C. The World is a Theatre
Solve the following coding problem using the programming language python: There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a gro...
```python from sys import stdin, stdout a, b, c = [int(a) for a in stdin.read().split()] ZA = [1, 1] for d in range(2, 31): ZA.append(d * ZA[d - 1]) e = 0 if c - b < 4: d = 4 else: d = c - b while d <= a and d < c: e = e + ZA[a] // ZA[d] // ZA[a - d] * ZA[b] // ZA[c - d] // ZA[b - c + d] d = d + 1 stdout.write(str...
vfc_54685
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 5\n", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3 5\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "28 28 ...
code_contests
verifiable_code
1338_E. JYPnation
Solve the following coding problem using the programming language python: Due to the success of TWICE, JYP Entertainment has earned countless money and emerged as the biggest entertainment firm by market capitalization. Therefore, the boss, JYP, has decided to create a new nation and has appointed you to provide a des...
vfc_54689
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n7F\n3F\n1F\n0C\n06\n03\n11\n18\n", "output": "88464\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1360_D. Buying Shovels
Solve the following coding problem using the programming language python: Polycarp wants to buy exactly n shovels. The shop sells packages with shovels. The store has k types of packages: the package of the i-th type consists of exactly i shovels (1 ≤ i ≤ k). The store has an infinite number of packages of each type. ...
```python from sys import stdin input=lambda : stdin.readline().strip() from math import ceil,sqrt,factorial,gcd for _ in range(int(input())): n,k=map(int,input().split()) if k>=n: print(1) else: l=[] s=int(sqrt(n)) for i in range(2,s+2): if n%i==0 and i<=k: l.append(n//i) t=n//i if t<=k: ...
vfc_54693
{ "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\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733\n", "output": "2\n8\n1\n999999733\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n15060 2\n", "output": "7530\n", ...
code_contests
verifiable_code
1380_E. Merging Towers
Solve the following coding problem using the programming language python: You have a set of n discs, the i-th disc has radius i. Initially, these discs are split among m towers: each tower contains at least one disc, and the discs in each tower are sorted in descending order of their radii from bottom to top. You wou...
```python import sys inpy = [int(x) for x in sys.stdin.read().split()] n, m = inpy[0], inpy[1] belong = inpy[2: 2 + n] qur = [] for i in range(m - 1): qur.append((inpy[i * 2 + 2 + n], inpy[i * 2 + 3 + n])) contain = [[] for _ in range(m + 1)] res = 0 for i in range(n -1): if belong[i] != belong[i+1]: ...
vfc_54697
{ "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": "7 4\n1 2 3 3 1 4 3\n3 1\n2 3\n2 4\n", "output": "5\n4\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10\n2 10 8 7 9 3 4 6 5 1\n10 4\n10 1\n10 6\n10 8\n10 2\n10 9\n10 7\n10 3\n10 ...
code_contests
verifiable_code
1400_E. Clear the Multiset
Solve the following coding problem using the programming language python: You have a multiset containing several integers. Initially, it contains a_1 elements equal to 1, a_2 elements equal to 2, ..., a_n elements equal to n. You may apply two types of operations: * choose two integers l and r (l ≤ r), then remove...
```python from bisect import * from collections import * from math import gcd,ceil,sqrt,floor,inf from heapq import * from itertools import * from operator import add,mul,sub,xor,truediv,floordiv from functools import * #------------------------------------------------------------------------ import os import sys from...
vfc_54701
{ "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\n1 4 1 1\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1424_E. 5G Antenna Towers
Solve the following coding problem using the programming language python: After making a strategic plan with carriers for expansion of mobile network throughout the whole country, the government decided to cover rural areas with the last generation of 5G network. Since 5G antenna towers will be built in the area of m...
vfc_54705
{ "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 3\n4 2 2 3 2 3 3 2 3\n3 3.5 2 4.5 2 4.5 3\n4 7 8 7.5 8.5 8 8 7.5 9\n5\n2 3.5 0.5\n3.3 2 0.4\n5 2.5 0.5\n7.5 8.5 0.5\n3 7 0.5\n", "output": "1.00000000 1 0\n1.50000000 2 0 1\n0.50000000 1 1\n0.25000000 1 2\n0.00000000 0\...
code_contests
verifiable_code
1445_A. Array Rearrangment
Solve the following coding problem using the programming language python: You are given two arrays a and b, each consisting of n positive integers, and an integer x. Please determine if one can rearrange the elements of b so that a_i + b_i ≤ x holds for each i (1 ≤ i ≤ n). Input The first line of input contains one ...
```python y = int(input()) for _ in range(y): q = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split()))[::-1] e = True for i in range(q[0]): if a[i] + b[i] <= q[1]: pass else: print("No") e = False ...
vfc_54709
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5\n", "output": "YES\nYES\nNO\nNO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
146_A. Lucky Ticket
Solve the following coding problem using the programming language python: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya loves tickets ver...
```python n = int(input()) s = input() print('YES' if set(s) <= {'4', '7'} and s[:len(s) // 2].count('4') == s[-(len(s) // 2):].count('4') else 'NO') ```
vfc_54713
{ "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\n4738\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n47\n", "output": "NO", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1495_C. Garden of the Sun
Solve the following coding problem using the programming language python: There are many sunflowers in the Garden of the Sun. Garden of the Sun is a rectangular table with n rows and m columns, where the cells of the table are farmlands. All of the cells grow a sunflower on it. Unfortunately, one night, the lightning...
```python import sys, os if os.environ['USERNAME']=='kissz': inp=open('in.txt','r').readline def debug(*args): print(*args,file=sys.stderr) else: inp=sys.stdin.readline def debug(*args): pass # SCRIPT STARTS HERE for _ in range(int(inp())): n,m=map(int,inp().split()) R=[] ...
vfc_54717
{ "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\n3 3\nX.X\n...\nX.X\n4 4\n....\n.X.X\n....\n.X.X\n5 5\n.X...\n....X\n.X...\n.....\nX.X.X\n1 10\n....X.X.X.\n2 2\n..\n..\n", "output": "\nXXX\n..X\nXXX\nXXXX\n.X.X\n.X..\n.XXX\n.X...\n.XXXX\n.X...\n.X...\nXXXXX\nXXXXXXXXXX\n...
code_contests
verifiable_code
1545_F. AquaMoon and Potatoes
Solve the following coding problem using the programming language python: AquaMoon has three integer arrays a, b, c of length n, where 1 ≤ a_i, b_i, c_i ≤ n for all i. In order to accelerate her potato farming, she organizes her farm in a manner based on these three arrays. She is now going to complete m operations t...
vfc_54725
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4\n1 2 3 4 5\n2 3 4 5 1\n5 1 2 3 4\n2 5\n1 2 3\n2 4\n2 5\n", "output": "3\n0\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
173_A. Rock-Paper-Scissors
Solve the following coding problem using the programming language python: Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!). Let us remind you the rules of this game. Rock-paper-scissors is played by two players. In each round the players choose one of three items independ...
```python n = int(input()) a = input() b = input() ai = 0 alen = len(a) bi = 0 blen = len(b) nik = 0 pol = 0 if alen == blen: rnd = alen else: rnd = alen*blen numofrounds = 0 for i in range(n): #print(i,rnd) if i == rnd: numofrounds = n//rnd # print(numofrounds) nik *= numofrounds ...
vfc_54729
{ "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": "7\nRPS\nRSPP\n", "output": "3 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nRRRRRRRR\nR\n", "output": "0 0", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
193_B. Xor
Solve the following coding problem using the programming language python: John Doe has four arrays: a, b, k, and p. Each array consists of n integers. Elements of all arrays are indexed starting from 1. Array p is a permutation of integers 1 to n. John invented a game for his friends and himself. Initially a player i...
vfc_54733
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 1\n7 7 7\n8 8 8\n1 2 3\n1 3 2\n", "output": "96\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
217_B. Blackboard Fibonacci
Solve the following coding problem using the programming language python: Fibonacci numbers are the sequence of integers: f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, ..., fn = fn - 2 + fn - 1. So every next number is the sum of the previous two. Bajtek has developed a nice way to compute Fibonacci numbers on a bl...
vfc_54737
{ "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": "6 10\n", "output": "2\nTBBTTB", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
241_A. Old Peykan
Solve the following coding problem using the programming language python: There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c1, c2, ..., cn. The Old Peykan wants to travel from city c1 to cn using roads. There are (n - 1) ...
```python # CF 241/A 1300 # S = supply in city i # D = distance from c[i] to c[i + 1] # k = refresh interval # min time to arrive at C[n] where n = m + 1 def f(k, D, S): n = len(D) # travel time is at least the sum of all distances time = sum(D) fuel = 0 best = 0 for i in range(n): ...
vfc_54741
{ "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 6\n1 2 5 2\n2 3 3 4\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n5 6\n5 5\n", "output": "14\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
265_E. Choosing Balls
Solve the following coding problem using the programming language python: There are n balls. They are arranged in a row. Each ball has a color (for convenience an integer) and an integer value. The color of the i-th ball is ci and the value of the i-th ball is vi. Squirrel Liss chooses some balls and makes a new sequ...
vfc_54745
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n-3 6 -1 2\n1 2 3 1\n1 -1\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n1 -2 3 4 0 -1\n1 2 1 2 1 1\n5 1\n-2 1\n1 0\n", "output": "20\n9\n4\n", "type...
code_contests
verifiable_code
289_E. Polo the Penguin and XOR operation
Solve the following coding problem using the programming language python: Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 to n, inclusive. For permutation p = p0, p1, ..., pn, Polo has defined its beauty — number <image>. Expression <image> means applying the operatio...
```python import sys from math import gcd,sqrt,ceil from collections import defaultdict,Counter,deque from bisect import bisect_left,bisect_right import math from itertools import permutations # input=sys.stdin.readline # def print(x): # sys.stdout.write(str(x)+"\n") # sys.stdin = open('input.txt', 'r') # sys.std...
vfc_54749
{ "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\n", "output": "20\n0 2 1 4 3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
314_E. Sereja and Squares
Solve the following coding problem using the programming language python: Sereja painted n points on the plane, point number i (1 ≤ i ≤ n) has coordinates (i, 0). Then Sereja marked each point with a small or large English letter. Sereja don't like letter "x", so he didn't use it to mark points. Sereja thinks that the...
vfc_54753
{ "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": "6\nabc???\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\na???\n", "output": "50\n", "type": "stdin_stdout" }, { "fn_name": null, "input...