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 | fbfrw2 | Solve the following coding problem using the programming language python:
Problem description
In the climax of an upcoming Bollywood movie "BHAI HO!", Bhai is standing at the centre of a large battlefield. Bhai is sorrounded by the army of Bacchha Singh from all sides. Each soldier of Bacchha's army is at some distanc... | ```python
T=int(raw_input());
for t in range(T) :
N=int(raw_input());
D=[int(i) for i in raw_input().split()];
D.sort();
survive=0;
killed=0;
for i in D :
survive=survive+1;
if survive > i :
break;
else :
killed=killed+1;
if killed % 6 ==0 :
survive=survive+1;
if killed == N :
print "Bhai Ho!"... | vfc_37541 | {
"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\n3 4 3 7 9\n5\n3 3 3 3 3",
"output": "Bhai Ho!\nKilled 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5\n3 3 3 7 9\n5\n3 3 3 3 3",
"output": "Bhai Ho!\nKilled 3\n",
"t... |
code_contests | verifiable_code | lcpesy | Solve the following coding problem using the programming language python:
As we all know, Chef is cooking string for long days, his new discovery on string is the longest common pattern length. The longest common pattern length between two strings is the maximum number of characters that both strings have in common. C... | ```python
test=input()
from collections import Counter
while test:
test-=1
s1=raw_input()
s2=raw_input()
a=Counter(s1)
b=Counter(s2)
count=0
for i in a:
if i in b:
count+=min(a[i],b[i])
print count
``` | vfc_37545 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nabcd\nxyz\nabcd\nbcda\naabc\nacaa\nCodechef\nelfedcc",
"output": "0\n4\n3\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\nabcd\nxyz\nabcd\nbcda\nacba\nacaa\nCodechef\nelfedcc",
... |
code_contests | verifiable_code | pinoch1 | Solve the following coding problem using the programming language python:
Pinocchio is a very interesting fictional character. Each time he lies, his nose is extended by 1 cm .
Pinocchio and Lampwick are best friends.
But Pinocchio's habit of lying has increased manyfold nowadays which has left Lampwick really upse... | ```python
# cook your code here
t = int(raw_input())
for i in xrange(t):
n = int(raw_input())
nums = map(int, raw_input().split())
print len(set(nums)) - 1
``` | vfc_37549 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7\n1 2 2 3 4 5 5",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n7\n1 2 2 3 5 5 5",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": n... |
code_contests | verifiable_code | strpalin | Solve the following coding problem using the programming language python:
Chef likes strings a lot but he likes palindromic strings more. Today, Chef has two strings A and B, each consisting of lower case alphabets.
Chef is eager to know whether it is possible to choose some non empty strings s1 and s2 where s1 is a... | ```python
t = input()
for _ in xrange(t):
a = raw_input()
b = raw_input()
if set(a) & set(b):
print "Yes"
else:
print "No"
``` | vfc_37553 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nabc\nabc\na\nb\nabba\nbaab",
"output": "Yes\nNo\nYes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nabc\nabc\nb\nb\nabba\nbaab",
"output": "Yes\nYes\nYes\n",
"type": "st... |
code_contests | verifiable_code | 1009_D. Relatively Prime Graph | Solve the following coding problem using the programming language python:
Let's call an undirected graph G = (V, E) relatively prime if and only if for each edge (v, u) ∈ E GCD(v, u) = 1 (the greatest common divisor of v and u is 1). If there is no edge between some pair of vertices v and u then the value of GCD(v, u)... | ```python
from math import gcd
from itertools import islice
def get_all(n):
for i in range(1, n+1):
for j in range(i+1, n+1):
if gcd(i, j) == 1: yield i, j
def solve(n, m):
x = list(islice(get_all(n), m))
if len(x) == m >= n - 1:
return x
res = solve(*map(int, input().split()))... | vfc_37557 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 6\n",
"output": "Possible\n1 2\n1 3\n1 4\n1 5\n2 3\n2 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 12\n",
"output": "Impossible\n",
"type": "stdin_stdout"
},
{... |
code_contests | verifiable_code | 1032_A. Kitchen Utensils | Solve the following coding problem using the programming language python:
The king's birthday dinner was attended by k guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen ... | ```python
import math
n, k = map(int, input().split())
a = [int(t) for t in input().split()]
d = {}
for i in a:
if d.get(i) is None:
d[i] = 0
d[i] += 1
print(math.ceil(max(d.values()) / k) * len(d.keys()) * k - n)
``` | vfc_37561 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 3\n1 3 3 1 3 5 5 5 5 100\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2\n1 2 2 1 3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_... |
code_contests | verifiable_code | 1054_G. New Road Network | Solve the following coding problem using the programming language python:
The king of some country N decided to completely rebuild the road network. There are n people living in the country, they are enumerated from 1 to n. It is possible to construct a road between the house of any citizen a to the house of any other... | vfc_37565 | {
"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": "2\n4 3\n0011\n1110\n0111\n3 3\n011\n101\n110\n",
"output": "YES\n1 2\n2 3\n3 4\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4 3\n0011\n1111\n0111\n3 3\n011\n101\n110\n",
"o... | |
code_contests | verifiable_code | 1076_G. Array Game | Solve the following coding problem using the programming language python:
Consider a following game between two players:
There is an array b_1, b_2, ..., b_k, consisting of positive integers. Initially a chip is placed into the first cell of the array, and b_1 is decreased by 1. Players move in turns. Each turn the c... | vfc_37569 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 6, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 1 3\n1 1 3 3 4\n2 1 5\n2 2 5\n2 3 5\n",
"output": "1\n2\n1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1118_F2. Tree Cutting (Hard Version) | Solve the following coding problem using the programming language python:
You are given an undirected tree of n vertices.
Some vertices are colored one of the k colors, some are uncolored. It is guaranteed that the tree contains at least one vertex of each of the k colors. There might be no uncolored vertices.
You ... | vfc_37577 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 3\n0 1 0 2 2 3 0\n1 3\n1 4\n1 5\n2 7\n3 6\n4 7\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2\n2 0 0 1 2\n1 2\n2 3\n2 4\n2 5\n",
"output": "1\n",
"type"... | |
code_contests | verifiable_code | 1145_D. Pigeon d'Or | Solve the following coding problem using the programming language python:
From "ftying rats" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons?
The upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spas... | ```python
n = int(input())
a = list(map(int, input().split()))
print(2+(min(a)^a[2]))
``` | vfc_37581 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1166_C. A Tale of Two Lands | Solve the following coding problem using the programming language python:
The legend of the foundation of Vectorland talks of two integers x and y. Centuries ago, the array king placed two markers at points |x| and |y| on the number line and conquered all the land in between (including the endpoints), which he declare... | ```python
num = int(input())
data = [abs(int(i)) for i in input().split()]
data.sort()
def bins(a, b, n):
if a == b:
if data[a] <= n:
return a+1
else:
return a
else:
m = (a+b)//2
if data[m] <= n:
return bins(m+1,b,n)
else:
... | vfc_37585 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 6\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 5 -3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... |
code_contests | verifiable_code | 1185_A. Ropewalkers | Solve the following coding problem using the programming language python:
Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad.
The rope is straight and infinite in both directions. At the beginning of the performance, Agafon, Boniface and Konrad a... | ```python
a, b, c, d = map(int, input().split())
a, b, c = sorted([a, b, c])
def solve1(a, b, c):
r1 = max(0, d-(b-a))
b += r1
r2 = max(0, d-(c-b))
return r1+r2
def solve2(a, b, c):
r1 = max(0, d-(c-b))
r2 = max(0, d-(b-a))
return r1+r2
def solve3(a, b, c):
r1 = max(0, d-(c-b))
b -=... | vfc_37589 | {
"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 2 6 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3 10 4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... |
code_contests | verifiable_code | 1203_E. Boxers | Solve the following coding problem using the programming language python:
There are n boxers, the weight of the i-th boxer is a_i. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.
... | ```python
N = int(input())
A = sorted([int(a) for a in input().split()])
k = 0
ans = 0
for i in range(N):
if k > A[i]:
pass
elif k >= A[i] - 1:
ans += 1
k += 1
else:
ans += 1
k = A[i] - 1
print(ans)
``` | vfc_37593 | {
"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\n1 1 1 4 4 4\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n3 2 4 1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1220_C. Substring Game in the Lesson | Solve the following coding problem using the programming language python:
Mike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string s and a number k (0 ≤ k < |s|).
At the beginning of the game, players are giv... | ```python
s = input().rstrip()
minimum = "z"
for ch in s:
if ch > minimum:
print("Ann")
else:
print("Mike")
minimum = ch
``` | vfc_37597 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "abba\n",
"output": "Mike\nAnn\nAnn\nMike\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "cba\n",
"output": "Mike\nMike\nMike\n",
"type": "stdin_stdout"
},
{
"fn_n... |
code_contests | verifiable_code | 1286_E. Fedya the Potter Strikes Back | Solve the following coding problem using the programming language python:
Fedya has a string S, initially empty, and an array W, also initially empty.
There are n queries to process, one at a time. Query i consists of a lowercase English letter c_i and a nonnegative integer w_i. First, c_i must be appended to S, and ... | vfc_37609 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\na 2\ny 2\nz 0\ny 2\n",
"output": "2\n2\n2\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\na 1\na 0\ny 3\ny 5\nv 4\nu 6\nr 8\n",
"output": "1\n2\n4\n5\n7\n9\n12\n",
"ty... | |
code_contests | verifiable_code | 1305_G. Kuroni and Antihype | Solve the following coding problem using the programming language python:
Kuroni isn't good at economics. So he decided to found a new financial pyramid called Antihype. It has the following rules:
1. You can join the pyramid for free and get 0 coins.
2. If you are already a member of Antihype, you can invite yo... | vfc_37613 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2 3\n",
"output": "2",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 132_D. Constants in the language of Shakespeare | Solve the following coding problem using the programming language python:
Shakespeare is a widely known esoteric programming language in which programs look like plays by Shakespeare, and numbers are given by combinations of ornate epithets. In this problem we will have a closer look at the way the numbers are describ... | ```python
s=list(raw_input()[::-1])
neg=[]
car=0
for i in xrange(len(s)):
if car==1:
if s[i]=="0":
car=0
s[i]="1"
else:
s[i]="0"
elif i!=0 and s[i]==s[i-1]=="1":
neg.append(i-1)
s[i]=s[i-1]="0"
car=1
if car==1: s.append("1")
print s.count("1")+len(neg)
for i,c in enumerate(s):
if c=="1":
print ... | vfc_37617 | {
"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": "1111\n",
"output": "2\n+2^4\n-2^0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1010011\n",
"output": "4\n-2^0\n+2^2\n+2^4\n+2^6\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 134_B. Pairs of Numbers | Solve the following coding problem using the programming language python:
Let's assume that we have a pair of numbers (a, b). We can get a new pair (a + b, b) or (a, a + b) from the given pair in a single step.
Let the initial pair of numbers be (1,1). Your task is to find number k, that is, the least number of steps... | ```python
import sys
def solve():
n = int(input())
if n == 1: return 0
res = 1000000
for other in range(n - 1, 0, -1):
pair = [n, other]
temp = 0
while (pair[0] > 1 or pair[1] > 1) and (pair[0] > 0 and pair[1] > 0):
pair.sort()
multiples = (pair[1] - 1) /... | vfc_37621 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1370_B. GCD Compression | Solve the following coding problem using the programming language python:
Ashish has an array a of consisting of 2n positive integers. He wants to compress a into an array b of size n-1. To do this, he first discards exactly 2 (any two) elements from a. He then performs the following operation until there are no eleme... | ```python
t = int(input())
def swap(a,b):
if len(a)>len(b):
return b,a
else:
return a,b
def printcomb(a,b):
a, b = swap(a,b)
for i in range(0,len(a),2):
print(a[i]+1, a[i+1]+1)
for i in range(0,len(b),2):
print(b[i]+1, b[i+1]+1)
for i in range(t):
... | vfc_37625 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n1 2 3 4 5 6\n2\n5 7 9 10\n5\n1 3 3 4 5 90 100 101 2 3\n",
"output": "2 4\n1 3\n1 2\n4 6\n7 9\n1 2\n3 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n9\n7 5 4 3 1 4 8 8 2 10 5 9... |
code_contests | verifiable_code | 1392_G. Omkar and Pies | Solve the following coding problem using the programming language python:
Omkar has a pie tray with k (2 ≤ k ≤ 20) spots. Each spot in the tray contains either a chocolate pie or a pumpkin pie. However, Omkar does not like the way that the pies are currently arranged, and has another ideal arrangement that he would pr... | vfc_37629 | {
"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": "4 2 5\n11000\n00011\n1 3\n3 5\n4 2\n3 4\n",
"output": "5\n1 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3 5\n11000\n00011\n1 3\n1 5\n2 4\n1 5\n",
"output": "3\n1 4\n",
... | |
code_contests | verifiable_code | 1434_A. Perform Easily | Solve the following coding problem using the programming language python:
After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret number j on the i-th string produces the note ... | ```python
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.... | vfc_37637 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 4 100 10 30 5\n6\n101 104 105 110 130 200\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1459_A. Red-Blue Shuffle | Solve the following coding problem using the programming language python:
There are n cards numbered 1, …, n. The card i has a red digit r_i and a blue digit b_i written on it.
We arrange all n cards in random order from left to right, with all permutations of 1, …, n having the same probability. We then read all red... | ```python
for _ in range(int(input())):
n=int(input())
s=input()
s1=input()
a=0
b=0
for i in range(n):
if s[i]>s1[i]:
a=a+1
elif s[i]<s1[i]:
b=b+1
if a>b:
print("RED")
elif b>a:
print("BLUE")
else:
print("EQUAL")
... | vfc_37641 | {
"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": "3\n3\n777\n111\n3\n314\n159\n5\n09281\n09281\n",
"output": "\nRED\nBLUE\nEQUAL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3\n777\n111\n3\n314\n159\n5\n14195\n09281\n",
"outpu... |
code_contests | verifiable_code | 162_F. Factorial zeros | Solve the following coding problem using the programming language python:
You are given a positive integer n. Output the number of trailing zeros in n! (n! denotes a product of integers between 1 and n, inclusive).
Input
The only line of input contains an integer n (1 ≤ n ≤ 1000000).
Output
Output the number of tr... | vfc_37657 | {
"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": "6\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "24\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 182_B. Vasya's Calendar | Solve the following coding problem using the programming language python:
Vasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present — the clock that shows not only the time, but also the date.
The clock's face can display any number from 1 to d. It is guarantee... | ```python
d = int(input())
n = int(input())
months = list(map(int, input().split()))
changes = 0
for month in months[:-1]:
changes += d - month
print(changes)
``` | vfc_37661 | {
"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": "31\n12\n31 28 31 30 31 30 31 31 30 31 30 31\n",
"output": "7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n3\n3 4 3\n",
"output": "3",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 205_D. Little Elephant and Cards | Solve the following coding problem using the programming language python:
The Little Elephant loves to play with color cards.
He has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Litt... | ```python
def solve():
n = int(input())
cards = []
cnt = {}
for i in range(n):
card = tuple(map(int, input().split(' ')))
cards.append(card)
cnt[card[0]] = [0, 0]
cnt[card[1]] = [0, 0]
for card in cards:
if card[0] != card[1]:
cnt[card[0]][0] += ... | vfc_37665 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 7\n4 7\n7 4\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n4 7\n7 4\n2 11\n9 7\n1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn... |
code_contests | verifiable_code | 255_B. Code Parsing | Solve the following coding problem using the programming language python:
Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string s, consisting of characters "x" and "y", and uses two following operations at runtime:
1. Find two consecutive ... | ```python
from sys import stdin,stdout
import bisect as bs
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int,stdin.readline().split()))
for _ in range(1):#nmbr()):
s=input()
n=len(s)
x=s.count('x')
y=n-x
if y>=x:
for i in range(y-x):
stdout.write('y')
else:
... | vfc_37673 | {
"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": "x\n",
"output": "x",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "yxyxy\n",
"output": "y",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 279_B. Books | Solve the following coding problem using the programming language python:
When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's num... | ```python
import bisect
n,t=list(map(int,input().split()))
a=list(map(int,input().rstrip().split()))
b=[0]
sol=0
for i in range(n):
b.append(b[-1]+a[i])
b.pop(0)
for i in range(n):
sol=max(sol,bisect.bisect_right(b,t)-i)
t+=a[i]
print(sol)
``` | vfc_37677 | {
"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 5\n3 1 2 1\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n2 2 3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 301_A. Yaroslav and Sequence | Solve the following coding problem using the programming language python:
Yaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of t... | ```python
#!/usr/bin/python3
n = int(input())
data = list(map(int, input().split()))
negative, zero, positive = 0, 0, 0
for element in data:
if element < 0:
negative += 1
elif element == 0:
zero += 1
else:
positive += 1
seen = {}
min_negative = negative
def go(negative, positive)... | vfc_37681 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n-1 -100 -1\n",
"output": "100\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 327_D. Block Tower | Solve the following coding problem using the programming language python:
After too much playing on paper, Iahub has switched to computer games. The game he plays is called "Block Towers". It is played in a rectangular grid with n rows and m columns (it contains n × m cells). The goal of the game is to build your own ... | ```python
#Connected component
import sys
from collections import deque
sys.setrecursionlimit(501 * 501)
n,m = [int(i) for i in input().split()]
a=[[0 for i in range(m)] for i in range(n)]
d=[(0,1),(0,-1),(1,0),(-1,0)]
q=deque()
def main():
global a
ans=[]
first=[]
q=deque()
for i in range(n):... | vfc_37685 | {
"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 3\n...\n",
"output": "7\nB 1 1\nB 1 2\nB 1 3\nD 1 3\nR 1 3\nD 1 2\nR 1 2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 349_E. Subset Sums | Solve the following coding problem using the programming language python:
You are given an array a1, a2, ..., an and m sets S1, S2, ..., Sm of indices of elements of this array. Let's denote Sk = {Sk, i} (1 ≤ i ≤ |Sk|). In other words, Sk, i is some element from set Sk.
In this problem you have to answer q queries of... | vfc_37689 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3 5\n5 -5 5 1 -4\n2 1 2\n4 2 1 4 5\n2 2 5\n? 2\n+ 3 4\n? 1\n+ 2 1\n? 2\n",
"output": "-3\n4\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10 10\n0 0 0 1 -5 8 7 2 9 -2\n8 1 9 7 8 ... | |
code_contests | verifiable_code | 373_A. Collecting Beats is Fun | Solve the following coding problem using the programming language python:
Cucumber boy is fan of Kyubeat, a famous music game.
Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.
Each panel has a timing to press (the preffered time when a player should press... | ```python
n = int(input())
memo = {}
for _ in range(4):
s = input()
for i in s:
if i != '.':
if i not in memo:
memo[i] = 1
else:
memo[i] += 1
res = True
for k, v in memo.items():
if v > n*2:
res = False
if res:
print("YES")
els... | vfc_37693 | {
"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\n..1.\n1111\n..1.\n..1.\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n.135\n1247\n3468\n5789\n",
"output": "YES\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 394_C. Dominoes | Solve the following coding problem using the programming language python:
During the break, we decided to relax and play dominoes. Our box with Domino was empty, so we decided to borrow the teacher's dominoes.
The teacher responded instantly at our request. He put nm dominoes on the table as an n × 2m rectangle so th... | ```python
n, m = map(int, input().split())
doubles, singles = 0, 0
for r in range(n):
for s in input().split():
if s == '11':
doubles += 1
elif s != '00':
singles += 1
lines = {
'zero': ' '.join(m * [ '00' ]),
'double': ' '.join(m * [ '11' ]),
'single_0': ' '.join... | vfc_37697 | {
"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 1\n11\n10\n01\n00\n",
"output": "11 \n10 \n01 \n00 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n01 11 00\n00 01 11\n",
"output": "11 11 10 \n00 00 01 \n",
"type": "s... |
code_contests | verifiable_code | 417_D. Cunning Gena | Solve the following coding problem using the programming language python:
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.
The participants... | vfc_37701 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2\n",
"output": "205",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2 1\n1 1 1\n1\n",
"output": "-1",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | 444_B. DZY Loves FFT | Solve the following coding problem using the programming language python:
DZY loves Fast Fourier Transformation, and he enjoys using it.
Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are sequences with length n, which are indexed from 0 to n - 1, and
<image>
... | vfc_37705 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4 2\n",
"output": "2\n2\n4\n5\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4 3\n",
"output": "5\n5\n5\n5\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": n... | |
code_contests | verifiable_code | 466_C. Number of Ways | Solve the following coding problem using the programming language python:
You've got array a[1], a[2], ..., a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same.
More formally, you need to find... | ```python
def NoW(xs):
if sum(xs) % 3 != 0:
return 0
else:
part = sum(xs) // 3
ci = ret = 0
acum = xs[0]
for i, x in enumerate(xs[1:]):
if acum == 2*part:
# print("2. x=",x)
ret += ci
if acum == part:
... | vfc_37709 | {
"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\n4 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 1 -1 0\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
code_contests | verifiable_code | 48_A. Rock-paper-scissors | Solve the following coding problem using the programming language python:
Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case it is hard to determine to... | ```python
I = lambda: int(input())
IL = lambda: list(map(int, input().split()))
L = [input()[0] for i in '123']
gt = {'r': 'rp', 'p': 'ps', 's': 'sr'}
print('F' if L[1] not in gt[L[0]] and L[2] not in gt[L[0]] else
'M' if L[0] not in gt[L[1]] and L[2] not in gt[L[1]] else
'S' if L[0] not in gt[L[2]] and L... | vfc_37713 | {
"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": "scissors\nrock\nrock\n",
"output": "?\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "scissors\npaper\nrock\n",
"output": "?\n",
"type": "stdin_stdout"
},
{
"fn_n... |
code_contests | verifiable_code | 513_D2. Constrained Tree | Solve the following coding problem using the programming language python:
You need to find a binary tree of size n that satisfies a given set of c constraints. Suppose that the nodes of the unknown binary tree are labeled using a pre-order traversal starting with 1. For the i-th constraint you are given two labels, ai... | vfc_37717 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n1 2 RIGHT\n1 3 LEFT\n",
"output": "IMPOSSIBLE",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n1 2 LEFT\n1 3 RIGHT\n",
"output": "2 1 3 ",
"type": "stdin_stdout"
}
... | |
code_contests | verifiable_code | 538_G. Berserk Robot | Solve the following coding problem using the programming language python:
Help! A robot escaped our lab and we need help finding it.
The lab is at the point (0, 0) of the coordinate plane, at time 0 the robot was there. The robot's movements are defined by a program — a string of length l, consisting of characters U... | vfc_37721 | {
"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": "2 2\n1 1 0\n999 1 0\n",
"output": "RL",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 1 0\n2 1 -1\n3 0 -1\n",
"output": "RDL",
"type": "stdin_stdout"
},
{
"f... | |
code_contests | verifiable_code | 567_A. Lineland Mail | Solve the following coding problem using the programming language python:
All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the Ox axis. No two cities are located at a single point.
Lineland residents love to send letters to each other. ... | ```python
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
print(min(abs(a[i]-a[(i+1)%n]), abs(a[i]-a[i-1])), max(abs(a[i]-a[0]), abs(a[i]-a[-1])))
``` | vfc_37725 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n-1 1\n",
"output": "2 2\n2 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-5 -2 2 7\n",
"output": "3 12\n3 9\n4 7\n5 12\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 588_C. Duff and Weight Lifting | Solve the following coding problem using the programming language python:
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away.... | ```python
from collections import *
import sys
import math
from functools import reduce
def factors(n):
return set(reduce(list.__add__,([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
def li():return [int(i) for i in input().rstrip('\n').split(' ')]
def st():return input().rstrip('\n')
def val(... | vfc_37729 | {
"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 1 2 3 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 1 2 3\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 60_E. Mushroom Gnomes | Solve the following coding problem using the programming language python:
Once upon a time in the thicket of the mushroom forest lived mushroom gnomes. They were famous among their neighbors for their magic mushrooms. Their magic nature made it possible that between every two neighboring mushrooms every minute grew an... | ```python
#!/usr/bin/pypy3
from sys import stdin, stdout
input, print = stdin.readline, stdout.write
p = 0
def readints():
return list(map(int, input().split()))
def writeln(x):
print(str(x) + '\n')
def mod(x):
return (x % p + p) % p
def matmul(a, b):
n = len(a)
c = [[0 for x in range(n)] for y ... | vfc_37733 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1 0 657276545\n1 2\n",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5 0 10000\n1 2 3 4\n",
"output": "1825",
"type": "stdin_stdout"
},
{
"fn_nam... |
code_contests | verifiable_code | 630_J. Divisibility | Solve the following coding problem using the programming language python:
IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the nex... | ```python
n = int(input())
a = n // 2 + n // 3 + n // 5 + n // 7
b = n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35
c = n // 30 + n // 42 + n // 70 + n // 105
d = n // 210
print(n - (a - b + c - d))
``` | vfc_37737 | {
"difficulty": "16",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 0, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3000\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2519\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 659_B. Qualifying Contest | Solve the following coding problem using the programming language python:
Very soon Berland will hold a School Team Programming Olympiad. From each of the m Berland regions a team of two people is invited to participate in the olympiad. The qualifying contest to form teams was held and it was attended by n Berland stu... | ```python
#!/usr/bin/env python3
read_ints = lambda : list(map(int, input().split()))
if __name__ == '__main__':
n, m = read_ints()
R = [[] for _ in range(m)]
for i in range(n):
n,r,s = input().split()
r = int(r)
s = int(s)
R[r-1].append((s,n))
for r in R:
r.so... | vfc_37741 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\nIvanov 1 763\nAndreev 2 800\nPetrov 1 595\nSidorov 1 790\nSemenov 2 503\n",
"output": "Sidorov Ivanov\nAndreev Semenov\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 681_D. Gifts by the List | Solve the following coding problem using the programming language python:
Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are n men in Sasha's family, so let's number them with integers from 1 to n.
Each man has at most one fat... | ```python
# [https://codeforces.com/contest/681/submission/37694242 <- https://codeforces.com/contest/681/status/D <- https://codeforces.com/contest/681 <- https://codeforces.com/blog/entry/45425 <- https://codeforces.com/problemset/problem/681/D <- https://algoprog.ru/material/pc681pD]
(n, m) = map(int, input().split... | vfc_37745 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n1 2\n2 3\n1 2 1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n1 2\n3 4\n1 2 3 3\n",
"output": "3\n2\n1\n3\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 704_C. Black Widow | Solve the following coding problem using the programming language python:
Natalia Romanova is trying to test something on the new gun S.H.I.E.L.D gave her. In order to determine the result of the test, she needs to find the number of answers to a certain equation. The equation is of form:
<image>
Where <image> repre... | vfc_37749 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 7\n2 4 -2\n2 6 3\n2 -7 1\n2 -5 1\n2 3 6\n2 -2 -5\n",
"output": "48\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 10\n1 -5\n2 4 -6\n2 -2 -6\n2 -7 9\n2 10 -1\n2 3 -1\n2 -8 9\n2 5 8\n",... | |
code_contests | verifiable_code | 727_A. Transformation: from A to B | Solve the following coding problem using the programming language python:
Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations:
* multiply the current number by 2 (that is, replace the number x by 2·x);
* append the digit 1 to the right of current num... | ```python
n, target = map(int, input().split())
def keep(target, ans):
#print(target)
while target % 2 == 0:
target = target // 2
ans = [target]+ans
if str(target).endswith("1") and target != 1:
return keep((target-1) // 10, [(target-1) // 10]+ans)
else:
return target, ... | vfc_37753 | {
"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 42\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 162\n",
"output": "YES\n5\n2 4 8 81 162 \n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 748_B. Santa Claus and Keyboard Check | Solve the following coding problem using the programming language python:
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place... | ```python
#k=int(input())
#n,m=map(int,input().split())
#a=list(map(int,input().split()))
#b=list(map(int,input().split()))
a=input()
b=input()
l=len(a)
d=set()
d2=set()
deg=dict()
for i in range(l):
if a[i]==b[i]:
d2.add(a[i])
deg[a[i]]=0
deg[b[i]]=0
for i in range(l):
if a[i]!=b[i]:
... | vfc_37757 | {
"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": "helloworld\nehoolwlroz\n",
"output": "3\nh e\nl o\nd z\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "hastalavistababy\nhastalavistababy\n",
"output": "0\n",
"type": "stdin_st... |
code_contests | verifiable_code | 816_B. Karen and Coffee | Solve the following coding problem using the programming language python:
To stay woke and attentive during classes, Karen needs some coffee!
<image>
Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, ... | ```python
ranges, maps, strs = range, map, str
fout = ""
count = 0
n, k, q = maps(int, input().split())
rangeArr = []
for i in ranges(200002):
rangeArr.append(0)
for recipe in ranges(n):
left, right = maps(int, input().split())
rangeArr[left] += 1
rangeArr[right + 1] -= 1
for recipe in ranges(1, len(rangeArr)... | vfc_37769 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 4\n91 94\n92 97\n97 99\n92 94\n93 97\n95 96\n90 100\n",
"output": "3\n3\n0\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1 1\n1 1\n200000 200000\n90 100\n",
"output": "0\n... |
code_contests | verifiable_code | 841_B. Godsend | Solve the following coding problem using the programming language python:
Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd su... | ```python
input()
for t in input().split():
if int(t) % 2:
print("First")
break
else:
print("Second")
``` | vfc_37773 | {
"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\n1 3 2 3\n",
"output": "First\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2 2\n",
"output": "Second\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 862_C. Mahmoud and Ehab and the xor | Solve the following coding problem using the programming language python:
Mahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil likes sets. This time he won't show them any set from his large collection, but will ask them to create a new set to replenish his beautiful collection of set... | ```python
n, x = map(int, input().split())
if (n == 2 and x == 0):
print("NO")
quit()
a = 2**17
b = 2**18
ans = 0
print("YES")
if(n == 1):
print(x)
quit()
if (n == 2):
print(x, 0)
quit()
for i in range(n-3):
print(i+1, end = " ")
ans = (ans ^ (i+1))
if (ans == x):
print(b, a, a+b)
el... | vfc_37777 | {
"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 6\n",
"output": "YES\n0 131072 131078\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n",
"output": "YES\n1 2 0 131072 131078\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 910_B. Door Frames | Solve the following coding problem using the programming language python:
Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed f... | ```python
n = int(input())
a = int(input())
b = int(input())
ans = 6
cnt = 0
cur = 2
cnt += 2 * ((n - b) // a)
while cnt < 4:
cur += 1
cnt += (n // a)
ans = min(ans, cur)
if b * 2 <= n:
cur, cnt = 0, 0
cur = 1
cnt += ((n - 2 * b) // a)
while cnt < 4:
cur += 1
cnt += (n // a)
... | vfc_37785 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n4\n2\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n3\n4\n",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n... |
code_contests | verifiable_code | 932_D. Tree | Solve the following coding problem using the programming language python:
You are given a node of the tree with index 1 and with weight 0. Let cnt be the number of nodes in the tree at any instant (initially, cnt is set to 1). Support Q queries of following two types:
* <image> Add a new node (index cnt + 1) with w... | vfc_37789 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n1 1 1\n2 2 0\n2 2 1\n1 3 0\n2 2 0\n2 2 2\n",
"output": "0\n1\n1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n1 1 3\n1 2 3\n2 3 4\n1 2 0\n1 5 3\n2 5 5\n2 7 22\n",
"output"... | |
code_contests | verifiable_code | 959_E. Mahmoud and Ehab and the xor-MST | Solve the following coding problem using the programming language python:
Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≤ u < v < n, vertex u and vertex v are co... | ```python
import math
n = int(input())
ans = 0
cur = 1
while cur < n:
cnt = math.ceil((n-cur)/(cur << 1))
ans += cnt*cur
cur <<= 1
print(ans)
``` | vfc_37793 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
... |
code_contests | verifiable_code | 986_C. AND Graph | Solve the following coding problem using the programming language python:
You are given a set of size m with integer elements between 0 and 2^{n}-1 inclusive. Let's build an undirected graph on these integers in the following way: connect two integers x and y with an edge if and only if x \& y = 0. Here \& is the [bit... | ```python
n, m = map(int, input().split())
a = set(map(int, input().split()))
y = 2 ** n
mk = [0] * (2 * y)
cur = 0
for x in a:
if mk[x]: continue
mk[x] = 1
st = [x]
def push(v):
if not mk[v]: mk[v] = 1; st.append(v)
while st:
u = st.pop()
if u < y:
push(y + u)
... | vfc_37797 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n1 2 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n5 19 10 20 12\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | akash-and-loneliness | Solve the following coding problem using the programming language python:
Akash is feeling lonely.So he decided to visit his friend's house.
His friend's house is located at the distance of K metres from his
house.Now,he can take a step of one metre ,two metres or three
metres at a time.Can you tell me number of wa... | ```python
dist = range(1000000)
dist[0] = 1
dist[1] = 2
dist[2] = 4
for i in xrange(3 , 1000000):
dist[i] = (dist[i-1] + dist[i-2] + dist[i-3])%1000000007
t = int(raw_input())
for _ in xrange(0,t):
n = int(raw_input())
print dist[n-1]
``` | vfc_37801 | {
"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\n3\n\nSAMPLE",
"output": "2\n4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\n1\n1\n9\n4\n10\n7\n2\n6\n6\n2\n12\n9\n8\n6\n6",
"output": "1\n1\n149\n7\n274\n44\n2\n24\n24\n2\n... |
code_contests | verifiable_code | brio-and-his-house-10 | Solve the following coding problem using the programming language python:
Brio wants to get a beautiful house constructed near the National Highway. As his in laws are very much fond of triangles, he decided to give his house a perfect Triangular Shape.
Now, here comes the problem that he faces. The plots in Hackers' ... | ```python
import math
t=input()
while t>0:
a,b,c=map(float, raw_input().split(" "))
r=(a*b*c)/(math.sqrt((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c)))
print("%.4f" % (3.1415*r*r))
t-=1
``` | vfc_37805 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5.0000 3.0000 4.0000\n12.0000 13.0000 5.0000\n\n\nSAMPLE",
"output": "19.6344\n132.7284\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5.0000 3.5218061682463278 4.0000\n12.0000 13.0... |
code_contests | verifiable_code | darshak-and-its-co-primes | Solve the following coding problem using the programming language python:
Darshak (Dark) was playing with numbers and started learning various concepts of prime numbers, composite numbers...
One day he got bored solving problems of easy level so he started searching new concepts and end up reading about relative prim... | ```python
def gcd(m,n):
if n==0:
return m
else:
return gcd(n,m%n)
t=input()
while t>0:
t-=1
a,b=map(int,raw_input().split())
flag=gcd(a,b)
if(flag==1):
print "Is a Co-Prime"
else:
print "Not a Co-Prime"
``` | vfc_37809 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5 32\n6 12\n\nSAMPLE",
"output": "Is a Co-Prime\nNot a Co-Prime\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50\n1 1000000\n1 1000000\n1 1000000\n1 1000000\n1 1000000\n1 1000000\n1 1... |
code_contests | verifiable_code | game-10 | Solve the following coding problem using the programming language python:
Joy and Rock decided to play a game. They have N cards numbered from 0 to N−1. Joy asks Rock to reverse the position of the cards, i.e., to change the order from say, 0,1,2,3 to 3,2,1,0. He further asks Rock to reverse the position of the cards ... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=input()
for _ in range(t):
b=[]
x=[]
y=[]
n,m=map(int,raw_input().split())
if((n-1)%2):
p=int(((n-1)/2)+1)
else :
p=(n-1)/2
for i in range(0,p):
b.append(n-i-1)... | vfc_37813 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 1 \n6 3\n\nSAMPLE",
"output": "3\n4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | kalas-army | Solve the following coding problem using the programming language python:
King Kala the Fighter has an army of N soldiers. Each soldier is either a BanVeer or a TalwarBaaz. There are M soldiers in the army who are TalwarBaaz. The King forms a strategy. For each battle, he doesn’t have the resources to send his army in... | ```python
fact = [0]*200005
inv = [0]*200005
MOD = 1000000009
def invMod (n):
return pow(n, MOD-2, MOD)
def solve (n, r):
if r < 0 or r > n:
return 0
x = ( fact[n] * ( inv[r]%MOD * inv[n-r]%MOD)%MOD)%MOD
return x
def main():
fact[0] = 1
inv[0] = 1
for i in xrange(1,200003):
fact[i] = (fact[i-1]*i)%MOD
i... | vfc_37817 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 2 2\n4 2 3\n10 4 3\n\nSAMPLE",
"output": "3\n11\n134",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n22 7 426\n445 77 81\n447 141 497\n202 59 325\n482 8 417\n156 120 402\n228 33 35... |
code_contests | verifiable_code | mishtis-castle | Solve the following coding problem using the programming language python:
To defend her castle Count Mishti has invented a new challenge. In this challenge, the participant goes to a room that has n corridors and each corridor has n cells. Each cell has some coins of gold in it i.e. the jth cell of the ith corridor ha... | ```python
noOfTestCases = int(raw_input())
def maxCoins(values, c):
i = 0
while(i<n):
j = 0
while(j<n):
values[i][j] = int(values[i][j])
j += 1
i += 1
i = 1
while(i<n):
values[i][0] += values[i-1][0]
i += 1
i = 1
while(i<n):
values[0][i] += values[0][i-1]
i += 1
i = 1
while(i<n)... | vfc_37821 | {
"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 7\n0 0\n8 0\n2 5\n0 1\n3 0\n\nSAMPLE",
"output": "1\n-1",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | palindromic-prime | Solve the following coding problem using the programming language python:
Consider the palindromic prime numbers(Numbers which are palindrome as well as prime).Let p be the product of non zero digits of a nth palindromic prime number.Let product of digits of a palindromic prime is multiplied by a number m to generate ... | ```python
l = [1, 2, 3, 5, 7, 1, 1, 3, 5, 8, 9, 9, 45, 63, 72, 98, 245, 392, 441, 81, 162, 3, 5, 6, 3, 4, 16, 28, 32, 27, 72, 81, 48, 112, 100, 125, 36, 108, 180, 216, 196, 441, 64, 256, 243, 648, 729, 9, 18, 36, 63, 72, 9, 45, 108, 144, 405, 720, 1152, 225, 225, 675, 1575, 648, 1620, 882, 2205, 576, 576, 4032, 1458, 9... | vfc_37825 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 1\n\nSAMPLE",
"output": "2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | staircase-problem-1 | Solve the following coding problem using the programming language python:
Joy is a short and lazy guy, he uses elevator to reach his flat. But unfortunately elevator is not working today and he became sad. Suddenly God came and made the stairs magical, such that he can jump on it in a magical way. Initially he can tak... | ```python
test = int(input())
while(test>0):
stairs = int(input())
steps = 0
size_of_step = 2
while(stairs > 0):
steps +=1
stairs = stairs - size_of_step
size_of_step+=1
test-=1
print(steps)
``` | vfc_37833 | {
"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\n3\n\nSAMPLE",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | tshirtselection-1 | Solve the following coding problem using the programming language python:
Ben believes a lot in tarot cards. He believes that they are lucky for him. He even decides to wear clothes according to the color predicted by a draw of a card. This irritates his wife, because sometimes he wears the same color t-shirt continuo... | ```python
def solve(a):
l, r = 0, 0
d = {}
for ii in a:
d[ii] = 0
i = 0
n = len(a)
best = 0
bestl, bestr = 0, 0
dist = 0
while r<n:
d[a[r]]+=1
if d[a[r]]==2:
while d[a[r]]!=1:
d[a[l]]-=1
l+=1
if (r-l)>best:
... | vfc_37837 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n1 2 3 4 5\n6\n1 2 1 3 1 5\n\n\nSAMPLE",
"output": "1 5\n2 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5\n1 2 3 4 5\n6\n1 2 1 3 1 8\n\n\nSAMPLE",
"output": "1 5\n2 4\n"... |
code_contests | verifiable_code | p00004 Simultaneous Equation | Solve the following coding problem using the programming language python:
Write a program which solve a simultaneous equation:
ax + by = c
dx + ey = f
The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.
Inpu... | ```python
import sys
lines = sys.stdin.readlines()
for l in lines:
nums = list(map(int, l.split()))
A = [nums[0], nums[1], nums[3], nums[4]]
B = [nums[2], nums[5]]
detA = A[0]*A[3] - A[1]*A[2]
inA = [A[3], -A[1], -A[2], A[0]]
solutions = [n/detA+0.0 for n in [inA[0]*B[0] + inA[1]*B[1], inA[2]*B... | vfc_37881 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5",
"output": "-1.000 2.000\n1.000 4.000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27",
"output": "0.000 3.000\n0.000 3.... |
code_contests | verifiable_code | p00457 Chain | Solve the following coding problem using the programming language python:
problem
There are the following games.
N characters are lined up in a vertical row. The color of these characters is red, blue, or yellow, and in the initial state, four or more characters of the same color are not lined up in a row. The playe... | ```python
# p周辺の4つは消えることが前提
def erase(array, i, N):
if array[i - 1] == array[i]:
up = i - 1
down = i
elif array[i] == array[i + 1]:
up = i
down = i + 1
else:
return N - 2
while True:
if array[up] == -1 or array[down] == -1 or not array[up] == array[down]:... | vfc_37893 | {
"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": "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0",
"output": "3\n12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n1... |
code_contests | verifiable_code | p00647 It's our delight!! | Solve the following coding problem using the programming language python:
You are a student of University of Aizu. And you work part-time at a restaurant.
Staffs of the restaurant are well trained to be delighted to provide more delicious products faster.
The speed providing products particularly depends on skill of... | ```python
while 1:
N = int(input())
if N == 0:
break
a = b = c = 0
a0 = b0 = c0 = 0
for i in range(N):
s0, s1 = input().split()
h, m = map(int, s0.split(":"))
tm = 100*h + m
m1 = int(s1)
if m1 < m:
m1 += 60
if 1100 <= tm < 1500:
... | vfc_37897 | {
"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\n12:57 59\n20:12 15\n12:19 21\n18:52 03\n16:09 14\n0",
"output": "lunch 100\ndinner 50\nmidnight no guest",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00791 Trapezoids | Solve the following coding problem using the programming language python:
If you are a computer user, you should have seen pictures drawn with ASCII characters. Such a picture may not look as good as GIF or Postscript pictures, but is much easier to handle. ASCII pictures can easily be drawn using text editors, and ca... | vfc_37901 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n********\n* *\n* *** *\n* * * *\n* *** *\n* *\n********\n9\n\n***\n* *\n***** *****\n* *\n*** *****\n* *\n* *\n***\n11\n**** *******************\n* * ********* ... | |
code_contests | verifiable_code | p00923 |C(O||W||A*RD*||S)* CROSSWORD Puzzle| | Solve the following coding problem using the programming language python:
The first crossword puzzle was published on December 21, 1913 by Arthur Wynne. To celebrate the centennial of his great-great-grandfather's invention, John "Coward" Wynne1 was struggling to make crossword puzzles. He was such a coward that whene... | vfc_37905 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n^(C|I|T|Y)*$\n^(C|O|P|S)*$\n^(F|L|I|P)*$\n^(B|A|C|K)*$\n2 2\n^HE|LL|O*$\n^(P|L|E|A|S|E)*$\n^(H|L)*$\n^EP|IP|EF$\n4 4\n^LONG|TALL|S*ALLY$\n^(R*EV*|OL*U(TIO)*N)*$\n^(STRAWBERRY|F*I*E*L*D*S*|FOREVER)*$\n^P.S.|I|LOVE|YOU$\n^(RE|A|... | |
code_contests | verifiable_code | p01056 Lights of Apartment | Solve the following coding problem using the programming language python:
Problem
A-chan, Rika-chan, and Hart-kun came to visit the condominium.
The three decided to sneak into a room where they could manage the electricity in all the rooms and play a trick.
This condominium has the shape of n cubes lined up in a ro... | vfc_37909 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 267386880,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n2 2\n2 3",
"output": "14",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n0 4",
"output": "27",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... | |
code_contests | verifiable_code | p01188 Slippy Floors | Solve the following coding problem using the programming language python:
The princess of the Fancy Kingdom has been loved by many people for her lovely face. However the witch of the Snow World has been jealous of the princess being loved. For her jealousy, the witch has shut the princess into the Ice Tower built by ... | vfc_37913 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n10 30\n......#############...........\n....##_____________#..........\n...#________________####......\n..#________####_________#.....\n.#________#....##________#....\n#_________#......#________#...\n#__________###...#_____^^_#..... | |
code_contests | verifiable_code | p01493 DisconnectedGame | Solve the following coding problem using the programming language python:
Example
Input
3
NNN
NNN
NNN
Output
Taro
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code. | ```python
from collections import deque
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N = int(readline())
G = [[] for i in range(N)]
for i in range(N):
*vs, = readline()
for j in range(N):
if vs[j] == "Y":
... | vfc_37921 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nNNN\nNNN\nNNN",
"output": "Taro",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nNNN\nNNO\nNNN",
"output": "Taro\n",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
code_contests | verifiable_code | p01655 Ancient Scrolls | Solve the following coding problem using the programming language python:
Problem Statement
You bought 3 ancient scrolls from a magician. These scrolls have a long string, and the lengths of the strings are the same. He said that these scrolls are copies of the key string to enter a dungeon with a secret treasure. Ho... | vfc_37925 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 1\nACM\nIBM\nICM\n5 2\niwzwz\niziwi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLnlyyGDA\nyLRnvyyGDA\n0 0",
"output": "ICM\niwiwi\n-1\nAARAlNyGDA",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... | |
code_contests | verifiable_code | p01941 Indecision | Solve the following coding problem using the programming language python:
D: Indecision-Indecision-
problem
Ebi-chan has been addicted to gal games lately, and her goal now is to capture two heroines at the same time.
Ebi-chan can use several events to increase her liking from the heroine, but only one heroine can ... | ```python
N, C = map(int, input().split())
events = []
for i in range(N):
events.append(list(map(int, input().split())))
def solve():
L = 250
dp = [[-10**18]*(L+1) for i in range(C+1)]
for j in range(C+1):
dp[j][0] = 0
for a, b, c in events:
for j in range(C-c, -1, -1):
... | vfc_37933 | {
"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": "3 4\n3 2 2\n2 1 1\n2 1 1",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n4 2 2\n2 1 1\n2 1 1",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_... |
code_contests | verifiable_code | p02090 Shuttle Run | Solve the following coding problem using the programming language python:
C: Shuttle Run
Story
University H has a unique physical fitness test program, aiming to grow the mindset of students. Among the items in the program, shuttle run is well-known as especially eccentric one. Surprisingly, there are yokans (sweet ... | ```python
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline(... | vfc_37937 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 3\n1 2",
"output": "2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | anubtg | Solve the following coding problem using the programming language python:
Problem description
It is winter super sale and all the shops have various offers. Suraj selected N items to buy and he is standing in the billing queue. It was then he noticed the offer "Buy two, get two". That means for every two items you buy... | ```python
T = int(raw_input())
for t in range(T):
N = int(raw_input())
A = map(int, raw_input().split())
A.sort()
A = A[::-1]
B = []
for i in range(len(A)):
if i%4==0 or i%4==1:
B.append(A[i])
print sum(B)
``` | vfc_37949 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n1 1 2 2\n2\n10 200\n7\n1 1 10 2 2 2 1",
"output": "4\n210\n14\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | chplgns | Solve the following coding problem using the programming language python:
Chef has N simple polygons (non self intersecting polygons) in which no two of them intersect with each other. For any two polygons P1, P2, either P1 lies inside P2 or vice versa.
Chef wants you to count number of polygons lying strictly inside... | ```python
class One:
def __init__(self,index,x):
self.index=index
self.x=x
t=int(input())
for i in range(0,t):
list=[]
n=int(input())
for j in range(0,n):
p=int(input())
e1=One(j,0)
arr=raw_input().split()
for k in range(0,p):
if(k==0):
e1.x=int(arr[2*k])
elif(int(arr[2*k]) > e1.x):
e1.x=i... | vfc_37953 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 3 -3 -3 3 -3",
"output": "1 0 2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3... |
code_contests | verifiable_code | equality | Solve the following coding problem using the programming language python:
An equation is an equality containing one or more variables. Solving the equation consists of determining which values of the variables make the equality true. In this situation, variables are also known as unknowns and the values which satisfy ... | ```python
t=input()
for i in range(t):
n=input()
l=map(int,raw_input().split())
s=sum(l)/(n-1)
for x in l:
if(x!=l[len(l)-1]):
print s-x,
else:
print s-x
``` | vfc_37957 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n9 6 5\n4\n13 11 10 8",
"output": "1 4 5\n1 3 4 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3\n9 5 5\n4\n13 11 10 8",
"output": "0 4 4\n1 3 4 6\n",
"type": "stdin... |
code_contests | verifiable_code | knightmv | Solve the following coding problem using the programming language python:
Chef develops his own computer program for playing chess. He is at the very beginning. At first he needs to write the module that will receive moves written by the players and analyze it. The module will receive a string and it should report at ... | ```python
from re import match
def process(M):
test1 = match(r'^([a-h])([1-8])\-([a-h])([1-8])$', M)
if not test1: return 'Error'
M = test1.groups()
M = ord(M[0])-96, int(M[1]), ord(M[2])-96, int(M[3])
D = abs(M[0]-M[2]), abs(M[1]-M[3])
if D==(1,2) or D==(2,1): return 'Yes'
return 'No'
def... | vfc_37961 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\na1-b3\nd2-h8\na3 c4\nErrorError",
"output": "Yes\nNo\nError\nError\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | pairing | Solve the following coding problem using the programming language python:
The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees ar... | ```python
for _ in range(int(raw_input())):
n, m = map(int, raw_input().split())
a = []
t = []
ans =[]
for __ in range(m):
a.append([map(int, raw_input().split())])
a.reverse()
for i in range(len(a)):
for p, q in a[i]:
if p not in t and q not in t:
... | vfc_37965 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 1",
"output": "1 4\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 0",
"output"... |
code_contests | verifiable_code | sreeni | Solve the following coding problem using the programming language python:
Mr. Sreeniketan the owner of Madras Super Kings is a very superstitious owner. He believes that certain gestures help the team to perform well. Whenever the team enters the field , they form a huddle to discuss strategies. Sreeni wishes that the... | ```python
t=input()
for k in range(t):
order=raw_input()
obs=raw_input()
obser=obs+obs
flag=False
for i in range(len(order)):
if order[0]==obser[i]:
if obser[i:i+len(order)]==order:
print "YES"
flag=True
break
if not(flag):
... | vfc_37969 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nBLAW\nAWBL\nAAABBL\nLBABAA",
"output": "YES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\nBLAW\nAWBL\nAAABBL\nAABABL",
"output": "YES\nNO\n",
"type": "stdin_stdout"... |
code_contests | verifiable_code | 102_E. Vectors | Solve the following coding problem using the programming language python:
At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector А:
* Turn the vector by 90 degrees clockwise.
* Add to the vector a certain ve... | vfc_37977 | {
"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": "0 0\n1 1\n0 1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0\n1 1\n1 1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... | |
code_contests | verifiable_code | 1073_F. Choosing Two Paths | Solve the following coding problem using the programming language python:
You are given an undirected unweighted tree consisting of n vertices.
An undirected tree is a connected undirected graph with n - 1 edges.
Your task is to choose two pairs of vertices of this tree (all the chosen vertices should be distinct) (... | ```python
import sys
n = int(sys.stdin.readline())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
i, j = tuple(int(k) for k in sys.stdin.readline().split())
i -= 1
j -= 1
edges[i].append(j)
edges[j].append(i)
# Prunes the graph starting from the vertices with
# only 1 edge until we reach a ... | vfc_37985 | {
"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": "9\n9 3\n3 5\n1 2\n4 3\n4 7\n1 7\n4 6\n3 8\n",
"output": "8 2\n5 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n6 8\n10 3\n3 7\n5 8\n1 7\n7 2\n2 9\n2 8\n1 4\n",
"output": "10 6... |
code_contests | verifiable_code | 1095_F. Make It Connected | Solve the following coding problem using the programming language python:
You are given an undirected graph consisting of n vertices. A number is written on each vertex; the number on vertex i is a_i. Initially there are no edges in the graph.
You may add some edges to this graph, but you have to pay for them. The co... | ```python
n, m = map(int, input().split())
a = list(map(int, input().split()))
e = []
for _ in range(m) :
u, v, w = map(int, input().split())
e.append((u-1, v-1, w))
a = sorted(zip(a, range(n)), key = lambda x : x[0])
for i in range(1, n) :
e.append((a[0][1], a[i][1], a[0][0] + a[i][0]))
fa = list(range(... | vfc_37989 | {
"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 4\n1 2 3 4 5\n1 2 8\n1 3 10\n1 4 7\n1 5 15\n",
"output": "18\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1117_A. Best Subsegment | Solve the following coding problem using the programming language python:
You are given array a_1, a_2, ..., a_n. Find the subsegment a_l, a_{l+1}, ..., a_r (1 ≤ l ≤ r ≤ n) with maximum arithmetic mean (1)/(r - l + 1)∑_{i=l}^{r}{a_i} (in floating-point numbers, i.e. without any rounding).
If there are many such subse... | ```python
n=int(input())
s=[int(x) for x in input().split()]
el=max(s)
pos1=-1
pos2=-1
c=0
ans=0
for i in range(0,len(s)):
if(s[i]==el):
c=c+1
else:
ans=max(ans,c)
c=0
ans=max(ans,c)
print(ans)
``` | vfc_37993 | {
"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\n6 1 6 6 0\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 5\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | 1143_C. Queen | Solve the following coding problem using the programming language python:
You are given a rooted tree with vertices numerated from 1 to n. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.
Ancestors of the vertex i are all vertices on the path from the root to the vertex i, ex... | ```python
"""
https://codeforces.com/problemset/problem/1143/C
"""
n = int(input())
respect = [0 for _ in range(n)]
child_respect = [0 for _ in range(n)]
root = -1
for i in range(n):
p, c = map(int,input().split())
if p == -1:
root = i
continue
respect[i] = c
if p != -1 and not c: ch... | vfc_37997 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3 1\n1 1\n-1 0\n2 1\n3 0\n",
"output": "1 2 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0\n",
"output": "5\n",
"type": "stdin_... |
code_contests | verifiable_code | 1163_C1. Power Transmission (Easy Edition) | Solve the following coding problem using the programming language python:
This problem is same as the next one, but has smaller constraints.
It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power ... | ```python
import sys
import collections
import math
import heapq
from operator import itemgetter
def getint():
return int(input())
def getints():
return [int(x) for x in input().split(' ')]
n = getint()
points = [tuple(getints()) for _ in range(n)]
result = 0
slopes = collections.defaultdict(set)
for i in r... | vfc_38001 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n0 0\n1 1\n0 3\n1 2\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0\n0 2\n0 4\n2 0\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn... |
code_contests | verifiable_code | 1184_A1. Heidi Learns Hashing (Easy) | Solve the following coding problem using the programming language python:
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her ... | ```python
from math import sqrt
def get_int():
from sys import stdin
return int(stdin.readline().replace('\n', ''))
def is_even(n):
return n%2 == 0
def heidi_hash(r):
k = r-1
rt = int(sqrt(k))
for x in range(1, rt+2):
if k % x == 0:
temp = k/x -x -1
if temp > ... | vfc_38005 | {
"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": "19\n",
"output": "1 8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "768407... |
code_contests | verifiable_code | 1201_D. Treasure Hunting | Solve the following coding problem using the programming language python:
You are on the island which can be represented as a n × m table. The rows are numbered from 1 to n and the columns are numbered from 1 to m. There are k treasures on the island, the i-th of them is located at the position (r_i, c_i).
Initially ... | ```python
from sys import stdin
from bisect import bisect_left
input=stdin.readline
n,m,k,q=map(int,input().split(' '))
x=sorted(list(map(int,input().split(' ')))for i in range(k))
y=sorted(list(map(int,input().split(' '))))
def rr(c0,c1,c2):
return abs(c2-c0)+abs(c1-c2)
def tm(c0,c1):
t=bisect_left(y,c0)
... | vfc_38009 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 6 3 2\n1 6\n2 2\n3 4\n1 6\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 3 2\n1 1\n2 1\n3 1\n2 3\n",
"output": "6\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 1219_C. Periodic integer number | Solve the following coding problem using the programming language python:
Alice became interested in periods of integer numbers. We say positive X integer number is periodic with length L if there exists positive integer number P with L digits such that X can be written as PPPP…P. For example:
X = 123123123 is period... | ```python
import math as m
def main():
n = int(input())
s = input()
l = len(s)
p = int(m.ceil(l/n))
if l%n!=0 :
t = '1'
for i in range(1,n):
t+='0'
for i in range(0,p):
print(t ,end = '')
else :
z = s[0:n]
t=''
for i in range(0,p):
t+=z
if t > s:
print(t)
return
z = str(int(s[0:n]... | vfc_38013 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n12345\n",
"output": "100100",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n123456\n",
"output": "124124",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1243_C. Tile Painting | Solve the following coding problem using the programming language python:
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in some co... | ```python
def prime_factor(n):
ass = []
for i in range(2,int(n**0.5)+1):
while n % i==0:
ass.append(i)
n = n//i
if n != 1:
ass.append(n)
return ass
n = int(input())
p = list(set(prime_factor(n)))
if len(p) == 1:
print(p[0])
else:
print(1)
``` | vfc_38017 | {
"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\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1263_B. PIN Codes | Solve the following coding problem using the programming language python:
A PIN code is a string that consists of exactly 4 digits. Examples of possible PIN codes: 7013, 0000 and 0990. Please note that the PIN code can begin with any digit, even with 0.
Polycarp has n (2 ≤ n ≤ 10) bank cards, the PIN code of the i-th... | ```python
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
# from math import gcd
# from itertools import combinations,permutations,accumulate, product # (string,3) 3回
# #from collections import deque
# from collections import deque,de... | vfc_38021 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n1234\n0600\n2\n1337\n1337\n4\n3139\n3139\n3139\n3139\n",
"output": "0\n1234\n0600\n1\n1337\n0337\n3\n3139\n0139\n1139\n2139\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n3\n1111... |
code_contests | verifiable_code | 1284_E. New Year and Castle Construction | Solve the following coding problem using the programming language python:
Kiwon's favorite video game is now holding a new year event to motivate the users! The game is about building and defending a castle, which led Kiwon to think about the following puzzle.
In a 2-dimension plane, you have a set s = \{(x_1, y_1), ... | vfc_38025 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n-1 0\n1 0\n-10 -1\n10 -1\n0 3\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1303_G. Sum of Prefix Sums | Solve the following coding problem using the programming language python:
We define the sum of prefix sums of an array [s_1, s_2, ..., s_k] as s_1 + (s_1 + s_2) + (s_1 + s_2 + s_3) + ... + (s_1 + s_2 + ... + s_k).
You are given a tree consisting of n vertices. Each vertex i has an integer a_i written on it. We define... | vfc_38029 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 6, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4 2\n3 2\n4 1\n1 3 3 7\n",
"output": "36\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 2\n1 2\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name"... | |
code_contests | verifiable_code | 1328_A. Divisibility Problem | Solve the following coding problem using the programming language python:
You are given two positive integers a and b. In one move you can increase a by 1 (replace a with a+1). Your task is to find the minimum number of moves you need to do in order to make a divisible by b. It is possible, that you have to make 0 mov... | ```python
t=int(input())
for i in range(0,t):
a,b=input().split()
a=int(a)
b=int(b)
print((b-a%b)%b)
``` | vfc_38033 | {
"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\n10 4\n13 9\n100 13\n123 456\n92 46\n",
"output": "2\n5\n4\n333\n0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1348_A. Phoenix and Balance | Solve the following coding problem using the programming language python:
Phoenix has n coins with weights 2^1, 2^2, ..., 2^n. He knows that n is even.
He wants to split the coins into two piles such that each pile has exactly n/2 coins and the difference of weights between the two piles is minimized. Formally, let a... | ```python
t=eval(input())
for j in range(t):
n=eval(input())
if n==2 :
print(2)
else:
sum=2
for i in range(1,n//2):
sum=sum+2**(i+1)
print(sum)
``` | vfc_38037 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n4\n",
"output": "2\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n2\n4\n6\n8\n10\n12\n14\n16\n18\n20\n22\n24\n26\n28\n30\n30\n30\n30\n20\n30\n30\n18\n14\n16\n30\n24\n30\n30\... |
code_contests | verifiable_code | 1368_H1. Breadboard Capacity (easy version) | Solve the following coding problem using the programming language python:
This is an easier version of the problem H without modification queries.
Lester and Delbert work at an electronics company. They are currently working on a microchip component serving to connect two independent parts of a large supercomputer.
... | vfc_38041 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5 0\nBBRR\nRBBR\nBBBBB\nRRRRR\n",
"output": "7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4 0\nBRBR\nBRBR\nRRBB\nRBBB\n",
"output": "7",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | 138_C. Mushroom Gnomes - 2 | Solve the following coding problem using the programming language python:
One day Natalia was walking in the woods when she met a little mushroom gnome. The gnome told her the following story:
Everybody knows that the mushroom gnomes' power lies in the magic mushrooms that grow in the native woods of the gnomes. Ther... | vfc_38045 | {
"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\n2 2 50 50\n1 1\n",
"output": "0.5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\n2 2 50 50\n4 2 50 50\n3 1\n",
"output": "0.25\n",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | 1413_A. Finding Sasuke | Solve the following coding problem using the programming language python:
Naruto has sneaked into the Orochimaru's lair and is now looking for Sasuke. There are T rooms there. Every room has a door into it, each door can be described by the number n of seals on it and their integer energies a_1, a_2, ..., a_n. All ene... | ```python
T = int(input())
a = []
b=[]
i = 0
j = 0
n = 0
for i in range(T):
n = int(input())
a = list(map(int, input().split()))
b.append([])
for j in range(int(n/2)):
if (a[j*2] > a[j*2 + 1]):
b[i].append(a[j*2 + 1])
b[i].append(-a[j*2])
elif(a[j*2 + 1] >= a[j*... | vfc_38049 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n1 100\n4\n1 2 3 6\n",
"output": "-100 1\n-2 1 -6 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n1 100\n4\n1 2 3 6\n",
"output": "-100 1\n-2 1 -6 3\n",
"type": "s... |
code_contests | verifiable_code | 1431_D. Used Markers | Solve the following coding problem using the programming language python:
Your University has a large auditorium and today you are on duty there. There will be n lectures today — all from different lecturers, and your current task is to choose in which order ord they will happen.
Each lecturer will use one marker to ... | vfc_38053 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n1 2 1 2\n2\n2 1\n3\n1 1 1\n4\n2 3 1 3\n",
"output": "\n4 1 3 2\n1 2\n3 1 2\n4 3 2 1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1455_A. Strange Functions | Solve the following coding problem using the programming language python:
Let's define a function f(x) (x is a positive integer) as follows: write all digits of the decimal representation of x backwards, then get rid of the leading zeroes. For example, f(321) = 123, f(120) = 21, f(1000000) = 1, f(111) = 111.
Let's de... | ```python
from sys import stdout,stdin,maxsize
from collections import defaultdict,deque
import math
t=int(stdin.readline())
for _ in range(t):
#n=int(stdin.readline())
#d=map(int,stdin.readline().split())
#l=list(map(int,stdin.readline().split()))
s=input()
print(len(s))
... | vfc_38057 | {
"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\n4\n37\n998244353\n1000000007\n12345678901337426966631415\n",
"output": "\n1\n2\n9\n10\n26\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10000000\n",
"output": "8\n",
"t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.