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 | 553_E. Kyoya and Train | Solve the following coding problem using the programming language python:
Kyoya Ootori wants to take the train to get to school. There are n train stations and m one-way train lines going between various stations. Kyoya is currently at train station 1, and the school is at station n. To take a train, he must pay for a... | vfc_75201 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 5 1\n1 2 100\n50000 0 50000 0 0\n2 3 100\n10000 0 0 0 90000\n3 4 100\n100000 0 0 0 0\n2 4 100\n0 0 0 50000 50000\n",
"output": "200.7500000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... | |
code_contests | verifiable_code | 57_D. Journey | Solve the following coding problem using the programming language python:
Stewie the Rabbit explores a new parallel universe. This two dimensional universe has the shape of a rectangular grid, containing n lines and m columns. The universe is very small: one cell of the grid can only contain one particle. Each particl... | vfc_75205 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n..\n.X\n",
"output": "0.8888888889\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n...\n.X.\n...\n",
"output": "2.0000000000\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | 601_C. Kleofáš and the n-thlon | Solve the following coding problem using the programming language python:
Kleofáš is participating in an n-thlon - a tournament consisting of n different competitions in n different disciplines (numbered 1 through n). There are m participants in the n-thlon and each of them participates in all competitions.
In each o... | vfc_75209 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 10\n2\n1\n2\n1\n",
"output": "1.000000000000000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n1\n2\n3\n4\n5\n",
"output": "2.750000000000000",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | 645_E. Intellectual Inquiry | Solve the following coding problem using the programming language python:
After getting kicked out of her reporting job for not knowing the alphabet, Bessie has decided to attend school at the Fillet and Eggs Eater Academy. She has been making good progress with her studies and now knows the first k English letters.
... | ```python
import sys
range = xrange
input = raw_input
n,k = [int(x) for x in input().split()]
s = list(ord(c)-97 for c in input())
n += len(s)
last = [-1]*k
for i in range(len(s)):
last[s[i]] = i
while len(s)<n:
letter = min(range(k),key = lambda i:last[i])
last[letter] = len(s)
s.append(letter)
DP... | vfc_75217 | {
"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": "0 2\naaba\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3\nac\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
code_contests | verifiable_code | 697_E. PLEASE | Solve the following coding problem using the programming language python:
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under ... | ```python
from functools import reduce
mod = 1000000007
n = input()
numbers = list(map(int,input().split()))
flag = 1 if len(list(filter(lambda x: x%2 == 0,numbers))) else -1
b = reduce(lambda x,y:pow(x,y,mod),numbers,2)
b = b*pow(2,mod-2,mod)%mod # b = 2^n-1
a = (b+flag)*pow(3,mod-2,mod)%mod #a = (2^n-1 -/+ 1) / 3
pri... | vfc_75225 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2\n",
"output": "1/2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 1\n",
"output": "0/1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2... |
code_contests | verifiable_code | 73_C. LionAge II | Solve the following coding problem using the programming language python:
Vasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character — non-empty string s, consisting of a lowercase Latin letter... | ```python
from math import inf
s,k= input().split()
k=int(k)
dict=[[0]*26 for i in range(26)]
for i in range(int(input())):
x=input().split()
# print(ord(x[0])-97,ord(x[1])-97)
dict[ord(x[0])-97][ord(x[1])-97]=int(x[2])
dp=[[[-inf]*26 for j in range(k+2)]for i in range(len(s))]
m=-1
for i in range(26):
... | vfc_75233 | {
"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": "abcdef 1\n5\na b -10\nb c 5\nc d 5\nd e 5\ne f 5\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "winner 4\n4\ns e 7\no s 8\nl o 13\no o 8\n",
"output": "36\n",
... |
code_contests | verifiable_code | 763_A. Timofey and a tree | Solve the following coding problem using the programming language python:
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.
Now it's time for Timofey birthday, and his mother asked him to remove t... | ```python
n = int(input())
a = {}
color = {}
sec = []
for i in range(1, n+1):
a[i] = []
for i in range(n-1):
u, v = map(int, input().split())
a[u].append(v)
a[v].append(u)
sec.append((u, v))
b = list(map(int, input().split()))
def check_sub_color(current_node, color=0, parent=0):
if not colo... | vfc_75237 | {
"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\n1 2\n2 3\n3 4\n1 2 1 2\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 786_C. Till I Collapse | Solve the following coding problem using the programming language python:
Rick and Morty want to find MR. PBH and they can't do it alone. So they need of Mr. Meeseeks. They Have generated n Mr. Meeseeks, standing in a line numbered from 1 to n. Each of them has his own color. i-th Mr. Meeseeks' color is ai.
Rick and... | vfc_75241 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n1 5 7 8 1 7 6 1\n",
"output": "8 4 3 2 1 1 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 3 4 3 3\n",
"output": "4 2 1 1 1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 808_B. Average Sleep Time | Solve the following coding problem using the programming language python:
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specific... | ```python
n,k = map(int, input().split())
a = list(map(int, input().split()))
slide = a[:k]
current = sum(slide)
ans = current
for x in range(1,n-k+1):
current = current - a[x-1] + a[x + k-1]
ans += current
print("{0:.6f}".format(ans/(n-k+1)))
``` | vfc_75245 | {
"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": "8 2\n1 2 4 100000 123 456 789 1\n",
"output": "28964.285714285713766",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 853_A. Planning | Solve the following coding problem using the programming language python:
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.
Metropolis airport is the main transport h... | ```python
import heapq
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = [0]*n
h = []
for i in range(k):
h.append((-1*l[i],i))
heapq.heapify(h)
som = 0
for i in range(k,n+k):
if i < n:
heapq.heappush(h, (-1 * l[i], i))
x = heapq.heappop(h)
s = -1*x[0]*(i-x[1])
som += ... | vfc_75253 | {
"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": "5 2\n4 2 1 10 2\n",
"output": "20\n3 6 7 4 5 ",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 877_E. Danil and a Part-time Job | Solve the following coding problem using the programming language python:
Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher.
Danil works in a rooted tree (undirected connected acyclic graph) with n vertices, vertex 1 is the root of the tree.... | ```python
class LazySegTree:
def __init__(self, init_val, seg_ide, lazy_ide, f, g, h):
self.n = len(init_val)
self.num = 2**(self.n-1).bit_length()
self.seg_ide = seg_ide
self.lazy_ide = lazy_ide
self.f = f #(seg, seg) -> seg
self.g = g #(seg, lazy, size) -> seg
... | vfc_75257 | {
"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 1 1\n1 0 0 1\n9\nget 1\nget 2\nget 3\nget 4\npow 1\nget 1\nget 2\nget 3\nget 4\n",
"output": "2\n0\n0\n1\n2\n1\n1\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n1 2 3 3 5 5 7 ... |
code_contests | verifiable_code | 901_A. Hashing Trees | Solve the following coding problem using the programming language python:
Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should mat... | ```python
''' Hey stalker :) '''
INF = 10**10
def main():
print = out.append
''' Cook your dish here! '''
h = get_int()
li = get_list()
possible = False
for i in range(h):
if li[i]>1 and li[i+1]>1:
possible = True
break
if not possible:
print("perfect"... | vfc_75261 | {
"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\n1 2 2\n",
"output": "ambiguous\n0 1 1 3 3 \n0 1 1 2 3 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1 1\n",
"output": "perfect",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 923_D. Picking Strings | Solve the following coding problem using the programming language python:
Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times:
* A <image> BC
* B <image> AC
* C <image> AB
* AAA <image> empty strin... | ```python
def pref_counts(string, char):
result = [0]
for c in string:
result.append(result[-1] + (c == char))
return result
def left_counts(string, char):
result = [0]
for c in string:
result.append(result[-1] + 1 if c == char else 0)
return result
s = input().replace("C", "B"... | vfc_75265 | {
"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": "AABCCBAAB\nABCB\n5\n1 3 1 2\n2 2 2 4\n7 9 1 1\n3 4 2 3\n4 5 1 3\n",
"output": "10011",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A\nCB\n1\n1 1 1 2\n",
"output": "1",
"type": ... |
code_contests | verifiable_code | 950_F. 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 ... | vfc_75269 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "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 | 979_B. Treasure Hunt | Solve the following coding problem using the programming language python:
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they... | ```python
from collections import Counter
n = int(input())
def score(s):
return Counter(s).most_common()[0][1];
a = [input() for i in range(3)]
l = len(a[0])
a = list(map(score, a))
if n == 1:
a = list(map(lambda x: x - 1 if x == l else x + 1, a))
else:
a = list(map(lambda x: min(l, x + n), a))
print('Draw' if a.... | vfc_75273 | {
"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\nabcabc\ncbabac\nababca\n",
"output": "Katie\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\nfoPaErcvJ\nmZaxowpbt\nmkuOlaHRE\n",
"output": "Draw\n",
"type": "stdin_stdout... |
code_contests | verifiable_code | colour-queries | Solve the following coding problem using the programming language python:
NOTE: All quotes are for clarity
You are given one n x m grid and q queries. Each cell of grid will have a value assigned to it. Each query will be of type "x y d". Read below on how you have to process them.
For each query, the grid is initia... | ```python
n, m, q = [int(x) for x in raw_input().split()]
totl=0
grid=[]
visit=[]
for i in range(0,n):#rows
grid.append([int(y) for y in raw_input().split()])
def loop(x,y,dif,mx,my,count):
cval=grid[x][y];
count=1
visit[x][y]+=1
if(x>0 and visit[x-1][y]==0):
val=grid[x-1][y]
if(abs(cval-val)<=dif):
count+=... | vfc_75285 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 3\n0 0 1 0\n1 2 1 0\n0 0 1 0\n1 0 1 0\n4 4 0\n4 3 1\n2 2 2\n\nSAMPLE",
"output": "4\n16\n16\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "29 99 64\n5248 63776 10752 92000 53632 12672... |
code_contests | verifiable_code | fibo-stones | Solve the following coding problem using the programming language python:
Suresh is a fan of Mario. But being a programmer he decided to modify the game. In one module he needs your help. He modified the game as follows:
There are N stones on the way indexed from 1 to N. Every stone having index i is associated with p... | ```python
def fib(n):
f=[]
f.append(1)
f.append(1)
for i in range(2,n):
p=f[i-1]
q=f[i-2]
f.append(p+q)
#print f
return sum(f)
temp=map(int,raw_input().split())
n=temp[0]
arr=map(int,raw_input().split())
a=[]
c1=fib(n)
print c1-sum(arr)
``` | vfc_75289 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n1 1 5\n\nSAMPLE",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\n1 1 5\n\nSAPMLE",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | i-will-find-you-and-correct-you-5 | Solve the following coding problem using the programming language python:
Somnath is a Grammar Nazi. He keeps pointing out others’ grammatical mistakes. However, for a given sentence, he tries to remember all the unique words only so that he can be more efficient with his annoying habit. You wish to join his team to h... | ```python
for _ in range(int(raw_input())):
s = set(raw_input().strip().split())
print len(s)
``` | vfc_75293 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nperfection is achieved not when there is nothing more to add but when there is nothing left to take away\nyou must be the change you wish to see in the world\nif the lessons of history teach us anything it is that nobody learns ... |
code_contests | verifiable_code | manish-playning-with-bits | Solve the following coding problem using the programming language python:
Manish like to play with bits, so he was recently gifted with a puzzle book on bits arithmetic by one of his friend on his birthday.
Manish couldn't solve any of the puzzles from the book and needs your help to solve one.
Given two integers m &... | ```python
import sys
tc=int(raw_input())
for x in range(0,tc) :
(k, n) = map(int,raw_input().split())
s = [0]*(500)
s[k] = 1 # T(k, k) = 1
for i in range(k + 1, n + 1):
s[i] = 2*s[i-1] + pow(2, (i - k - 1)) - s[i-1-k]
a = s[n]
print pow(2,n)-a
``` | vfc_75297 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 3\n\nSAMPLE",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n2 3\n2 2\n2 4\n3 3\n3 5\n3 8",
"output": "5\n3\n8\n7\n24\n149",
"type": "stdin_stdout"
}
... |
code_contests | verifiable_code | number-game-1-1 | Solve the following coding problem using the programming language python:
rakesh loves to play number games. when He was surfing on google he found one of the game. The theme of the game is to find the shortest way that he can make the number equal to 1. He can only perform only three operations they are -1, /2, /3. A... | ```python
for _ in xrange(input()):
n=input()
ans=0
while n>1:
if n%3==0:
n/=3
elif n%2==0:
n/=2
else:
n-=1
ans+=1
print ans
``` | vfc_75301 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n12\n35\n\nSAMPLE",
"output": "3\n7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "40\n238472219\n222222222\n333444555\n565656563\n121\n234567853\n237483758\n212343535\n231452323\n99667... |
code_contests | verifiable_code | question-2-20 | Solve the following coding problem using the programming language python:
Problem Statement:
Nash, a high school student studies the concepts of Functions(Mathematics), for the first time.After learning the definitions of Domain and Range, he tries to find the number of functions possible,given the number of elements ... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
test = raw_input()
test = int(test)
for i in range(test):
l = raw_input()
l = l.split()
a = int(l[0])
b = int(l[1])
x = b**a
print x%1000000007
``` | vfc_75305 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "47\n428 580\n692 254\n221 613\n14 794\n116 115\n926 200\n325 265\n517 290\n219 90\n947 543\n218 544\n149 976\n28 233\n879 494\n530 715\n853 618\n5 378\n369 781\n813 967\n880 841\n610 707\n205 655\n73 468\n187 715\n442 535\n413 765\... |
code_contests | verifiable_code | shil-and-round-numbers | Solve the following coding problem using the programming language python:
Shil likes Round numbers very much . A number is called Round number if its non-negative and its first and last digits are same. For example 0 , 3 , 343 and 50005 are round numbers whereas 1000 is not a round number. Shil has an array A1 , ... | ```python
def update(x,v):
while x<=N:
bit[x]+=v
x += x&-x
def query(x):
total = 0;
while x>0:
total+=bit[x]
x -= x&-x
return total
(N,Q) = [int(s) for s in raw_input().strip().split(" ")]
S = [s for s in raw_input().strip().split(" ")]
X = []
bit = [0 for j in range(N+1)]
for i in range(N):
if S[i][0]==... | vfc_75309 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 \n1 2 33 456 111\n1 1 2\n1 1 5\n2 1 6\n2 2 1000\n1 1 5\n\nSAMPLE",
"output": "2\n4\n3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10\n999999999999980689 -999999999999985424 999999... |
code_contests | verifiable_code | the-magical-shop | Solve the following coding problem using the programming language python:
There is a magical shop owned by The Monk, which consists of magical potions. On the first day there are A number of potions. Let, potions[I] denote the number of potions present in the shop on the I^th day.
potions[I] = potions[I-1] * potio... | ```python
a,b=map(int,raw_input().split())
s=raw_input()
m,n=[0]*(len(s)),[0]*(len(s))
ans=j=sum=0
#m[j]=a
#j+=1
for i in range(len(s)):
if s[i]=='1' and i==0:
#ans=pow(,2,b)
sum+=a%b
m[j]=a
#print m[j],i
j+=1
elif s[i]=='0' and i==0:
m[j]=a
j+=1
elif s[i]=='1':
m[j]=pow(m[j-1],2,b)
sum+=m[j]%b
#... | vfc_75313 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 100\n101\n\nSAMPLE",
"output": "30\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 100\n101\n\nASMPLE",
"output": "30\n",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | zrzr | Solve the following coding problem using the programming language python:
Link to Russian translation the problem
You are given a number N. How many zeroes does N! end on?
Input
The first line contains one integer T - number of test cases.
The following T lines contain one integer each - N.
Output
For each test cas... | ```python
t=int(raw_input())
for i in xrange(t):
n=int(raw_input())
res=0
while n!=0:
res+=n/5
n=n/5
print res
``` | vfc_75317 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n9\n11\n20\n\nSAMPLE",
"output": "1\n2\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000\n0\n71\n70\n80\n41\n10\n45\n39\n45\n59\n82\n32\n65\n64\n59\n43\n59\n70\n0\n27\n86\n65\n0\n2... |
code_contests | verifiable_code | p00087 Strange Mathematical Expression | Solve the following coding problem using the programming language python:
Dr .: Peter, I've finally done it.
Peter: See you again? What kind of silly invention is this time?
Dr .: I finally came up with a revolutionary way to process mathematical formulas on a computer. Look at this table.
Ordinary notation | Dr.'s... | ```python
# Aizu Problem 0087: Strange Mathematical Expression
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def upn(inputs):
# inverse polish notation
res = 0
stack = []
for inp in inputs:
if inp in ['+',... | vfc_75361 | {
"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": "10 2 12 - /\n3 4 - 7 2 3 * + *\n-1 -2 3 + +",
"output": "-1.000000\n-13.000000\n0.000000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2 12 - /\n6 4 - 7 2 3 * + *\n-1 -2 3 + +",
"... |
code_contests | verifiable_code | p00219 A Popular Ice-cream Shop | Solve the following coding problem using the programming language python:
There is an ice cream shop named Ten Ice Cream. At this store, we always have 10 types of ice cream on the shelves. The store manager creates a daily graph showing how well ice cream is selling for reference in product development.
For such a s... | ```python
while True:
c=[0]*10
n=int(input())
if n==0:
break
for i in range(n):
a=int(input())
c[a]+=1
for i in c:
if i==0:
print("-")
else:
print("*"*i)
``` | vfc_75365 | {
"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": "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0",
"output": "*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1... |
code_contests | verifiable_code | p00597 Finding the Largest Carbon Compound Given Its Long | Solve the following coding problem using the programming language python:
An bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon with 7 carbons. It has nine isomers. Th... | ```python
# AOJ 1011: Finding the Largest Carbon Compound Give...
# Python3 2018.7.4 bal4u
a = [0]*32
a[1], a[2] = 1, 2
for i in range(3, 31): a[i] = 3*a[i-2] + 2
while True:
try: i = int(input())
except: break
print(a[i])
``` | vfc_75373 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4",
"output": "1\n8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n6",
"output": "1\n26\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00733 Dr. Podboq or: How We Became Asymmetric | Solve the following coding problem using the programming language python:
After long studying how embryos of organisms become asymmetric during their development, Dr. Podboq, a famous biologist, has reached his new hypothesis. Dr. Podboq is now preparing a poster for the coming academic conference, which shows a tree ... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def parse(S):
S = S + "$"
cur = 0
mp = {"01": 0}
sp = {"01": {0}}
sv = {"01": (0, 1)}
lbl = 1
fmt = "0{}{}1".format
def comp(left, right):
lcs, lb = left
rcs, rb = right
a0, b0 = sv[lb]
... | vfc_75377 | {
"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": "(((x x) x) ((x x) (x (x x))))\n(((x x) (x x)) ((x x) ((x x) (x x))))\n(((x x) ((x x) x)) (((x (x x)) x) (x x)))\n(((x x) x) ((x x) (((((x x) x) x) x) x)))\n(((x x) x) ((x (x x)) (x (x x))))\n((((x (x x)) x) (x ((x x) x))) ((x (x x)... |
code_contests | verifiable_code | p00873 Zigzag | Solve the following coding problem using the programming language python:
Given several points on a plane, let’s try to solve a puzzle connecting them with a zigzag line. The puzzle is to find the zigzag line that passes through all the given points with the minimum number of turns. Moreover, when there are several zi... | vfc_75381 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n0 0\n10 9\n4\n0 0\n3 1\n0 3\n3 3\n10\n2 2\n4 2\n6 2\n2 4\n4 4\n6 4\n2 6\n4 6\n6 6\n3 3\n10\n0 0\n2 0\n4 0\n0 2\n2 2\n4 2\n0 4\n2 4\n4 4\n6 8\n9\n0 0\n1 0\n3 0\n0 1\n1 1\n3 1\n0 2\n1 2\n2 2\n10\n0 0\n1 0\n0 1\n1 1\n9 9\n9 10\n10 ... | |
code_contests | verifiable_code | p01004 Balloon Contest | Solve the following coding problem using the programming language python:
Problem
The appearance of the sky is different from usual. A variety of colorful hot-air balloons covered the sky. Today is a hot-air balloon tournament. It seems that all the participants will compete for the scored ball dropped from the hot-a... | vfc_75385 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4\n10 75\n50 5\n90 75\n50 50 10 10 2\n40 90 1 1 3\n10 20 10 15 1\n50 70 50 50 4\n4 2\n25 25\n25 75\n75 75\n75 25\n50 50 10 10 1\n50 50 15 15 2\n1 1\n5 5\n1 1 1 1 1\n0 0",
"output": "5.442857\n0.750000\n1.000000",
"typ... | |
code_contests | verifiable_code | p01136 Gather the Maps! | Solve the following coding problem using the programming language python:
It is said that a legendary treasure left by Mr. Yao is sleeping somewhere in Hachioji long ago. The treasure map, which is said to show its whereabouts, has been handed down by Yao's n descendants, divided into several pieces.
Now, the descend... | ```python
while True:
n = int(input())
if n == 0:
break
days = [[] for _ in range(31)]
for i in range(n):
hima = list(map(int, input().split()))
for d in hima[1:]:
days[d].append(i)
tos = [{i} for i in range(n)]
end = {i for i in range(n)}
for i in range(31):
gather = set()
fo... | vfc_75389 | {
"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\n1 1\n2 2 3\n2 1 2\n3 3 4 5\n0",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 1\n2 2 3\n2 1 2\n3 4 4 5\n0",
"output": "-1\n",
"type": "stdin_stdout"
},... |
code_contests | verifiable_code | p01275 Dial Lock | Solve the following coding problem using the programming language python:
A dial lock is a kind of lock which has some dials with printed numbers. It has a special sequence of numbers, namely an unlocking sequence, to be opened.
You are working at a manufacturer of dial locks. Your job is to verify that every manufac... | ```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_75393 | {
"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\n1357 4680\n6\n777777 003330\n0",
"output": "1\n2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p01445 Mobile Network | Solve the following coding problem using the programming language python:
The trafic on the Internet is increasing these days due to smartphones. The wireless carriers have to enhance their network infrastructure.
The network of a wireless carrier consists of a number of base stations and lines. Each line connects tw... | ```python
import collections
class MyList(list):
def __init__(self, x=[]):
list.__init__(self, x)
def __iadd__(self, A):
ret = MyList()
for a, b in zip(self, A):
ret.append(a + b)
return ret
def __isub__(self, A):
ret = MyList()
for a, b in zip... | vfc_75397 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n1 2 x+2\n2 3 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 2\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 x^2+2x+3\n3 4 x+2\n0 0",
"output": "2x+3\n0\n2\nx+2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n... |
code_contests | verifiable_code | p01751 Yamanote Line | Solve the following coding problem using the programming language python:
Mr. A wants to get to the destination on the Yamanote line.
After getting on the train, Mr. A gets up for a minute and sleeps for b minutes repeatedly. It is c minutes after boarding to the destination, and you can get off if you are awake at t... | ```python
"山手線"
a, b, c = map(int, input().split())
flag = True
if a+b == 60 and c > a: # 必ず辿りつけない
print(-1)
else:
right = 0
left = a
i = 0
while True:
# print('left : ', left)
# print('right : ', right)
# print('c : ', c)
if left >= c and c >= right:
pr... | vfc_75405 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20 20 20",
"output": "20",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50 40 51",
"output": "111",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10... |
code_contests | verifiable_code | p01891 Cabbage | Solve the following coding problem using the programming language python:
Problem statement
AOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \ ldots, N $ in order from the outside, and the dirtiness of the $ i $ th leaf is $ D_i $. The larger this value is, the worse the degree of... | ```python
#!/usr/bin/env python3
def solve(n, m, a, b, ds):
is_waste = [False for _ in range(n)]
for i in range(n):
if ds[i] >= a:
is_waste[i] = True
else:
break
if sum(is_waste) > n - m:
for i in range(n)[::-1]:
if is_waste[i]:
i... | vfc_75409 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3 6 9\n9 7 5 3 1",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3 6 9\n9 1 5 3 1",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
code_contests | verifiable_code | p02028 Mail Order | Solve the following coding problem using the programming language python:
N: Mail order
Mr. Komozawa bought building blocks toys from Makai mail order.
The building blocks are in the shape of a cube with a side length of 1, and are stacked on squares divided into $ H $ pieces vertically and $ W $ pieces horizontally... | ```python
from bisect import bisect_left as bl
from itertools import accumulate
h, w= map(int, input().split())
aList = sorted(map(int, input().split()))
bList = list(map(int, input().split()))
acc = [0]+list(accumulate(aList))
aList.insert(0, -1)
ans = 0
for b in bList:
index = bl(aList, b)
ans += acc[index ... | vfc_75413 | {
"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": "2 2\n1 5\n1 5",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n0 5\n1 5",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | p02311 Common Tangent | Solve the following coding problem using the programming language python:
Find common tangent lines of two circles $c1$ and $c2$.
Constraints
* $-1,000 \leq c1x, c1y, c2x, c2y \leq 1,000$
* $1 \leq c1r, c2r \leq 1,000$
* $c1$ and $c2$ are different
Input
Center coordinates ($cix$, $ciy$) and radii $cir$ of two cir... | ```python
from math import acos, atan2, cos, hypot, isclose, pi, sin
from typing import List, Tuple
def tangent_points(c1x: float, c1y: float, c1r: float,
c2x: float, c2y: float, c2r: float) -> List[Tuple[float, float]]:
c1c2 = hypot(c2x - c1x, c2y - c1y)
t0 = atan2(c2y - c1y, c2x - c1x)
... | vfc_75421 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2 1\n4 2 2",
"output": "0.6666666667 1.0571909584\n0.6666666667 2.9428090416\n2.0000000000 2.0000000000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2 1\n3 2 2",
"output": "0.50... |
code_contests | verifiable_code | chfmax | Solve the following coding problem using the programming language python:
You are given a string of lower case characters. You have to find the character with the most frequency. In case there are 2 such characters, consider the one with lower ASCII value.
After this replace the character with the maximum frequency wi... | ```python
T=input();
for t in range(T) :
S=raw_input();
maxc=0;
char=-1;
for i in range(26) :
c=S.count(chr(97+i));
if c>maxc :
maxc=c;
char=i;
S=S.replace(chr(97+char),'?')
print S;
``` | vfc_75433 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\naba",
"output": "?b?",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\nabb",
"output": "a??\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | egrcake | Solve the following coding problem using the programming language python:
Chef has bought N robots to transport cakes for a large community wedding. He has assigned unique indices, from 1 to N, to each of them. How it will happen?
Chef arranges the N robots in a row, in the (increasing) order of their indices. Then, h... | ```python
def GI(): return int(raw_input())
def GIS(): return map(int, raw_input().split())
def main():
# Trying for better than O(N)
gcd = lambda a, b: gcd(b, a%b) if a%b else b
for i in xrange(GI()):
N, M = GIS()
if M == 0:
cakes_distributed = 1
else:
g = ... | vfc_75437 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 0\n2 1\n4 2",
"output": "No 1\nYes\nNo 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 0\n2 1\n4 2",
"output": "Yes\nYes\nNo 2\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | kingship | Solve the following coding problem using the programming language python:
Chef is the new king of the country Chefland. As first and most important responsibility he wants to reconstruct the road system of Chefland. There are N (1 to N) cities in the country and each city i has a population Pi. Chef wants to build som... | ```python
for _ in xrange(input()):
n = input()
p = map(int, raw_input().strip().split())
p.sort()
min = p[0]
print sum([min*p[i] for i in range(1,n)])
``` | vfc_75441 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n5 10\n4\n15 10 7 13",
"output": "50\n266\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n5 5\n4\n15 10 7 13",
"output": "25\n266\n",
"type": "stdin_stdout"
}
... |
code_contests | verifiable_code | onoz | Solve the following coding problem using the programming language python:
3:33
It's possible for all the digits displayed on a digital clock in the hours:minutes format to be identical. The time shown above (3:33) is an example of such a situation. Other examples are 2:2 and 1:11. Note that the digits of 33:33 are ide... | ```python
for _ in xrange(input()):
H, M = map(int, raw_input().split())
count = 0
for i in range(1, H):
if i < 10 or i % 11 == 0:
start = str(i)[0]
while int(start) in range(M):
count += 1
start += str(i)[0]
print count + 1
``` | vfc_75445 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 1",
"output": "19\n20\n10\n11\n10\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 2",
"output": "19... |
code_contests | verifiable_code | spit3 | Solve the following coding problem using the programming language python:
On Internet sites usually the registration form automatically checks and validate the passowrd's crypt resistance. If the user's password isn't complex enough a message is displayed. You have already implemented password validation in Web Progr... | ```python
import re
t=raw_input()
flag=1
if len(t)<5:
flag=0
regex=re.compile('[a-z]')
if len(regex.findall(t))==0:
flag=0
regex2=re.compile('[A-Z]')
if len(regex2.findall(t))==0:
flag=0
regex3=re.compile('[0-9]')
if len(regex3.findall(t))==0:
flag=0
if flag==1:
print "YES"
else:
print "NO"
``` | vfc_75449 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "SPIT_Coders_Club_2.0",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abcdefgh",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 104_D. Russian Roulette | Solve the following coding problem using the programming language python:
After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now... | ```python
n, k, p = map(int, input().split())
for i in range(p):
pos = int(input())
if n % 2:
if pos == n:
print('X' if k > 0 else '.', end='')
else:
if k * 2 > n + 1:
print('X' if (pos & 1) == 0 or (n - pos) // 2 \
+ n // 2 + 1<= ... | vfc_75461 | {
"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 1 3\n1\n2\n3\n",
"output": "..X",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 3 6\n1\n2\n3\n4\n5\n6\n",
"output": ".X.X.X",
"type": "stdin_stdout"
},
{
"fn_na... |
code_contests | verifiable_code | 1114_A. Got Any Grapes? | Solve the following coding problem using the programming language python:
[The Duck song](https://www.youtube.com/watch?v=MtN1YnoL46Q)
For simplicity, we'll assume that there are only three types of grapes: green grapes, purple grapes and black grapes.
Andrew, Dmitry and Michal are all grapes' lovers, however their ... | ```python
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 17 15:00:31 2019
@author: avina
"""
x,y,z = map(int, input().strip().split())
a,b,c = map(int,input().strip().split())
k=0
if a+b+c >= x+y+z:
if a+b >= x+y:
if a>=x:
k+=1
if k != 0:
print("YES")
else:
print("NO")
``` | vfc_75473 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 6 2\n4 3 3\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1162_D. Chladni Figure | Solve the following coding problem using the programming language python:
Inaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≤ i < n) are adjacent, and so are points n and 1.
There are m straight seg... | ```python
n, m = map(int, input().split())
a = set()
for i in range(m):
c, d = map(int, input().split())
c %= n
d %= n
a.add((min(c, d), max(c, d)))
def comprobar(x):
global a, n
b = set()
for c, d in a:
c += x
d += x
c %= n
d %= n
if (min(c, d), max(c, d)) not in a:
return False
#print("COMPAR... | vfc_75481 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 3\n1 2\n3 2\n7 2\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 6\n4 5\n5 6\n7 8\n8 9\n1 2\n2 3\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 1183_C. Computer Game | Solve the following coding problem using the programming language python:
Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k.
During each turn Vova can choose wh... | ```python
n=int(input())
for i in range(0,n):
p=input().rstrip().split(' ')
k=int(p[0])
K=k;
n=int(p[1])
CC=n;
a=int(p[2])
b=int(p[3])
T=min(a,b);
if (k%T==0):
H=(k//T)-1;
else:
H=(k//T)
if n>H:
print(-1)
else:
if k%a==0:
A=(k//... | vfc_75485 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n15 5 3 2\n15 5 4 3\n15 5 2 1\n15 5 5 1\n16 7 5 2\n20 5 7 3\n",
"output": "4\n-1\n5\n2\n0\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1000000000 499999999 3 2\n",
"output... |
code_contests | verifiable_code | 1200_D. White Lines | Solve the following coding problem using the programming language python:
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of n rows and n columns of square cells. The rows are numbered from 1 to n, from top to bottom, and the columns are numbered from 1 ... | ```python
from collections import deque
def final(ans,arr):
queue=deque()
count=0
for i in range(n):
count=0
queue=deque()
for j in range(n-1,-1,-1):
if(queue and queue[0]-j+1>k):
queue.popleft()
count=max(count-1,0)
if(i>=arr[... | vfc_75489 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1\nWW\nWW\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\nBWB\nWWB\nBWB\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1218_F. Workout plan | Solve the following coding problem using the programming language python:
Alan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift X[i] grams on day i. In order to improve his workout performance at the g... | ```python
import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]... | vfc_75493 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 10000\n10000 30000 30000 40000 20000\n20000\n5 2 8 3 6\n",
"output": "5",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1242_C. Sum Balance | Solve the following coding problem using the programming language python:
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers are d... | ```python
import sys
n = sys.stdin.readline()
n = int(n)
def get_graph(n):
graph = []
for _ in range(n):
entries = list(map(lambda x : int(x), sys.stdin.readline().split(" ")[1:]))
graph.append(entries)
return graph
def chain(target, buckets, reverse_bucket, sum_bucket, bucket_num, val):
... | vfc_75497 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 3 -2\n2 -1 5\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n3 1 7 4\n2 3 2\n2 8 5\n1 10\n",
"output": "Yes\n7 2\n2 3\n5 1\n10 4\n",
"type": "stdin_st... |
code_contests | verifiable_code | 1261_C. Arson In Berland Forest | Solve the following coding problem using the programming language python:
The Berland Forest can be represented as an infinite cell plane. Every cell contains a tree. That is, contained before the recent events.
A destructive fire raged through the Forest, and several trees were damaged by it. Precisely speaking, you... | vfc_75501 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 6\nXXXXXX\nXXXXXX\nXXXXXX\n",
"output": "1\n......\n.XXXX.\n......\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10\n.XXXXXX...\n.XXXXXX...\n.XXXXXX...\n.XXXXXX...\n.XXXXXXXX.\n...X... | |
code_contests | verifiable_code | 1283_E. New Year Parties | Solve the following coding problem using the programming language python:
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
n friends live in a city which can be represented as a number line. The i-th friend lives in a house with an integer coordinate x_i. Th... | ```python
# cook your dish here
n = int(input())
f = list(map(int, input().split()))
f.sort()
f1 = []
for i in range(n):
f1.append(f[i])
if (f1[0] > 0):
f1[0] -= 1
for i in range(1, n):
if (f1[i]-f1[i-1] > 1):
f1[i] -= 1
elif (f1[i] == f1[i-1]):
if (i == n-1 or f1[i+1] > f1[i])... | vfc_75505 | {
"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 2 4 4\n",
"output": "2 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n1 1 8 8 8 4 4 4 4\n",
"output": "3 8\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1303_A. Erasing Zeroes | Solve the following coding problem using the programming language python:
You are given a string s. Each character is either 0 or 1.
You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegment, and if the string is 01... | ```python
n=int(input())
for i in range(n):
x=input()
if '1' in x:
a=x.index('1')
c=0
for j in range(a+1,len(x)):
if x[j]=='1':
c+=x.count('0',a,j)
a=j
print(c)
else:
print(0)
``` | vfc_75509 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n010011\n0\n1111000\n",
"output": "2\n0\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n01111110\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | 1327_B. Princesses and Princes | Solve the following coding problem using the programming language python:
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LX... | ```python
t = int(input())
setups = []
for _ in range(t):
n = int(input())
setup = []
for _ in range(n):
count_and_list = input().split(" ")
if len(count_and_list) == 1:
husbands = tuple()
else:
husbands = tuple(int(x) for x in count_and_list[1:])
setu... | vfc_75513 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n4\n2 2 3\n2 1 2\n2 3 4\n1 3\n2\n0\n0\n3\n3 1 2 3\n3 1 2 3\n3 1 2 3\n1\n1 1\n4\n1 1\n1 2\n1 3\n1 4\n",
"output": "IMPROVE\n4 4 \nIMPROVE\n1 1 \nOPTIMAL\nOPTIMAL\nOPTIMAL\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 1368_B. Codeforces Subsequences | Solve the following coding problem using the programming language python:
Karl likes Codeforces and subsequences. He wants to find a string of lowercase English letters that contains at least k subsequences codeforces. Out of all possible strings, Karl wants to find a shortest one.
Formally, a codeforces subsequence ... | ```python
k = int(input())
cur = 10**18
best = []
for p in range(1, 41):
for q in range(1, 41):
for i in range(1, 10):
res = (p**i)*(q**(10-i))
if res >= k:
temp = p*i+q*(10-i)-10
if temp <= cur:
cur = temp
best... | vfc_75521 | {
"difficulty": "8",
"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\n",
"output": "codeforces",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "ccoodeforces",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1389_D. Segment Intersections | Solve the following coding problem using the programming language python:
You are given two lists of segments [al_1, ar_1], [al_2, ar_2], ..., [al_n, ar_n] and [bl_1, br_1], [bl_2, br_2], ..., [bl_n, br_n].
Initially, all segments [al_i, ar_i] are equal to [l_1, r_1] and all segments [bl_i, br_i] are equal to [l_2, r... | ```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_75525 | {
"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\n3 5\n1 2\n3 4\n2 1000000000\n1 1\n999999999 999999999\n10 3\n5 10\n7 8\n",
"output": "7\n2000000000\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10 10\n1 1\n1 1\n",
"outp... |
code_contests | verifiable_code | 140_A. New Year Table | Solve the following coding problem using the programming language python:
Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider all plates to be round and ha... | ```python
import math
x=[int(i) for i in input().split()]
n,R,r=x[0],x[1],x[2]
if r>R:
print('NO')
raise SystemExit
if 2*r>R:
if n>1:
print('NO')
raise SystemExit
else:
print('YES')
raise SystemExit
z=2*n*math.asin(r/(R-r))
if z>2*math.pi+0.0000000001:
print('NO')... | vfc_75529 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 10 10\n",
"output": "YES",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1430_E. String Reversal | Solve the following coding problem using the programming language python:
You are given a string s. You have to reverse it — that is, the first letter should become equal to the last letter before the reversal, the second letter should become equal to the second-to-last letter before the reversal — and so on. For exam... | ```python
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write i... | vfc_75533 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\naaaza\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\ncbaabc\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
code_contests | verifiable_code | 1454_A. Special Permutation | Solve the following coding problem using the programming language python:
You are given one integer n (n > 1).
Recall that a permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2, 3, 1, 5, 4] is a permutation of length 5, but [1, 2, 2] is not a permutati... | ```python
def lip(): return list(map(int,input().split()))
def splip(): return map(int,input().split())
def intip(): return int(input())
for _ in range(intip()):
n = intip()
l = [i for i in range(1,n+1)]
l = l[::-1]
mid = n//2
if n==2:
print(*l)
elif n%2!=0:
l[mid] , l[mid-1] =... | vfc_75537 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n5\n",
"output": "\n2 1\n2 1 5 3 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\... |
code_contests | verifiable_code | 1477_E. Nezzar and Tournaments | Solve the following coding problem using the programming language python:
In the famous Oh-Suit-United tournament, two teams are playing against each other for the grand prize of precious pepper points.
The first team consists of n players, and the second team consists of m players. Each player has a potential: the p... | vfc_75541 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4 3\n1 2 7\n3 4 5 6\n3 5\n1 1 10\n3 5\n",
"output": "\n-4\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 8 12\n958125 14018 215153 35195 90380 30535 204125\n591020 930598 252577 33... | |
code_contests | verifiable_code | 1505_A. Is it rated - 2 | Solve the following coding problem using the programming language python:
Interaction
This is an interactive problem. You need to read participants' queries from standard input and print your responses to standard output. You don't know the number of queries upfront, so you'll need to process them as you get them; ... | ```python
try:
while(1):
a=input()
print("NO")
except EOFError as e:
pass
``` | vfc_75545 | {
"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": "Is it rated?\nIs it rated?\nIs it rated?\n",
"output": "\nNO\nNO\nNO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Is it rated?\nIs it rated?\nIs it rated?\n",
"output": "Correct!",
... |
code_contests | verifiable_code | 1528_B. Kavi on Pairing Duty | Solve the following coding problem using the programming language python:
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with e... | ```python
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
#from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations... | vfc_75549 | {
"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\n",
"output": "\n6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
... |
code_contests | verifiable_code | 15_A. Cottage Village | Solve the following coding problem using the programming language python:
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two hou... | ```python
n,t=list(map(int,input().split()))
amount=2
houses=[]
for i in range(n):
c,l=list(map(int,input().split()))
l=l/2
start,end=c-l,c+l
houses.append([start,end])
houses.sort(key=lambda x:x[0])
prev_end=houses[0][0]
for start,end in houses:
gap=start-prev_end
if gap>t:
amount+=2
... | vfc_75553 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n0 4\n5 2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n0 4\n6 2\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 178_F1. Representative Sampling | Solve the following coding problem using the programming language python:
The Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The problem is as follows.
There is a collection of n proteins ... | vfc_75557 | {
"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": "3 2\naba\nbzd\nabq\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\neee\nrrr\nttt\nqqq\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name"... | |
code_contests | verifiable_code | 201_D. Brand New Problem | Solve the following coding problem using the programming language python:
A widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcoder.com. But there's a pro... | ```python
import itertools
def count_inversions(enumerate_seq):
tmp = list(enumerate_seq[:])
result = 0
for i in range(len(tmp)):
for j in range(len(tmp) - 1):
if tmp[j][0] > tmp[j + 1][0]:
result += 1
tmp[j], tmp[j + 1] = tmp[j + 1], tmp[j]
return r... | vfc_75561 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nfind the next palindrome\n1\n10 find the previous palindrome or print better luck next time\n",
"output": "1\n[:||||||:]\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nadd two decim... |
code_contests | verifiable_code | 226_C. Anniversary | Solve the following coding problem using the programming language python:
There are less than 60 years left till the 900-th birthday anniversary of a famous Italian mathematician Leonardo Fibonacci. Of course, such important anniversary needs much preparations.
Dima is sure that it'll be great to learn to solve the f... | ```python
import os
import sys
import traceback
def recfib(n,m):
if n == 0: return (0, 1)
a, b = recfib(n / 2,m)
c = a * ( ((2 * b) - a) % m )
d = ((b * b)%m) + ((a * a)%m)
c %= m
d %= m
if n % 2 == 0: return (c, d)
return (d, (c + d)%m,)
def fibn(n,m):
return recfib(n,m)[0]
def d_down( r,l,k ):... | vfc_75565 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 1 8 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1 8 3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | 250_A. Paper Work | Solve the following coding problem using the programming language python:
Polycarpus has been working in the analytic department of the "F.R.A.U.D." company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in... | ```python
from math import ceil
n=int(input())
reports = list(map(int,input().split()))
k=0
count=0
lst=[]
for i in reports:
count += 1
if i<0:
if k+1 > 2:
lst.append(count-1)
count=1
k=1
else:
k+=1
lst.append(count)
print(len(lst))
for i in lst:
... | vfc_75569 | {
"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\n0 -1 100 -1 0\n",
"output": "1\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n",
"output": "3\n5 3 3 ",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 275_B. Convex Shape | Solve the following coding problem using the programming language python:
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of ... | ```python
n,m = map(int, input().split())
row, col_sum, row_sum, black = [], [], [], []
for i in range(n):
row.append(input())
t = [0]
for j in range(m):
t += [t[j] + (row[i][j] == 'B')]
row_sum += [t]
d = [[0,1], [1,0], [-1,0], [0,-1]]
for i in range(n):
for j in range(m):
if row[... | vfc_75573 | {
"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\nB\nB\nW\n",
"output": "YES",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 298_D. Fish Weight | Solve the following coding problem using the programming language python:
It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk h... | ```python
n, m, k = [int(x) for x in input().split()]
alice = [int(x) for x in input().split()]
bob = [int(x) for x in input().split()]
alice.sort()
bob.sort()
balance = 0
i = n - 1
j = m - 1
while i >= 0 and j >= 0:
if alice[i] > bob[j]:
balance += 1
i -= 1
elif alice[i] < bob[j]:
ba... | vfc_75577 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 3\n2 2 2\n1 1 3\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 7 9\n5 2 7 3\n3 5 2 7 3 8 7\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 321_B. Ciel and Duel | Solve the following coding problem using the programming language python:
Fox Ciel is playing a card game with her friend Jiro.
Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's ... | ```python
n, m = map(int, input().split())
(a, d, my) = ([], [], [])
for i in range(n):
t, val = input().split()
(a if t == 'ATK' else d).append(int(val))
my = sorted([int(input()) for i in range(m)])
a.sort()
d.sort()
def solve1():
ret = 0
used = [False] * m
for val in d:
for i in rang... | vfc_75581 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\nATK 2000\nDEF 1700\n2500\n2500\n2500\n",
"output": "3000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\nATK 10\nATK 100\nATK 1000\n1\n11\n101\n1001\n",
"output": "992\n",
... |
code_contests | verifiable_code | 345_G. Suffix Subgroup | Solve the following coding problem using the programming language python:
You are given a group of n strings: s1, s2, ..., sn.
You should find a subgroup si1, si2, ..., sik (1 ≤ i1 < i2 < ... < ik ≤ n) of the group. The following two conditions must hold:
* there exists a string t such, that each string from found... | vfc_75585 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\nbb\nbb\nb\naaa\naa\nz\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 369_D. Valera and Fools | Solve the following coding problem using the programming language python:
One fine morning, n fools lined up in a row. After that, they numbered each other with numbers from 1 to n, inclusive. Each fool got a unique number. The fools decided not to change their numbers before the end of the fun.
Every fool has exactl... | vfc_75589 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n100\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 391_C3. The Tournament | Solve the following coding problem using the programming language python:
This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.
Manao decided to pursue a fighter's c... | ```python
m = 301000
ns = [0] * m
es = [0] * m
c = [0] * m
b = [0] * m
t = [0] * m
P = 0
def add(b, k):
k = t[k]
while k:
e = es[k]
if b[-1] > e: b[-1] = e
b[e] += 1
k = ns[k]
def delete(b):
for i in range(b[m - 1], m + 1):
if b[i]:
b[i] -= 1
b[-... | vfc_75593 | {
"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\n2 10\n2 10\n1 1\n3 1\n3 1\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n1 1\n1 4\n2 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 413_D. 2048 | Solve the following coding problem using the programming language python:
The programmers from the R2 company love playing 2048. One day, they decided to invent their own simplified version of this game — 2k on a stripe.
Imagine an infinite in one direction stripe, consisting of unit squares (the side of each square ... | ```python
from collections import defaultdict
def main():
n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
d = lambda: defaultdict(int)
dp0, dp1 = d(), d()
ans = 0
dp0[0] = 1
mod = 1000000007
k = 2 ** (k - 2)
for v in a:
ndp0, ndp1 = d(), d()
nan... | vfc_75597 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4\n2 0 0 4 4\n",
"output": "2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 440_A. Forgotten Episode | Solve the following coding problem using the programming language python:
Polycarpus adores TV series. Right now he is ready to finish watching a season of a popular sitcom "Graph Theory". In total, the season has n episodes, numbered with integers from 1 to n.
Polycarpus watches episodes not one by one but in a rand... | ```python
import sys
input=sys.stdin.buffer.readline
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
z=0
for i in range(0,n-1):
if arr[i]==i+1:
continue
else:
print(i+1)
z=1
break
if z==0:
print(n)
``` | vfc_75601 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n3 8 10 1 7 9 6 5 2\n",
"output": " 4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n5 2 4 3\n",
"output": " ... |
code_contests | verifiable_code | 462_C. Appleman and Toastman | Solve the following coding problem using the programming language python:
Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:
* Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to... | ```python
import heapq
n=int(input())
a=list(map(lambda x:-int(x),input().split()))
heapq.heapify(a)
ans=0
for i in range(n-1):
x=heapq.heappop(a)
y=heapq.heappop(a)
ans+=x+y
heapq.heappush(a,x+y)
print(-ans-sum(a))
``` | vfc_75605 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3 1 5\n",
"output": "26\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 486_B. OR in Matrix | Solve the following coding problem using the programming language python:
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logic... | ```python
from sys import stdin
input = stdin.readline
from heapq import heapify,heappush,heappop,heappushpop
from collections import defaultdict as dd, deque as dq,Counter as C
from math import factorial as f ,ceil,gcd,sqrt,log
from bisect import bisect_left as bl ,bisect_right as br
from itertools import combinations... | vfc_75609 | {
"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 3\n1 1 1\n1 1 1\n",
"output": "YES\n1 1 1\n1 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n1 0\n0 0\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 50_A. Domino piling | Solve the following coding problem using the programming language python:
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as t... | ```python
#domino piling
M,N=map(int,input().split())
d=(M*N)//2
print(d)
``` | vfc_75613 | {
"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 4\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 6\n",... |
code_contests | verifiable_code | 534_C. Polycarpus' Dice | Solve the following coding problem using the programming language python:
Polycarp has n dice d1, d2, ..., dn. The i-th dice shows numbers from 1 to di. Polycarp rolled all the dice and the sum of numbers they showed is A. Agrippina didn't see which dice showed what number, she knows only the sum A and the values d1, ... | ```python
n, a = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
s = 0
for i in t:
s+=i
k = []
for i in range(n):
k.append(0)
if s-a < t[i]:
k[i]+=t[i]-s+a-1
if t[i] - (a - n+1) > 0:
k[i]+=(t[i] - (a - n+1))
print(*k)
``` | vfc_75617 | {
"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": "1 3\n5\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 8\n4 4\n",
"output": "3 3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 559_C. Gerald and Giant Chess | Solve the following coding problem using the programming language python:
Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white a... | ```python
from sys import stdin
input = stdin.buffer.readline
f, inv = [1], [1, 1]
mod = 1000000007
def c(n, k):
return f[n] * inv[k] * inv[n - k] % mod
h, w, n = map(int, input().split())
for i in range(1, 200001):
f.append(f[i - 1] * i % mod)
for i in range(2, 200001):
inv.append((-(mod // i) * inv[mod % i]) % mod... | vfc_75621 | {
"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 4 2\n2 2\n2 3\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 585_A. Gennady the Dentist | Solve the following coding problem using the programming language python:
Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.
All children love to cry loudly at the reception at the dentist. We enumerate the children with integers f... | ```python
from sys import stdin
def input():
return stdin.readline()
from collections import deque as d
class Child:
def __init__(self, cry, leave, cond):
self.cry = cry
self.leave = leave
self.cond = cond
self.alive = True
N = int(input())
queue = d()
for i in range(N):
... | vfc_75625 | {
"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\n4 5 1\n5 3 9\n4 1 2\n2 1 8\n4 1 9\n",
"output": "4\n1 2 4 5 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n4 2 2\n4 1 2\n5 2 4\n3 3 5\n5 1 2\n",
"output": "2\n1 3 ",
"typ... |
code_contests | verifiable_code | 628_F. Bear and Fair Set | Solve the following coding problem using the programming language python:
Limak is a grizzly bear. He is big and dreadful. You were chilling in the forest when you suddenly met him. It's very unfortunate for you. He will eat all your cookies unless you can demonstrate your mathematical skills. To test you, Limak is go... | vfc_75633 | {
"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": "10 20 3\n15 10\n5 0\n10 5\n",
"output": "fair\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 20 1\n10 10\n",
"output": "fair\n",
"type": "stdin_stdout"
},
{
"... | |
code_contests | verifiable_code | 653_A. Bear and Three Balls | Solve the following coding problem using the programming language python:
Limak is a little polar bear. He has n balls, the i-th ball has size ti.
Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy:
* No two friends can get... | ```python
n = int(input())
s = map(int, input().split())
l = []
a = 'NO'
for i in s:
if i not in l:
l += [i]
l = sorted(l)
if len(l) >= 3:
for i in range(len(l) - 2):
if l[i] + 2 == l[i + 1] + 1 == l[i + 2]:
a = 'YES'
print(a)
``` | vfc_75637 | {
"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": "6\n40 41 43 44 44 44\n",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n5 972 3 4 1 4 970 971\n",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn... |
code_contests | verifiable_code | 678_E. Another Sith Tournament | Solve the following coding problem using the programming language python:
The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As one of them loses, his place is taken by the next random... | ```python
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO, IOBase
def main():
n = int(input())
p = [list(map(float,input().split())) for _ in range(n)]
y = 1<<n
dp = [[0]*y for _ in range(n)]
# dp[i][j] is prob of 0 win when j fought and i left
... | vfc_75641 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n0.0 0.5 0.8\n0.5 0.0 0.4\n0.2 0.6 0.0\n",
"output": "0.68\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0.0 1.0 1.0 1.0\n0.0 0.0 0.0 0.0\n0.0 1.0 0.0 0.0\n0.0 1.0 1.0 0.0\n",
... |
code_contests | verifiable_code | 700_E. Cool Slogans | Solve the following coding problem using the programming language python:
Bomboslav set up a branding agency and now helps companies to create new logos and advertising slogans. In term of this problems, slogan of the company should be a non-empty substring of its name. For example, if the company name is "hornsandhoo... | vfc_75645 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11\nabracadabra\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nabc\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... | |
code_contests | verifiable_code | 723_A. The New Year: Meeting Friends | Solve the following coding problem using the programming language python:
There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the third friend lives at the point x3. They plan to celebrate the New Year together, so they... | ```python
a=list(map(int,input().split()))
a.sort()
if len(a)%2!=0:
s=a[int(len(a)/2)]
count=0
for x in a:
count+=abs(x-s)
print(count)
``` | vfc_75649 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 1 4\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "30 20 10\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
code_contests | verifiable_code | 744_E. Hongcow Masters the Cyclic Shift | Solve the following coding problem using the programming language python:
Hongcow's teacher heard that Hongcow had learned about the cyclic shift, and decided to set the following problem for him.
You are given a list of n strings s1, s2, ..., sn contained in the list A.
A list X of strings is called stable if the f... | vfc_75653 | {
"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\na\nab\nb\nbba\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\naab\nab\nbba\nb\nab\nc\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_... | |
code_contests | verifiable_code | 768_B. Code For 1 | Solve the following coding problem using the programming language python:
Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so he can return and take the deceased Aemon... | ```python
'''
Auther: ghoshashis545 Ashis Ghosh
College: jalpaiguri Govt Enggineering College
Date:08/06/2020
'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,ins... | vfc_75657 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 2 5\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 3 10\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1... |
code_contests | verifiable_code | 792_A. New Bus Route | Solve the following coding problem using the programming language python:
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.
It is possible to get from one city to another only by bus. But al... | ```python
n = int(input())
array = list(map(int, input().split()))
array = sorted(array)
mink = array[-1] - array[0]
count = 0
for i in range(1, len(array)):
if mink > array[i] - array[i-1]:
mink = array[i] - array[i-1]
count = 1
elif mink == array[i] - array[i-1]:
count += 1
print(mink... | vfc_75661 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n-2 0 2\n",
"output": "2 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n6 -3 0 4\n",
"output": "2 1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 812_C. Sagheer and Nubian Market | Solve the following coding problem using the programming language python:
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost ai Egyptian p... | ```python
n,m1=map(int,input().split())
lp=list(map(int,input().split()))
l=0
r=n
while l<r :
m=(l+r+1)//2
l1=lp[::]
for i in range(n) :
l1[i]=lp[i]+((i+1)*m)
l1=sorted(l1)
s=sum(l1[:m])
if s>m1 :
r=m-1
else :
l=m
l1=lp[::]
for i in range(n) :
l1[i]=lp[i]+((i+1)*l... | vfc_75665 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 100\n1 2 5 6\n",
"output": "4 54",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 11\n2 3 5\n",
"output": "2 11",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 838_C. Future Failure | Solve the following coding problem using the programming language python:
Alice and Bob are playing a game with a string of characters, with Alice going first. The string consists n characters, each of which is one of the first k letters of the alphabet. On a player’s turn, they can either arbitrarily permute the char... | vfc_75669 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2 100000007\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "123456 26 330502547\n",
"output": "122021241\n",
"type": "stdin_stdout"
},
{
"fn_n... | |
code_contests | verifiable_code | 858_F. Wizard's Tour | Solve the following coding problem using the programming language python:
All Berland residents are waiting for an unprecedented tour of wizard in his Blue Helicopter over the cities of Berland!
It is well-known that there are n cities in Berland, some pairs of which are connected by bidirectional roads. Each pair of... | vfc_75673 | {
"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": "4 5\n1 2\n3 2\n2 4\n3 4\n4 1\n",
"output": "2\n4 3 2\n4 2 1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 883_L. Berland.Taxi | Solve the following coding problem using the programming language python:
Berland.Taxi is a new taxi company with k cars which started operating in the capital of Berland just recently. The capital has n houses on a straight line numbered from 1 (leftmost) to n (rightmost), and the distance between any two neighboring... | vfc_75677 | {
"difficulty": "19",
"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 1\n1 5\n10 3 5\n",
"output": "1 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2 2\n1 5\n10 3 5\n20 4 1\n",
"output": "1 2\n2 1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 908_A. New Year and Counting Cards | Solve the following coding problem using the programming language python:
Your friend has n cards.
You know that each card has a lowercase English letter on one side and a digit on the other.
Currently, your friend has laid out the cards on a table so only one side of each card is visible.
You would like to know if... | ```python
s = list(input())
d = {'a', 'u', 'o', 'e', 'i', '1', '3', '5', '7', '9'}
ans = 0
for i in s:
if i in d:
ans += 1
print(ans)
``` | vfc_75681 | {
"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": "ee\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "z\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0ay1\n",
... |
code_contests | verifiable_code | 928_D. Autocompletion | Solve the following coding problem using the programming language python:
Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.
Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires o... | ```python
# python3
# utf-8
class Trie:
def __init__(self):
self.letter___node = {}
self.words_nr = 0
def add_word(self, word):
word = word + '$'
curr_node = self
for letter in word:
if letter not in curr_node.letter___node:
curr_node.letter_... | vfc_75685 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "'co-co-co, codeforces?!'\n",
"output": "25\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "snow affects sports such as skiing, snowboarding, and snowmachine travel.\nsnowboarding is a recr... |
code_contests | verifiable_code | 958_A1. Death Stars (easy) | Solve the following coding problem using the programming language python:
The stardate is 1977 and the science and art of detecting Death Stars is in its infancy. Princess Heidi has received information about the stars in the nearby solar system from the Rebel spies and now, to help her identify the exact location of ... | ```python
n=int(input())
a=[]
b=[]
for i in range(n):
a.append(input())
for i in range(n):
b.append(input())
def h(d):
c=[]
for i in range(n):
c.append(d[n-i-1])
return c
def r(d):
c=[]
for i in range(n):
temp=""
for j in range(n):
temp+=d[j][n-i-1]
... | vfc_75689 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nXOOO\nXXOO\nOOOO\nXXXX\nXOOO\nXOOO\nXOXO\nXOXX\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\nXX\nOO\nXO\nOX\n",
"output": "No\n",
"type": "stdin_stdo... |
code_contests | verifiable_code | a-needle-in-the-haystack-1 | Solve the following coding problem using the programming language python:
Our hacker, Little Stuart lately has been fascinated by ancient puzzles. One day going through some really old books he finds something scribbled on the corner of a page. Now Little Stuart believes that the scribbled text is more mysterious than... | ```python
t=int(raw_input())
while(t>0):
s=raw_input()
str=raw_input()
s2=s[::-1]
if s in str or s2 in str:
print "YES"
else:
print "NO"
t-=1
``` | vfc_75697 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nhack\nindiahacks\ncode\neddy\ncoder\niamredoc\n\nSAMPLE",
"output": "YES\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nhacj\nindiahacks\ncode\neddy\ncoder\niamredoc\n\nSAM... |
code_contests | verifiable_code | birthday-party | Solve the following coding problem using the programming language python:
My flatmate, Sayan, once invited all his relatives and friends from all over the city to join him on his birthday party.
He is also famous for boasting that all his friends and relatives belong to "proper" families.
Now, he appointed a gaurd to ... | ```python
from collections import Counter as C
t=int(raw_input())
def positiveSubsetSum( A, x ):
# preliminary
if x < 0 or x > sum( A ): # T = sum(A)
return 0
# algorithm
sub_sum = [0] * ( x + 1 )
sub_sum[0] = 1
p = 0
while not sub_sum[x] and p < len( A ):
a = A[p]
q = ... | vfc_75701 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n8 3\n1 2 8\n2 2 2 3 4 4 4 4\n10 3\n2 4 6\n2 9 9 9 19 19 19 19 19 20\n\nSAMPLE",
"output": "2\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n899 188\n8 12 19 22 27 28 29 34 35 38 42... |
code_contests | verifiable_code | crazy-kangaroo | Solve the following coding problem using the programming language python:
Little Jhool is a world renowned kangaroo trainer. He's now living in Australia, and is training kangaroos for his research project on mobile soccer. (We don't know the connection, too.) Anyway, for the project to be completed he observes kanga... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
count = int(raw_input())
for i in range(count):
val = map(int, raw_input().split(" "))
B = val[1]
A = val[0]
M = val[2]
print (B/M)-(A-1)/M
``` | vfc_75705 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 10 2\n5 10 3\n7 9 5SAMPLE",
"output": "5\n2\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000\n99617 152603 778\n99085 150178 336\n99614 152906 650\n99579 150491 28\n99310 149769 ... |
code_contests | verifiable_code | flip-flop-5 | Solve the following coding problem using the programming language python:
Deepak like strings which are in flip flop in nature. For example, he likes XYXYX, while he doesn't like XXYX. Now he want to convert every string into a string which he likes. for this, he only delete the character in the string.
Now find the ... | ```python
n=input()
for nn in range(n):
s=raw_input()
last=s[0]
cnt=0
for c in s[1:]:
if c==last: cnt+=1
last=c
print cnt
``` | vfc_75709 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nXXXX\nYYYYY\nXYXYXYXY\nYXYXYX\nXXXYYY\n\nSAMPLE",
"output": "3\n4\n0\n0\n4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | jal-mahal-lake | Solve the following coding problem using the programming language python:
Jal Mahal Lake is famous tourist place in Jaipur. The lake has floating planks in a straight line. The planks are currently not attached to each other, and there may be gaps between some of them. You have to push them all together and connect th... | ```python
for _ in xrange(input()):
n=input()
pos=map(int,raw_input().split())
sz=map(int,raw_input().split())
a=[]
for i in xrange(n):
a.append([pos[i],sz[i]])
a.sort()
tmp=a[0][0]+a[0][1]
ans=0
for i in xrange(1,n):
ans+=a[i][0]-tmp
tmp+=a[i][1]
for z in xrange(1,n):
t=0
tmp=a[z][0]+a[z][1]
for ... | vfc_75713 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n1 3 10 20\n2 2 5 3\n3\n100 50 1\n10 2 1\n\nSAMPLE",
"output": "15\n96",
"type": "stdin_stdout"
}
]
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.