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 | 1479_B2. Painting the Array II | Solve the following coding problem using the programming language python:
The only difference between the two versions is that this version asks the minimal possible answer.
Homer likes arrays a lot. Today he is painting an array a_1, a_2, ..., a_n with two kinds of colors, white and black. A painting assignment for ... | ```python
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
A = [int(a) for a in input().split()]
S = set()
ans = 0
la = -1
for a in A:
if a == la:
continue
elif a in S:
S = {a, la}
else:
S.add(a)
la = a
ans += 1
print(ans)
``` | vfc_38061 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n1 2 1 2 1 2 1\n",
"output": "\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 2 3 1 2 2\n",
"output": "\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": n... |
code_contests | verifiable_code | 1506_A. Strange Table | Solve the following coding problem using the programming language python:
Polycarp found a rectangular table consisting of n rows and m columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns":
* cells are numbered starting from one;
* cells are numbered f... | ```python
def somefunc(n, m, x):
if n == m and n == 1:
return x
ans = 0
row = 0
if x % n == 0:
# 2
row = x / n
else:
row = x // n + 1
col = x % n
if col == 0:
col = n
ans = int(m * (col - 1))
ans += row
return int(ans)
for t in range(i... | vfc_38065 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 1 1\n2 2 3\n3 5 11\n100 100 7312\n1000000 1000000 1000000000000\n",
"output": "\n1\n2\n9\n1174\n1000000000000\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 160_B. Unlucky Ticket | Solve the following coding problem using the programming language python:
Each of you probably has your personal experience of riding public transportation and buying tickets. After a person buys a ticket (which traditionally has an even number of digits), he usually checks whether the ticket is lucky. Let us remind y... | ```python
number_of_testcases = 1 #int(input())
for _ in range(number_of_testcases):
number_of_digits = int(input())
ticket_number = input()
ticket_number = list(ticket_number)
first_half = ticket_number[:number_of_digits]
second_half = ticket_number[number_of_digits:]
#print(first_half)
f... | vfc_38073 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3754\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n0135\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 17_D. Notepad | Solve the following coding problem using the programming language python:
Nick is attracted by everything unconventional. He doesn't like decimal number system any more, and he decided to study other number systems. A number system with base b caught his attention. Before he starts studying it, he wants to write in hi... | ```python
#!/usr/bin/python
primes = [
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
233, 239, 241, 251, 257,... | vfc_38077 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3 4\n",
"output": " 4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3 3\n",
"output": " ... |
code_contests | verifiable_code | 202_E. Fragile Bridges | Solve the following coding problem using the programming language python:
You are playing a video game and you have just reached the bonus level, where the only possible goal is to score as many points as possible. Being a perfectionist, you've decided that you won't leave this level until you've gained the maximum po... | vfc_38081 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2 1 2 1\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 227_D. Naughty Stone Piles | Solve the following coding problem using the programming language python:
There are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.
During one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the current size of pile i, and... | ```python
n = int(input())
stones = list(map(lambda t : int(t), input().split()))
q = int(input())
queries = list(map(lambda t : int(t), input().split()))
stones.sort()
added_stones = []
added_stones.append(stones[0])
for i in range(1, n, 1):
added_stones.append(stones[i] + added_stones[i - 1])
computed_queries ... | vfc_38085 | {
"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\n2 3 4 1 1\n2\n2 3\n",
"output": "9 8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 6 8\n1\n6\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name":... |
code_contests | verifiable_code | 251_B. Playing with Permutations | Solve the following coding problem using the programming language python:
Little Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n.
A permutation a of length n is a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ n), all integers there are distinct.
There is o... | ```python
n,k=map(int,input().strip().split())
a=list(map(int,input().strip().split()))
b=list(map(int,input().strip().split()))
ups = [[i+1 for i in range(n)]]
downs = [[i+1 for i in range(n)]]
def apply(arr):
out = [0]*n
for i in range(n):
out[i] = arr[a[i]-1]
return out
def unapply(arr):
ou... | vfc_38089 | {
"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 1\n4 3 1 2\n3 4 2 1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n4 3 1 2\n2 1 4 3\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"... |
code_contests | verifiable_code | 276_C. Little Girl and Maximum Sum | Solve the following coding problem using the programming language python:
The little girl loves the problems on array queries very much.
One day she came across a rather well-known problem: you've got an array of n elements (the elements of the array are indexed starting from 1); also, there are q queries, each one i... | ```python
n,m = map(int,input().split())
a = list(map(int,input().split()))
l = [0]*(n+2)
for i in range(m):
x,y=map(int,input().split())
l[x] += 1
l[y+1] -= 1
for i in range(2, n+2):
l[i] += l[i-1]
l.sort(reverse=True)
a.sort(reverse=True)
# print(l, a)
ans=0
for i in range(n):
ans += l[i]*a[i]
print(ans)
... | vfc_38093 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3\n",
"output": "33\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n5 3 2\n1 2\n2 3\n1 3\n",
"output": "25\n",
"type": "stdin_stdout"
}
]... |
code_contests | verifiable_code | 299_E. Cube Problem | Solve the following coding problem using the programming language python:
Yaroslav, Andrey and Roman love playing cubes. Sometimes they get together and play cubes for hours and hours!
Today they got together again and they are playing cubes. Yaroslav took unit cubes and composed them into an a × a × a cube, Andrey ... | vfc_38097 | {
"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": "93163582512000\n",
"output": "39090",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... | |
code_contests | verifiable_code | 347_A. Difference Row | Solve the following coding problem using the programming language python:
You want to arrange n integers a1, a2, ..., an in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.
More formally, let's denote some arrangement as a sequence of inte... | ```python
# t=int(input())
# import math
# for _ in range(t):
# n,k=list(map(int,input().split()))
# s=input()
# a=[]
# summer=0
# for i in range(len(s)):
# if(s[i]=='1'):
# a.append(i)
# i=0
# while(i<len(a)-1):
# dist=a[i+1]-k-1-(a[i]+k+1)+1
# # print(a,... | vfc_38105 | {
"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\n100 -100 50 0 -50\n",
"output": "100 -50 0 50 -100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50\n-262 -377 -261 903 547 759 -800 -53 670 92 758 109 547 877 152 -901 -318 -527 -388... |
code_contests | verifiable_code | 370_B. Berland Bingo | Solve the following coding problem using the programming language python:
Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have equal numbers. The card ... | ```python
n = int(input())
cards = [None] + [[] for i in range(n)]
for i in range(1, n+1):
cards[i] = list(map(int, input().split()))[1:]
ans = [None] + [True for i in range(n)]
#print(cards, ans)
for i in range(1, n + 1):
for j in range( 1, n + 1):
if i == j :
continue;
if set(card... | vfc_38109 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1\n1 1\n",
"output": "NO\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1\n3 2 4 1\n2 10 11\n",
"output": "YES\nNO\nYES\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 391_F2. Stock Trading | Solve the following coding problem using the programming language python:
This problem consists of three subproblems: for solving subproblem F1 you will receive 8 points, for solving subproblem F2 you will receive 15 points, and for solving subproblem F3 you will receive 10 points.
Manao has developed a model to pred... | vfc_38113 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 5\n2\n7\n3\n9\n8\n7\n9\n7\n1\n9\n",
"output": "21\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2\n2\n7\n3\n9\n8\n7\n9\n7\n1\n9\n",
"output": "15\n",
"type": "stdin_std... | |
code_contests | verifiable_code | 414_E. Mashmokh's Designed Problem | Solve the following coding problem using the programming language python:
After a lot of trying, Mashmokh designed a problem and it's your job to solve it.
You have a tree T with n vertices. Each vertex has a unique index from 1 to n. The root of T has index 1. For each vertex of this tree v, you are given a list of ... | vfc_38117 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 9\n1 2\n1 3\n1 4\n0\n1 1 4\n2 4 2\n1 3 4\n3 1\n3 2\n2 3 2\n1 1 2\n3 1\n3 2\n",
"output": "3\n2\n2\n4\n1\n3\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n1 2\n0\n1 2 1\n3 1\n",
... | |
code_contests | verifiable_code | 441_C. Valera and Tubes | Solve the following coding problem using the programming language python:
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection... | ```python
import sys
import math as mt
#input=sys.stdin.buffer.readline
#import bisect
mod=1000000007
#t=int(input())
#tot=0
t=1
for __ in range(t):
#n=int(input())
n,m,k=map(int,input().split())
x,y=1,0
d=0
r=1
ch=1
cnt1=1
for i in range(k-1):
print(2,end=" ")
for j... | vfc_38121 | {
"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 3 3\n",
"output": "2 1 1 1 2\n2 1 3 2 3\n5 2 2 2 1 3 1 3 2 3 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3 1\n",
"output": "6 1 1 1 2 1 3 2 3 2 2 2 1\n",
"type": "std... |
code_contests | verifiable_code | 463_D. Gargari and Permutations | Solve the following coding problem using the programming language python:
Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in some order. Now he should f... | ```python
n, k = map(int, input().split())
ra = [[0] * k for _ in range(n)]
for p in range(k):
for i, v in enumerate(map(int, input().split())):
v -= 1
ra[v][p] = i
g = [[] for _ in range(n)]
for u in range(n):
for v in range(n):
if all(x < y for x, y in zip(ra[u], ra[v])):
g... | vfc_38125 | {
"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 3\n1 4 2 3\n4 1 2 3\n1 2 4 3\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 3\n2 5 1 4 6 3\n5 1 4 6 2 3\n5 4 2 6 3 1\n",
"output": "4",
"type": "stdin_stdou... |
code_contests | verifiable_code | 487_C. Prefix Product Sequence | Solve the following coding problem using the programming language python:
Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence <image>.
Now given n, find a permutation of [1, 2, ..., n], such that its prefix product sequence is a permutation of [0, 1, ..., n - 1].
Input
The only input line con... | ```python
n = int(input())
if n == 1:
print('YES\n1')
exit(0)
if n == 4:
print('YES\n1 3 2 4')
exit(0)
for p in range(2, int(n ** 0.5) + 1):
if n % p == 0:
print('NO')
exit(0)
print('YES')
print(1)
for j in range(2, n):
print(j * pow(j - 1, n - 2, n) % n)
print(n)
``` | vfc_38129 | {
"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\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
"output": "YES\n1\n2\n5\n6\n3\n4\n7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 510_B. Fox And Two Dots | Solve the following coding problem using the programming language python:
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this:
<image>
Each cell contains a dot that has some color. We will use different uppercase Latin characters to expres... | ```python
'''
Zijian He
1429876
'''
# Import
from sys import setrecursionlimit
setrecursionlimit(10**6)
# Function from class
class Graph:
def __init__ (self):
self._alist = {}
def add_vertex (self, vertex):
if vertex not in self._alist:
self._alist[vertex] = set()
def add_ed... | vfc_38133 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 13\nABCDEFGHIJKLM\nNOPQRSTUVWXYZ\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 6\nAAAAAB\nABBBAB\nABAAAB\nABABBB\nABAAAB\nABBBAB\nAAAAAB\n",
"output": "Yes\n"... |
code_contests | verifiable_code | 535_C. Tavas and Karafs | Solve the following coding problem using the programming language python:
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.
<image>
Each Karafs has a positive integer height. Tavas has ... | ```python
a,b,n=map(int,input().split())
for _ in range(n):
l,t,m=map(int,input().split())
lo=l
hi=100000000
while lo<hi:
mid=(lo+hi)//2
count=(mid-l)+1
first=a+(l-1)*b
last=a+(mid-1)*b
if last<=t and (count*(first+last))//2<=m*t:
lo=mid+1
else... | vfc_38137 | {
"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 5 2\n1 5 10\n2 7 4\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 55_D. Beautiful numbers | Solve the following coding problem using the programming language python:
Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautifu... | vfc_38141 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n12 15\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1 9\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... | |
code_contests | verifiable_code | 586_A. Alena's Schedule | Solve the following coding problem using the programming language python:
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is ... | ```python
n = int(input())
a = list(map(int, input().split())) + [0]
home = True
ans = 0
for i in range(n):
if a[i]:
ans += 1
home = False
elif not a[i + 1] and not home:
home = True
elif not home:
ans += 1
print(ans)
``` | vfc_38145 | {
"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\n0 1 0 1 1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n1 0 1 0 0 1 0\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 608_B. Hamming Distance Sum | Solve the following coding problem using the programming language python:
Genos needs your help. He was asked to solve the following programming problem by Saitama:
The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as <image>, where si is the i-th ... | ```python
from sys import stdin
input=stdin.readline
'''
if i+k
'''
def getcnt(a):
cnt=[[0,0] for i in range(len(a)+1)]
for i in range(len(a)):
# if i==0:
# cnt[i][a[i]]+=1
# else:
cnt[i+1][0]=cnt[i][0]
cnt[i+1][1]=cnt[i][1]
cnt[i+1][a[i]]+=1
return cnt
d... | vfc_38149 | {
"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": "01\n00111\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0011\n0110\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
code_contests | verifiable_code | 62_A. A Student's Dream | Solve the following coding problem using the programming language python:
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting the ma... | ```python
g_l,g_r=input().split()
b_l,b_r=input().split()
g_l=int(g_l)
g_r=int(g_r)
b_l=int(b_l)
b_r=int(b_r)
flag=0
if g_l==b_r:
flag=1
elif g_l>b_r and g_l-1==b_r:
flag=1
elif b_r>g_l and 2*g_l+2>=b_r:
flag=1
if flag==0:
if g_r == b_l:
flag = 1
elif g_r > b_l and g_r - 1 == b_l:
f... | vfc_38153 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5\n3 3\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1\n10 5\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 653_G. Move by Prime | Solve the following coding problem using the programming language python:
Pussycat Sonya has an array consisting of n positive integers. There are 2n possible subsequences of the array. For each subsequence she counts the minimum number of operations to make all its elements equal. Each operation must be one of two:
... | vfc_38157 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n60 60 40\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 3 4\n",
"output": "24\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... | |
code_contests | verifiable_code | 701_F. Break Up | Solve the following coding problem using the programming language python:
Again, there are hard times in Berland! Many towns have such tensions that even civil war is possible.
There are n towns in Reberland, some pairs of which connected by two-way roads. It is not guaranteed that it is possible to reach one town f... | vfc_38165 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n1 2\n1 2 734458840\n1 2 817380027\n1 2 304764803\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\n1 5\n2 1 3\n3 2 1\n3 4 4\n4 5 2\n",
"output": "1\n1\n2",
... | |
code_contests | verifiable_code | 724_A. Checking the Calendar | Solve the following coding problem using the programming language python:
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equ... | ```python
a = str(input())
b = str(input())
k = {'monday':1,'tuesday':2,'wednesday':3,'thursday':4,'friday':5,'saturday':6,'sunday':7}
a=k[a]-1
b=k[b]-1
res = False
res = res or ((a+2)%7+1)%7==b
res = res or ((a+1)%7+1)%7==b
res = res or ((a+6)%7+1)%7==b
if res:
print("YES")
else:
print("NO")
``` | vfc_38169 | {
"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": "monday\ntuesday\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "saturday\ntuesday\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 746_A. Compote | Solve the following coding problem using the programming language python:
Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't cr... | ```python
l = int(input())
a = int(input())
p = int(input())
ll = l
aa = a // 2
pp = p // 4
print(min(ll,aa,pp) * 1 + min(ll,aa,pp) * 2 + min(ll,aa,pp) * 4)
``` | vfc_38173 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n7\n",
"output": "7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n7\n13\n",
"output": "21",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2... |
code_contests | verifiable_code | 769_A. Year of University Entrance | Solve the following coding problem using the programming language python:
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the universi... | ```python
n = int(input())
a = list(map(int, input().split()))
a.sort()
if n % 2:
print(a[n//2])
``` | vfc_38177 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2050\n",
"output": "2050\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2014 2016 2015\n",
"output": "2015\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
code_contests | verifiable_code | 793_A. Oleg and shares | Solve the following coding problem using the programming language python:
Oleg the bank client checks share prices every day. There are n share prices he is interested in. Today he observed that each second exactly one of these prices decreases by k rubles (note that each second exactly one price changes, but at diffe... | ```python
n,k=map(int,input().split())
l=list(map(int,input().split()))
K=min(l)
for i in range(n):
if (l[i]-K)%k!=0:
print(-1)
exit()
Sum=sum(l)
K=K*n
Sum=Sum-K
print(Sum//k)
``` | vfc_38181 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n10 9\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n12 9 15\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 859_F. Ordering T-Shirts | Solve the following coding problem using the programming language python:
It's another Start[c]up, and that means there are T-shirts to order. In order to make sure T-shirts are shipped as soon as possible, we've decided that this year we're going to order all of the necessary T-shirts before the actual competition. T... | ```python
from sys import*
from itertools import*
from collections import*
def main():
n, c = map(int, stdin.readline().split())
s = map(int, stdin.readline().split(), repeat(10, 2 * n - 1))
l = len(s)
st = min(c, s[0])
ss = s[0]
ans = st
q = deque([(s[0], st)])
for i in xrange(2, l, 2):... | vfc_38193 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 160\n88 69 62 29 58 52 44\n",
"output": "314\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 200\n100 250 100\n",
"output": "200\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 884_E. Binary Matrix | Solve the following coding problem using the programming language python:
You are given a matrix of size n × m. Each element of the matrix is either 1 or 0. You have to determine the number of connected components consisting of 1's. Two cells belong to the same component if they have a common border, and both elements... | vfc_38197 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 16000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4\n1\nA\n8\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 4\n0\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... | |
code_contests | verifiable_code | 930_A. Peculiar apple-tree | Solve the following coding problem using the programming language python:
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any... | ```python
from collections import defaultdict,Counter,deque as dq
from sys import stdin
input=stdin.readline
n=int(input())
g=defaultdict(list)
w=list(map(int,input().strip().split()))
for i in range(len(w)):
g[w[i]-1].append(i+1)
g[i+1].append(w[i]-1)
# print(g)
q=dq([0])
d=[-1]*(n)
d[0]=1
cnt=defaultdict(int)
cn... | vfc_38205 | {
"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": "18\n1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 958_C2. Encryption (medium) | Solve the following coding problem using the programming language python:
Heidi has now broken the first level of encryption of the Death Star plans, and is staring at the screen presenting her with the description of the next code she has to enter. It looks surprisingly similar to the first one – seems like the Empir... | vfc_38209 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3 10\n3 4 7 2\n",
"output": "16\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5 12\n16 3 24 13 9 8 7 5 12 12\n",
"output": "37\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 984_A. Game | Solve the following coding problem using the programming language python:
Two players play a game.
Initially there are n integers a_1, a_2, …, a_n written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i. e. n - 1 turn... | ```python
x = int(input())
l = [int(n) for n in input().split()]
l.sort()
i = 0
while len(l) > 1:
if i % 2 == 0:
l = l[0:len(l) - 1]
else:
l = l[1:len(l)]
i = i + 1
print(l[0])
``` | vfc_38213 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 2 2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 1 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | a-team | Solve the following coding problem using the programming language python:
Hannibal is on a mission. He has to shoot a criminal. Hannibal was on the point (0, 0) and the criminal is on the point (Xc, Yc). But there is a wall between the point (X1, Y1) and (X2, Y2).
You have to tell whether Hannibal can shoot criminal... | ```python
def are_points_colinear(x1,y1,x2,y2,x3,y3):
return x1*(y2-y3)+y1*(x3-x2)+x2*y3-x3*y2 == 0
def slope_positive(x1,y1,x2,y2):
if x1 == x2 or y1 == y2:
return False
else:
return float(x2-x1)/float(y2-y1) > 0
def slope_negative(x1,y1,x2,y2):
if x1 == x2 or y1 == y2:
return ... | vfc_38217 | {
"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 2 2 3 3\n2 2 3 3 1 1\n\nSAMPLE",
"output": "NO\nYES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1 2 2 3 3\n2 2 3 3 1 1",
"output": "NO\nYES",
"type": "stdin_stdou... |
code_contests | verifiable_code | blocks | Solve the following coding problem using the programming language python:
You have 4 types of lego blocks, of sizes (1 x 1 x 1), (1 x 1 x 2), (1 x 1 x 3), and (1 x 1 x 4). Assume that you have an infinite number of blocks of each type.
Using these blocks, you want to make a wall of height N and width M. The wall shou... | ```python
limit = 1004
f = [0] * limit
f[0] = 1
for x in xrange(1, limit):
a = 0
if x >= 1: a = f[x-1]
b = 0
if x >= 2: b = f[x-2]
c = 0
if x >= 3: c = f[x-3]
d = 0
if x >= 4: d = f[x-4]
f[x] = (a + b + c + d) % 1000000007
def get(n, m):
g = [0] * (m+1)
p = map(lambda x: pow... | vfc_38221 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 2\n3 2\n2 3\n4 4\n\nSAMPLE",
"output": "3\n7\n9\n3375",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 2\n3 2\n2 3\n4 4\n\nELPMAS",
"output": "3\n7\n9\n3375\n",
"type": ... |
code_contests | verifiable_code | cricket-rating-30 | Solve the following coding problem using the programming language python:
India is a cricket crazy nation. Chang also loves cricket and computations related to cricket. Chang has created a Cricket app.This app analyses the performance of a cricketer. If a cricketer under-performs, then a negative rating is awarded. If... | ```python
n=input();
if n==0: print 0;
else:
A=map(int,raw_input().split()); val,max_v=0,0;
for i in A:
if i+val>0:
val+=i;
if val>max_v: max_v=val;
else: val=0;
print max_v;
``` | vfc_38225 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n-1 -4 4 -2 0 1 4 -5\n\nSAMPLE",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n-1 -2 5 -1 -2 3 2 -1",
"output": "7\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | food-stall | Solve the following coding problem using the programming language python:
Saurav has put up Chinese food stall in the college fest. He has arranged everything but he was not able to find chop-sticks in any shop. He decided to make some himself. After hours of efforts, he was able to collect a few ice cream sticks that... | ```python
'''
ChopStick
'''
import math
def Fun_Wid_Code():
tc=int(raw_input())
while(tc):
n,d=map(int,raw_input().split())
num=[0]*n
i=0
while(i<n):
num[i]=int(raw_input())
i+=1
num.sort()
i=0
count=0
while(i<n-1):
... | vfc_38229 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 5\n1\n6\n\nSAMPLE",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4 5\n1\n6\n4\n9",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name":... |
code_contests | verifiable_code | joker-vs-batman | Solve the following coding problem using the programming language python:
Joker is back again with his destructive plan . He has set N bombs in various parts of Gotham city and has challenged the police department to defuse all bombs in one day . City can be treated as a 1-D line with 'N' bombs situated in such a m... | ```python
def get_mod_pow(a,b,m):
ans=1
while b > 0:
if b % 2 == 1:
ans = (ans * a) % m
a = (a ** 2) % m
b = b / 2
return ans
def find(n,x,m):
if n==0:return 0
if n==1:return x
poly=find(n/2,x,m)
if n%2==1:
return (poly+(1+poly)*get_mod_pow(x,(n+1... | vfc_38233 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 1 10\n2 2 10\n2 5 3\n2 8 100\n10 1 10\n\nSAMPLE",
"output": "2\n2\n0\n44\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "25\n100021238 100007719 39 \n100011797 100008855 2438 \n10001... |
code_contests | verifiable_code | milly-and-chocolates-iii-2 | Solve the following coding problem using the programming language python:
Milly loves chocolates very much. She is at the land of chocolates. This land has N rooms such that there are some chocolates of different brands in every room. It is possible that there can be multiple chocolates of same brand in a particular r... | ```python
NOT_FOUND = 100000000
def isOKay(ChocolateMap):
Cnt = 0
for k, v in ChocolateMap.iteritems():
if v >= 1:
Cnt += 1
return Cnt
def Rec(N, K, Chocolates, Position, ChocolateMap):
if (Position == N):
if isOKay(ChocolateMap) >= K:
return 0
return ... | vfc_38237 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 2\n1 KITKAT\n2 FIVESTAR KITKAT\n2 KITKAT PERK\n\nSAMPLE",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n10 40\n10 ggl fhklnkh addejhpo igkknigiq c egfhh egfhh edhdhh... |
code_contests | verifiable_code | painting-the-road | Solve the following coding problem using the programming language python:
There is a kingdom, that has a long straight road of length L meters and width 0. Coordinate x on the road denotes point that is at x meters from the start of the road. That is coordinate 0 denotes beginning of the road and coordinate L denotes ... | ```python
'''input
3
9 6
2 7 10
7 8 3
3 4 8
0 8 2
5 6 4
3 7 1
9 6
7 8 6
6 9 6
2 5 8
3 6 10
0 7 6
2 9 1
3 4
0 3 8
0 2 4
0 1 10
2 3 8
'''
def min(a,b):
if a != 0 and a <= b:
return a
return b
tc = int(raw_input())
for t in xrange(tc):
n,k = map(int,raw_input().split())
ip = [""] * (k+1)
for i in xrange(1,k+1):... | vfc_38241 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n9 6\n2 7 10\n7 8 3\n3 4 8\n0 8 2\n5 6 4\n3 7 1\n9 6\n7 8 6\n6 9 6\n2 5 8\n3 6 10\n0 7 6\n2 9 1\n3 4\n0 3 8\n0 2 4\n0 1 10\n2 3 8\n\nSAMPLE",
"output": "-1\n7\n8",
"type": "stdin_stdout"
},
{
"fn_name": ... |
code_contests | verifiable_code | rescue-the-hackland | Solve the following coding problem using the programming language python:
Hackland is being attacked by Greyland, and you have been assigned the job to save it. Your enemies, known as Grey hats, are numbered starting from L to R, both inclusive. But, here is the fun part: Grey hats are known to switch sides, and you ... | ```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!'
testcases = int(raw_input())
for i in range(testcases):
num=raw_input().split()
L=int(num[0])
R=int(num[1])
K=int(num[2])
x=L;
count=0;
while(x<... | vfc_38245 | {
"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 10 10\n1 11 10\n\nSAMPLE",
"output": "1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "200\n1 1001 1000\n5 511 10\t\n5 4747 10\n1 1000000 10\t\n10 10110 10\n1 1 10\t\n1000000 1000... |
code_contests | verifiable_code | sort-1 | Solve the following coding problem using the programming language python:
The dark lord wants to send armies of imps to assault Hogwarts in the first wave of offense. The imps are accustomed to fight in communities and will not fight separately. Communities are sent to battle such that the size of each community sent ... | ```python
T = raw_input("")
for i in range(int(T)):
raw_input("")
str2 = raw_input("")
str2 = str2.split()
str2 = [int(i) for i in str2]
str2.sort()
str1 = ' '.join(str(e) for e in str2)
print(str1)
``` | vfc_38249 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n1 2 2\n2\n9 2\n\nSAMPLE",
"output": "1 2 2\n2 9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n100\n5644 1134 9689 3313 8924 5073 6948 8330 4393 1486 440 9499 890 9913 6345 3036... |
code_contests | verifiable_code | toss-ka-boss | Solve the following coding problem using the programming language python:
Cricket has gone from a history of format which are test match, 50-50 and 20-20. Therefore, ICC decided to start a new type of format i.e. toss. For this ICC started a competition known as ‘Toss ka Boss’. Here the team captains compete with each... | ```python
T = input()
for i in range(0,T):
a = []
s = raw_input()
for i in range(0, len(s)):
a.append(s[i])
#print a
for i in range(0, len(a)):
if(a[i]=='T'):
a[i] = 0
#print a
c = 1
sum1 = 0
for i in range(0, len(a)):
if(a[i]==0):
... | vfc_38253 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nHHTTHTTHHH\nHHTTTTTTTTTT\nTTTTTTTTTTTTHT\nHHHHHHHHHH\nHHHHTHHHHTHHHHT\n\nSAMPLE",
"output": "10\n3\n1\n55\n30\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\nHHTTHTTHHH\nHHTTTTTTTTTT... |
code_contests | verifiable_code | p00122 Summer of Pyonkichi | Solve the following coding problem using the programming language python:
The University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyonkichi lives in this par... | ```python
move = [[-1, 2], [0, 2], [1, 2],
[-1, -2], [0, -2], [1, -2],
[2, 1], [2, 0], [2, -1],
[-2, 1], [-2, 0], [-2, -1]]
spraing_range = [[-1, 1], [0, 1], [1, 1],
[-1, 0], [0, 0], [1, 0],
[-1, -1], [0, -1], [1, -1]]
def main():
while True:
px, ... | vfc_38301 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 9 0\n0 0",
"output": "OK\nNA",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 1\n10\n6 4 3 3 1... |
code_contests | verifiable_code | p00255 Salary for a Plumber | Solve the following coding problem using the programming language python:
I am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have too many pipes, you can't... | ```python
# -*- coding: utf-8 -*-
"""
Salary for a Plumber
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0260
"""
import sys
def solve(n):
pipes = [int(p) for p in input().split()]
joints = sorted([int(j) for j in input().split()])
total_length = sum(pipes)
record = total_length * n
w... | vfc_38305 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1 1\n3 3\n4\n3 3 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0",
"output": "12\n48\n76",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 1\n3 3\n4\n3 1 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0"... |
code_contests | verifiable_code | p00441 The Oldest Site | Solve the following coding problem using the programming language python:
problem
Once upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in the ruins. Was a clue to t... | ```python
def main():
while True:
n = int(input())
if not n:
break
ps = [list(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add((t[0],t[1]))
ans = 0
for i in range(n):
for j in range(n):
p1 = ps[i]
p2 = ps[j]
p1x = p1... | vfc_38309 | {
"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": "10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0",
"output": "10\n10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n9 4\n4 3... |
code_contests | verifiable_code | p00632 Ghost Buster! | Solve the following coding problem using the programming language python:
The city is full of ghosts, something the average person doesn't know about. Most of them are harmless, but the trouble is that there are quite a few evil spirits that curse people.
There was a girl who fought against such evil spirits. She goe... | ```python
from collections import deque
while True:
h, w = map(int, input().split())
if h == 0:
break
mp = [list("X" + input() + "X") for _ in range(h)]
mp.insert(0, ["X"] * (w + 2))
mp.append(["X"] * (w + 2))
for y in range(h + 2):
for x in range(w + 2):
if mp[y][x] == "A":
ax, ay ... | vfc_38313 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n5\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n2\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n4\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n442668\n1 10\nA#.......B\n55555554\n1 10\nA#.......B\n5555... |
code_contests | verifiable_code | p00776 Encryption System | Solve the following coding problem using the programming language python:
Encryption System
A programmer developed a new encryption system. However, his system has an issue that two or more distinct strings are `encrypted' to the same string.
We have a string encrypted by his system. To decode the original string, w... | ```python
from itertools import chain
alph = "abcdefghijklmnopqrstuvwxyz"
# s = input()
def solve1(s):
cands = [s]
for c in reversed(alph[:-1]):
cands = chain.from_iterable(
[candidates(s, c) for s in cands]
)
cands = list(cands)
cands.sort()
print(len(cands))
if l... | vfc_38317 | {
"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": "enw\nabc\nabcdefghijklmnopqrst\nz\n#",
"output": "1\nfox\n5\nacc\nacd\nbbd\nbcc\nbcd\n17711\nacceeggiikkmmooqqssu\nacceeggiikkmmooqqstt\nacceeggiikkmmooqqstu\nacceeggiikkmmooqrrtt\nacceeggiikkmmooqrrtu\nbcdefghijklmnopqrrtt\n... |
code_contests | verifiable_code | p00907 Find the Outlier | Solve the following coding problem using the programming language python:
Professor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial function f(x) = x2 + 2x + 1, fo... | ```python
from itertools import combinations
def build(X, Y):
A = []
for x in X:
res = 1
for xi in X:
if x == xi:
continue
res *= x - xi
A.append(Y[x] / res)
return A
def calc(X, A, x):
base = 1
for xi in X:
base *= i - xi
... | vfc_38321 | {
"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\n1.0\n4.0\n12.0\n16.0\n25.0\n1\n-30.5893962764\n5.76397083962\n39.3853798058\n74.3727663177\n4\n42.4715310246\n79.5420238202\n28.0282396675\n-30.3627807522\n-49.8363481393\n-25.5101480106\n7.58575761381\n5\n-21.9161699038\n-48.46... |
code_contests | verifiable_code | p01174 Rotation Estimation | Solve the following coding problem using the programming language python:
Mr. Nod is an astrologist and has defined a new constellation. He took two photos of the constellation to foretell a future of his friend. The constellation consists of n stars. The shape of the constellation in these photos are the same, but th... | vfc_38329 | {
"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\n0.0 0.0\n1.0 1.0\n0.0 1.0\n3.0 3.0\n2.0 2.0\n3.0 2.0\n0",
"output": "3.14159265359",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01310 Drawing Lots | Solve the following coding problem using the programming language python:
Natsume loves big cats. Natsume decided to head to a corner of the schoolyard where stray cats always gather in order to brush the stray cats, which is a daily routine today.
N cats gathered at the spot today. Natsume wanted to brush everyone, ... | vfc_38333 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n4 2 1\n10 1\n10 3",
"output": "1\n0\n1\n1\n0\n1\n1\n2\n0\n1\n0\n1\n2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... | |
code_contests | verifiable_code | p01479 Chicken or the Egg | Solve the following coding problem using the programming language python:
Time Limit: 8 sec / Memory Limit: 64 MB
Example
Input
eggchickenegg
Output
egg
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code. | ```python
s=input()
i=c=p=0;b=''
while i<len(s):
if s[i]==b:
if c > p:r=b;p=c
c=0
b=s[i]
i+=[3,7][s[i]=='c']
c+=1
if c>p:r=b
print(['chicken','egg'][r=='e'])
``` | vfc_38337 | {
"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": "eggchickenegg",
"output": "egg",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "egichgckenegg",
"output": "egg\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | p01640 Get Lost | Solve the following coding problem using the programming language python:
ICPC World Finals Day 5
Mr. Tee got lost in the city of R country. The trouble is that the streets are similar, so I have no idea where I am now. Country R is "sorry", so you have to return to the hotel before being attacked by the enemy. Fortu... | vfc_38341 | {
"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": "w h g",
"output": "9",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01791 Card Game Strategy | Solve the following coding problem using the programming language python:
Example
Input
4 2 58 100
10 10 50 80
Output
75
2 3
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code. | vfc_38345 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 1073741824,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2 58 100\n10 10 50 80",
"output": "75\n2 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 2 58 100\n10 10 50 80",
"output": "70\n2 3\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | p01926 Game Balance | Solve the following coding problem using the programming language python:
Game balance
You are creating an adventure game. The player of this game advances the adventure by operating the hero to defeat the enemy monsters and raising the level of the hero. The initial level of the hero is 1.
There are N types of enem... | ```python
while 1:
n, m = map(int, raw_input().split())
if n == m == 0:
break
S = map(int, raw_input().split())
left = 0; right = sum(S)+2
def check(mid):
if 1+mid <= S[0]:
return 10**9
cnt = 0; l = 1
target = S[n-1] - mid
for i in xrange(n-1):
... | vfc_38349 | {
"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 4\n1 5 9\n1 2\n1\n2 10\n1 1000000\n2 4\n1 10\n0 0",
"output": "3\n-1\n499996\n4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n2 5 9\n1 2\n1\n2 10\n1 1000000\n2 4\n1 10\n0 0",
... |
code_contests | verifiable_code | p02064 Restore Shortest Path | Solve the following coding problem using the programming language python:
E: Restoration of shortest path
story
Competition programmers solve the shortest path problem every day. BFS, Bellman Ford, Dijkstra, Worshall Floyd and many other algorithms are also known.
Meanwhile, you had a shortest path problem that you... | vfc_38353 | {
"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": "",
"output": "",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | chefa | Solve the following coding problem using the programming language python:
Chef and Roma are playing a game. Rules of the game are quite simple.
Initially there are N piles of stones on the table.
In each turn, a player can choose one pile and remove it from the table.
Each player want to maximize the total number of s... | ```python
for i in range(input()):
input()
a = map(int,raw_input().split())
a.sort(reverse = True)
i = 2
s=a[0]
while i<len(a):
s+=a[i]
i+=2
print s
``` | vfc_38365 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n1 2 3\n3\n1 2 1",
"output": "4\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3\n1 2 3\n3\n1 2 2",
"output": "4\n3\n",
"type": "stdin_stdout"
},
{
"f... |
code_contests | verifiable_code | devperf | Solve the following coding problem using the programming language python:
There is a haunted town called HauntedLand. The structure of HauntedLand can be thought of as a grid of size n * m. There is a house in each cell of the grid. Some people have fled from their houses because they were haunted. '.' represents a ha... | ```python
for t in xrange(int(raw_input())):
n, m = map(int, raw_input().split())
r, c = n, m
row = []
col = []
for i in xrange(m):
col.append("")
for i in xrange(n):
s = raw_input()
row.append(s)
for j in xrange(m):
col[j] += s[j]
for i in range(n):
if (row[i].count(".") == m):
r -= 1
el... | vfc_38369 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 2\n*.\n..\n3 4\n.*..\n***.\n.*..",
"output": "1\n2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | insm06 | Solve the following coding problem using the programming language python:
Ronak’s class teacher gives him an NxN matrix.
Then, she gives him M numbers. Every number is an angle, the angle by which he has to rotate the matrix in clockwise direction. (The angles are multiples of 90.)
Help him with the task.
Input
... | ```python
n,m=map(int, raw_input().split())
a=[ raw_input().split() for j in xrange(n) ]
while m>0:
m-=1
ang=input()
ang/=90
ang%=4
if(ang==1):
for j in xrange(0,n):
for i in xrange(n-1,-1,-1):
print a[i][j],
print
elif(ang==2):
for i in xrange(n-1,-1,-1):
for j in xrange(n-1,-1,-1):
print a... | vfc_38373 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n1 2 3 4\n4 5 6 7\n6 8 4 3\n8 1 4 7\n90\n180",
"output": "8 6 4 1\n1 8 5 2\n4 4 6 3\n7 3 7 4\n\n7 4 1 8\n3 4 8 6\n7 6 5 4\n4 3 2 1",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | newsch | Solve the following coding problem using the programming language python:
Scheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows how. But don't tell anyone... | ```python
mod=1000000007
test=input()
while test:
n=input()
print (pow(3,n,mod)+3*pow(-1,n))%mod
test-=1
``` | vfc_38377 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n3\n5",
"output": "12\n24\n240\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | sad | Solve the following coding problem using the programming language python:
Our Chef is very happy that his son was selected for training in one of the finest culinary schools of the world.
So he and his wife decide to buy a gift for the kid as a token of appreciation.
Unfortunately, the Chef hasn't been doing good busi... | ```python
r, c = map(int, raw_input().split())
grid = []
ans = []
for i in range(r):
grid.append(map(int, raw_input().split()))
ans.append([0]*c)
m = min(grid[i])
for j in range(c):
if (grid[i][j] == m):
ans[i][j] += 1
grid = zip(*grid)
for i in range(c):
m = max(grid[i])
for j in range(r):
if (grid[i... | vfc_38381 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n9 8 8\n2 6 11",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n9 8 11\n2 6 34\n5 9 11",
"output": "GUESS\n",
"type": "stdin_stdout"
},
{
"... |
code_contests | verifiable_code | ynoutput | Solve the following coding problem using the programming language python:
The state space of the output of this problem (and as a matter of fact, all the problems in this Cook-Off) is - 2 to the power T -
where T is the number of test cases (so be extra careful!). Each test case consists of T lines consisting of "YES"... | ```python
t=int(raw_input())
b=[]
l=[]
d=0
for i in xrange(0,t*t):
k=raw_input()
if(k[0]=='Y'):
d='1'
elif(k[0]=='N'):
d='0'
l.append(d)
if(i%t==t-1):
b.append(''.join(l))
l=[]
#print b
ans=0
for i in xrange(0,t):
f=1
for j in xrange(0,t):
if((b[i]==b[j] and b[i][j]=='0') or (b[i]!=b[j] and b[i][j]==... | vfc_38385 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nNO\nNO\nNO\nYES",
"output": "NO\nYES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\nNO\nON\nNO\nYES",
"output": "NO\nYES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1045_B. Space Isaac | Solve the following coding problem using the programming language python:
Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \{0,1,…,M-1\}, f... | ```python
import sys
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
a = list(map(int, input().split())) + [0]*500000
ans_S = 0
a[n] = a[0] + m
s = [0]*600600
for i in range(n):
s[i] = a[i + 1] - a[i]
s[n] = -1
for i in range(n):
s[2*n - i] = s[i]... | vfc_38393 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 1000000000\n5 25 125 625\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 4\n1 3\n",
"output": "2\n0 2 \n",
"type": "stdin_stdout"
},
{
"fn_na... |
code_contests | verifiable_code | 1068_B. LCM | Solve the following coding problem using the programming language python:
Ivan has number b. He is sorting through the numbers a from 1 to 10^{18}, and for every a writes ([a, b])/(a) on blackboard. Here [a, b] stands for least common multiple of a and b. Ivan is very lazy, that's why this task bored him soon. B... | ```python
b=int(input())
out=[1]
n=b
i=0
while n%2==0:
i=i+1
out.append(2**i)
n=int(n/2)
out1=[]
for i in range (1,int(n**0.5)+1,2):
if n%i==0:
out1.append(i)
out1.append(int(n/i))
out2=set()
for i in out:
for j in out1:
out2.add(i*j)
#print (out2)
print (len(out2))
``... | vfc_38397 | {
"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\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "244078129\n... |
code_contests | verifiable_code | 1109_D. Sasha and Interesting Fact from Graph Theory | Solve the following coding problem using the programming language python:
Once, during a lesson, Sasha got bored and decided to talk with his friends. Suddenly, he saw Kefa. Since we can talk endlessly about Kefa, we won't even start doing that. The conversation turned to graphs. Kefa promised Sasha to tell him about ... | vfc_38405 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 1 1 2\n",
"output": "2",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1139_A. Even Substrings | Solve the following coding problem using the programming language python:
You are given a string s=s_1s_2... s_n of length n, which only contains digits 1, 2, ..., 9.
A substring s[l ... r] of s is a string s_l s_{l + 1} s_{l + 2} … s_r. A substring s[l ... r] of s is called even if the number represented by it is ev... | ```python
n = int(input())
s = input()
k = 0
for i in range(1, n + 1):
d = int(s[i - 1])
if d % 2 == 0:
k += i
print(k)
``` | vfc_38409 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 0, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1234\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1179_C. Serge and Dining Room | Solve the following coding problem using the programming language python:
Serge came to the school dining room and discovered that there is a big queue here. There are m pupils in the queue. He's not sure now if he wants to wait until the queue will clear, so he wants to know which dish he will receive if he does. As ... | vfc_38417 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 6\n1 8 2 4\n3 3 6 1 5 2\n3\n1 1 1\n2 5 10\n1 1 6\n",
"output": "8\n-1\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n1\n1\n1 1 100\n",
"output": "100\n",
"type": ... | |
code_contests | verifiable_code | 1197_E. Culture Code | Solve the following coding problem using the programming language python:
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has n different matryoshkas. Any matryoshka is a figure of volume out_i with an empty space insi... | ```python
from sys import stdin, stdout
mod = 10**9+7
n = int(input())
dolls = []
for i in range(n):
o, i = map(int, stdin.readline().split())
dolls.append((o, i))
dolls.sort()
dolls = [(i, o) for (o, i) in dolls]
#print(dolls)
def bin_search(i):
lo = -1
hi = n-1
while lo+1 < hi:
mid = ... | vfc_38421 | {
"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": "7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2\n",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1000000000 999999999\n",
"output": "1",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 1214_F. Employment | Solve the following coding problem using the programming language python:
Two large companies "Cecsi" and "Poca Pola" are fighting against each other for a long time. In order to overcome their competitor, "Poca Pola" started a super secret project, for which it has total n vacancies in all of their offices. After man... | vfc_38425 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 3\n1 4 8\n8 3 6\n",
"output": "4\n2 3 1 ",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1237_H. Balanced Reversals | Solve the following coding problem using the programming language python:
You have two strings a and b of equal even length n consisting of characters 0 and 1.
We're in the endgame now. To finally make the universe perfectly balanced, you need to make strings a and b equal.
In one step, you can choose any prefix of ... | ```python
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.bu... | vfc_38429 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n0100011011\n1101011000\n10101010\n10101010\n0011\n1001\n100011\n110010\n",
"output": "11\n2 2 4 4 6 4 6 6 8 8 10 \n8\n8 2 2 4 4 6 6 8 \n-1\n6\n2 2 2 4 4 6 \n",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
code_contests | verifiable_code | 1256_A. Payment Without Change | Solve the following coding problem using the programming language python:
You have a coins of value n and b coins of value 1. You always pay in exact change, so you want to know if there exist such x and y that if you take x (0 ≤ x ≤ a) coins of value n and y (0 ≤ y ≤ b) coins of value 1, then the total value of taken... | ```python
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
def main():
q = int(input())
for i in range(... | vfc_38433 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 2 3 4\n1 2 3 6\n5 2 6 27\n3 3 5 18\n",
"output": "YES\nNO\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n16 2 3 55\n",
"output": "NO\n",
"type": "stdin_stdout... |
code_contests | verifiable_code | 127_A. Wasted Time | Solve the following coding problem using the programming language python:
Mr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to count the time he has wasted... | ```python
n,k = list(map(int,input().split()))
ans = 0
for i in range(n):
if i==0:
x,y= list(map(int,input().split()))
else:
X,Y = list(map(int,input().split()))
d = ((X-x)**2+(Y-y)**2)**(1/2)
x,y=X,Y
ans += d
ans=((ans*k)/50)
print('%.9f'%ans)
``` | vfc_38437 | {
"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 1\n0 0\n10 0\n",
"output": "0.200000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 10\n5 0\n4 0\n6 0\n3 0\n7 0\n2 0\n",
"output": "3.000000000\n",
"type": "stdin_stdou... |
code_contests | verifiable_code | 129_E. Games with Rectangle | Solve the following coding problem using the programming language python:
In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n × m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint ins... | ```python
n, m, k = map(int, raw_input().strip().split())
def fac(x):
ret = 1
for i in xrange(1, x + 1):
ret *= i
return ret
def c(n, r):
return fac(n) / (fac(n - r) * fac(r)) if r <= n else 0
print c(n - 1, k * 2) * c(m - 1, k * 2) % (10 ** 9 + 7)
``` | vfc_38441 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 1\n",
"output": "9\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1342_A. Road To Zero | Solve the following coding problem using the programming language python:
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation:
* ... | ```python
def to_list(s):
return list(map(lambda x: int(x), s.split(' ')))
def solve(x,y,a,b):
cost = 0
if b <= 2*a:
min_val = min(x,y)
cost += b*min_val
x -= min_val
y -= min_val
max_val = max(x,y)
cost += max_val*a
else:
cost = (x+y)*a
print... | vfc_38449 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 3\n391 555\n0 0\n9 4\n",
"output": "1337\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n129 8437\n5 3\n",
"output": "41927\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1364_A. XXXXX | Solve the following coding problem using the programming language python:
Ehab loves number theory, but for some reason he hates the number x. Given an array a, find the length of its longest subarray such that the sum of its elements isn't divisible by x, or determine that such subarray doesn't exist.
An array a is ... | ```python
t = int(input())
for tc in range(t):
n = int(input())
a = list(map(int, input().split()))
s = set(a)
print(len(s))
``` | vfc_38453 | {
"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\n3 3\n1 2 3\n3 4\n1 2 3\n2 2\n0 6\n",
"output": "2\n3\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n1 1\n1\n1\n",
"output": "1\n1\n",
"type": "stdin_stdout"
}... |
code_contests | verifiable_code | 144_E. Competition | Solve the following coding problem using the programming language python:
The secondary diagonal of a square matrix is a diagonal going from the top right to the bottom left corner. Let's define an n-degree staircase as a square matrix n × n containing no squares above the secondary diagonal (the picture below shows a... | ```python
from heapq import *
n,m=map(int,raw_input().split())
zz=list()
for i in xrange(m):
ll=map(int,raw_input().split())
ll[1]=n-ll[1]+1;
ll.sort()
zz.append(ll+[i+1])
zz.sort()
zi=iter(zz)
nn=zi.next()
h=[]
rr=[]
for i in xrange(1,n+1):
while nn[0]<=i:
heappush(h,(nn[1],nn[2]))
... | vfc_38469 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n2 3\n3 2\n3 3\n",
"output": "3\n1 2 3 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 20\n2 9\n3 8\n4 7\n4 8\n5 6\n6 5\n6 6\n6 7\n6 9\n7 5\n7 10\n8 6\n8 9\n9 3\n9 6\n10 1\n10 2\n10 ... |
code_contests | verifiable_code | 1473_E. Minimum Path | Solve the following coding problem using the programming language python:
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with indices... | ```python
import io
import os
# import __pypy__
def dijkstra(*args):
# return dijkstraHeap(*args) # 2979 ms
return dijkstraHeapComparatorWrong(*args) # 2823 ms
# return dijkstraHeapComparator(*args) # 2370 ms
# return dijkstraSegTree(*args) # 2417 ms with inf=float('inf), 2995 ms with inf=-1
... | vfc_38473 | {
"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": "7 10\n7 5 5\n2 3 3\n4 7 1\n5 3 6\n2 7 6\n6 2 6\n3 7 6\n4 2 1\n3 1 4\n1 7 4\n",
"output": "\n3 4 2 7 7 3 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\n5 3 4\n2 1 1\n3 2 2\n2 4 2\n",... |
code_contests | verifiable_code | 1521_E. Nastia and a Beautiful Matrix | Solve the following coding problem using the programming language python:
You like numbers, don't you? Nastia has a lot of numbers and she wants to share them with you! Isn't it amazing?
Let a_i be how many numbers i (1 ≤ i ≤ k) you have.
An n × n matrix is called beautiful if it contains all the numbers you have, a... | ```python
def cheak(x):
return x**2-(x//2)**2>=m and x*(x//2+(1 if x%2!=0 else 0))>=mx
for test in range(int(input())):
m,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
mx=max(a)
z=0;y=m*4
while z!=y:
x=(z+y)//2
if cheak(x):
y=x
else:
... | vfc_38481 | {
"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\n3 4\n2 0 0 1\n15 4\n2 4 8 1\n",
"output": "\n2\n4 1\n0 1\n5\n3 0 0 2 2\n3 2 3 3 0\n0 1 0 4 0\n3 0 0 0 0\n2 1 3 3 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n9 3\n1 0 8\n",
... |
code_contests | verifiable_code | 177_B1. Rectangular Game | Solve the following coding problem using the programming language python:
The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b... | ```python
n=int(input())
r=n+1
i=2
s=n**0.5
while i<=s:
if n%i==0:
r+=n//i
n//=i
s=n**0.5
i=1
i+=1
print(r)
``` | vfc_38489 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n",
"output": "16\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99916185... |
code_contests | verifiable_code | 197_E. Paint Tree | Solve the following coding problem using the programming language python:
You are given a tree with n vertexes and n points on a plane, no three points lie on one straight line.
Your task is to paint the given tree on a plane, using the given points as vertexes.
That is, you should correspond each vertex of the tre... | vfc_38493 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3\n2 3\n0 0\n1 1\n2 0\n",
"output": "1 3 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2\n2 3\n1 4\n-1 -2\n3 5\n-3 3\n2 0\n",
"output": "2 4 1 3\n",
"type": "stdi... | |
code_contests | verifiable_code | 221_A. Little Elephant and Function | Solve the following coding problem using the programming language python:
The Little Elephant enjoys recursive functions.
This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function... | ```python
n=int(input())
l=list(range(1,n+1))
l=sorted(l)
l.insert(0,l[-1])
l.pop()
print(*l)
``` | vfc_38497 | {
"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\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "2 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000\n",
... |
code_contests | verifiable_code | 245_B. Internet Address | Solve the following coding problem using the programming language python:
Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:
<protocol>://<domain>.ru[/<context>]
where:
* <pro... | ```python
s = input()
if s[:3] == "ftp":
pre = "ftp://"
s = s[3:]
elif s[:4] == "http":
pre = "http://"
s = s[4:]
index = s[1:].index("ru")+1
if index == len(s)-2:
s = pre+s[:index]+"."+s[index:]
else:
s = pre+s[:index]+"."+s[index:index+2]+"/"+s[index+2:]
print(s)
``` | vfc_38501 | {
"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": "httpsunrux\n",
"output": "http://sun.ru/x\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ftphttprururu\n",
"output": "ftp://http.ru/ruru\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 26_E. Multithreading | Solve the following coding problem using the programming language python:
You are given the following concurrent program. There are N processes and the i-th process has the following pseudocode:
repeat ni times
yi := y
y := yi + 1
end repeat
Here y is a shared variable.... | ```python
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, w = map(int, input().split())
a = [0] + list(map(int, input().split()))
total = sum(a)
def ng():
print('No')
exit()
def ok(a):
print('Yes')
print(*a)
exit()
if ... | vfc_38505 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 10\n11\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n4 4\n",
"output": "Yes\n1 2 2 2 2 2 2 1 2 1 1 1 1 2 1 1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 316_G3. Good Substrings | Solve the following coding problem using the programming language python:
Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is... | vfc_38513 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "ltntlnen\n3\nn 0 0\nttlneenl 1 4\nlelllt 1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "a\n0\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 340_E. Iahub and Permutations | Solve the following coding problem using the programming language python:
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sabotag... | ```python
#lahub and Permutations
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
mod = 10**9+7
def pow(n,p,mod=mod): #繰り返し二乗法(nのp乗)
res = 1
while p > 0:
if p % 2 == 0:
n = n ** 2 % mod
p //= 2
else:
res = res * n % mod
... | vfc_38517 | {
"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": "5\n-1 -1 4 3 -1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n-1 -1 -1 -1 -1 -1\n",
"output": "265\n",
"type": "stdin_stdout"
},
{
"fn_name"... |
code_contests | verifiable_code | 364_B. Free Market | Solve the following coding problem using the programming language python:
John Doe has recently found a "Free Market" in his city — that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any numbe... | vfc_38521 | {
"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": "10 10000\n10000 9999 1 10000 10000 10000 1 2 3 4\n",
"output": "50010 6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n1 3 10\n",
"output": "4 3",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | 388_A. Fox and Box Accumulation | Solve the following coding problem using the programming language python:
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box).
Since all the boxes have the same size, Ci... | ```python
I=lambda:list(map(int,input().split()))
n,=I()
l=I()
l.sort()
ans=0
i=0
k=1
while i<n:
if l[i]<i//k:
k+=1
i+=1
print(k)
``` | vfc_38525 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "9\n0 1 0 2 0 1 1 2 10\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n0 1 2 3 4\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 408_D. Long Path | Solve the following coding problem using the programming language python:
One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one.
The maze is organized as follows. Ea... | ```python
n = int(input())
a = list(map(int,input().split()))
values = [0 for k in range(n)]
for k in range(n) :
back = a[k]
if a[k] == k+1 :
values[k] = 2
else :
values[k] += 2
for t in range(a[k]-1,k) :
values [k] += values[t]
values[k] %= int(1e9 +7... | vfc_38529 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 1 1 1 1\n",
"output": "62\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
code_contests | verifiable_code | 435_E. Special Graph | Solve the following coding problem using the programming language python:
In this problem you will need to deal with an n × m grid graph. The graph's vertices are the nodes of the n × m grid. The graph's edges are all the sides and diagonals of the grid's unit squares.
The figure below shows a 3 × 5 graph. The black ... | vfc_38533 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\n10101\n00020\n01000\n",
"output": "13131\n42424\n31313\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n11\n00\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 459_A. Pashmak and Garden | Solve the following coding problem using the programming language python:
Pashmak has fallen in love with an attractive girl called Parmida since one year ago...
Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the g... | ```python
#!/usr/bin/env python3
import atexit
import io
import sys
import bisect
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B
@atexit.register
def write():
sys.__stdout__.write(_O_B.getvalue())
def main():
x1,y1,x2,y2=map(int,input().split())
i... | vfc_38537 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 0 1 2\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 0 1\n",
"output": "1 0 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
code_contests | verifiable_code | 47_E. Cannon | Solve the following coding problem using the programming language python:
Bertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian system of coordinates, ... | ```python
import sys
from array import array # noqa: F401
from math import pi, sin, cos
from bisect import bisect_left
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, v = map(int, input().split())
v = float(v)
alpha = [float(input()) for _ in range(n)]
m = int(input())
wall = sorted(tuple(ma... | vfc_38541 | {
"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": "2 10\n0.7853\n0.3\n2\n4.0 2.4\n6.0 1.9\n",
"output": "10.204081436 0.000000000\n4.000000000 0.378324889\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 10\n0.7853\n0.3\n3\n5.0 5.0\n4.0 2... |
code_contests | verifiable_code | 504_E. Misha and LCP on Tree | Solve the following coding problem using the programming language python:
Misha has a tree with characters written on the vertices. He can choose two vertices s and t of this tree and write down characters of vertices lying on a path from s to t. We'll say that such string corresponds to pair (s, t).
Misha has m quer... | vfc_38545 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\nbbbabb\n2 1\n3 2\n4 3\n5 2\n6 5\n6\n2 5 3 1\n1 5 2 3\n5 6 5 6\n6 3 4 1\n6 2 3 4\n2 2 4 5\n",
"output": "2\n2\n2\n0\n1\n0\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 554_A. Kyoya and Photobooks | Solve the following coding problem using the programming language python:
Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo bookl... | ```python
s = input()
l = list(s)
a = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(s)+1):
for j in a:
l.insert(i, j)
print(len(l)-2*len(s))
``` | vfc_38553 | {
"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": "hi\n",
"output": "76\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "a\n",
"output": "51\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 57_E. Chess | Solve the following coding problem using the programming language python:
Brian the Rabbit adores chess. Not long ago he argued with Stewie the Rabbit that a knight is better than a king. To prove his point he tries to show that the knight is very fast but Stewie doesn't accept statements without evidence. He construc... | vfc_38557 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 0\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 7\n-1 2\n1 2\n2 1\n2 -1\n1 -2\n-1 -2\n-2 -1\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | 624_B. Making a String | Solve the following coding problem using the programming language python:
You are given an alphabet consisting of n letters, your task is to make a string of the maximum possible length so that the following conditions are satisfied:
* the i-th letter occurs in the string no more than ai times;
* the number of ... | ```python
n = int(input())
m = list(map(int, input().split()))
m.sort(reverse = True)
ans = m[0]
last = m[0]
for i in range(1, len(m)):
last = max(min(last - 1, m[i]), 0)
ans += last
print(ans)
``` | vfc_38565 | {
"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\n2 5 5\n",
"output": "11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
code_contests | verifiable_code | 645_F. Cowslip Collections | Solve the following coding problem using the programming language python:
In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning to plant some flower gardens to complement the lush, grassy fields of Bovinia. As any good horticulturist knows, each garden they plant must have ... | vfc_38569 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 1 2\n6\n5\n4\n3\n2\n1\n",
"output": "20\n21\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 2\n4\n6\n9\n8\n6\n",
"output": "5\n16\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | 672_D. Robin Hood | Solve the following coding problem using the programming language python:
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.
There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take ... | ```python
import sys
sys.stderr = sys.stdout
def hood(n, k, C):
C.sort()
m, r = divmod(sum(C), n)
m1 = (m + 1) if r else m
c_lo = C[0]
k_lo = k
for i, c in enumerate(C):
if c_lo == m:
break
c_m = min(c, m)
dc = c_m - c_lo
dk = i * dc
if k_lo... | vfc_38573 | {
"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 1\n1 1 4 2\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 697_F. Legen... | Solve the following coding problem using the programming language python:
Barney was hanging out with Nora for a while and now he thinks he may have feelings for her. Barney wants to send her a cheesy text message and wants to make her as happy as possible.
<image>
Initially, happiness level of Nora is 0. Nora loves... | vfc_38577 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 6, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 6\n3 2 8\nheart\nearth\nart\n",
"output": " 16\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 718_E. Matvey's Birthday | Solve the following coding problem using the programming language python:
Today is Matvey's birthday. He never knows what to ask as a present so friends gave him a string s of length n. This string consists of only first eight English letters: 'a', 'b', ..., 'h'.
First question that comes to mind is: who might ever n... | vfc_38581 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nabc\n",
"output": "2 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\naaabaaa\n",
"output": "2 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... | |
code_contests | verifiable_code | 73_D. FreeDiv | Solve the following coding problem using the programming language python:
Vasya plays FreeDiv. In this game he manages a huge state, which has n cities and m two-way roads between them. Unfortunately, not from every city you can reach any other one moving along these roads. Therefore Vasya decided to divide the state ... | ```python
import sys
rl=sys.stdin.readline
n,m,k=map(int,rl().split())
c = [-1]*n
def root(x):
p = x
while c[p]>=0: p=c[p]
while c[x]>=0:
t = c[x]
c[x] = p
x = t
return p
#def root(x):
# if c[x]<0: return x
# c[x]=root(c[x])
# return c[x]
for i in xrange(m):
x,y=rl(... | vfc_38585 | {
"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": "3 3 2\n1 2\n2 3\n3 1\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 0 2\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.