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 | 1154_E. Two Teams | Solve the following coding problem using the programming language python:
There are n students standing in a row. Two coaches are forming two teams — the first coach chooses the first team and the second coach chooses the second team.
The i-th student has integer programming skill a_i. All programming skills are dist... | ```python
import sys
input = sys.stdin.readline
def main():
n, k = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i, a in enumerate(A):
B.append((a, i+1))
B.sort()
#print(B)
bit = [0]*(n+1)
def bit_query(i, bit):
res = 0
while i > 0:
... | vfc_78389 | {
"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 1\n2 4 5 3 1\n",
"output": "21112\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1176_C. Lose it! | Solve the following coding problem using the programming language python:
You are given an array a consisting of n integers. Each a_i is one of the six following numbers: 4, 8, 15, 16, 23, 42.
Your task is to remove the minimum number of elements to make this array good.
An array of length k is called good if k is d... | ```python
_=int(input())
a=list(map(int,input().split()))
b=[4,8,15,16,23,42]
c=[0]*6
for i in range(len(a)):
x = b.index(a[i])
if x == 0:
c[0] +=1
elif c[x-1]!=0:
c[x-1]-=1
c[x]+=1
print(len(a)-6*c[5])
``` | vfc_78393 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n4 8 15 16 23\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\n4 8 4 8 15 16 8 16 23 15 16 4 42 23 42\n",
"output": "3\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 1195_B. Sport Mafia | Solve the following coding problem using the programming language python:
Each evening after the dinner the SIS's students gather together to play the game of Sport Mafia.
For the tournament, Alya puts candies into the box, which will serve as a prize for a winner. To do that, she performs n actions. The first actio... | ```python
n,x=map(int,input().split())
formula=0
i=0
if(n==1):
print(0)
else:
formula=1000000
while(abs(n-(i+formula))!=x):
i=i+1
formula=(i*(i+1))//2
print(abs(n-i))
``` | vfc_78397 | {
"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": "1 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 11\n"... |
code_contests | verifiable_code | 1211_F. kotlinkotlinkotlinkotlin... | Solve the following coding problem using the programming language python:
Polycarp really likes writing the word "kotlin". He wrote this word several times in a row without spaces. For example, he could write the string like "kotlinkotlinkotlinkotlin".
Polycarp sliced (cut) the written string into n pieces and mixed ... | vfc_78401 | {
"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\nlin\nkot\n",
"output": "\n2 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\nlinkotlinkotlinkotl\nkotlin\nin\nkot\n",
"output": "\n2 4 1 3 ",
"type": "stdin_stdout"
}... | |
code_contests | verifiable_code | 1253_C. Sweets Eating | Solve the following coding problem using the programming language python:
Tsumugi brought n delicious sweets to the Light Music Club. They are numbered from 1 to n, where the i-th sweet has a sugar concentration described by an integer a_i.
Yui loves sweets, but she can eat at most m sweets each day for health reason... | ```python
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
f = [0] * 1000000
sum = [0] * 1000000
for i in range(n):
sum[i] = sum[i - 1] + a[i]
for i in range(n):
f[i] = f[i - m] + sum[i]
print(f[i], end = " ")
``` | vfc_78409 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n7\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 2\n6 19 3 4 4 2 6 7 8\n",
"output": "2 5 11 18 30 43 62 83 121\n",
"type": "stdin_stdout"
},
{... |
code_contests | verifiable_code | 1277_B. Make Them Odd | Solve the following coding problem using the programming language python:
There are n positive integers a_1, a_2, ..., a_n. For the one move you can choose any even value c and divide by two all elements that equal c.
For example, if a=[6,8,12,6,3,12] and you choose c=6, and a is transformed into a=[3,8,12,3,3,12] af... | ```python
for _ in range(int(input())):
n=int(input())
a=[int(y) for y in input().split()]
a=sorted(a)
a=a[::-1]
d={}
count=0
for i in range(n):
d[a[i]]=0
for i in range(n):
if(d[a[i]] == 0):
s=a[i]
while(a[i]%2==0):
a[i]/=2
... | vfc_78413 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n6\n40 6 40 3 20 1\n1\n1024\n4\n2 4 8 16\n3\n3 1 7\n",
"output": "4\n10\n4\n0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1297_B. Cartoons | Solve the following coding problem using the programming language python:
Tanya likes cartoons. She knows that n new cartoons will be released in his favorite cinema: the i-th of them will be airing from the day a_i to the day b_i (1 ≤ a_i ≤ b_i ≤ 10^9).
The cinema has a special offer: there is a huge discount every ... | vfc_78417 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1\n1 1\n3\n2 1000000000\n2 500000000\n500000002 1000000000\n3\n1 2\n3 4\n1 4\n2\n4 11\n4 9\n3\n1 5\n10 10\n1 5\n",
"output": "\n1\n500000001\n-1\n10\n10\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1320_C. World of Darkraft: Battle for Azathoth | Solve the following coding problem using the programming language python:
Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.
Roma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i h... | ```python
# quick input by @c1729 and @pajenegod
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from bisect import bisect_right
from operator import itemgetter
class SegmTree:
'''
- increment on interval
- get max on interval
'''
def __init__(self, size):
N = 1
... | vfc_78421 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3 3\n2 3\n4 7\n2 4\n3 2\n5 11\n1 2 4\n2 1 6\n3 4 6\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4 5\n5 10\n6 2\n10 3\n9 5\n7 7\n4 3\n9 2\n3 6\n7 1 6\n8 3 2\n2 6 9\n... |
code_contests | verifiable_code | 133_A. HQ9+ | Solve the following coding problem using the programming language python:
HQ9+ is a joke programming language which has only four one-character instructions:
* "H" prints "Hello, World!",
* "Q" prints the source code of the program itself,
* "9" prints the lyrics of "99 Bottles of Beer" song,
* "+" increment... | ```python
s=input()
flag=0
for i in range(len(s)):
if(s[i]=='H' or s[i]=='Q' or s[i]=='9'):
print('YES')
flag=1
break
if flag==0:
print('NO')
``` | vfc_78425 | {
"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": "Codeforces\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Hi!\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | 1424_K. Light switches | Solve the following coding problem using the programming language python:
Nikola owns a large warehouse which is illuminated by N light bulbs, numbered 1 to N. At the exit of the warehouse, there are S light switches, numbered 1 to S. Each switch swaps the on/off state for some light bulbs, so if a light bulb is off, ... | vfc_78441 | {
"difficulty": "17",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3 4\n2 1 2\n2 2 3\n1 2\n1 1\n2 1 3\n3 1 2 3\n3 1 2 4\n",
"output": "2\n2\n3\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 8 10\n2 1 3\n5 1 4 5 6 7\n2 1 4\n6 1 3 4 5 6 7\n3 5 6 7\... | |
code_contests | verifiable_code | 1446_B. Catching Cheaters | Solve the following coding problem using the programming language python:
You are given two strings A and B representing essays of two students who are suspected cheaters. For any two strings C, D we define their similarity score S(C,D) as 4⋅ LCS(C,D) - |C| - |D|, where LCS(C,D) denotes the length of the Longest Commo... | ```python
n, m = map(int, input().split())
a = input()
b = input()
res = 0
dp = [[0 for _ in range(m + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, m + 1):
if a[i - 1] == b[j - 1]:
dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2)
dp[i][j] = max(dp[i][j], max(dp[i ... | vfc_78445 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 7\nuiibwws\nqhtkxcn\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5\nabba\nbabab\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": nu... |
code_contests | verifiable_code | 1470_B. Strange Definition | Solve the following coding problem using the programming language python:
Let us call two integers x and y adjacent if (lcm(x, y))/(gcd(x, y)) is a perfect square. For example, 3 and 12 are adjacent, but 6 and 9 are not.
Here gcd(x, y) denotes the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest... | ```python
from sys import stdin
dct = {i:i for i in range(1000001)}
for i in range(2, 1001):
for j in range(1, (10 ** 6) // (i ** 2) + 1):
dct[(i ** 2) * j] = j
t = int(stdin.readline())
for _ in range(t):
n = int(stdin.readline())
elements = map(int, stdin.readline().split())
q = int(stdin.readline())
dct2 = {}... | vfc_78449 | {
"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\n4\n6 8 4 2\n1\n0\n6\n12 3 20 5 80 1\n1\n1\n",
"output": "\n2\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n5\n1 1 3 3 1\n1\n4294967296\n",
"output": "5\n",
"type": "... |
code_contests | verifiable_code | 1519_F. Chests and Keys | Solve the following coding problem using the programming language python:
Alice and Bob play a game. Alice has got n treasure chests (the i-th of which contains a_i coins) and m keys (the j-th of which she can sell Bob for b_j coins).
Firstly, Alice puts some locks on the chests. There are m types of locks, the locks... | vfc_78457 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n3 3\n1 1 4\n10 20 100\n20 15 80\n",
"output": "\n205\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n3 4\n1 1 4\n10 20 100\n20 15 80\n",
"output": "\n-1\n",
"type": "... | |
code_contests | verifiable_code | 1546_F. AquaMoon and Wrong Coordinate | Solve the following coding problem using the programming language python:
Cirno gives AquaMoon a problem. There are m people numbered from 0 to m - 1. They are standing on a coordinate axis in points with positive integer coordinates. They are facing right (i.e. in the direction of the coordinate increase). At this mo... | vfc_78461 | {
"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": "5 7\n6 9 9 6 9\n10 7 10 8 10\n11 11 11 10 8\n12 12 12 12 9\n14 13 12 10 13\n11 14 16 14 14\n12 15 18 15 15\n",
"output": "4 13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 7\n9 6 6 9 ... | |
code_contests | verifiable_code | 174_B. File List | Solve the following coding problem using the programming language python:
Eudokimus, a system administrator is in trouble again. As a result of an error in some script, a list of names of very important files has been damaged. Since they were files in the BerFS file system, it is known that each file name has a form "... | ```python
s=input()
n=len(s)
a=s.find('.')
b=s.rfind('.')
from sys import exit
if a==b==-1:print('NO');exit()
if a==0 or n-b-1==0:print('NO');exit()
if not 0<a<9 or not 0<n-b-1<4:print('NO');exit()
s2=s[a+1:b+1]
res=[s[:a+1]]
app=res.append
length,item=0,''
for i,x in enumerate(s2):
if x=='.':
if not 1<leng... | vfc_78465 | {
"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": "read.meexample.txtb.cpp\n",
"output": "YES\nread.mee\nxample.txt\nb.cpp\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "version.infontldrcontestdata.zip\n",
"output": "NO\n",
"... |
code_contests | verifiable_code | 194_C. Cutting Figure | Solve the following coding problem using the programming language python:
You've gotten an n × m sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find the minimum number of squares that we can delete from set A to make it not c... | ```python
n, m = map(int, input().split())
p, s = [], {}
x = 0
for i in range(n):
for j, q in enumerate(input()):
if q != '#': continue
s[(i, j)] = x
p.append([])
if (i, j - 1) in s:
p[x] += [x - 1]
p[x - 1] += [x]
if (i - 1, j) in s:
y = s... | vfc_78469 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\n#####\n#...#\n#####\n#...#\n#####\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 218_C. Ice Skating | Solve the following coding problem using the programming language python:
Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed that in this way it's imp... | ```python
#start the code from here
n=int(input())
global parent
parent=[i for i in range(n)]
# n is total number of nodes
# finding parent of a node
def find(w):
global parent
if parent[w]==w:
return w
else:
return find(parent[w])
def union(a,b):
global parent
w=find(a)
y=find(b)
if w==y:
return
par... | vfc_78473 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 1\n1 2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2 1\n4 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 241_G. Challenging Balloons | Solve the following coding problem using the programming language python:
Martha — as a professional problemsetter — proposed a problem for a world-class contest. This is the problem statement:
Tomorrow is Nadia's birthday, and Bardia (her brother) is assigned to make the balloons ready!
There are n balloons (initia... | ```python
print(302)
print("0 1000000")
coord, rad = 17321*2, 300
for i in range(300):
print(coord, rad)
coord, rad = coord+600, rad-1
print("1000000 1000000")
``` | vfc_78477 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "",
"output": "302\n0 500000\n24495 300\n25094 299\n25691 298\n26286 297\n26879 296\n27470 295\n28059 294\n28646 293\n29231 292\n29814 291\n30395 290\n30974 289\n31551 288\n32126 287\n32699 286\n33270 285\n33839 284\n34406 283... |
code_contests | verifiable_code | 267_A. Subtractions | Solve the following coding problem using the programming language python:
You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pai... | ```python
for i in range(int(input())):
a,b=map(int,input().split())
sm=0
while a and b:
sm+=a//b
t=b
b=a%b
a=t
print(sm)
``` | vfc_78481 | {
"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\n4 17\n7 987654321\n",
"output": "8\n141093479\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\... |
code_contests | verifiable_code | 290_A. Mysterious strings | Solve the following coding problem using the programming language python:
Input
The input contains a single integer a (1 ≤ a ≤ 40).
Output
Output a single string.
Examples
Input
2
Output
Adams
Input
8
Output
Van Buren
Input
29
Output
Harding
The input will be given via stdin and the output shou... | ```python
ans = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]
print(ans[int(input())])
``` | vfc_78485 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n",
"output": "Van Buren\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 316_A1. Special Task | Solve the following coding problem using the programming language python:
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood ty... | ```python
hint = input()
seen = []
if 'A' <= hint[0] <= 'J':
num = 9
seen = [hint[0]]
elif '0' <= hint[0] <= '9':
num = 1
elif hint[0] == '?':
num = 9
for l in hint[1:]:
if 'A' <= l <= 'J':
if not l in seen:
num *= 10 - len(seen)
seen += [l]
elif l == '?':
... | vfc_78489 | {
"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?AA\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AJ\n",
"output": "81\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "?C\n... |
code_contests | verifiable_code | 338_C. Divisor Tree | Solve the following coding problem using the programming language python:
A divisor tree is a rooted tree that meets the following conditions:
* Each vertex of the tree contains a positive integer number.
* The numbers written in the leaves of the tree are prime numbers.
* For any inner vertex, the number wi... | vfc_78493 | {
"difficulty": "9",
"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\n6 72 8 4\n",
"output": "12\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 360_E. Levko and Game | Solve the following coding problem using the programming language python:
Levko loves sports pathfinding competitions in his city very much. In order to boost his performance, Levko spends his spare time practicing. The practice is a game.
The city consists of n intersections connected by m + k directed roads. Two or... | vfc_78497 | {
"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 1 3\n1 3 4\n3 2 2\n1 2 1 3\n2 4 1 3\n3 4 1 3\n",
"output": "WIN\n1 1 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1 3\n1 3 4\n3 2 2\n1 2 1 3\n2 4 1 3\n3 4 1 2\n",
"output": ... | |
code_contests | verifiable_code | 384_C. Milking cows | Solve the following coding problem using the programming language python:
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows ... | ```python
n = int(input())
lis = list(map(int,input().split()))
ans=b=0
for i in range(n-1,-1,-1):
if lis[i]==1:
ans+=b
else:
b+=1
print(ans)
``` | vfc_78501 | {
"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\n1 0 1 0 1\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0 1 0\n",
"output": "1",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 405_B. Domino Effect | Solve the following coding problem using the programming language python:
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".
Chris arranges n dominoes in a line, placing each piece vertical... | ```python
n = int(input())
s = input()+'R'
r = 0
flag = 'L'
a = 0
for _ in range(n+1):
if s[_] == '.':
a+=1
elif s[_] == 'L':
if flag =='L':
a = 0
else:
if a%2==1:
r+=1
a = 0
flag = 'L'
else:
if flag =='L':
... | vfc_78505 | {
"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": "14\n.L.R...LR..L..\n",
"output": "4",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 432_C. Prime Swaps | Solve the following coding problem using the programming language python:
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
* choose two indexes, i and j (1 ≤ ... | ```python
def sieve(n):
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
n = int(input())
prime = [True for i in range(n+2)]
prime[0]=0
prime[1]=0
sieve(n+1)
aa=[0]*(n+1)
for i in range(n+1):
if prime[i]:... | vfc_78509 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 2 1\n",
"output": "1\n1 3\n\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 2\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 477_C. Dreamoon and Strings | Solve the following coding problem using the programming language python:
Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates <image> that is defined as the maximal number of non-overlapping substrings equal to p that can be f... | ```python
s, p = input(), input()
n, m = len(s) + 1, len(p)
d = [[0] * n for t in range(n)]
for x in range(1, n):
i, j = x, m
while i and j:
j -= s[i - 1] == p[j - 1]
i -= 1
if not j:
for y in range(i + 1): d[x][y + x - i - m] = d[i][y] + 1
for y in range(x): d[x][y] = max(d[x][y... | vfc_78517 | {
"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": "aaaaa\naa\n",
"output": "2 2 1 1 0 0 \n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 4_D. Mysterious Present | Solve the following coding problem using the programming language python:
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the hei... | ```python
inputi = [int(i) for i in input().split(" ")]
amt = inputi[0]
cardW = inputi[1]
cardH = inputi[2]
envelopes = []
cur_amt = 1
for i in range(amt):
inputi = [int(i) for i in input().split(" ")]
if inputi[0] > cardW and inputi[1] > cardH:
envelopes.append((inputi[0],inputi[1],inputi[0]*inputi[1],... | vfc_78521 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 3\n5 4\n12 11\n9 8\n",
"output": "3\n1 3 2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 525_C. Ilya and Sticks | Solve the following coding problem using the programming language python:
In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length li.
Ilya decided to make a rectangle from the sticks.... | ```python
n = int(input())
rects = [int(s) for s in input().split()]
rects.sort()
sumsquare = 0
stash = []
i = len(rects) - 1
while i > 0:
if rects[i] - rects[i-1] == 1 or rects[i] == rects[i-1]:
if len(stash) == 2:
sumsquare += stash[0]*stash[1]
stash.clear()
stash.append(rects[i-1])
rects.pop()
re... | vfc_78525 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 4 4 2\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 2 3 5\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 550_D. Regular Bridge | Solve the following coding problem using the programming language python:
An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components.
Build a connected undirected ... | ```python
def nextEdge():
global v
for i in range(1, v + 1):
for j in range(i + 1, v + 1):
yield (i, j)
k = int(input())
if k % 2 == 0:
print("NO")
elif k == 1:
print("YES", "2 1", "1 2", sep = "\n")
else:
n = 2 * k + 4
m = k * (k + 2)
print("YES")
print(n, m, sep =... | vfc_78529 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "YES\n2 1\n1 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "30\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | 577_E. Points on Plane | Solve the following coding problem using the programming language python:
On a plane are n points (xi, yi) with integer coordinates between 0 and 106. The distance between the two points with numbers a and b is said to be the following value: <image> (the distance calculated by such formula is called Manhattan distanc... | vfc_78533 | {
"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\n0 7\n8 10\n3 4\n5 0\n9 12\n",
"output": "4 3 1 2 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n0 0\n1000000 1000000\n",
"output": "1 2 ",
"type": "stdin_stdout"
}... | |
code_contests | verifiable_code | 59_C. Title | Solve the following coding problem using the programming language python:
Vasya has recently finished writing a book. Now he faces the problem of giving it the title. Vasya wants the title to be vague and mysterious for his book to be noticeable among others. That's why the title should be represented by a single word... | ```python
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
k = int(input())
a = list(input().rstrip())
n = len(a)
unused = [1] * k
def ng():
print('IMPOSSIBLE')
exit()
try:
for i in range(n):
if a[i] == '?' and a[n - i - 1] ... | vfc_78537 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\na?c\n",
"output": "IMPOSSIBLE\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 621_A. Wet Shark and Odd and Even | Solve the following coding problem using the programming language python:
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from t... | ```python
n=int(input())
l=list(map(int,input().split()))
s=sum(l)
ls=set(l)
lss=list(ls)
lss.sort()
c=0
for i in range(len(lss)):
if lss[i]%2!=0:
c=lss[i]
break
if s%2==0:
print(s)
else:
print(s-c)
``` | vfc_78541 | {
"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\n999999999 999999999 999999999 999999999 999999999\n",
"output": "3999999996",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2 3\n",
"output": "6",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 641_F. Little Artem and 2-SAT | Solve the following coding problem using the programming language python:
Little Artem is a very smart programmer. He knows many different difficult algorithms. Recently he has mastered in 2-SAT one.
In computer science, 2-satisfiability (abbreviated as 2-SAT) is the special case of the problem of determining whether... | vfc_78545 | {
"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 1 1\n1 2\n1 2\n",
"output": "SIMILAR\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 66_D. Petya and His Friends | Solve the following coding problem using the programming language python:
Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to n.
Let us remind you the definition of the greatest common divisor: GCD(a1, ..., ak) = d, wher... | ```python
import math
def checkprime(n):
if(n==1):
return 0
i=2
while(i*i<=n):
if(n%i==0):
return 0
i+=1
return 1
primes=[]
primes.append(0)
i=1
while(i<=1000):
if(checkprime(i)==1):
primes.append(i)
i+=1
n=int(input())
if(n==2):
print(-1)
exit(0)
res=[]
i=1
while(i<=n):
product=1
j=i
while(j<i+n-... | vfc_78549 | {
"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\n",
"output": "105\n70\n42\n30\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 691_A. Fashion in Berland | Solve the following coding problem using the programming language python:
According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swing... | ```python
n = int(input())
a = list(map(int,input().split()))
c = a.count(0)
if (c>1 or c<1) and n>1 :
print('NO')
elif n==1 and c==1:
print('NO')
else:
print('YES')
``` | vfc_78553 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 0 0\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 0 1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
code_contests | verifiable_code | 716_A. Crazy Computer | Solve the following coding problem using the programming language python:
ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed disappear!
More formally, if you typed a word at second a and then the next word at second b, then if b - a ≤ c, just the... | ```python
"""
second a and then the next word at second b, then if b - a ≤ c,
just the new word is appended to other words on the screen.
If b - a > c, then everything on the screen disappears and after that the word
you have typed appears on the screen.
"""
num1 = input()
num2 = input()
a = []
b = []
def get_t... | vfc_78557 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 1\n1 3 5 7 9 10\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 5\n1 3 8 14 19 20\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 736_C. Ostap and Tree | Solve the following coding problem using the programming language python:
Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph.
Ostap's tree now has n vertices. He wants to paint some vertices of the tree black such t... | ```python
def main():
n, k = map(int, input().split())
cnt = [[[0] * 21 for _ in (0, 1)] for _ in range(n + 1)]
edges, mod = [[] for _ in range(n + 1)], 1000000007
for _ in range(n - 1):
u, v = map(int, input().split())
edges[u].append(v)
edges[v].append(u)
def dfs(u, f):
... | vfc_78561 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1\n1 2\n",
"output": "3",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 760_C. Pavel and barbecue | Solve the following coding problem using the programming language python:
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the rev... | ```python
n = int(input())
p = list(map(int, input().split()))
b = list(map(int, input().split()))
s = sum(b[i] for i in range(n))
if s % 2 == 0:
ans = 1
else:
ans = 0
visited = [0] * n
ptr = 0
start = 1
visited[0] = 1
q = 1
c = 1
while q < n:
start = p[start - 1]
if visited[start - 1] == 1:
c +... | vfc_78565 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4 3 2 1\n0 1 1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 3 1\n0 0 0\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": n... |
code_contests | verifiable_code | 780_G. Andryusha and Nervous Barriers | Solve the following coding problem using the programming language python:
Andryusha has found a perplexing arcade machine. The machine is a vertically adjusted board divided into square cells. The board has w columns numbered from 1 to w from left to right, and h rows numbered from 1 to h from the bottom to the top.
... | vfc_78569 | {
"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": "10 5 1\n3 2 3 10\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5 2\n3 1 3 10\n5 3 5 10\n",
"output": "16\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 82_C. General Mobilization | Solve the following coding problem using the programming language python:
The Berland Kingdom is a set of n cities connected with each other with n - 1 railways. Each road connects exactly two different cities. The capital is located in city 1. For each city there is a way to get from there to the capital by rail.
In... | vfc_78577 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n5 4 3 2 1\n1 2 1\n2 3 1\n2 4 1\n4 5 1\n",
"output": "0 1 4 2 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n40 10 30 20\n1 2 1\n2 3 1\n4 2 1\n",
"output": "0 1 3 2\n",
... | |
code_contests | verifiable_code | 850_E. Random Elections | Solve the following coding problem using the programming language python:
The presidential election is coming in Bearland next year! Everybody is so excited about this!
So far, there are three candidates, Alice, Bob, and Charlie.
There are n citizens in Bearland. The election result will determine the life of all c... | vfc_78581 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n01010101\n",
"output": "216\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n01101001\n",
"output": "168\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 875_A. Classroom Watch | Solve the following coding problem using the programming language python:
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answe... | ```python
n = int(input())
res = []
def sum_digits(x):
return sum([int(i) for i in x])
for i in range(max(0, n - 80), n):
# print(sum_digits(str(i)))
if i + sum_digits(str(i)) == n:
res.append(i)
print(len(res))
if len(res) != 0:
for r in sorted(res):
print(r)
``` | vfc_78585 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "21\n",
"output": "1\n15 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "75\n",... |
code_contests | verifiable_code | 899_F. Letters Removing | Solve the following coding problem using the programming language python:
Petya has a string of length n consisting of small and large English letters and digits.
He performs m operations. Each operation is described with two integers l and r and a character c: Petya removes from the string all characters c on positi... | ```python
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
class FenwickTree:
def __init__(self, x):
"""transform list into BIT"""
self.bit = x
for i in range(len(x)):
j = i | (i + 1)
if j < len(x):
x[j] += x[i]
def updat... | vfc_78589 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\nA0z\n1 3 0\n1 1 z\n",
"output": "Az\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 4\nagtFrgF4aF\n2 5 g\n4 9 F\n1 5 4\n1 7 a\n",
"output": "tFrg4\n",
"type": "stdin_st... |
code_contests | verifiable_code | 948_E. Picking Strings | Solve the following coding problem using the programming language python:
Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times:
* A <image> BC
* B <image> AC
* C <image> AB
* AAA <image> empty strin... | vfc_78597 | {
"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": "AABCCBAAB\nABCB\n5\n1 3 1 2\n2 2 2 4\n7 9 1 1\n3 4 2 3\n4 5 1 3\n",
"output": "10011\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AAAAACAAAAAB\nAAAAABAAAAAC\n20\n1 6 10 12\n10 12 7 12\n... | |
code_contests | verifiable_code | 976_E. Well played! | Solve the following coding problem using the programming language python:
Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:
Max owns n creatures, i-th of them can be described wit... | ```python
import sys
read=lambda:map(int,sys.stdin.buffer.readline().split())
n,a,b=read()
v=[tuple(read()) for _ in range(n)]
ans=0
if b>0:
c=[v[x][0]-v[x][1] for x in range(n)]
w,r=list(range(n)),[0]*n
w.sort(key=lambda x:c[x],reverse=True)
for i in range(n): r[w[i]]=i
f=True;s=0;m=min(n,b)
for i in range(m):
... | vfc_78601 | {
"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": "2 1 1\n10 15\n6 1\n",
"output": "27\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 0 3\n10 8\n7 11\n5 2\n",
"output": "26\n",
"type": "stdin_stdout"
},
{
"fn_n... |
code_contests | verifiable_code | 996_C. Tesla | Solve the following coding problem using the programming language python:
Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange them, h... | ```python
n, k = list(map(int, input().split()))
table = []
for row in range(4):
table.append(list(map(int, input().split())))
moves = []
def make_move(start,finish):
moves.append((table[start[0]][start[1]], finish[0]+1, finish[1]+1))
table[finish[0]][finish[1]] = table[start[0]][start[1]]
table[start... | vfc_78605 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2\n1\n1\n2\n2\n",
"output": "2\n1 1 1\n2 4 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5\n1 2 0 4\n1 2 0 4\n5 0 0 3\n0 5 0 3\n",
"output": "12\n1 1 1\n2 1 2\n4 1 4\n3 4 4\n... |
code_contests | verifiable_code | bandu-the-saviour | Solve the following coding problem using the programming language python:
The Bandu of the Hackers' community had a very urgent job to do. He needs to diffuse all the bombs placed by Poker. Poker is extremely clever and cruel. He selected a region of 1000 X 1000 points, chose N center points of the form (X,Y) and plac... | ```python
t = int(input())
mat = [ [0 for i in range(0, 1001)] for j in range(0, 1001)]
while(t):
val = str(raw_input())
val = val.split(" ")
x,y,r = int(val[0]), int(val[1]), int(val[2])
#print("X Y R")
#print x,y,r
rSquare = r ** 2
#print("rSquare %d"% rSquare)
for i in range(1,1001) :
for j in range(1,... | vfc_78609 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n172 686 234",
"output": "0",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | city-and-fireman-vincent | Solve the following coding problem using the programming language python:
Fatland is a town with N cities numbered 1, 2, ..., N, connected with 2-way roads. Vincent is a villian who wants to set the entire town ablaze. For each city, there is a certain risk factor E[i] for setting that city ablaze. But once a city c i... | ```python
from collections import defaultdict
class Graph():
def __init__(self, connections=[], directed=False):
self.status_dict = defaultdict(lambda : 1)
self.graph_dict = defaultdict(list)
self.is_directed = directed
def add_edge(self,node1, node2):
... | vfc_78613 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 3 3 3\n2\n1 2\n4 1\n\nSAMPLE",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "523\n99 579 761 271 923 129 332 471 667 607 959 414 553 147 885 77 776 670 194 603 22 688 2... |
code_contests | verifiable_code | et-comes-to-india | Solve the following coding problem using the programming language python:
An extraterrestrial visit!
Remember your childhood friend JAADU from outer space?? Well, he is back again to our mighty Planet Earth.
But do you expect us geeks to introduce a character like Rohit Mehra in this story?
A Hell No!!
Instead, he... | ```python
def sol(n,k):
L = (2**n) - 1
if k > L :
return -1
if k == L/2+1 :
return 0
if k < L/2+1 :
return sol(n-1,k)
else:
return 1-sol(n-1,L+1-k)
#def sol(n,k):
# L = (2**n) - 1 ;
# if k > L :
# return -1
# f=0
# while n>-1 :
# if n==1:
# if k==1: return f
# else: return -1
# if k == L/2 + 1 :... | vfc_78617 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1\n2 1\n2 3\n2 5\n\nSAMPLE",
"output": "G\nG\nC\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 1\n2 1\n2 3\n2 5",
"output": "G\nG\nC\n-1\n",
"type": "stdin_stdou... |
code_contests | verifiable_code | help-out-the-indian-army | Solve the following coding problem using the programming language python:
Protection of the Indian border and safe transport of items from one point to another along the border are the paramount jobs for the Indian army. However they need some information about the protection status along the length of the border. The... | ```python
N,S,E = map(int, raw_input().split())
data = []
for i in range(N):
x,p = map(int, raw_input().split())
data.append([x-p, x+p])
#print 'S is:{0} and E is:{1}'.format(S,E)
#print data
data.sort()
diff = 0
for i in range(len(data)):
temp_arr = data[i]
temp_start = temp_arr[0]
temp_end = ... | vfc_78621 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 229 8419\n1795 95\n4873 720\n3149 81\n6101 2325\n3674 629\n\nSAMPLE",
"output": "2626\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 438 8419\n1795 95\n4873 720\n3149 81\n6101 2325\n3... |
code_contests | verifiable_code | lucky-time | Solve the following coding problem using the programming language python:
Alice is a geeky girl. She has a lot of codes to execute but she always choose a lucky time to execute a code.
Time is shown in 24 hour format as hh:mm:ss
Time is said to be lucky if all the 6 characters (except ':') are different.
Given the t... | ```python
import sys
class test:
def __init__(self):
self.s = raw_input()
self.ti = self.s.split(':')
for i in range(0, 3):
self.ti[i] = int(self.ti[i])
if self.ti[0] > 23 or self.ti[1] > 59 or self.ti[2] > 59:
raise Exception(str(self.ti[0]) + str(self.ti[1])... | vfc_78625 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n00:00:00\n12:59:59\n23:59:59\n\nSAMPLE",
"output": "01:23:45\n13:02:45\n01:23:45\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | navi-and-maths | Solve the following coding problem using the programming language python:
Navi is a famous mathematician. He is working on Division, Multiplication and Addition. He is in need of some hidden patterns to discover some new concepts. He is giving you a task to find that sub-sequence of an array which has the maximum P... | ```python
#from math import *
def findp(arr , n):
m = 10**9 + 7
maximum = -1
for i in range(1 , 1<<n):
prod , s = 1 , 0
for j in range(n):
if i & (1<<j):
s += arr[j]
prod = (prod * arr[j]) % m
maximum = max( ( prod * pow(s , m-2 , m) ) % m , maximum )
return maximum
t = int(raw_input())
for k ... | vfc_78629 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n2 2\n2\n6 3\n\nSAMPLE",
"output": "Case #1: 1\nCase #2: 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n2 2\n2\n3 3\n\nSAMPLE",
"output": "Case #1: 1\nCase #2: 50000000... |
code_contests | verifiable_code | prof-k-trivedis-love-for-strings | Solve the following coding problem using the programming language python:
Aditya is a professor in Engilsh loves to play with words. Today he asks his assistant Abishek to perform an experiment where he wants him to calculate the total number of word that can be formed from a given word such that the characters are ar... | ```python
import collections
a=[]
t=int(raw_input())
for q in range(0,t):
s=raw_input()
letters = collections.Counter(s)
print(len(letters.values()))
``` | vfc_78633 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nankit\naman\ncvrcebhubaneswar\n\nSAMPLE",
"output": "5\n3\n11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\nyqypgenznlzztptieaqkgldlzzvfptbgkaxbfygoqyaagbvulzulemtnybvszhmpbrqmyo... |
code_contests | verifiable_code | sherlock-and-ciphers-5 | Solve the following coding problem using the programming language python:
Sherlock has intercepted some encrypted messages, which he suspects are from Professor Moriarty. He found that the number of characters in each message (including spaces) is always a square number. From this he deduces that it must be a Caesar B... | ```python
n = input()
for _ in xrange(n):
s = raw_input()
m = int(len(s) ** .5)
l = []
for i in xrange(m):
v = []
for j in xrange(m):
v += [s[i*m+j]]
l += [v]
print ''.join(map(lambda t: ''.join(list(t)), zip(*l)))
``` | vfc_78637 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "101\ng hJtLZNqYMMjePTIaxEBMyVWqwohAxuXQLPzJH JsJCjQeNmJbKYjU FyEFnTZSwNKEmkZktwcQCPGtgzYjeZbg OXIiEBMzomm\nBDSBHdwXUpfbYonKssmVOlcsQGKAohfsHcdQvUeywFRhOLUDuzRFquPqwHJrEslf\neYLKUFamzcZ CZMHwiTLZBxhXgiFpThKSYhg\nwiUcahEtiTIUZxirNMRP... |
code_contests | verifiable_code | the-cipher | Solve the following coding problem using the programming language python:
Vinay loves stories on serial killers. He is hypnotized to the stories of The Zodiac Killer. Zodiac was a serial killer in USA in late 1960s and early 1970s. He never revealed his original identity but named himself as Zodiac on the letters he p... | ```python
import sys
for t in range(input()):
n=int(raw_input())
lst=map(int,raw_input().split())
for i in range(n):
sys.stdout.write(chr(255-lst[i]))
print
``` | vfc_78641 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n6\n133 144 155 150 158 156\n\nSAMPLE",
"output": "zodiac\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n21\n182 223 158 146 223 165 144 155 150 158 156 223 172 143 154 158 148 150 ... |
code_contests | verifiable_code | p00570 Stove | Solve the following coding problem using the programming language python:
JOI has a stove in your room. JOI himself is resistant to the cold, so he doesn't need to put on the stove when he is alone in the room, but he needs to put on the stove when there are visitors.
On this day, there are N guests under JOI. The it... | ```python
n, k = map(int, input().split())
li = [int(input()) for i in range(n)]
diff = []
for j in range(n-1):
diff.append(li[j+1]-li[j]-1)
diff.sort(reverse=True)
print(n+sum(diff[k-1:]))
``` | vfc_78701 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n1\n3\n6",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n1\n3\n11",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
code_contests | verifiable_code | p00717 Polygonal Line Search | Solve the following coding problem using the programming language python:
Multiple polygonal lines are given on the xy-plane. Given a list of polygonal lines and a template, you must find out polygonal lines which have the same shape as the template.
A polygonal line consists of several line segments parallel to x-ax... | ```python
# -*- coding: utf-8 -*-
def main():
N = int(input())
while N:
lines = []
for _ in range(N+1):
tmp = []
M = int(input())
x0, y0 = map(int, input().split())
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
... | vfc_78705 | {
"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": "5\n5\n0 0\n2 0\n2 1\n4 1\n4 0\n5\n0 0\n0 2\n-1 2\n-1 4\n0 4\n5\n0 0\n0 1\n-2 1\n-2 2\n0 2\n5\n0 0\n0 -1\n2 -1\n2 0\n4 0\n5\n0 0\n2 0\n2 -1\n4 -1\n4 0\n5\n0 0\n2 0\n2 1\n4 1\n4 0\n4\n4\n-60 -75\n-60 -78\n-42 -78\n-42 -6\n4\n10 3\n10... |
code_contests | verifiable_code | p00988 Fun Region | Solve the following coding problem using the programming language python:
Fun Region
Dr. Ciel lives in a planar island with a polygonal coastline. She loves strolling on the island along spiral paths. Here, a path is called spiral if both of the following are satisfied.
* The path is a simple planar polyline with no... | vfc_78713 | {
"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": "4\n10 0\n20 10\n10 30\n0 10",
"output": "300.00",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01258 Memory Match | Solve the following coding problem using the programming language python:
Memory match is a single-player game which employs a set of 2M cards. Each card is labeled with a number between 1 and M on its face. For each number i (1 ≤ i ≤ M), there are exactly two cards which have the number i. At the start of the game, a... | vfc_78721 | {
"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\n4\n6\n8\n10\n52\n0",
"output": "0.0000000000\n0.6666666667\n1.3333333333\n1.9238095238\n2.5523809524\n15.4435236099",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4\n6\n8\n10\n38\n0",... | |
code_contests | verifiable_code | p01419 On or Off | Solve the following coding problem using the programming language python:
Saving electricity is very important!
You are in the office represented as R \times C grid that consists of walls and rooms. It is guaranteed that, for any pair of rooms in the office, there exists exactly one route between the two rooms. It ta... | ```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in ... | vfc_78725 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 5\n...\n.##\n..#\n1 1 1\n1 0 0\n1 1 0\n3 3 3\n3 0 0\n3 3 0\n5 4 5\n4 0 0\n5 4 0\n1 0\n2 1\n0 2\n2 0\n0 0",
"output": "77",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3 2\n...\n1 1 1... |
code_contests | verifiable_code | p01573 Complex Integer Solutions | Solve the following coding problem using the programming language python:
Let f(x) = a0 + a1x + a2x2 + ... + adxd be the function where each ai (0 ≤ i ≤ d) is a constant integer (and ad is non-zero) and x is a variable. Your task is to write a program that finds all complex integer solutions of the equation f(x) = 0 f... | vfc_78729 | {
"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\n-2 0 0 0 2",
"output": "4\n-1 -i i 1",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01875 Complex Oracle | Solve the following coding problem using the programming language python:
D: Complex Oracle --Complex Oracle-
problem
* This problem is a reactive problem. In other words, it is necessary to create a program that derives the correct answer by interactively responding to the program prepared on the server side. Also,... | vfc_78737 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "",
"output": "",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p02011 Enlarge Circles | Solve the following coding problem using the programming language python:
You are given $N$ distinct points on the 2-D plane. For each point, you are going to make a single circle whose center is located at the point. Your task is to maximize the sum of perimeters of these $N$ circles so that circles do not overlap ea... | vfc_78741 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "9\n91 -18\n13 93\n73 -34\n15 2\n-46 0\n69 -42\n-23 -13\n-87 41\n38 68",
"output": "1049.191683488",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n0 0\n5 0\n0 5",
"output": "53.63034... | |
code_contests | verifiable_code | p02154 Equilateral Triangle | Solve the following coding problem using the programming language python:
Problem
Given a convex polygon consisting of $ N $ vertices.
When considering an equilateral triangle that includes all the vertices of the convex polygon, find the minimum value of the length of one side of the equilateral triangle.
Constrai... | vfc_78745 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 3\n1 2\n2 1\n3 2",
"output": "3.04720672",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | cake1am | Solve the following coding problem using the programming language python:
Your friend Сhef has prepared a rectangular cake for you. Both of you want to divide the cake among yourselves. Your friend is generous enough to let you choose your share first. You have decided to take two pieces.For the first piece you make a... | ```python
for t in xrange(int(raw_input())):
r1=map(int,raw_input().split())
r2=map(int,raw_input().split())
area1=(r1[2]-r1[0])*(r1[3]-r1[1])
area2=(r2[2]-r2[0])*(r2[3]-r2[1])
r3=[]
r3.append(max(r1[0],r2[0]))
r3.append(max(r1[1],r2[1]))
r3.append(min(r1[2],r2[2]))
r3.append(min(r1[3],r2[3]))
area3=max(r3[2]... | vfc_78757 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1 10 10\n11 11 20 20\n1 1 20 20\n11 11 30 30",
"output": "162\n641\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1 10 10\n11 7 20 20\n1 1 20 20\n11 11 30 30",
"output": "... |
code_contests | verifiable_code | cops | Solve the following coding problem using the programming language python:
There are 100 houses located on a straight line. The first house is numbered 1 and the last one is numbered 100. Some M houses out of these 100 are occupied by cops.
Thief Devu has just stolen PeePee's bag and is looking for a house to hide in.
... | ```python
t = int(input())
for test in xrange(t):
chk = [1]*101
m,x,y = map(int,raw_input().split())
arr = map(int,raw_input().split())
for v in xrange(m):
for e in xrange(arr[v]-(x*y),arr[v]+(x*y)+1,1):
try:
if e>=0:
chk[e] = 0
except:... | vfc_78761 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 7 8\n12 52 56 8\n2 10 2\n21 75\n2 5 8\n10 51",
"output": "0\n18\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n4 7 8\n12 52 56 8\n2 11 2\n21 75\n2 5 8\n10 51",
"output": ... |
code_contests | verifiable_code | goc203 | Solve the following coding problem using the programming language python:
Prof. R.K.Vats of NIT Hamirpur has given a problem to the whole class and has imposed a condition that he won't give attendance to those who don't solve it within time. He gave the equation ,
ax+by=c
where a, b, c are three positive integers. Th... | ```python
from fractions import gcd
t=int(raw_input())
counter=0
for i in range(t):
counter+=1
a,b,c=map(int,raw_input().split())
gcdans=gcd(a,b)
if c%gcdans==0:
print "Case "+str(counter)+": Yes"
else:
print "Case "+str(counter)+": No"
``` | vfc_78765 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 4 8\n3 6 7",
"output": "Case 1: Yes\nCase 2: No",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | masnum | Solve the following coding problem using the programming language python:
Mason is yet again in danger.
Consider an N digit number A.
let the new number formed by reversing the digits of A be called B .
Mason has to tell that how many N digit numbers A exist such that A + B = 10^N - 1 ?
Note: A should not have any ... | ```python
for x in range(input()):
n = input()
print "9".ljust(((n/2)),"0") if n%2==0 else "0"
``` | vfc_78769 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n2",
"output": "0\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n0\n2",
"output": "9\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | racelane | Solve the following coding problem using the programming language python:
You are in charge of painting the lanes on a 500 meter race track for a forthcoming amateur track event. There are 9 lanes in total which means you must paint 10 lines around the track to delimit these lanes. Fortunately, you have special equipm... | ```python
# code chef - easy - racing lanes - racelane.py
t = int(raw_input())
RACELENGTH = 500
for iter in range(t):
b = int(raw_input())
racetrack = [0]*(RACELENGTH+1)
for bubble in range(b):
s,e,l = map(int, raw_input().split())
mask = 1<<l # turn l into bit mask
for i in... | vfc_78773 | {
"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\n1 3 1\n2 5 2\n2\n1 3 1\n2 5 3\n5\n60 60 4\n60 61 5\n61 61 6\n100 100 8\n100 100 9",
"output": "498\n500\n497",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2\n1 1 1\n2 5 2\n2\n1 3 ... |
code_contests | verifiable_code | torr | Solve the following coding problem using the programming language python:
Problem description.
One day Toretto wanted to make some extra money. We all know his obsession with cars so all he could manage to get hold of, was some information regarding the buying and selling prices of cars for the next N days.
The buying... | ```python
t=int(raw_input())
while t>0:
n,m=[int(x) for x in raw_input().split()]
p=[int(x) for x in raw_input().split()]
if n==1:
print m
else:
ans=m
for i in range (len(p)):
if p[i]<=m:
for j in range(i,n):
if p[j]>p[i]:
... | vfc_78777 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 5\n4 8\n4 100\n10 7 6 4\n4 100\n10 6 7 4",
"output": "9\n100\n116",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1015_C. Songs Compression | Solve the following coding problem using the programming language python:
Ivan has n songs on his phone. The size of the i-th song is a_i bytes. Ivan also has a flash drive which can hold at most m bytes in total. Initially, his flash drive is empty.
Ivan wants to copy all n songs to the flash drive. He can compress ... | ```python
n,m = input().split()
n=int(n)
m=int(m)
songs=list()
for i in range(n):
songs.append([int(c) for c in input().split()])
def sumList(lista,inx):
sum=0
for i in range(len(lista)):
sum+=lista[i][inx]
return sum
songs=sorted(songs,key=lambda x: x[1]-x[0])
suma = sumList(songs,0)
f... | vfc_78781 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 16\n10 8\n7 4\n3 1\n5 4\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 21\n10 8\n7 4\n3 1\n5 4\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 1039_A. Timetable | Solve the following coding problem using the programming language python:
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the r... | ```python
def read():
return list(map(int, input().split(' ')))
def fail():
print('No')
exit(0)
n, t = read()
aa = read()
xx = read()
res = [0] * n
prevX = 0
prevV = -10
for i in range(n):
x = xx[i] - 1
if x < prevX or x < i:
fail()
prevX = x
res[i] = prevV = max(aa[i + 1] + t if... | vfc_78785 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1\n1 2\n2 1\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 10\n4 6 8\n2 2 3\n",
"output": "Yes\n16 17 18\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1061_C. Multiplicity | Solve the following coding problem using the programming language python:
You are given an integer array a_1, a_2, …, a_n.
The array b is called to be a subsequence of a if it is possible to remove some elements from a to get b.
Array b_1, b_2, …, b_k is called to be good if it is not empty and for every i (1 ≤ i ≤ ... | ```python
import math
def nextDiv(a):
ret = []
i = 1;
while (i*i <= a):
if (a%i == 0):
ret.append(i)
j = a//i
if (i != j):
ret.append(j)
i += 1
return reversed(ret)
MOD = int(1e9+7)
def solve(n, lis):
dp = [0] * (max(lis)+1)
... | vfc_78789 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 2 1 22 14\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
code_contests | verifiable_code | 1130_D1. Toy Train (Simplified) | Solve the following coding problem using the programming language python:
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of... | ```python
from collections import defaultdict as dd
n,m=[int(i) for i in input().split(' ')]
a=[]
b=[]
def fnx(i,j):
if i<j:
return(j-i)
else:
return(n-i+j)
def fnr(r):
if r%n==0:
return(n)
else:
return(r%n)
for i in range(m):
x,y=[int(i) for i in input().split(' '... | vfc_78801 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n1 2\n1 2\n1 2\n",
"output": "5 6 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 7\n2 4\n5 1\n2 3\n3 4\n4 1\n5 3\n3 5\n",
"output": "10 9 10 10 9 \n",
"type": "stdin_st... |
code_contests | verifiable_code | 1150_E. Tree Generator™ | Solve the following coding problem using the programming language python:
Owl Pacino has always been into trees — unweighted rooted trees in particular. He loves determining the diameter of every tree he sees — that is, the maximum length of any simple path in the tree.
Owl Pacino's owl friends decided to present him... | vfc_78805 | {
"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": "6 4\n(((())()))\n6 7\n5 4\n6 4\n7 4\n",
"output": "4\n4\n4\n5\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n(((())))\n4 5\n3 4\n5 6\n3 6\n2 5\n",
"output": "4\n3\n3\n2\n4\n... | |
code_contests | verifiable_code | 1190_B. Tokitsukaze, CSL and Stone Game | Solve the following coding problem using the programming language python:
Tokitsukaze and CSL are playing a little game of stones.
In the beginning, there are n piles of stones, the i-th pile of which has a_i stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a n... | ```python
def find(A):
from collections import defaultdict
A=sorted(A)
N=len(A)
dic=defaultdict(int)
for i in range(N):
dic[A[i]]+=1
checked=[]
count=set([])
for x in A:
if dic[x]>2:
return "cslnb"
if dic[x]==2:
count.add(x)
... | vfc_78813 | {
"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\n2 2\n",
"output": "sjfnb\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 0\n",
"output": "cslnb\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 1209_E2. Rotate Columns (hard version) | Solve the following coding problem using the programming language python:
This is a harder version of the problem. The difference is only in constraints.
You are given a rectangular n × m matrix a. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as ma... | vfc_78817 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 3\n2 5 7\n4 2 4\n3 6\n4 1 5 2 10 4\n8 6 6 4 9 10\n5 4 9 5 8 7\n3 3\n9 9 9\n1 1 1\n1 1 1\n",
"output": "12\n29\n27\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4 2\n1 1\n2 1\n1 2... | |
code_contests | verifiable_code | 1228_E. Another Filling the Grid | Solve the following coding problem using the programming language python:
You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below.
* All numbers in the grid should be between 1 and k inclusive.
* Minimum number of the i-th row is 1 (1 ≤ i ≤ n).
* Minimum ... | ```python
def Solve(n,k):
mod = 10**9+7
max_n = 10**4
#precalcular los factoriales
fac = [1] + [0] * max_n
fac_i = [1] + [0] * max_n
for i in range(1,n+1):
fac[i] = fac[i-1] * (i) % mod
fac_i[i] = fac_i[i- 1] * pow(i,mod-2,mod) % mod
#calculo de las combinaciones con factorial inver... | vfc_78821 | {
"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": "123 456789\n",
"output": "689974806\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1250_L. Divide The Students | Solve the following coding problem using the programming language python:
A group of students has recently been admitted to the Faculty of Computer Sciences at the Berland State University. Now the programming teacher wants to divide them into three subgroups for practice sessions.
The teacher knows that a lot of pro... | vfc_78825 | {
"difficulty": "19",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3 5 7\n4 8 4\n13 10 13\n1000 1000 1000\n13 22 7\n",
"output": "\n5\n6\n13\n1000\n14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 3 4\n1000 1000 1\n4 1 2\n325 226 999\n939 861 50... | |
code_contests | verifiable_code | 1270_E. Divide Points | Solve the following coding problem using the programming language python:
You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds:
For every two points P and Q, write the [Euclidean... | ```python
# -*- coding: utf-8 -*-
import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List
"""
created by shhuan at 2019/12/30 21:55
"""
N = int(input())
A = []
for i in range(N):
x, y = map(int, input().split())
A.append((x, y))... | vfc_78829 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n0 0\n0 1\n1 0\n",
"output": "1\n1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1000000 -1000000\n1000000 1000000\n",
"output": "1\n1 \n",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 1293_C. NEKO's Maze Game | Solve the following coding problem using the programming language python:
[3R2 as DJ Mashiro - Happiness Breeze](https://open.spotify.com/track/2qGqK8GRS65Wlf20qUBEak)
[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/dj-mashiro-is-dead-or-alive)
NEKO#ΦωΦ has just got a new maze game on her PC!
The... | ```python
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
n, q = [int(item) for item in input().split()]
block = [[0] * (n + 6) for _ in range(2)]
wall = 0
for _ in range(q):
x, y = [int(item) - 1 for item in input().split()]
y += 3
invx = (x + 1) % 2
if block[x][y]:
block[x][y] =... | vfc_78833 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\n2 3\n1 4\n2 4\n2 3\n1 4\n",
"output": "Yes\nNo\nNo\nNo\nYes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "76183 37\n1 68009\n2 68008\n2 68008\n2 51883\n1 51882\n2 51883\n2 51881\n2 ... |
code_contests | verifiable_code | 1313_C1. Skyscrapers (easy version) | Solve the following coding problem using the programming language python:
This is an easier version of the problem. In this version n ≤ 1000
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva.... | ```python
import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)
class FastIO... | vfc_78837 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n10 6 8\n",
"output": "10 6 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 2 3 2 1\n",
"output": "1 2 3 2 1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1335_F. Robots on a Grid | Solve the following coding problem using the programming language python:
There is a rectangular grid of size n × m. Each cell of the grid is colored black ('0') or white ('1'). The color of the cell (i, j) is c_{i, j}. You are also given a map of directions: for each cell, there is a direction s_{i, j} which is one o... | ```python
import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI():... | vfc_78841 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2\n01\nRL\n3 3\n001\n101\n110\nRLL\nDLD\nULL\n3 3\n000\n000\n000\nRRD\nRLD\nULL\n",
"output": "2 1\n4 3\n2 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2\n01\nRL\n3 3\n000\n... |
code_contests | verifiable_code | 1358_C. Celex Update | Solve the following coding problem using the programming language python:
During the quarantine, Sicromoft has more free time to create the new functions in "Celex-2021". The developers made a new function GAZ-GIZ, which infinitely fills an infinite table to the right and down from the upper left corner as follows:
<... | ```python
t = int(input())
for _ in range(t):
x1, y1, x2, y2 = map(int, input().split())
print((x2-x1)*(y2-y1)+1)
``` | vfc_78845 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1 2 2\n1 2 2 4\n179 1 179 100000\n5 7 5 7\n",
"output": "2\n3\n1\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1 1 3 6\n",
"output": "11",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 1375_H. Set Merging | Solve the following coding problem using the programming language python:
You are given a permutation a_1, a_2, ..., a_n of numbers from 1 to n. Also, you have n sets S_1,S_2,..., S_n, where S_i=\\{a_i\}. Lastly, you have a variable cnt, representing the current number of sets. Initially, cnt = n.
We define two kinds... | vfc_78849 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4\n2 1\n1 2\n1 2\n1 2\n1 1\n",
"output": "3\n2 1\n3 3 3 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n1 3 2\n2 3\n1 3\n",
"output": "7\n1 3\n1 2\n4 2\n3 2\n7 6 \n",
"... | |
code_contests | verifiable_code | 1423_A. Wakanda Forever | Solve the following coding problem using the programming language python:
In the Kingdom of Wakanda, the 2020 economic crisis has made a great impact on each city and its surrounding area. Cities have made a plan to build a fast train rail between them to boost the economy, but because of the insufficient funds, each ... | vfc_78857 | {
"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\n2 5 8\n7 1 12\n4 6 7\n8 4 5\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n35 19 20\n76 14 75\n23 43 78\n14 76 98\n",
"output": "3\n4\n1\n2\n",
"type":... | |
code_contests | verifiable_code | 1440_E. Greedy Shopping | Solve the following coding problem using the programming language python:
You are given an array a_1, a_2, …, a_n of integers. This array is non-increasing.
Let's consider a line with n shops. The shops are numbered with integers from 1 to n from left to right. The cost of a meal in the i-th shop is equal to a_i.
Yo... | vfc_78861 | {
"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": "10 6\n10 10 10 6 6 5 5 5 3 1\n2 3 50\n2 4 10\n1 3 10\n2 2 36\n1 4 7\n2 2 17\n",
"output": "8\n3\n6\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n5\n2 1 6\n",
"output": "1\n... | |
code_contests | verifiable_code | 1492_A. Three swimmers | Solve the following coding problem using the programming language python:
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for the ... | ```python
t=int(input())
for i in range(t):
p,a,b,c=map(int,input().split())
if(p%a==0 or p%b==0 or p%c==0):
print(0)
else:
a1=a-p%a
b1=b-p%b
c1=c-p%c
print(min(a1,b1,c1))
``` | vfc_78869 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n9 5 4 8\n2 6 10 9\n10 2 5 10\n10 9 9 9\n",
"output": "\n1\n4\n0\n8\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1515_B. Phoenix and Puzzle | Solve the following coding problem using the programming language python:
Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below.
<image> A puzzle piece
The goal of the puzzle is to create a square using the n pieces. He is al... | ```python
import math
def issqr(x):
root = int(math.sqrt(x))
return root*root == x
for i in range(int(input())):
n = int(input())
print("YES" if (n % 4 == 0 and issqr(n//4)) or (n % 2 == 0 and issqr(n//2)) else "NO")
``` | vfc_78873 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n4\n6\n",
"output": "\nYES\nYES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n200040002\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name"... |
code_contests | verifiable_code | 1542_A. Odd Set | Solve the following coding problem using the programming language python:
You are given a multiset (i. e. a set that can contain multiple equal integers) containing 2n integers. Determine if you can split it into exactly n pairs (i. e. each element should be in exactly one pair) so that the sum of the two elements in ... | ```python
t=int(input())
for _ in range(t):
n=int(input())
l=list(map(int,input().split()))
x=[]
y=[]
for i in l:
if i%2==0:
x.append(i)
else:
y.append(i)
if len(x)==len(y):
print("YES")
else:
print("NO")
``` | vfc_78877 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2\n2 3 4 5\n3\n2 3 4 5 5 5\n1\n2 4\n1\n2 3\n4\n1 5 3 2 6 7 3 4\n",
"output": "Yes\nNo\nNo\nYes\nNo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n28\n15 72 79 36 2 77 100 11 84 94 7... |
code_contests | verifiable_code | 16_A. Flag | Solve the following coding problem using the programming language python:
According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour... | ```python
#--------------------#
#INCLUDE <HajLorenzo>
#INCLUDE <MUSIC.H>
#Mitchell Broom - Ascension
#--------------------#
_=list(map(int,input().split()))
__=True
____="WTF"
for _i_ in range(_[0]):
___=input()
if((___.count(___[0])!=_[1]) or (___[0]==____)):__=False
____=___[0]
print("YES" if(__) el... | vfc_78881 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n000\n111\n222\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 18_D. Seller Bob | Solve the following coding problem using the programming language python:
Last year Bob earned by selling memory sticks. During each of n days of his work one of the two following events took place:
* A customer came to Bob and asked to sell him a 2x MB memory stick. If Bob had such a stick, he sold it and got 2x ... | ```python
N = int(input())
L = [-1]*2010
DP = [0]*5010
for i in range(N):
type, cost = input().split()
cost = int(cost)
if type == 'win':
L[cost] = i
elif L[cost] >= 0:
DP[i+1] = DP[L[cost]]+(2**cost)
DP[i+1] = max(DP[i], DP[i+1])
print(DP[N])
``` | vfc_78885 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 128000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\nwin 10\nwin 5\nwin 3\nsell 5\nsell 3\nwin 10\nsell 10\n",
"output": "1056",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nwin 5\nsell 6\nsell 4\n",
"output": "0",
"type": "... |
code_contests | verifiable_code | 213_D. Stars | Solve the following coding problem using the programming language python:
Furik loves painting stars. A star is a shape that results if we take a regular pentagon and paint all diagonals in it.
<image>
Recently he decided to teach Rubik to paint stars. After many years of training Rubik could paint stars easily. Bu... | ```python
p1,p2,p3,p4,p5=[[3.830127018922193,3.366025403784439],
[-3.601321235851749,10.057331467373021],
[0.466045194906253,19.192786043799030],
[10.411264148588986,18.147501411122495],
[12.490381056766580,8.366025403784439]]
zz=[p1,p2,p3,p4,p5]
otrx=p3[0]-p1[0]
otry=p3[1]-p1[1]
n=int(raw_input())
lelem=[]
def getind(... | vfc_78889 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "5\n3.830127018922193 3.366025403784439\n-3.601321235851749 10.057331467373022\n0.466045194906253 19.192786043799028\n10.411264148588986 18.147501411122494\n12.490381056766580 8.366025403784439\n1 2 3 4 5\n1 3... |
code_contests | verifiable_code | 237_D. T-decomposition | Solve the following coding problem using the programming language python:
You've got a undirected tree s, consisting of n nodes. Your task is to build an optimal T-decomposition for it. Let's define a T-decomposition as follows.
Let's denote the set of all nodes s as v. Let's consider an undirected tree t, whose node... | ```python
import sys
input = sys.stdin.readline
N = 10**5 + 5
g = [[] for _ in range(N)]
p = [0]*N
def bfs(cur):
q = [cur]
i = 0
while i < len(q):
cur = q[i]
i += 1
for nxt in g[cur]:
if(nxt != p[cur]):
p[nxt] = cur
q.append(nxt)
n = int(input())
for i in range(n-1):
a, b = map(int, input().split()... | vfc_78893 | {
"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\n2 1\n3 1\n4 1\n",
"output": "3\n2 2 1\n2 3 1\n2 4 1\n1 2\n2 3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 262_B. Roma and Changing Signs | Solve the following coding problem using the programming language python:
Roma works in a company that sells TVs. Now he has to prepare a report for the last year.
Roma has got a list of the company's incomes. The list is a sequence that consists of n integers. The total income of the company is the sum of all intege... | ```python
rd = lambda: list(map(int, input().split()))
k = kk = rd()[1]
a = rd()
k -= sum(x<0 for x in a)
a[:kk] = list(map(abs, a[:kk]))
print(sum(a)-(2*min(a) if k>0 and k&1 else 0))
# Made By Mostafa_Khaled
``` | vfc_78897 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n-1 -1 1\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n-1 -1 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 286_B. Shifting | Solve the following coding problem using the programming language python:
John Doe has found the beautiful permutation formula.
Let's take permutation p = p1, p2, ..., pn. Let's define transformation f of this permutation:
<image>
where k (k > 1) is an integer, the transformation parameter, r is such maximum integ... | vfc_78901 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "1 3 2 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "4 2 3 1 ",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 311_B. Cats Transport | Solve the following coding problem using the programming language python:
Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, numbered from 1 to n from left to right. The distance between hill i and (i - 1) is di meters. Th... | vfc_78905 | {
"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 6 2\n1 3 5\n1 0\n2 1\n4 9\n1 10\n2 10\n3 12\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 6 2\n1 3 5\n1 0\n2 1\n4 9\n1 1\n2 10\n3 12\n",
"output": "4\n",
... | |
code_contests | verifiable_code | 333_E. Summer Earnings | Solve the following coding problem using the programming language python:
Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gerald was quite an unusual schoolboy, he found quite unusual work. A certain Company agreed to pay ... | vfc_78909 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 9, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n2 -3\n-2 -3\n3 0\n-3 -1\n1 -2\n2 -2\n-1 0\n",
"output": "1.5811387129\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n0 1\n1 0\n1 1\n",
"output": "0.4999998055\n",
"type"... | |
code_contests | verifiable_code | 356_E. Xenia and String Problem | Solve the following coding problem using the programming language python:
Xenia the coder went to The Olympiad of Informatics and got a string problem. Unfortunately, Xenia isn't fabulous in string algorithms. Help her solve the problem.
String s is a sequence of characters s1s2... s|s|, where record |s| shows the le... | vfc_78913 | {
"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": "aba\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaaaaa\n",
"output": "15\n",
"type": "stdin_stdout"
}
]
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.