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 | 1492_C. Maximum width | Solve the following coding problem using the programming language python:
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: s of length n and t of length m.
A sequence p_1, p_2, …, p_m, where 1 ≤ p_1 < p_2 < … < p_m ≤ n, is called beautiful, if s_{p_i}... | ```python
n,m=map(int,input().split())
s=input()
t=input()
l=[0]*m
r=[0]*m
i,j=0,0
while j<m:
if s[i]==t[j]:
l[j]=i
j+=1
i+=1
i=n-1
j=m-1
while j>0:
if s[i]==t[j]:
r[j]=i
j-=1
i-=1
print(max(r[i+1]-l[i] for i in range(m-1)))
``` | vfc_56381 | {
"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": "5 2\naaaaa\naa\n",
"output": "\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\nab\nab\n",
"output": "\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1515_D. Phoenix and Socks | Solve the following coding problem using the programming language python:
To satisfy his love of matching socks, Phoenix has brought his n socks (n is even) to the sock store. Each of his socks has a color c_i and is either a left sock or right sock.
Phoenix can pay one dollar to the sock store to either:
* reco... | ```python
from collections import defaultdict
t = int(input())
while t!=0:
t=t-1
n,l,r = map(int,input().split())
list1 = list(map(int,input().split()))
d1 = defaultdict(int)
d2 = defaultdict(int)
for i in range(l):
d1[list1[i]]+=1
for i in range(l,n):
d2[list1[i]]+=1
... | vfc_56385 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n6 3 3\n1 2 3 2 2 2\n6 2 4\n1 1 2 2 2 2\n6 5 1\n6 5 4 3 2 1\n4 0 4\n4 4 4 3\n",
"output": "\n2\n3\n5\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n6 3 3\n1 2 6 2 2 2\n6 2 4\n1 1 ... |
code_contests | verifiable_code | 1542_C. Strange Function | Solve the following coding problem using the programming language python:
Let f(i) denote the minimum positive integer x such that x is not a divisor of i.
Compute ∑_{i=1}^n f(i) modulo 10^9+7. In other words, compute f(1)+f(2)+...+f(n) modulo 10^9+7.
Input
The first line contains a single integer t (1≤ t≤ 10^4), t... | ```python
def gcd(a,b):
"""Compute the greatest common divisor of a and b"""
while b > 0:
a, b = b, a % b
return a
def lcm(a, b):
"""Compute the lowest common multiple of a and b"""
return a * b // gcd(a, b)
t=int(input())
for _ in range(t):
n=int(input())
mod=10**9+7
l=1
... | vfc_56389 | {
"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": "6\n1\n2\n3\n4\n10\n10000000000000000\n",
"output": "2\n5\n7\n10\n26\n366580019\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4642392862013167\n",
"output": "1048\n",
"type... |
code_contests | verifiable_code | 16_C. Monitor | Solve the following coding problem using the programming language python:
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular ... | ```python
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.... | vfc_56393 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 0, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1 1 2\n",
"output": "0 0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "800 600 4 3\n",
"output": "800 600",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 190_A. Vasya and the Bus | Solve the following coding problem using the programming language python:
One day Vasya heard a story: "In the city of High Bertown a bus number 62 left from the bus station. It had n grown-ups and m kids..."
The latter events happen to be of no importance to us. Vasya is an accountant and he loves counting money. So... | ```python
class CodeforcesTask190ASolution:
def __init__(self):
self.result = ''
self.passengers = []
def read_input(self):
self.passengers = [int(x) for x in input().split(" ")]
def process_task(self):
if self.passengers[0]:
if self.passengers[0] >= self.passen... | vfc_56397 | {
"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": "0 5\n",
"output": "Impossible\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 214_A. System of Equations | Solve the following coding problem using the programming language python:
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given... | ```python
n,m = map(int,input().split())
a = 0
for i in range(0, 1000):
for j in range(0, 1000):
if i * i + j == n and j * j + i == m:
a = a + 1
print(a)
``` | vfc_56401 | {
"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": "14 28\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 3\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 20\n",
... |
code_contests | verifiable_code | 238_A. Not Wool Sequences | Solve the following coding problem using the programming language python:
A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive... | ```python
n, m = map(int, input().split())
MOD = 10 ** 9 + 9
ans = pow(2, m, MOD) - 1
step = pow(2, m, MOD) - 2
for i in range(n - 1):
ans = (ans * step) % MOD
step -= 1
while ans < 0:
ans += MOD
while ans >= MOD:
ans -= MOD
print(ans)
``` | vfc_56405 | {
"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 2\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 262_D. Maxim and Restaurant | Solve the following coding problem using the programming language python:
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant from 1 to n. Maxim knows the... | ```python
n=int(input())
arr=list(map(int,input().split()))
p=int(input())
dp=[[[0 for k in range(n+1)] for i in range(p+1)] for i in range(n+1)]
for j in range(p+1):
for k in range(n+1):
dp[0][j][k]=1
for i in range(1,n+1):
for j in range(p+1):
for k in range(1,n+1):
if j>=arr[k-1]:... | vfc_56409 | {
"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\n1 2 3\n3\n",
"output": "1.3333333333\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n20\n",
"output": "20\n",
"type": "stdin_std... |
code_contests | verifiable_code | 286_D. Tourists | Solve the following coding problem using the programming language python:
A double tourist path, located at a park in Ultima Thule, is working by the following principle:
* We introduce the Cartesian coordinate system.
* At some points of time there are two tourists going (for a walk) from points ( - 1, 0) and (... | vfc_56413 | {
"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\n0 3 4\n0 1 2\n2 4 0\n1 3 4\n",
"output": "2\n4\n4\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 334_B. Eight Point Sets | Solve the following coding problem using the programming language python:
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except fo... | ```python
a = []
for i in range(8):
x, y = map(int, input().split())
a.append((x, y))
a.sort()
if a[0][1] != a[1][1] and a[1][1] != a[2][1] and a[2][1] != a[0][1]:
if a[0][0] != a[3][0] and a[3][0] != a[5][0] and a[5][0] != a[0][0]:
if a[0][0] == a[1][0] == a[2][0]:
if a[3][0] == a[4][0]... | vfc_56421 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n",
"output": "ugly",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0\n",
"output": "ugly",
"type": "s... |
code_contests | verifiable_code | 357_B. Flag Day | Solve the following coding problem using the programming language python:
In Berland, there is the national holiday coming — the Flag Day. In the honor of this event the president of the country decided to make a big dance party and asked your agency to organize it. He has several conditions:
* overall, there must ... | ```python
#! /usr/bin/env python
n, m = [int(x) for x in input().split()]
dancers = {}
for i in range(m):
dance = [int (x) for x in input().split()]
for j in range(3):
if dance[j] not in dancers:
dancers[dance[j]] = j
else:
dancers[dance[(j + 1) % 3]] = (dancers[dance[j]... | vfc_56425 | {
"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": "7 3\n1 2 3\n1 4 5\n4 6 7\n",
"output": "1 2 3 2 3 1 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 3\n3 6 9\n2 5 8\n1 4 7\n",
"output": "1 1 1 2 2 2 3 3 3\n",
"type": "std... |
code_contests | verifiable_code | 497_A. Removing Columns | Solve the following coding problem using the programming language python:
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second... | ```python
from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
return list(map(int,input().split()))
def ma():
return map(int,input().split())
def inp():
return int(input())
def fk(a,s,k):
b=[]
for i in range(len(a)):
... | vfc_56449 | {
"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\ncodeforces\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\ncase\ncare\ntest\ncode\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn... |
code_contests | verifiable_code | 520_C. DNA Alignment | Solve the following coding problem using the programming language python:
Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences.
Let's assume that strings s and t have the same length... | ```python
import sys
# sys.stdin = open('in.txt')
R = lambda: map(int, input().split())
n = int(input())
s = input()
ca = s.count('A')
cg = s.count('G')
cc = s.count('C')
ct = s.count('T')
mx = max(ca, cg, cc, ct)
sum = (ca==mx)+(cg==mx)+(cc==mx)+(ct==mx)
ans = 1
for i in range(n):
ans = (ans*sum)%1000000007
... | vfc_56453 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nAG\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 547_E. Mike and Friends | Solve the following coding problem using the programming language python:
What-The-Fatherland is a strange country! All phone numbers there are strings consisting of lowercase English letters. What is double strange that a phone number can be associated with several bears!
In that country there is a rock band called ... | vfc_56457 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\na\nab\nabab\nababab\nb\n1 5 1\n3 5 1\n1 5 2\n1 5 3\n1 4 5\n",
"output": "7\n5\n6\n3\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3\nf\n1 1 1\n1 1 1\n1 1 1\n",
"output": ... | |
code_contests | verifiable_code | 595_E. Edo and Magnets | Solve the following coding problem using the programming language python:
Edo has got a collection of n refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door mus... | ```python
from sys import*
#
def check(u, d, l, r):
used = [pointsx[i][1] for i in range(l)]
used += [pointsx[-1 - i][1] for i in range(r)]
used += [pointsy[i][1] for i in range(u)]
used += [pointsy[-1 - i][1] for i in range(d)]
if len(set(used)) > k:
return DOHERA
dx = pointsx[-1 - r][0... | vfc_56465 | {
"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": "4 1\n1 1 2 2\n1 9 2 10\n9 9 10 10\n9 1 10 2\n",
"output": "64",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n1 1 2 2\n2 2 3 3\n3 3 4 4\n",
"output": "1",
"type": "stdin_std... |
code_contests | verifiable_code | 617_B. Chocolate | Solve the following coding problem using the programming language python:
Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between... | ```python
n = int(input())
a = list(map(int, input().split()))
k = sum(a)
if k == 0:
print(0)
exit()
oneMet = False
d = 1
p = 0
for i in range(n):
if a[i] == 1:
p += 1
if oneMet:
d *= p
oneMet = True
p = 0
k -= 1
if k == 0:
break
if a[i] ==... | vfc_56469 | {
"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\n0 1 0\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 0 1 0 1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 637_C. Promocodes with Mistakes | Solve the following coding problem using the programming language python:
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquit... | ```python
n = int(input())
codes = []
max_matches = 0
for i in range(n):
codes.append(input())
for i in range(n - 1):
for j in range(i + 1, n):
matches = 0
for num in range(6):
if codes[i][num] == codes[j][num]:
matches += 1
max_matches = max(max_matches, matc... | vfc_56473 | {
"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\n000000\n999999\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n211111\n212111\n222111\n111111\n112111\n121111\n",
"output": "0",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 665_C. Simple Strings | Solve the following coding problem using the programming language python:
zscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.
zscoder is given a string s. He wants to change a minimum numbe... | ```python
s=list(input())
n=len(s)
def call(a,b):
str="anfrozeyuibiu"
for i in str:
if i!=a and i!=b:
return i
def call1(a):
str="urweifbn"
for i in str:
if i!=a:
return i
for i in range(1,n):
if s[i]==s[i-1]:
if i==n-1:
s[i]=call1(s[i])
... | vfc_56477 | {
"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": "zscoder\n",
"output": "zscoder\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aab\n",
"output": "acb\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | 68_A. Irrational problem | Solve the following coding problem using the programming language python:
Little Petya was given this problem for homework:
You are given function <image> (here <image> represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x) = x.
It is a pity... | ```python
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from itertools import (
accumulate, combinations, combinations_with_replacement, groupby,
permutations, product)
fr... | vfc_56481 | {
"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 7 1 8 2 8\n",
"output": "0",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 711_D. Directed Roads | Solve the following coding problem using the programming language python:
ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered from 1 to n.
There are n directed roads in the Udayland. i-th of them goes from town i to some other town ai (ai ≠ i... | ```python
class Solution():
def __init__(self):
self.n = int(input())
self.G = [ int(x) for x in input().strip().split(' ') ]
self.G.insert(0,0)
self.used = [0 for i in range(self.n+1)]
self.dis = [0 for i in range(self.n+1)]
self.circle = []
self.mod = 10**... | vfc_56485 | {
"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\n2 3 1\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 1 1 1\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 732_D. Exams | Solve the following coding problem using the programming language python:
Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.
About every day we know exam for which one of m subjects can be passed on that day. Perhaps, some day you can't pa... | ```python
import math
global n,m,d,a
d=[]
a=[]
def intdec(x):
return int(x)-1
def check(x):
global n,m,d,a
vis=[0]*m
seq=[]
h=0; cnt=0
for i in range(x,-1,-1):
if d[i]<0 or vis[d[i]]:
if len(seq)<=h:
pass
else:
cnt+=1
... | vfc_56489 | {
"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": "7 2\n0 1 0 2 1 0 2\n2 1\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 3\n0 0 1 2 3 0 2 0 1 2\n1 1 4\n",
"output": "9\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 756_E. Byteland coins | Solve the following coding problem using the programming language python:
There are n types of coins in Byteland. Conveniently, the denomination of the coin type k divides the denomination of the coin type k + 1, the denomination of the coin type 1 equals 1 tugrick. The ratio of the denominations of coin types k + 1 a... | vfc_56493 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n4 4\n2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n\n4\n2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... | |
code_contests | verifiable_code | 778_A. String Game | Solve the following coding problem using the programming language python:
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t ... | ```python
import math as mt
import sys,string
input=sys.stdin.readline
import random
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
def isSubseq(s,b,v):
i=0
j=0
while(i<len(s) a... | vfc_56497 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "bbbabb\nbb\n1 6 3 4 2 5\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ababcba\nabb\n5 3 4 1 7 6 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 802_D. Marmots (easy) | Solve the following coding problem using the programming language python:
Heidi is a statistician to the core, and she likes to study the evolution of marmot populations in each of V (1 ≤ V ≤ 100) villages! So it comes that every spring, when Heidi sees the first snowdrops sprout in the meadows around her barn, she im... | vfc_56501 | {
"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": "2\n92 100 99 109 93 105 103 106 101 99 ... (input is truncated)\n28 180 147 53 84 80 180 85 8 16 ... (input is truncated)",
"output": "uniform\nuniform\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | 822_F. Madness | Solve the following coding problem using the programming language python:
The second semester starts at the University of Pavlopolis. After vacation in Vičkopolis Noora needs to return to Pavlopolis and continue her study.
Sometimes (or quite often) there are teachers who do not like you. Incidentally Noora also has ... | vfc_56505 | {
"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\n1 2\n2 3\n",
"output": "2\n1 1 1 2 0.0000000000\n1 2 2 3 0.0000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "60\n23 32\n34 51\n39 43\n26 53\n33 18\n25 1\n37 1\n45 60\n5 11\n39 ... | |
code_contests | verifiable_code | 847_K. Travel Cards | Solve the following coding problem using the programming language python:
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate st... | ```python
import heapq
import sys
num_trips, a, b, k, f = sys.stdin.readline().strip().split(" ")
a, b, k, f = int(a), int(b), int(k), int(f)
#print(a, b, k, f)
trips = []
for line in sys.stdin:
trips.append(line.strip().split(" "))
"""
a = 5
b = 3
k = 1
f = 8
trips = [["BerBank", "University"],
["University", "... | vfc_56509 | {
"difficulty": "17",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2 1 300 1000\na A\nA aa\naa AA\nAA a\n",
"output": "5",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 86_A. Reflection | Solve the following coding problem using the programming language python:
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. No... | ```python
def ref(n):
return int(''.join([str(9-int(x)) for x in str(n)]))
l,r=map(int,input().split())
ans=0
ans=max(ans,ref(l)*l)
ans=max(ans,ref(r)*r)
cur=5
for i in range(20):
if(l<=cur<=r):
ans=max(ans,ref(cur)*cur)
cur*=10
print(ans)
``` | vfc_56513 | {
"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": "8 10\n",
"output": "890\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 7\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1... |
code_contests | verifiable_code | 917_A. The Monster | Solve the following coding problem using the programming language python:
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Ups... | ```python
import sys
import math
input = sys.stdin.readline
from functools import cmp_to_key;
def pi():
return(int(input()))
def pl():
return(int(input(), 16))
def ti():
return(list(map(int,input().split())))
def ts():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().... | vfc_56521 | {
"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": "((?))\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "??()??\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "(?... |
code_contests | verifiable_code | 93_A. Frames | Solve the following coding problem using the programming language python:
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbi... | ```python
n, m, a, b = map(int, input().split())
a -= 1
x, y = a % m, b % m
d = b // m - a // m
if b == n and y: d += 1
u, v = x == 0, y == 0 or b == n
print(1 if u and v or d <= v else 2 if x == y or u or v or d == 1 else 3)
``` | vfc_56525 | {
"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": "20 5 2 20\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11 4 3 9\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
code_contests | verifiable_code | 965_D. Single-use Stones | Solve the following coding problem using the programming language python:
A lot of frogs want to cross a river. A river is w units width, but frogs can only jump l units long, where l < w. Frogs can also jump on lengths shorter than l. but can't jump longer. Hopefully, there are some stones in the river to help them.
... | ```python
w, l = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = res = sum(a[:l])
for i in range(l, w - 1):
s += a[i] - a[i - l]
res = min(res, s)
print(res)
``` | vfc_56529 | {
"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": "10 3\n1 1 1 1 2 1 1 1 1\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5\n0 0 1 0 2 0 0 1 0\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 992_D. Nastya and a Game | Solve the following coding problem using the programming language python:
Nastya received one more array on her birthday, this array can be used to play a traditional Byteland game on it. However, to play the game the players should first select such a subsegment of the array that <image>, where p is the product of al... | ```python
from sys import stdin
import math
# stdin = open('in')
n, k = map(int, stdin.readline().split())
a = [int(x) for x in stdin.readline().split()]
nxt = [-1]*n
pref = []
f, s = -1, 0
for i in range(n):
s += a[i]
pref.append(s)
nxt[n-1-i] = f
if a[n-1-i] != 1:
f = n-1-i
ans = 0
for i in range(n):
pos, cur... | vfc_56533 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n6 3 8 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | ascii-value | Solve the following coding problem using the programming language python:
Given a character C, print the ASCII value of that character.
Input:
First and only line in input contains a character C.
Output:
Print the ASCII value of the character C.
Constraints:
C ∈ ASCII characters
SAMPLE INPUT
b
SAMPLE OUTPUT
98... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
k=raw_input()
print ord(k)
``` | vfc_56537 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "b\n\nSAMPLE",
"output": "98\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "a",
"output": "97\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4",... |
code_contests | verifiable_code | chess-lovers | Solve the following coding problem using the programming language python:
Programmers generally love to play chess! You too have recently acquired an interest in playing chess and you find bishop to be the most fascinating warrior of all. During a random chess practice session, you are faced with this problem :
"Two... | ```python
def diagonal(x1, y1, x2, y2):
if abs(x1 - x2) == abs(y1 - y2):
return True
return False
def solve():
C = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 1, 0, 1, 0],
[0, 0, 1, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 1, 0, 1, ... | vfc_56541 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1 1 2\n2 2 3 3\n\nSAMPLE",
"output": "-1\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1 1 2\n0 2 3 3\n\nSAMPLE",
"output": "-1\n-1\n",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | drag-racing-3 | Solve the following coding problem using the programming language python:
Several drivers had lined up for the Drag Racing Competition at the Tokyo Drift Street. Dom had organized the competition, but he was not available during all the races and hence he did not know their results. In the drag race match, 2 drivers r... | ```python
'''
# Read input from stdin and provide input before running code
'''
from collections import Counter
name = int(raw_input(''))
list=[]
for line in range((2**name)-1):
winner=raw_input('').split(' ')[0]
list.append(winner)
print(str(Counter(list).most_common(1)[0][0]))
``` | vfc_56545 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\na b\na c\nc d\n\nSAMPLE",
"output": "a\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11\nfovjpmznym zhpfejofcp\nisbdmefcnz kgrkqwecpc\nfpyiwhfmxj wauoluqowk\nidvreukgrg qrryquogop\nnn... |
code_contests | verifiable_code | grid-count-1 | Solve the following coding problem using the programming language python:
The fight between Batman and Superman just got dirty. Superman tried to trick Batman and locked him inside an N x N grid. This gird is really special. It has values at each of its cell which is some positive integer.
Superman gave Batman a seri... | ```python
n,k= map( int, raw_input().split() )
a = [ [] for i in range(n+1) ]
a[0] = [0 for i in range(n+1) ]
for i in range(1,n+1):
a[i] = [0] + map( int,raw_input().split() )
for i in range(1,n+1):
for j in range(1,n+1):
a[i][j] = a[i][j] + a[i-1][j] + a[i][j-1] - a[i-1][j-1]
ans = 0
for i in range(k,n+1):
... | vfc_56549 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n5 69 2 \n42 9 9 \n5 8 1 \n\nSAMPLE",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n9 69 2 \n42 9 9 \n5 8 1 \n\nSAMPLE",
"output": "2\n",
"type": "stdin... |
code_contests | verifiable_code | little-kuldeep-and-contests | Solve the following coding problem using the programming language python:
Everyone who is involved with HackerEarth in what so ever form knows who Little Kuldeep is. He's not so little, but he's called that. (No one knows why!) He's pretty efficient at organizing, mentoring, managing various hiring challenges, contest... | ```python
def do_overlap(start_time1,end_time1,start_time2,end_time2):
latest_start = max(start_time1, start_time2)
earliest_end = min(end_time1, end_time2)
return latest_start < earliest_end
t=input()
start_times=[]
end_times=[]
while t>0:
t-=1
time_input=raw_input().split('-')
a,b=time_input[0].split(':')
... | vfc_56553 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n11:00-13:30\n13:00-13:45\n\nSAMPLE",
"output": "Will need a moderator!\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n09:00-09:50\n13:00-17:00\n09:50-10:30",
"output": "Who ne... |
code_contests | verifiable_code | my-prime | Solve the following coding problem using the programming language python:
Recently you invented a brand-new definition of prime numbers. For a given set of positive integers S let's call X a prime if there are no elements in S which are divisors of X (except X itself).
You are given a set S. Find elements in it whic... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
#let my set of number is in a list s.
s = []
prime_list = s
output = []
item = raw_input()
maxLengthList = int(item)
item1 = raw_input()
#item1 = input("... | vfc_56557 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n10 5 3 15 16\n\nSAMPLE",
"output": "5 3 16\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n54 65644 131234 196824 262414 328004 393594 459184 524774 590364 15 65566 131117 196668 2... |
code_contests | verifiable_code | prime-equation | Solve the following coding problem using the programming language python:
Recently Akash got this equation. Now being curious he wanted to know that for a given N , is it possible to find P1, P2, P3 and P4 for below equation under following conditions.
( P1-P2 ) + ( P3 - P4 ) = N
P1, P2, P3, P4 are prime numbers
P1 ... | ```python
t=input()
while t:
t-=1
n = input()
if n%2==0 and n>=4 and n<=308:
print 'YES'
else: print 'NO'
``` | vfc_56561 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n4\n15\n30\n100\n1000\n\nSAMPLE",
"output": "YES\nNO\nYES\nYES\nNO",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | sandwichsharing-6 | Solve the following coding problem using the programming language python:
Betty had invited her friends over for breakfast. Being great at tongue twisters, Betty decides to have some fun with the others by making them repeat one of her tongue twisters while she made the sandwich.
Betty bought a bit of butter, but the... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t =int(raw_input())
while ( t > 0):
t-=1
n,p = [int(i) for i in raw_input().split(' ')]
while (n > 3 and p > 0) :
n = n/2 + 1 if n%2 == 0 else n/2 +2
p = p-1
print n
... | vfc_56565 | {
"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 1\n8 2\n\nSAMPLE",
"output": "3\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n213 7\n432 3\n195 1\n240 5\n222 9\n292 9\n494 731\n147 21\n376 3\n284 6\n849 798\n223 705\n827 ... |
code_contests | verifiable_code | supernatural-squad-2 | Solve the following coding problem using the programming language python:
Fatal Eagle has decided to do something to save his favorite city against the attack of Mr. XYZ, since no one else surprisingly seems bothered about it, and are just suffering through various attacks by various different creatures.
Seeing Fata... | ```python
t=int(raw_input())
a=[[0 for x in range(201)] for x in range(201)]
for n in range(1,200):
a[n][n]=1
for k in range(n-1,0,-1):
a[n][k]=a[n-k][k]+a[n][k+1]
for ii in range(t):
z=map(int,raw_input().strip().split(' '))
print a[z[0]][z[1]]
``` | vfc_56569 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10 3\n20 5\n\nSAMPLE",
"output": "5\n13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n113 6\n93 2\n163 20\n163 8\n143 2\n121 3\n199 5\n156 16\n54 9\n133 1",
"output": "62484... |
code_contests | verifiable_code | whats-separatist-planning | Solve the following coding problem using the programming language python:
Before the Battle of Kamino the Confederacy of Independent Systems developed the a way to communicate with the far systems. This way is very unique as every word consists of exactly L lowercase letters. Also, there are exactly D words in this.
... | ```python
import sys
L=map(str, sys.stdin.read().split())
l, D, N= int(L[0]), int(L[1]), int(L[2])
known=L[3: 3+D]
L=L[3+D: ]
for x in xrange(N):
temp=[]
for y in xrange(l):
temp.append([])
flag=False
ctr=0
for y in L[x]:
if y=="(":
flag=True
elif y==")":
flag=False
ctr+=1
elif fl... | vfc_56573 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5 4\nabc\nbca\ndac\ndbc\ncba\n(ab)(bc)(ca)\nabc\n(abc)(abc)(abc)\n(zyx)bc\n\nSAMPLE",
"output": "2\n1\n3\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 25 10\nnwlrbbmqbh\ncdarzowkky... |
code_contests | verifiable_code | p00049 Blood Groups | Solve the following coding problem using the programming language python:
Create a program that reads the attendance numbers of students in a class and the data that stores the ABO blood group and outputs the number of people for each blood type. There are four types of ABO blood types: A, B, AB, and O.
Input
A co... | ```python
from collections import Counter
import sys
d=Counter([i.split(",")[1].strip() for i in sys.stdin])
[print(d[i]) for i in ["A","B","AB","O"]]
``` | vfc_56617 | {
"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,B\n2,A\n3,B\n4,AB\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A",
"output": "5\n4\n3\n2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1,B\n2,A\n3,B\n4,AB\n5,B\n5,O\n7,A\n8,O\n... |
code_contests | verifiable_code | p00179 Mysterious Worm | Solve the following coding problem using the programming language python:
Dr. A of the Aizu Institute of Biological Research discovered a mysterious insect on a certain southern island. The shape is elongated like a hornworm, but since one segment is shaped like a ball, it looks like a beaded ball connected by a threa... | ```python
from collections import deque
def new_color(s, i, rgb):
for color in rgb:
if color != s[i] and color != s[i + 1]:
break
return s[:i] + color * 2 + s[i + 2:]
def solve(s):
length = len(s)
monos = ["r" * length, "g" * length, "b" * length]
if s in monos:
print(0)
return
dic = {s:... | vfc_56621 | {
"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": "rbgrg\nrbbgbbr\nbgr\nbgrbrgbr\nbggrgbgrr\ngbrggrbggr\nrrrrr\nbgbr\n0",
"output": "5\n7\n1\n6\nNA\n8\n0\n4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "rbgrg\nrbbgbbr\nbgr\nrgbbrgbr\nbggrg... |
code_contests | verifiable_code | p00693 Cyber Guardian | Solve the following coding problem using the programming language python:
In the good old days, the Internet was free from fears and terrorism. People did not have to worry about any cyber criminals or mad computer scientists. Today, however, you are facing atrocious crackers wherever you are, unless being disconnecte... | ```python
# AOJ 1111: Cyber Guardian
# Python3 2018.7.15 bal4u
import re
while True:
n, m = map(int, input().split())
if (n|m) == 0: break
rule, ans = [], []
for i in range(n):
g, s, d = input().split()
rule.append((g[0] == 'p', re.compile((s+d).replace("?", "\d"))))
for i in range(m):
s, d, m = input().sp... | vfc_56633 | {
"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": "2 5\npermit 192168?? ?12??34?\ndeny 19216899 012343?5\n19216711 11233340 HiIamACracker\n19216891 01234345 Hello\n19216899 01234345 HiIamAlsoACracker\n19216809 11200340 World\n00000000 99999999 TheEndOfTheWorld\n1 2\npermit 12345678... |
code_contests | verifiable_code | p00834 Inherit the Spheres | Solve the following coding problem using the programming language python:
In the year 2xxx, an expedition team landing on a planet found strange objects made by an ancient species living on that planet. They are transparent boxes containing opaque solid spheres (Figure 1). There are also many lithographs which seem to... | ```python
from collections import defaultdict, deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N = int(readline())
if N == 0:
return False
C0 = [list(map(int, readline().split())) for i in range(N)]
U = [1]*N
D = defaultdict(list)
for i in range(N):
... | vfc_56637 | {
"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\n95 20 180 18\n125 20 185 18\n40 27 195 10\n1\n5 5 5 4\n2\n5 5 5 4\n5 5 5 3\n2\n5 5 5 4\n5 7 5 3\n16\n2338 3465 29034 710\n1571 14389 25019 842\n1706 8015 11324 1155\n1899 4359 33815 888\n2160 10364 20511 1264\n2048 8835 23706 19... |
code_contests | verifiable_code | p00966 String Puzzle | Solve the following coding problem using the programming language python:
Problem J String Puzzle
Amazing Coding Magazine is popular among young programmers for its puzzle solving contests offering catchy digital gadgets as the prizes. The magazine for programmers naturally encourages the readers to solve the puzzles... | ```python
from bisect import bisect
n, a, b, q = map(int, input().split())
W = [input().split() for i in range(a)]
X = [int(x) for x, c in W]
C = [c for x, c in W]
P = [list(map(int, input().split())) for i in range(b)]
Y = [y for y, h in P] + [n+1]
D = [0]*b
for i in range(b):
y0, h = P[i]; y1 = Y[i+1]
l = ... | vfc_56641 | {
"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": "9 4 5 4\n3 C\n4 I\n7 C\n9 P\n2 1\n4 0\n6 2\n7 0\n8 4\n8\n1\n9\n6",
"output": "ICPC",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 4 5 3\n3 C\n4 I\n7 C\n9 P\n2 1\n4 0\n6 2\n7 0\n8 4\n8\n1\... |
code_contests | verifiable_code | p01098 Deciphering Characters | Solve the following coding problem using the programming language python:
Deciphering Characters
Image data which are left by a mysterious syndicate were discovered. You are requested to analyze the data. The syndicate members used characters invented independently. A binary image corresponds to one character written... | ```python
from collections import deque
db = ((-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1))
dw = ((-1, 0), (0, -1), (1, 0), (0, 1))
def make():
h, w = map(int, raw_input().split())
if h == w == 0:
return None
P = ["."*(w+2)]+["."+raw_input()+"." for i in xrange(h)]+["."*(w+2)... | vfc_56645 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 6\n.#..#.\n#.##.#\n.#..#.\n8 7\n.#####.\n#.....#\n#..#..#\n#.#.#.#\n#..#..#\n#..#..#\n.#####.\n...#...\n3 3\n#..\n...\n#..\n3 3\n#..\n.#.\n#..\n3 3\n...\n...\n...\n3 3\n...\n.#.\n...\n3 3\n.#.\n#.#\n.#.\n3 3\n.#.\n###\n.#.\n7 7\n... |
code_contests | verifiable_code | p01235 Electrophoretic | Solve the following coding problem using the programming language python:
Scientist Frank, majoring in electrochemistry, has developed line-shaped strange electrodes called F-electrodes. During being activated, each F-electrode causes a special potential on and between the two lines touching the F-electrode’s endpoint... | vfc_56649 | {
"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\n2 1 2 2\n0 0 1 0\n0 1 0 2\n0",
"output": "Case 1: 3.00000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3 1 2 2\n0 0 1 0\n0 1 0 2\n0",
"output": "Case 1: 4.00000\n",
"typ... | |
code_contests | verifiable_code | p01368 Merry Christmas | Solve the following coding problem using the programming language python:
International Christmas Present Company (ICPC) is a company to employ Santa and deliver presents on Christmas. Many parents request ICPC to deliver presents to their children at specified time of December 24. Although same Santa can deliver two ... | ```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_56653 | {
"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 2 3\n0 1 10\n1 2 10\n0 0\n1 10\n2 0\n3 2 4\n0 1 10\n1 2 10\n0 0\n1 10\n2 20\n0 40\n10 10 10\n0 1 39\n2 3 48\n3 5 20\n4 8 43\n3 9 10\n8 9 40\n3 4 5\n5 7 20\n1 7 93\n1 3 20\n0 0\n1 100000000\n2 100\n3 543\n4 500\n5 400\n6 300\n7 20... |
code_contests | verifiable_code | p01550 Card | Solve the following coding problem using the programming language python:
Now I have a card with n numbers on it. Consider arranging some or all of these appropriately to make numbers. Find the number obtained by adding all the numbers created at this time.
For example, if you have 1 and 2, you will get 4 numbers 1, ... | ```python
import sys
read = sys.stdin.read
write = sys.stdout.write
def solve():
MOD = 10**9 + 7
N, *A = map(int, read().split())
L = 10**5
fact = [1]*(L+1)
rfact = [1]*(L+1)
r = 1
for i in range(1, L+1):
fact[i] = r = r * i % MOD
rfact[L] = r = pow(fact[L], MOD-2, MOD)
for... | vfc_56657 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 262144000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2",
"output": "36",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0\n4\n7\n8",
"output": "135299",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | p01706 Reverse a Road II | Solve the following coding problem using the programming language python:
Problem Statement
JAG Kingdom is a strange kingdom such that its $N$ cities are connected only by one-way roads. The $N$ cities are numbered $1$ through $N$. ICPC (International Characteristic Product Corporation) transports its products from t... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
from collections import deque
class Dinic:
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
self.D = {}
def add_edge(self, fr, to, cap):
forward = [to, cap, None]
forward[2] = b... | vfc_56661 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 1 4\n1 2\n3 1\n4 2\n3 4\n7 8 1 7\n1 2\n1 3\n2 4\n3 4\n4 5\n4 6\n5 7\n7 6\n6 4 5 2\n1 2\n1 3\n4 5\n5 6\n10 21 9 10\n9 1\n9 2\n9 3\n9 4\n10 1\n10 2\n10 3\n10 4\n1 5\n2 5\n2 6\n3 6\n3 7\n4 7\n4 8\n1 8\n5 10\n6 10\n7 10\n10 8\n10 9... |
code_contests | verifiable_code | p01851 Baseball | Solve the following coding problem using the programming language python:
Watching baseball
The other day, your competitive programming companion, Mr. O, went out to watch a baseball game. The games I watched were a total of four games, Team X and Team Y, but it was a one-sided development, and Team X won all the gam... | vfc_56665 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1 0 1 1\n0 0 2 3 2\n4 0 0 33 4\n5 4 2 20 25\n4726 87361 2742 23497 162843\n328324 420923 12782 834286 538297\n0 0 0 0 0",
"output": "2\n0\n114660\n512095631\n673703234\n166259450",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | p01986 Antiaircraft Shield | Solve the following coding problem using the programming language python:
Anti-aircraft shield
In 3xxx, human beings who advanced to planets outside the solar system were troubled by the damage to the base caused by the arrival of a large number of meteorites. The International Cosmic Protection Company has developed... | vfc_56669 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n2 1\n2 2\n10\n10 4\n1 1\n1 5\n1 9\n1\n5 7\n1000000000 1\n1000000000 1\n1000000000 3\n1000000000 3\n1000000000 5\n1000000000 5\n1\n10000 11\n10934235 560\n3155907 1508\n10901182 2457\n3471816 3590\n10087848 4417\n16876957 5583\... | |
code_contests | verifiable_code | p02273 Koch Curve | Solve the following coding problem using the programming language python:
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) ... | ```python
import math
def koch(d,x1,y1,x2,y2):
if d == 0:
return
xs = (2*x1+x2)/3
ys = (2*y1+y2)/3
xt = (x1+2*x2)/3
yt = (y1+2*y2)/3
xu = (xt-xs)*math.cos(math.pi/3) - (yt-ys)*math.sin(math.pi/3) + xs
yu = (xt-xs)*math.sin(math.pi/3) + (yt-ys)*math.cos(math.pi/3) + ys
koch(d... | vfc_56677 | {
"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": "2",
"output": "0.00000000 0.00000000\n11.11111111 0.00000000\n16.66666667 9.62250449\n22.22222222 0.00000000\n33.33333333 0.00000000\n38.88888889 9.62250449\n33.33333333 19.24500897\n44.44444444 19.24500897\n50.00000000 28.86... |
code_contests | verifiable_code | p02420 Shuffle | Solve the following coding problem using the programming language python:
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.
A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.
The deck of cards is represented by a str... | ```python
while 1:
s = input()
if s == "-": break
for _ in range(int(input())):
h = int(input())
s = s[h:] + s[:h]
print(s)
``` | vfc_56681 | {
"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": "aabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-",
"output": "aabc\nxyzvw",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaac\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-",
"output": "aaac\nxyzvw\n",
"typ... |
code_contests | verifiable_code | bao | Solve the following coding problem using the programming language python:
Problem description
John and Dave are two close friends. One day John bluffs to Dave that in past some weeks he has learnt to program using any programming languages. Dave started laughing wildly on John but John insisted that he can really do p... | ```python
t=input()
for _ in xrange(t):
n,x=raw_input().split()
n=int(n)
while n>0:
x=eval(x+raw_input(""))
x=str("{0:.2f}".format(x))
n-=1
print x
``` | vfc_56685 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 12\n+5\n * 2 \n2 2.13\n+ 0.2\n/ 2",
"output": "34.00\n1.17",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | cme04 | Solve the following coding problem using the programming language python:
Ramesh is contemplating putting a new flooring throughout his house, but he has an important constraint: no tiles must be cut in the process of tiling any room. The floor of every room must be completely tiled, and all tiles in a particular room... | ```python
t = int(raw_input())
for i in range(t):
X, Y, x, y = map(int, raw_input().split())
room = X*Y
tile = x*y
if room%tile == 0:
print "yes"
else:
print "no"
``` | vfc_56689 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n50 70 2 3",
"output": "no\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n50 140 2 3",
"output": "no\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | flow015 | Solve the following coding problem using the programming language python:
According to Gregorian Calendar, it was Monday on the date 01/01/2001. If any year is input, Write a program to display what is the day on the 1st January of this year.
Input
The first line contains an integer T, total number of testcases. T... | ```python
total_cases = int(raw_input())
def convert(a) :
if a==0 :
return 'sunday'
elif a==1:
return 'monday'
elif a==2:
return 'tuesday'
elif a==3:
return 'wednesday'
elif a==4:
return 'thursday'
elif a==5:
return 'friday'
elif a==6:
return 'saturday'
while total_cases > 0:
total_cases -= 1
day... | vfc_56693 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 \n1994\n1991\n2014",
"output": "saturday\ntuesday\nwednesday\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | life | Solve the following coding problem using the programming language python:
In Conway's Game of Life, cells in a grid are used to simulate biological cells.
Each cell is considered to be either alive or dead.
At each step of the simulation
each cell's current status and number of living neighbors is used to determine th... | ```python
#program for one dimensional game of life
iteration = int(raw_input())
match = [[0,1],[3,2],[5,4],[6,7]]
poss = [[0,3,5,6],[1,2,4,7]]
for i in range(iteration):
count = 0
row = raw_input()
arr = poss[int(row[-1])]
for el in arr:
output = str(el % 2)
current = el
for j in range(len(row)):
current ... | vfc_56697 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n00011101\n000\n000001\n11110",
"output": "01100101\nMultiple solutions\nNo solution\n10010\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n00011101\n100\n000001\n11110",
"outpu... |
code_contests | verifiable_code | prcnsr5 | Solve the following coding problem using the programming language python:
Little Red Riding Hood inherited an enormously large number of Candies from her father's Candy factory. Now she wants to divide these candies equally among her and her horse Hood. After the division, both Red and Hood get an equal, integral nu... | ```python
n=input()
if str(n)[-1] in "02468":
print "YES"
else:
print "NO"
``` | vfc_56701 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1291901284091794073817410275012865216851",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1780502495772436925635846379902242203677",
"output": "NO\n",
"type": "s... |
code_contests | verifiable_code | taaplusb | Solve the following coding problem using the programming language python:
Have you ever implemented a program adding two big integers that cannot be represented by the primitive data type of your programming language? The algorithm is just simulation of the column addition method that we have been taught in elementary... | ```python
t=int(raw_input())
for i in xrange(t):
n=int(raw_input())
print (9*n -1 + 10.0**(-n))/18
``` | vfc_56705 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n2\n3",
"output": "0.45\n0.945\n1.4445\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1010_C. Border | Solve the following coding problem using the programming language python:
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, ... | ```python
from math import gcd
n, k = map(int, input().split())
A = list(map(int, input().split()))
g = 0
for ai in A:
g = gcd(g, ai)
s = set()
x = 0
while True:
d = (g*x) % k
if d not in s:
s.add(d)
else:
break
x += 1
print(len(s))
print(*sorted(s))
``` | vfc_56709 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 10\n10 20 30\n",
"output": "1\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 8\n12 20\n",
"output": "2\n0 4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1056_H. Detect Robots | Solve the following coding problem using the programming language python:
You successfully found poor Arkady near the exit of the station you've perfectly predicted. You sent him home on a taxi and suddenly came up with a question.
There are n crossroads in your city and several bidirectional roads connecting some of... | vfc_56717 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n2\n4 1 2 3 5\n3 1 4 3\n",
"output": "Human\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 107_D. Crime Management | Solve the following coding problem using the programming language python:
Zeyad wants to commit n crimes in Egypt and not be punished at the end. There are several types of crimes. For example, bribery is a crime but is not considered such when repeated twice. Therefore, bribery is not considered a crime when repeated... | vfc_56721 | {
"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": "8 3\nA 2\nA 3\nB 2\n",
"output": "128\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 3\nA 1\nB 2\nC 3\n",
"output": "113\n",
"type": "stdin_stdout"
},
{
"fn_na... | |
code_contests | verifiable_code | 109_C. Lucky Tree | Solve the following coding problem using the programming language python:
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya encountered... | ```python
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mo... | vfc_56725 | {
"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\n1 2 4\n1 3 47\n1 4 7447\n",
"output": "24\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 4\n3 1 2\n1 4 7\n",
"output": "16\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 1147_E. Rainbow Coins | Solve the following coding problem using the programming language python:
Carl has n coins of various colors, and he would like to sort them into piles. The coins are labeled 1,2,…,n, and each coin is exactly one of red, green, or blue. He would like to sort the coins into three different piles so one pile contains al... | vfc_56733 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 6, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n1\n1\n1\n3\n1\n0\n0\n6\n000\n010\n100\n001\n000\n",
"output": "Q 1 1 2 \nQ 1 2 3 \nA 3 0 0\n1 2 3 \n\n\nA 1 0 0\n1 \n\n\nQ 1 1 2 \nQ 1 2 3 \nA 2 1 0\n1 2 \n3 \n\n",
"type": "stdin_stdout"
},
{
"fn_na... | |
code_contests | verifiable_code | 1169_A. Circle Metro | Solve the following coding problem using the programming language python:
The circle line of the Roflanpolis subway has n stations.
There are two parallel routes in the subway. The first one visits stations in order 1 → 2 → … → n → 1 → 2 → … (so the next stop after station x is equal to (x+1) if x < n and 1 otherwise... | ```python
n,a,x,b,y=map(int,input().split(" "))
flag =1
while a!=x and b!=y:
a = a+ 1
b = b-1
if(a==n+1):
a = 1
if(b==0):
b=n
if(a==b):
flag =0
print('YES')
break;
if flag==1:
print ('NO')
``` | vfc_56737 | {
"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 1 4 3 2\n",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2 1 9 10\n",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
code_contests | verifiable_code | 1187_C. Vasya And Array | Solve the following coding problem using the programming language python:
Vasya has an array a_1, a_2, ..., a_n.
You don't know this array, but he told you m facts about this array. The i-th fact is a triple of numbers t_i, l_i and r_i (0 ≤ t_i ≤ 1, 1 ≤ l_i < r_i ≤ n) and it means:
* if t_i=1 then subbarray a_{l_i... | ```python
"""609C"""
# import math
# import sys
def main():
n,m = map(int,input().split())
l = []
s = []
r = []
d = [0]*n
for _ in range(m):
a,b,c = map(int,input().split())
s.append(a)
b-=1
l.append(b)
c-=1
r.append(c)
if a==1:
d[b]+=1
d[c]-=1
dx = [-1]*(n-1)
add = 0
for i in range(n):
... | vfc_56741 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 4\n1 1 3\n1 2 5\n0 5 6\n1 6 7\n",
"output": "YES\n7 7 7 7 7 6 6 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n1 1 4\n0 2 3\n",
"output": "NO\n",
"type": "stdin_stdout... |
code_contests | verifiable_code | 1206_B. Make Product Equal One | Solve the following coding problem using the programming language python:
You are given n numbers a_1, a_2, ..., a_n. With a cost of one coin you can perform the following operation:
Choose one of these numbers and add or subtract 1 from it.
In particular, we can apply this operation to the same number several times... | ```python
def func(lst):
prod = 1
for item in lst:
if item!=0:
prod = prod*item
return prod
w = int(input())
a=list(map(int,input().split()))
count=0
count1=0
for i,item in enumerate(a):
if item<0 and item !=-1:
count+=abs(item+1)
a[i]=-1
if ... | vfc_56745 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n-5 -3 5 3 0\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0 0 0\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1223_E. Paint the Tree | Solve the following coding problem using the programming language python:
You are given a weighted tree consisting of n vertices. Recall that a tree is a connected graph without cycles. Vertices u_i and v_i are connected by an edge with weight w_i.
Let's define the k-coloring of the tree as an assignment of exactly k... | vfc_56749 | {
"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": "2\n4 1\n1 2 5\n3 1 2\n3 4 3\n7 2\n1 2 5\n1 3 4\n1 4 2\n2 5 1\n2 6 2\n4 7 3\n",
"output": "8\n14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n9 3\n7 4 10\n6 8 1\n1 3 6\n2 4 10\n2 9 1... | |
code_contests | verifiable_code | 1249_B1. Books Exchange (easy version) | Solve the following coding problem using the programming language python:
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his book ... | ```python
import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
import os
self.os = os
self._fd = file.fileno()
... | vfc_56753 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3\n",
"output": "1 1 1 1 1\n3 3 3\n2 3 3 2 1 3\n1\n2 2 2 2\n4 4 4 1 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... |
code_contests | verifiable_code | 128_B. String | Solve the following coding problem using the programming language python:
One day in the IT lesson Anna and Maria learned about the lexicographic order.
String x is lexicographically less than string y, if either x is a prefix of y (and x ≠ y), or there exists such i (1 ≤ i ≤ min(|x|, |y|)), that xi < yi, and for any... | ```python
from heapq import *
l=input()
k=int(input())
n=len(l)
if k>n*(n+1)/2:
print("No such line.")
quit()
ss=[(l[i],i) for i in range(n)]
heapify(ss)
while k:
k-=1
t=heappop(ss)
if k==0:
print(t[0])
else:
if t[1]<n-1:
heappush(ss,(t[0]+l[t[1]+1],t[... | vfc_56761 | {
"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": "abc\n5\n",
"output": "bc\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abab\n7\n",
"output": "b\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 130_H. Balanced brackets | Solve the following coding problem using the programming language python:
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters «+» and «1». For example, sequences «(())()», «()» and «(()(()))» are balanced, while «)(», «(()» and «(()))(» are not.
You are given... | vfc_56765 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "(()(()))()\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1352_F. Binary String Reconstruction | Solve the following coding problem using the programming language python:
For some binary string s (i.e. each character s_i is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length 2 were written. For each pair (substring of length 2), the number of '... | ```python
for testcase in range(int(input())):
n0, n1, n2 = map(int, input().split())
if n1 == 0:
if n0:
ans = "0" * (n0 + 1)
else:
ans = "1" * (n2 + 1)
else:
ans = ["0" * (n0 + 1), "1" * (n2 + 1)]
for i in range(n1 - 1):
ans.append(str(i &... | vfc_56773 | {
"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": "7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0\n",
"output": "0011111101\n0011\n0000111101010101\n01\n0000111\n1111\n000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n1 3 5\n1 1 1... |
code_contests | verifiable_code | 1395_C. Boboniu and Bit Operations | Solve the following coding problem using the programming language python:
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers a_1,a_2,…,a_n and b_1,b_2,…,b_m.
For each i (1≤ i≤ n), you're asked to choose a j (1≤ j≤ m) and let c_i=a_i\& b_j, where \... | ```python
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
z=[]
ma=0
for i in a:
x=float("infinity")
for j in b:
x=min(i&j,x)
ma=max(x,m... | vfc_56781 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 6\n1 9 1 9 8 1 0\n1 1 4 5 1 4\n",
"output": "0",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1419_E. Decryption | Solve the following coding problem using the programming language python:
An agent called Cypher is decrypting a message, that contains a [composite number](https://en.wikipedia.org/wiki/Composite_number) n. All divisors of n, which are greater than 1, are placed in a circle. Cypher can choose the initial order of num... | ```python
from sys import stdin, stdout
# 6
# 2 3 6
# 30
# 2,3,5
# 2 30 6 3 15 5 10
# 2 - (30) - 6 - 3 - 15 - 5 - 10
# P1 - (x*P1) - P1P2 - P2 - (x*P2) - P2P3 - P3 - (x*P3) - P1P3
def decryption(n):
r1 = []
r2 = 0
factor_a = getfactor(n)
prime_a = getprime(n)
hs = set()
prime_dic = {}
... | vfc_56785 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n6\n4\n30\n",
"output": "2 3 6\n1\n2 4\n0\n2 30 6 3 15 5 10\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n18\n",
"output": "2 6 3 9 18\n0\n",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 1437_F. Emotional Fishermen | Solve the following coding problem using the programming language python:
n fishermen have just returned from a fishing vacation. The i-th fisherman has caught a fish of weight a_i.
Fishermen are going to show off the fish they caught to each other. To do so, they firstly choose an order in which they show their fish... | ```python
from collections import defaultdict
import sys
input = sys.stdin.readline
n = int(input())
a = map(int, input().split())
mod = 998244353
d = defaultdict(int)
for x in a:
d[x] += 1
d[0] = 0
b = list(d.items())
b.sort()
m = len(b)
ba = [0] * m
cn = [0] * (m + 1)
k = h = 0
for i, x in enumerate(b):
while... | vfc_56789 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4 3 2 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n42 1337 13 37 420 666 616 97\n",
"output": "19200\n",
"type": "stdin_stdout"
},
{
"... |
code_contests | verifiable_code | 1511_B. GCD Length | Solve the following coding problem using the programming language python:
You are given three integers a, b and c.
Find two positive integers x and y (x > 0, y > 0) such that:
* the decimal representation of x without leading zeroes consists of a digits;
* the decimal representation of y without leading zeroes... | ```python
for _ in range(int(input())):
a,b,c=map(int,input().split())
x=(10**(a-c)+1)*(10**(c-1))
y=10**(b-1)
print(x,y)
``` | vfc_56801 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 3 1\n2 2 2\n6 6 2\n1 1 1\n",
"output": "\n11 492\n13 26\n140133 160776\n1 1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1538_G. Gift Set | Solve the following coding problem using the programming language python:
Polycarp has x of red and y of blue candies. Using them, he wants to make gift sets. Each gift set contains either a red candies and b blue candies, or a blue candies and b red candies. Any candy can belong to at most one gift set.
Help Polycar... | ```python
import sys,io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
read = lambda: map(int,input().split())
O = []
for _ in range(int(input())):
x,y,a,b = read()
if a==b:
O.append(str(min(x,y)//a))
continue
if a<b: a,b = b,a
d = a-b
L = [0,(x+y)//(a+b)+1]
whil... | vfc_56805 | {
"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": "9\n10 12 2 5\n1 1 2 2\n52 311 13 27\n1000000000 1000000000 1 1\n1000000000 1 1 1000000000\n1 1000000000 1000000000 1\n1 2 1 1\n7 8 1 2\n4 1 2 3\n",
"output": "\n3\n0\n4\n1000000000\n1\n1\n1\n5\n0\n",
"type": "stdin_stdo... |
code_contests | verifiable_code | 165_B. Burning Midnight Oil | Solve the following coding problem using the programming language python:
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he w... | ```python
"""
Solution to the 706B problem on CodeForces.
"""
import sys
import math
def binary_search(k, target):
beg, end = 1, target
while beg + 1 < end:
number = (beg + end) // 2
if (lambda_function(target, k, number)):
end = number
else:
beg = number
if ... | vfc_56809 | {
"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\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "59 9\n",
"output": "54",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "948889213... |
code_contests | verifiable_code | 186_C. Plant | Solve the following coding problem using the programming language python:
Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards" and... | ```python
N = int(input())
result = (pow(2, N, int(1e9 + 7)) * (pow(2, N, int(1e9 + 7)) + 1)) % int(1e9+7)
result = (result * pow(2, int(1e9+5), int(1e9+7))) % int(1e9+7)
print(result)
``` | vfc_56813 | {
"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\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 207_D5. The Beaver's Problem - 3 | Solve the following coding problem using the programming language python:
The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:
Y... | ```python
print('2')
``` | vfc_56817 | {
"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": "24000\nN.Y. BANK DISCOUNT BORROWINGS 169 MLN DLRS\nNEW YORK, April 9 - The eight major New York City banks had\ndaily average borrowings of 169 mln dlrs from the Federal\nReserve in the week ended April 8, a Fed spokesman said.\nA ... |
code_contests | verifiable_code | 232_D. Fence | Solve the following coding problem using the programming language python:
John Doe has a crooked fence, consisting of n rectangular planks, lined up from the left to the right: the plank that goes i-th (1 ≤ i ≤ n) (from left to right) has width 1 and height hi. We will assume that the plank that goes i-th (1 ≤ i ≤ n) ... | vfc_56821 | {
"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\n1 2 2 1 100 99 99 100 100 100\n6\n1 4\n1 2\n3 4\n1 5\n9 10\n10 10\n",
"output": "1\n2\n2\n0\n2\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n100000\n2\n1 1\n1 1\n",
"outp... | |
code_contests | verifiable_code | 258_C. Little Elephant and LCM | Solve the following coding problem using the programming language python:
The Little Elephant loves the LCM (least common multiple) operation of a non-empty set of positive integers. The result of the LCM operation of k positive integers x1, x2, ..., xk is the minimum positive integer that is divisible by each of numb... | vfc_56825 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6 3\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 4 3 2\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... | |
code_contests | verifiable_code | 281_C. Rectangle Puzzle | Solve the following coding problem using the programming language python:
You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the... | ```python
import os
import sys
from io import BytesIO, IOBase
import math
def main():
pass
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
... | vfc_56829 | {
"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 1 45\n",
"output": "0.828427",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 4 30\n",
"output": "19.668385",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 304_B. Calendar | Solve the following coding problem using the programming language python:
Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap yea... | ```python
import sys
import datetime
y1, m1, d1 = map(int, input().split(':'))
y2, m2, d2 = map(int, input().split(':'))
print(abs((datetime.date(y1, m1, d1) - datetime.date(y2, m2, d2)).days))
``` | vfc_56833 | {
"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": "1900:01:01\n2038:12:31\n",
"output": "50768\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1996:03:09\n1991:11:12\n",
"output": "1579\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 330_C. Purification | Solve the following coding problem using the programming language python:
You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the col... | ```python
n = int(input())
grid = [input() for line in range(n)]
total = sum([ln.count('.') for ln in grid])
rowsWSpcN = len([True for ln in grid if '.' in ln])
colsWSpcN = len([True for col in range(n) if '.' in [ln[col] for ln in grid]])
rowsWSpc = [ln.count('.') for ln in grid]
colsWSpc = [[ln[col] for ln in grid].c... | vfc_56837 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nEEE\nE..\nE.E\n",
"output": "-1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 376_B. I.O.U. | Solve the following coding problem using the programming language python:
Imagine that there is a group of three friends: A, B and С. A owes B 20 rubles and B owes C 20 rubles. The total sum of the debts is 40 rubles. You can see that the debts are not organized in a very optimal manner. Let's rearrange them like that... | ```python
n,m = map(int, input().split())
debt=[0]*(n+1)
for i in range(m):
a,b,c = map(int, input().split())
debt[a]-=c
debt[b]+=c
ans=0
for i in debt:
if i>0:
ans+=i
print(ans)
``` | vfc_56845 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n1 2 10\n2 3 1\n2 4 1\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n1 2 1\n2 3 1\n3 1 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 398_D. Instant Messanger | Solve the following coding problem using the programming language python:
User ainta decided to make a new instant messenger called "aintalk". With aintalk, each user can chat with other people. User ainta made the prototype of some functions to implement this thing.
1. login(u): User u logins into aintalk and beco... | vfc_56849 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2 9\n1\n4\n1 3\n3 4\nC 3\nA 2 5\nO 1\nD 1 3\nA 1 2\nA 4 2\nC 2\nF 4\nC 2\n",
"output": "1\n2\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5 10\n10\n3 2 7 8 1 10 5 4 6 9\n9 10\n4... | |
code_contests | verifiable_code | 420_E. Playing the ball | Solve the following coding problem using the programming language python:
A coder cannot sit and code all day. Sometimes it is a good idea to rise from the desk, have a rest, have small talk with colleagues and even play. The coders of the F company have their favorite ball game.
Let's imagine the game on the plane w... | vfc_56853 | {
"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": "2 5\n1 1 1\n5 0 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 10\n20 0 10\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... | |
code_contests | verifiable_code | 447_C. DZY Loves Sequences | Solve the following coding problem using the programming language python:
DZY has a sequence a, consisting of n integers.
We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment o... | ```python
"""
pppppppppppppppppppp
ppppp ppppppppppppppppppp
ppppppp ppppppppppppppppppppp
pppppppp pppppppppppppppppppppp
pppppppppppppppppppppppppppppppp
pppppppppp... | vfc_56857 | {
"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": "6\n7 2 3 1 5 6\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1000000000 1000000000\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | 469_D. Two Sets | Solve the following coding problem using the programming language python:
Little X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied:
* If number x belongs to set A, then number a - x must also belong to set A.
* If numb... | ```python
class DisjointSet:
def __init__(self, n):
self._fa = list(range(n))
def union(self, x, y):
x = self.get_father(x)
y = self.get_father(y)
self._fa[x] = y
return y
def get_father(self, x):
y = self._fa[x]
if self._fa[y] == y:
return... | vfc_56861 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5 9\n2 3 4 5\n",
"output": "YES\n0 0 1 1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 4\n1 2 4\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_nam... |
code_contests | verifiable_code | 491_C. Deciphering | Solve the following coding problem using the programming language python:
One day Maria Ivanovna found a Sasha's piece of paper with a message dedicated to Olya. Maria Ivanovna wants to know what is there in a message, but unfortunately the message is ciphered. Maria Ivanovna knows that her students usually cipher the... | vfc_56865 | {
"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": "9 4\ndacbdacbd\nacbdacbda\n",
"output": "9\ncdba\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2\naaaaaaabbb\nbbbbaaabbb\n",
"output": "6\nab\n",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | 515_D. Drazil and Tiles | Solve the following coding problem using the programming language python:
Drazil created a following problem about putting 1 × 2 tiles into an n × m grid:
"There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover all empty cells and no two tiles should cover... | vfc_56869 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n.\n",
"output": "Not unique\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n...\n.*.\n...\n",
"output": "Not unique\n",
"type": "stdin_stdout"
},
{
"fn_... | |
code_contests | verifiable_code | 56_A. Bar | Solve the following coding problem using the programming language python:
According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to d... | ```python
a=['ABSINTH','BEER','BRANDY','CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE']
l=0
for i in range(int(input())):
x=input()
try:
if(int(x)<18):
l+=1
except:
if(x in a):
l+=1
print(l)
``` | vfc_56877 | {
"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\n18\nVODKA\nCOKE\n19\n17\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n813\nIORBQITQXMPTFAEMEQDQIKFGKGOTNKTOSZCBRPXJLUKVLVHJYNRUJXK\nRUM\nRHVRWGODYWWTYZFLFYKCVUFFRT... |
code_contests | verifiable_code | 590_D. Top Secret Task | Solve the following coding problem using the programming language python:
A top-secret military base under the command of Colonel Zuev is expecting an inspection from the Ministry of Defence. According to the charter, each top-secret military base must include a top-secret troop that should... well, we cannot tell you... | vfc_56881 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 2\n2 4 1\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2 3\n3 1 4 2 5\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | 612_C. Replace To Make Regular Bracket Sequence | Solve the following coding problem using the programming language python:
You are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace < by the br... | ```python
s = input()
stack = []
res = 0
for c in s:
if c in '(<[{':
stack.append(c)
else:
if not stack:
print('Impossible')
break
last = stack.pop()
if last + c not in ('[]', '()', '<>', '{}'):
res += 1
else:
if stack:
print('Impo... | vfc_56885 | {
"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": "{()}[]\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "[<}){}\n",
"output": "Impossible\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 632_C. The Smallest String Concatenation | Solve the following coding problem using the programming language python:
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest concate... | ```python
from functools import cmp_to_key
def comparator(a,b):
return -1 if a+b <= b+a else 1
def smallest_string(str_list):
return "".join(sorted(str_list, key=cmp_to_key(comparator)))
if __name__ == '__main__':
n = int(input())
str_list = []
for _ in range(n):
s = input()
str_l... | vfc_56889 | {
"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\nabba\nabacaba\nbcd\ner\n",
"output": "abacabaabbabcder\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\nx\nxx\nxxa\nxxaa\nxxaaa\n",
"output": "xxaaaxxaaxxaxxx\n",
"type": ... |
code_contests | verifiable_code | 660_F. Bear and Bowling 4 | Solve the following coding problem using the programming language python:
Limak is an old brown bear. He often goes bowling with his friends. Today he feels really good and tries to beat his own record!
For rolling a ball one gets a score — an integer (maybe negative) number of points. Score for the i-th roll is mult... | vfc_56893 | {
"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\n-60 -70 -80\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 683_J. The Hero with Bombs | Solve the following coding problem using the programming language python:
In a new computer game you need to help the hero to get out of the maze, which is a rectangular field of size n × m. The hero is located in one of the cells of this field. He knows where the exit of the maze is, and he wants to reach it.
In one... | vfc_56897 | {
"difficulty": "16",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\nXEX.X\nX.XXT\nX.X.X\n",
"output": "SSMNNTSSNEMWWTEEEE\n",
"type": "stdin_stdout"
}
]
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.