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
make-the-word
Solve the following coding problem using the programming language python: One day alice and bob were playing with their old toys , they had moved all the rakes and drawers to in the pursuit of their childhood toys. Finally they found bunch of cubes ,with letters and digits written on it ,which they recalled they use...
```python a,b=map(str,raw_input().split()) fnd=[] f=0 for i in range(int(b)): l=list(map(str,raw_input().split())) for i in range(len(a)): if i not in fnd: if a[i] in l: fnd.append(i) break if len(fnd)==len(a): f=1 break if(f): print 'Y...
vfc_53641
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "egos 4\nd 1 w e 7 9\no 2 h a v e\ng 3 c o o k\ns 3 i e s 5\n\nSAMPLE", "output": "YES", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
non-fibo
Solve the following coding problem using the programming language python: Seeing the fame received by the Fibonacci numbers, the other Natural Numbers were feeling jealous. Therefore, to give them their shot at glory Mr. Non-Fibo now wants you to tell him the N^th- Non Fibonacci Number. Input: First line contains T wh...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name print 'Hello World!''' T = int(raw_input()) while T>0: T-=1 N = int(raw_input()) a = 1 b = 1 while N>0: c = a + b N -= c-b-1 a = b b = c print c+N-1 ```
vfc_53645
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n2\n3\n\nSAMPLE", "output": "4\n6\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2\n2\n3\n\nSAMPLE", "output": "6\n6\n7\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
quantum-and-divisibility-2
Solve the following coding problem using the programming language python: Quantum love solving mathematical problems. One day his teacher give him problem on divisibility to check his mathematical skills. He give him four numbers a,b,c,d and asked him to check whether (a^b) is divisible by (c^d) or not. As the constra...
```python P=[1]*100001 p=[] for i in range(2,100001): if P[i]: p.append(i) for j in range(i<<1,100001,i): P[j]=0 for t in range(input()): a,b,c,d=map(int,raw_input().split()) ap=[] ae=[] cp=[] ce=[] if d==0: print "Divisible" continue for x in p: if a%x==0: cnt=0 while a%x==0: a/=x ...
vfc_53649
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 6 2 4\n\nSAMPLE", "output": "Divisible", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n4 6 1 4\n\nSAMPLE", "output": "Divisible\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
shil-and-palindrome
Solve the following coding problem using the programming language python: Shil is your new boss and he likes palindromes very much. Palindrome is a string that can be read the same way in either direction, from the left to the right and from the right to the left. (ex. madam , aabaa, racecar) Given a string S , be...
```python s = raw_input() alphabet = [chr(i + ord('a')) for i in xrange(26)] f = dict(zip(alphabet, [0]*26)) for c in s: f[c] += 1 output = '' for c in alphabet: while f[c] > 1: output += c f[c] -= 2 mid = [] for k, v in f.iteritems(): if v == 1: mid.append(k) if len(mid) > 1: print ...
vfc_53653
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "aabcc\n\nSAMPLE", "output": "acbca\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "yvqszlrqoxkfaupflahrnwygzetlwynhxalauuzhaaeoxzkyroertpxdwxlngzfoxregqxqhgmoklururjaetlwwnsggpyarhrxwgfaqh...
code_contests
verifiable_code
the-lord-of-the-strings-1
Solve the following coding problem using the programming language python: Given a word consisting of lowercase English letters, write a program to remove duplicates from the word. The characters in the output must preserve the same order, as their first appearance in the original word. Input Format The input consist...
```python t=input() for x in range(t): s=raw_input() str='' for i in s: if i not in str: str+=i print str ```
vfc_53657
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nbananasqr\naaaaa\nabcde\nayacazkeafagahbcbdbebfbg\nqweer", "output": "bansqr\na\nabcde\nayczkefghbd\nqwer\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nbananasqr\naaaaa\ndbcae\naya...
code_contests
verifiable_code
zeros-in-factorial
Solve the following coding problem using the programming language python: Ram was busy calclutaing the factorials of some numbers. He saw a pattern in the number of zeros in the end of the factorial. Let n be the number and Z(n) be the number of zeros in the end of the factorial of n then for x < y Z (x) ≤ Z(y) i.e...
```python def sum_to(n): return n * (n-1) / 2 def count_zeros(lo, hi): S = 0 for pow5 in (5**i for i in xrange(1,9)): #print pow5 S += pow5 * (sum_to(hi//pow5) - sum_to(lo//pow5)) #print S S += (hi % pow5 + 1) * (hi // pow5) - (lo % pow5) * (lo // pow5) #print S r...
vfc_53661
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 5\n\nSAMPLE", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00217 Walking in the Hospital
Solve the following coding problem using the programming language python: At Aizu Riverside Hospital, inpatients walk twice a day for rehabilitation and health promotion. As the number of people trying to recover their physical strength by walking is increasing day by day in order to leave the hospital energetically, ...
```python while True: n = int(input()) if n == 0: break ls = [] for i in range(n): v = list(map(int,input().split())) ls.append((sum(v[1:]),v[0])) ls.sort() ls.reverse() print(ls[0][1],ls[0][0]) ```
vfc_53709
{ "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\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0", "output": "5000 5633\n345 7396", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
p00595 Greatest Common Divisor
Solve the following coding problem using the programming language python: Please find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task. Input The input file consists of several lines with pairs of two natural numbers in each line. The numbers do no...
```python import sys def gcd(a,b): if(b): return gcd(b,(a%b)) else: return a List = [] for i in sys.stdin: List.append(i) for data in List: print(gcd(int(data.split()[0]),int(data.split()[1]))) ```
vfc_53717
{ "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": "57 38\n60 84", "output": "19\n12", "type": "stdin_stdout" }, { "fn_name": null, "input": "57 38\n19 84", "output": "19\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00731 Cliff Climbing
Solve the following coding problem using the programming language python: At 17:00, special agent Jack starts to escape from the enemy camp. There is a cliff in between the camp and the nearest safety zone. Jack has to climb the almost vertical cliff by stepping his feet on the blocks that cover the cliff. The cliff h...
```python import sys import math import bisect import heapq import copy sys.setrecursionlimit(1000000) from collections import deque from itertools import permutations def main(): dy = [-2,-1,0,1,2,-1,0,1,0] rx = [1,1,1,1,1,2,2,2,3] lx = [-1,-1,-1,-1,-1,-2,-2,-2,-3] inf = 1000000007 while True: ...
vfc_53721
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 6\n4 4 X X T T\n4 7 8 2 X 7\n3 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X ...
code_contests
verifiable_code
p00871 Top Spinning
Solve the following coding problem using the programming language python: Spinning tops are one of the most popular and the most traditional toys. Not only spinning them, but also making one’s own is a popular enjoyment. One of the easiest way to make a top is to cut out a certain shape from a cardboard and pierce an...
vfc_53725
{ "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": "start 0 0\narc 2 2 -2\nline 2 5\narc 0 3 -2\nclose\nstart -1 1\nline 2 1\nline 2 2\nline -2 2\narc -3 1 -1\nline -3 -2\narc -2 -3 -1\nline 2 -3\nline 2 -2\nline -1 -2\nline -1 -1\narc -1 0 2\nclose\nstart 0 0\nline 3 0\nline 5 -1\n...
code_contests
verifiable_code
p01134 Area Separation
Solve the following coding problem using the programming language python: Mr. Yamada Springfield Tanaka was appointed as Deputy Deputy Director of the National Land Readjustment Business Bureau. Currently, his country is in the midst of a major land readjustment, and if this land readjustment can be completed smoothly...
```python import math EPS = 1e-10 def eq(a, b): return (abs(a-b) < EPS) def eqv(a, b): return (eq(a.real, b.real) and eq(a.imag, b.imag)) def cross(a, b): return a.real * b.imag - a.imag * b.real def is_intersected_ls(a1, a2, b1, b2): return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) and \ ...
vfc_53733
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n-100 -20 100 20\n-20 -100 20 100\n2\n-100 -20 -20 -100\n20 100 100 20\n0", "output": "4\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n-100 -20 100 20\n-20 -100 18 100\n2\n-100 -20...
code_contests
verifiable_code
p01273 Infected Computer
Solve the following coding problem using the programming language python: Adam Ivan is working as a system administrator at Soy Group, Inc. He is now facing at a big trouble: a number of computers under his management have been infected by a computer virus. Unfortunately, anti-virus system in his company failed to det...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split...
vfc_53737
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 1 2\n2 2 3\n3 2\n2 3 2\n1 2 1\n0 0", "output": "3\n1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01443 Number Sorting
Solve the following coding problem using the programming language python: Consider sets of natural numbers. Some sets can be sorted in the same order numerically and lexicographically. {2, 27, 3125, 9000} is one example of such sets; {2, 27, 243} is not since lexicographic sorting would yield {2, 243, 27}. Your task ...
vfc_53741
{ "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": "1 10 1000\n1 100000 1000000000\n999999999 1000099998 1000000000\n0 0 0", "output": "513\n899507743\n941554688", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 10 1000\n1 100000 1000000000\n...
code_contests
verifiable_code
p01592 Blame Game
Solve the following coding problem using the programming language python: Problem B: Blame Game Alice and Bob are in a factional dispute. Recently a big serious problem arised in a project both Alice and Bob had been working for. This problem was caused by lots of faults of Alice's and Bob's sides; those faults are c...
vfc_53745
{ "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": "1 1\n1 1", "output": "Bob", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n3 1 2 3\n1 3\n1 3", "output": "Alice", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01749 Substring Pairs
Solve the following coding problem using the programming language python: Sunuke came up with a pun called "s de t t", but forgot it. Sunuke remembers the following. * The length of s is N. * The length of t is M. * t is a substring of s. (There is a part of consecutive M characters of s that matches t.) Divide th...
vfc_53749
{ "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 2 2", "output": "14", "type": "stdin_stdout" }, { "fn_name": null, "input": "200 50 1000", "output": "678200960", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01889 Compressed Formula
Solve the following coding problem using the programming language python: Example Input 1 5 1 Output 11111 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_53753
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 1", "output": "11111", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5 0", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n...
code_contests
verifiable_code
p02026 Demon's Cedar
Solve the following coding problem using the programming language python: L: Sugi (Demon's Cedar) Tsukinose decided to change the trees all over the city to sugi trees and annoy people with hay fever in order to do something devilish. There are $ N $ types of trees. The heavenly rank of the $ i $ tree is $ A_i $, an...
vfc_53757
{ "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\n1 2 5\n6 3 4", "output": "0\n1\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 2 5\n6 3 4", "output": "0\n2\n2\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
cc1
Solve the following coding problem using the programming language python: Problem description. Chris brown and Rihanna are in a nxn grid(1 indexed). Chris brown want to reach Rihanna in minimum number of moves but the thing is he can move only diagonally and whatever may be the number of steps he takes it is considere...
```python t=int(input()) for i in range(t): n=int(input()) [a,b,c,d]=map(int,raw_input().split()) if a==c and b==d: ans=0 elif (a+b)%2 == (c+d)%2: ac=max(a,c)-min(a,c) bd=max(b,d)-min(b,d) if (a+b)==(c+d) or ac==bd: ans=1 else: ans=2 el...
vfc_53773
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n1 1 3 3 \n4\n1 1 1 3", "output": "1\n2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
csixierl
Solve the following coding problem using the programming language python: Given a string, count the number of aplhabets which are repeated   Input The first line contains a single integer T <= 40, the number of test cases. T test cases follow. The only line of each test case contains a non-empty text composed only of...
```python n=input() for i in range(n): string1=raw_input().lower() count=0 for y in range (97,122): if string1.count(chr(y))>1: count+=1 print count ```
vfc_53777
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naalmlc\naPlmFl\nXcCnLb", "output": "2\n1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\naalmlc\naPlmFl\nXdCnLb", "output": "2\n1\n0\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
hes
Solve the following coding problem using the programming language python: Ananya, is a class 12 student and is preparing for IIT-JEE examination to be held later this year out of the 3 subjects asked in IIT JEE , physics, chemistry and mathematics she only likes mathematics and is a virtuoso in mathematics seeing her...
```python import sys T = int(raw_input()) while T : n , p = map(int,sys.stdin.readline().split()) x = pow(n,p) res = x sum = 0 while res : sum = sum + (res%10) res/=10 print x , sum T-=1 def pow(n,p) : if p == 0 : return 1 else : if p%2 : return n*pow(n,p-1) else : k = pow(...
vfc_53781
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 4\n3 4\n9 3", "output": "16 7\n81 9\n729 18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 4\n3 4\n12 3", "output": "16 7\n81 9\n1728 18\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
misterm
Solve the following coding problem using the programming language python: Chef is array maniac.He use to play with arrays.Chef's friend given him an array of size n-1 integers and these integers are in the range of 1 to n. There are no duplicates in array. One of the integers is missing in the array.Now chef has to wr...
```python n=input() for i in range(n): a=input() f=map(int,raw_input().split()) for i in range(1,a+1): if i not in f: print i ```
vfc_53785
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n9\n8 9 3 2 4 5 7 6 \n5\n3 1 2 4", "output": "1\n5", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n9\n8 9 3 2 4 5 7 6 \n2\n3 1 2 4", "output": "1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
ren2013k
Solve the following coding problem using the programming language python: You are provided with a set of numbers which is infinitely large. The numbers in this set are of the form :- { 2^2^n + 1 } where n is a positive integer. Now these set of numbers are kept in sorted order. Now queries are defined on this set suc...
```python t = input() while t: t-=1 x,y = [int(x) for x in raw_input().split()] print( ( (y - x + 1) * (y - x) ) / 2 ) ```
vfc_53789
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1 3", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
tsort
Solve the following coding problem using the programming language python: Given the list of numbers, you are to sort them in non decreasing order. Input t – the number of numbers in list, then t lines follow [t <= 10^6]. Each line contains one integer: N [0 <= N <= 10^6] Output Output given numbers in non decreas...
```python x=int(raw_input()) a=[] for z in range(x): a.append(int(raw_input())) a.sort() for z in a: print z ```
vfc_53793
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5\n3\n6\n7\n1", "output": "1\n3\n5\n6\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5\n3\n3\n7\n1", "output": "1\n3\n3\n5\n7\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1017_B. The Bits
Solve the following coding problem using the programming language python: Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question: Given two binary numbers a and b of length n. How many different ways of swapping two digits in a (only in a, not b) so that bitwise OR...
```python n = int(input()) a = input() b = input() index = [] zeros = 0 ones = 0 for i in range(n): if b[i]=='0': index.append(i) if a[i]=='0': zeros += 1 else: ones += 1 ans = 0 interchange = 0 for i in index: if a[i]=='0': ans += ones zeros -= 1 else: ...
vfc_53797
{ "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": "6\n011000\n010011\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n01011\n11001\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
1040_D. Subway Pursuit
Solve the following coding problem using the programming language python: This is an interactive problem. In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the predictio...
```python import sys import random random.seed() n, k = [int(x) for x in input().split()] sson = 8*k + 1 ssoff = 4*k + 1 l = 1 r = n ss = True if r-l > sson else False while True: if ss: al = l ar = (l + r) // 2 print(al, ar) sys.stdout.flush() ans = input() if ...
vfc_53801
{ "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": "10 2\n\nYes\n\nNo\n\nYes\n\nYes\n", "output": "2 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n\nYes\n\nNo\n\nYer\n\nYes\n", "output": "1 1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
1063_D. Candies for Children
Solve the following coding problem using the programming language python: At the children's festival, children were dancing in a circle. When music stopped playing, the children were still standing in a circle. Then Lena remembered, that her parents gave her a candy box with exactly k candies "Wilky May". Lena is not ...
vfc_53805
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 4 12\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 5 5 1\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
1085_C. Connect Three
Solve the following coding problem using the programming language python: The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner. Three friends, Alic...
```python koor = dict() a = input() xa = int(a.split()[0]) ya = int(a.split()[1]) b = input() xb = int(b.split()[0]) yb = int(b.split()[1]) c = input() xc = int(c.split()[0]) yc = int(c.split()[1]) koor[ya] = xa koor[yb] = xb koor[yc] = xc print(max(xa, xb, xc) + max(ya, yb, yc) - min(xa, xb, xc) - min(ya, yb, yc) +...
vfc_53809
{ "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": "0 0\n1 1\n2 2\n", "output": "5\n0 0\n1 0\n1 1\n1 2\n2 2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1105_A. Salem and Sticks
Solve the following coding problem using the programming language python: Salem gave you n sticks with integer positive lengths a_1, a_2, …, a_n. For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from a to b ...
```python n = int(input()) a = [int(t) for t in input().split(' ')] mincost = 1000 * 100 + 1 best_t = None for t in range(1, 101): cost = 0 for x in a: cost += max(0, abs(x - t) - 1) if cost < mincost: mincost = cost best_t = t print(best_t, mincost) ```
vfc_53813
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10 1 4\n", "output": "3 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 2 2 3\n", "output": "2 0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1132_D. Stressful Training
Solve the following coding problem using the programming language python: Berland SU holds yet another training contest for its students today. n students came, each of them brought his laptop. However, it turned out that everyone has forgot their chargers! Let students be numbered from 1 to n. Laptop of the i-th stu...
```python import sys import os from math import trunc s = os.read(0,os.fstat(0).st_size) inp = [] sign = 1.0 numb = 0.0 for i in range(len(s)): if s[i]>=48: numb = 10.0*numb + s[i]-48.0 else: if s[i]==45: sign = -1.0 elif s[i]!=13: inp.append(sign*numb) ...
vfc_53817
{ "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": "2 4\n3 2\n4 2\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 6\n4\n2\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1152_F2. Neko Rules the Catniverse (Large Version)
Solve the following coding problem using the programming language python: This problem is same as the previous one, but has larger constraints. Aki is playing a new video game. In the video game, he will control Neko, the giant cat, to fly between planets in the Catniverse. There are n planets in the Catniverse, num...
vfc_53821
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100 1 2\n", "output": "100", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1174_E. Ehab and the Expected GCD Problem
Solve the following coding problem using the programming language python: Let's define a function f(p) on a permutation p as follows. Let g_i be the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of elements p_1, p_2, ..., p_i (in other words, it is the GCD of the prefix of leng...
```python p=10**9+7 import math def r(l): x=1 for m in l: x=x*m%p return x n=int(input()) a,k,x,t=[],int(math.log2(n)),n,0 while x>0: a.append(x-x//2) x//=2 b=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)] d=[n//2**i-n//(3*2**i) for i in range(k+1)] y=r([i for i in range(2,n+1)]) s=k if n<3*2...
vfc_53825
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", ...
code_contests
verifiable_code
1193_A. Amusement Park
Solve the following coding problem using the programming language python: You have been hired to supervise the project of a new amusement park. The park will have a special gimmick: directed slides that can get customers from one attraction to another quickly and in an entertaining way. The park owner has given you t...
vfc_53829
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n1 2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2\n2 3\n1 3\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1231_A. Dawid and Bags of Candies
Solve the following coding problem using the programming language python: Dawid has four bags of candies. The i-th of them contains a_i candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amoun...
```python a1, a2, a3, a4 = map(int, input().split()) n = sum([a1, a2, a3, a4]) if n % 2 != 0: print('NO') else: if (a1 + a3 == a2 + a4 or a1 + a4 == a2 + a3 or a1 + a2 == a3 + a4): print('YES') elif (a1 - (n - a1) == 0 or a2 - (n - a2) == 0 or a3 - (n - a3) == 0 ...
vfc_53837
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 3 2 5\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 7 11 5\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1252_D. Find String in a Grid
Solve the following coding problem using the programming language python: You have a grid G containing R rows (numbered from 1 to R, top to bottom) and C columns (numbered from 1 to C, left to right) of uppercase characters. The character in the r^{th} row and the c^{th} column is denoted by G_{r, c}. You also have Q ...
vfc_53841
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 5\nABC\nBCD\nDAB\nABC\nBC\nBD\nAC\nA\n", "output": "\n2\n3\n1\n0\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 3\nAAA\nAAA\nA\nAAA\nAAAAA\n", "output": "\n6\n4\n0\n", ...
code_contests
verifiable_code
1272_C. Yet Another Broken Keyboard
Solve the following coding problem using the programming language python: Recently, Norge found a string s = s_1 s_2 … s_n consisting of n lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string s. Yes, all (n (n + 1))/(2) of them! A substring of s is a non...
```python n, k = [int(i) for i in input().split()] s = input() arr = input().split() subs = [0] for x in s: if(x in arr): subs[-1] += 1 else: subs.append(0) count = 0 for x in subs: count += x*(x+1)/2 print(int(count)) ```
vfc_53845
{ "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": "7 2\nabacaba\na b\n", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 3\nsadfaasdda\nf a d\n", "output": "21\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
1337_F. Yui and Mahjong Set
Solve the following coding problem using the programming language python: This is an interactive problem. Yui is a girl who enjoys playing Mahjong. <image> She has a mysterious set which consists of tiles (this set can be empty). Each tile has an integer value between 1 and n, and at most n tiles in the set have th...
vfc_53857
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 6\n2 9\n5 12\n5 24\n6 24\n", "output": "+ 1\n+ 2\n+ 3\n+ 4\n+ 1\n! 0 3 1 2 -4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "71\n1 0 0 4 0 7 2 1 1 1 1 0 15 0 1 7 0 9 1 19 4 0 0 1 18...
code_contests
verifiable_code
135_D. Cycle
Solve the following coding problem using the programming language python: Little Petya very much likes rectangular tables that consist of characters "0" and "1". Recently he has received one such table as a gift from his mother. The table contained n rows and m columns. The rows are numbered from top to bottom from 1 ...
vfc_53861
{ "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": "7 7\n1111111\n1000101\n1000101\n1000101\n1000111\n1000001\n1111111\n", "output": "24\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
137_E. Last Chance
Solve the following coding problem using the programming language python: Having read half of the book called "Storm and Calm" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw Innocentius reading fiction books instead o...
```python s=[(0,0)] c=0 for i,x in enumerate(input()) : c+=-1 if x.lower() in 'aeiou' else 2 s.append((c,i+1)) #print(s) lis = sorted(s) #print(lis) u = 10**9 d = {} answer = 0 for i in lis : if u < i[1] : if i[1]-u >= answer : answer = i[1]-u d[answer] = d.get(answer , 0) + 1 ...
vfc_53865
{ "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": "OEIS\n", "output": "3 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "EA\n", "output": "No solution\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
13_E. Holes
Solve the following coding problem using the programming language python: Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules: There are N holes located in a single row and numbered from left to right with numbers from 1 to N. Each hole has...
vfc_53869
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 5\n1 1 1 1 1 2 8 2\n1 1\n0 1 3\n1 1\n0 3 4\n1 2\n", "output": "8 7\n8 5\n7 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10\n5 1 2 4 1 7 3 8 10 8\n0 5 6\n1 8\n1 1\n0 10 3\n1 5\n1 ...
code_contests
verifiable_code
1444_A. Division
Solve the following coding problem using the programming language python: Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division. To improve his division skills, Oleg came up with t pairs of integers p_i and q_i and for each pair decided to find the greatest integer x_i, suc...
```python from sys import stdin, stdout from math import sqrt #stdin = open('Q3.txt', 'r') def II(): return int(stdin.readline()) def MI(): return map(int, stdin.readline().split()) bigp=10**18+7 primes=[] def SieveOfEratosthenes(n,primes): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): ...
vfc_53877
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10 4\n12 6\n179 822\n", "output": "10\n4\n179\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n42034266112 80174\n", "output": "1048576\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
1469_B. Red and Blue
Solve the following coding problem using the programming language python: Monocarp had a sequence a consisting of n + m integers a_1, a_2, ..., a_{n + m}. He painted the elements into two colors, red and blue; n elements were painted red, all other m elements were painted blue. After painting the elements, he has wri...
```python for _ in range(int(input())): n=int(input()) r=list(map(int,input().split())) m=int(input()) b=list(map(int,input().split())) c,t,prev,prevv=0,0,0,0 for i in r: t+=i prev=max(t,prev) t=0 for i in b: t+=i prevv=max(t,prevv) if prev <...
vfc_53881
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n6 -5 7 -3\n3\n2 3 -4\n2\n1 1\n4\n10 -3 2 2\n5\n-1 -2 -3 -4 -5\n5\n-1 -2 -3 -4 -5\n1\n0\n1\n0\n", "output": "\n13\n13\n0\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n4\n6 -5 ...
code_contests
verifiable_code
1494_D. Dogeforces
Solve the following coding problem using the programming language python: The Dogeforces company has k employees. Each employee, except for lower-level employees, has at least 2 subordinates. Lower-level employees have no subordinates. Each employee, except for the head of the company, has exactly one direct superviso...
```python import heapq class UF: def __init__(self, N): self.par = list(range(N)) self.sz = [1] * N def find(self, x): if self.par[x] != x: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): xr, yr = self.find(x), self.find(y)...
vfc_53885
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 5 7\n5 1 7\n7 7 4\n", "output": "\n5\n2 1 4 7 5 \n4\n1 5\n2 5\n5 4\n3 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n97 99 100 99\n99 98 100 99\n100 100 99 100\n99 99 100 98\n",...
code_contests
verifiable_code
1517_C. Fillomino 2
Solve the following coding problem using the programming language python: Fillomino is a classic logic puzzle. (You do not need to know Fillomino in order to solve this problem.) In one classroom in Yunqi town, some volunteers are playing a board game variant of it: Consider an n by n chessboard. Its rows are numbere...
```python import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.wri...
vfc_53889
{ "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\n2 3 1\n", "output": "\n2\n2 3\n3 3 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "\n1\n2 2\n3 3 3\n4 4 4 4\n5 5 5 5 5\n", "type": "stdin_stdou...
code_contests
verifiable_code
172_A. Phone Code
Solve the following coding problem using the programming language python: Polycarpus has n friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings s1, s2, ..., sn. All these strings consist only of digits and have the same length. Once Polycarpus needed to figure out Tarasov city...
```python n = int(input()) phone = [] for i in range(n): s = input().strip() phone.append(s) c = 0 k = 0 flag = True while True: for p in phone: if p[k] != phone[0][k]: flag = False break k += 1 if flag: c += 1 else: print(c) break ```
vfc_53897
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n00209\n00219\n00999\n00909\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n2\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
192_B. Walking in the Rain
Solve the following coding problem using the programming language python: In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and t...
```python n=int(input()) l=list(map(int,input().split())) c=9999 for i in range(n-1): if(l[i]<=l[i+1] and l[i+1]<c): c=l[i+1] elif(l[i]>l[i+1] and l[i]<c): c=l[i] print(min(l[0],l[n-1],c)) ```
vfc_53901
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n10 2 8 3 5\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n10 3 5 10\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
216_B. Forming Teams
Solve the following coding problem using the programming language python: One day n students come to the stadium. They want to play football, and for that they need to split into teams, the teams must have an equal number of people. We know that this group of people has archenemies. Each student has at most two arche...
```python def arr_inp(): return [int(x) for x in stdin.readline().split()] class graph: # initialize graph def __init__(self, gdict=None): if gdict is None: gdict = defaultdict(list) self.gdict = gdict # get edges def edges(self): return self.find_edges() ...
vfc_53905
{ "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": "6 2\n1 4\n3 4\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n1 2\n2 4\n5 3\n1 4\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
23_B. Party
Solve the following coding problem using the programming language python: n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by t...
```python for i in range(int(input())): x = int(input()) print(max(0,x-2)) ```
vfc_53909
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n4\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2\...
code_contests
verifiable_code
264_E. Roadside Trees
Solve the following coding problem using the programming language python: Squirrel Liss loves nuts. Liss asks you to plant some nut trees. There are n positions (numbered 1 to n from west to east) to plant a tree along a street. Trees grow one meter per month. At the beginning of each month you should process one que...
vfc_53913
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 6\n1 1 1\n1 4 4\n1 3 4\n2 2\n1 2 8\n2 3\n", "output": "1\n2\n3\n2\n2\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 20\n1 2 1\n1 1 3\n1 7 7\n2 3\n1 5 7\n1 4 5\n1 3 1\n2 1\n2 2\n1 ...
code_contests
verifiable_code
288_E. Polo the Penguin and Lucky Numbers
Solve the following coding problem using the programming language python: Everybody knows that lucky numbers are positive integers that contain only lucky digits 4 and 7 in their decimal representation. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Polo the Penguin have two positive integers l and...
vfc_53917
{ "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": "474\n777\n", "output": "2316330\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
313_E. Ilya and Two Numbers
Solve the following coding problem using the programming language python: Ilya has recently taken up archaeology. He's recently found two numbers, written in the m-based notation. Each of the found numbers consisted of exactly n digits. Ilya immediately started looking for information about those numbers. He learned t...
vfc_53921
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n2 4 4 1 3\n1 0 1 2 4\n", "output": "4 4 4 3 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 7\n5 4 3 2\n5 6 5 4\n", "output": "6 4 2 1\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
359_C. Prime Number
Solve the following coding problem using the programming language python: Simon has a prime number x and an array of non-negative integers a1, a2, ..., an. Simon loves fractions very much. Today he wrote out number <image> on a piece of paper. After Simon led all fractions to a common denominator and summed them up, ...
```python import sys import heapq input = sys.stdin.readline MOD = int(1e9+7) n, x = list(map(int, input().split())) a = list(map(int, input().split())) s, h = sum(a), [] for i in a: heapq.heappush(h, s-i) p, cnt = 0, 0 while h: z = heapq.heappop(h) if p == z: cnt += 1 if cnt == x: ...
vfc_53929
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2 3\n", "output": "27\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n0 0 0 0\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
382_B. Number Busters
Solve the following coding problem using the programming language python: Arthur and Alexander are number busters. Today they've got a competition. Arthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approaches to number bustings. Ale...
```python a, b, w, x, c = map(int, input().split()) def result(a, b, w, x, c, s): na = a - (s * x - b) / w nc = c - s return (na, nc) def solve(a, b, w, x, c): left = 0 right = 10e15 if (c <= a): return 0 while (left < right): half = (left+right) // 2 ret = result(a, b, w, x, c, half) if (ret[1] <= re...
vfc_53933
{ "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": "4 2 3 1 7\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 2 1 1\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
430_B. Balls Game
Solve the following coding problem using the programming language python: Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game? There are n balls put in a row. Each ball is colored in one of k colors. Initially the row doesn't contain three or more contiguous balls with the same...
```python def destroy_balls(_a, _b, _x): if len(_a) == 0 or len(_b) == 0: return 0 lenb = len(_b) a_cur_index = len(_a) - 1 b_cur_index = 0 if _a[a_cur_index] == _b[b_cur_index]: to_be_destroyed = 2 a_cur_index -= 1 b_cur_index += 1 while a_cur_index >= 0: ...
vfc_53941
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1\n1\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2 2\n1 1 2 2 1 1\n", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
452_E. Three strings
Solve the following coding problem using the programming language python: You are given three strings (s1, s2, s3). For each integer l (1 ≤ l ≤ min(|s1|, |s2|, |s3|) you need to find how many triples (i1, i2, i3) exist such that three strings sk[ik... ik + l - 1] (k = 1, 2, 3) are pairwise equal. Print all found numbe...
```python MOD = 1000000007 oo = int(2e9) class Node: def __init__(self, p, l = oo): self.spos = p self.slink = 0 self.length = l self.next_node = [0 for _ in range(28)] #Ukkonen class SuffixTree: def __init__(self, s): self.nodes = [Node(0)] self.s = [] ...
vfc_53945
{ "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": "abc\nbc\ncbc\n", "output": "3 1 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
475_C. Kamal-ol-molk's Painting
Solve the following coding problem using the programming language python: Rumors say that one of Kamal-ol-molk's paintings has been altered. A rectangular brush has been moved right and down on the painting. Consider the painting as a n × m rectangular grid. At the beginning an x × y rectangular brush is placed somew...
vfc_53949
{ "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 5\nXXXX.\nXXXX.\n.XX..\n.XX..\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\nXX..\nXX..\nXXXX\nXXXX\n", "output": "4\n", "type": "stdin_stdout" },...
code_contests
verifiable_code
522_D. Closest Equals
Solve the following coding problem using the programming language python: You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print the minimum distance between such pair of elements ax and ay (x ≠ y), that: * both indexes of the elements lie within range [lj, r...
```python import sys class Fenwick(object): def __init__(self, n): self.n = n self.a = [10**9 for i in range(n)] self.w= 10**9 def zag(self, i, zn): self.w= min(self.w, zn) while i < self.n: self.a[i] = min(self.a[i], zn) i = (i | (i + 1)) def pol(self, r): ans= 10**9 wh...
vfc_53957
{ "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": "5 3\n1 1 2 3 2\n1 5\n2 4\n3 5\n", "output": "1\n-1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 5\n1 2 1 3 2 3\n4 6\n1 3\n2 5\n2 4\n1 6\n", "output": "2\n2\n3\n-1\n2\n", ...
code_contests
verifiable_code
549_F. Yura and Developers
Solve the following coding problem using the programming language python: Yura has a team of k developers and a list of n tasks numbered from 1 to n. Yura is going to choose some tasks to be done this week. Due to strange Looksery habits the numbers of chosen tasks should be a segment of consecutive integers containin...
vfc_53961
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n1 2 3 4\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n4 4 7 4\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
575_H. Bots
Solve the following coding problem using the programming language python: Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based...
```python # https://codeforces.com/problemset/problem/575/H import sys import math MOD = 1000000007 def inv(a, b): if(a > 1): return b-inv(b % a, a)*b//a else: return 1 def main(): # sys.stdin = open('E:\\Sublime\\in.txt', 'r') # sys.stdout = open('E:\\Sublime\\out.txt', 'w') #...
vfc_53965
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "19\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "69\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", ...
code_contests
verifiable_code
598_C. Nearest vectors
Solve the following coding problem using the programming language python: You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and...
```python from functools import cmp_to_key n = int(input()) def dot(p1,p2): x1,y1 = p1 x2,y2 = p2 return x1 * x2 + y1 * y2 def cross(p1,p2): x1,y1 = p1 x2,y2 = p2 return x1 * y2 - x2 * y1 def top(p): x,y = p return y > 0 or (y == 0 and x > 0) def polarCmp(p1,p2): res = False...
vfc_53969
{ "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\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6\n", "output": "5 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n-1 0\n0 -1\n1 0\n1 1\n", "output": "3 4\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
61_A. Ultra-Fast Mathematician
Solve the following coding problem using the programming language python: Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second. ...
```python a = input() b = input() res = [] for i in range(len(a)): if(a[i] != b[i]): res.append('1') else: res.append('0') print(''.join(res)) ```
vfc_53973
{ "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": "1010100\n0100101\n", "output": "1110001\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "000\n111\n", "output": "111\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
667_C. Reberland Linguistics
Solve the following coding problem using the programming language python: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, whic...
```python s = input()[5:][::-1] n = len(s) mu = set() can2 = [0]*(n+1) can3 = [0]*(n+1) if n >= 2: mu.add(s[0:2][::-1]) can2[2] = 1 if n >= 3: mu.add(s[0:3][::-1]) can3[3] = 1 if n >= 4 and s[0:2] != s[2:4]: mu.add(s[2:4][::-1]) can2[4] = 1 if n >= 5: mu.add(s[2:5][::-1]) mu.add(s[3:5]...
vfc_53981
{ "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": "abacabaca\n", "output": "3\naca\nba\nca\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abaca\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
713_E. Sonya Partymaker
Solve the following coding problem using the programming language python: Owl Sonya decided to become a partymaker. To train for this role she gather all her owl friends in the country house. There are m chairs located in a circle and consequently numbered with integers from 1 to m. Thus, chairs i and i + 1 are neighb...
vfc_53989
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n2\n1 6\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n3\n1 3 5\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
734_C. Anton and Making Potions
Solve the following coding problem using the programming language python: Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a special kettle, that can prepare one potions in x seconds. Also, he knows spells of ...
```python """ ref: http://codeforces.com/blog/entry/48397 At first, observe that if we'll take the i-th potion of the first type and the j-th potion of the second type, then we can prepare all the potions in ai*(n-cj) seconds. So, we have to minimize this number. Let's iterate over what potion of the first type we'll ...
vfc_53993
{ "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": "20 3 2\n10 99\n2 4 3\n20 10 40\n4 15\n10 80\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20 3 2\n10 99\n2 4 3\n200 100 400\n4 15\n100 800\n", "output": "200\n", ...
code_contests
verifiable_code
758_C. Unfair Poll
Solve the following coding problem using the programming language python: On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seating in the class looks like a rectangle, where n rows with m pupils in each. The teacher asks pupils in the followin...
```python import math import sys def printf(*a): if len(sys.argv) > 1: print(a) n, m, k, x, y = map(int, input().split()) mi = 0 ma = 0 serg = 0 filed_lines = k//m partial_line = k%m printf(filed_lines, partial_line) if n==1: mi = filed_lines ma = filed_lines if partial_line > 0: ma += 1 if y <= ...
vfc_53997
{ "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": "100 100 1000000000000000000 100 100\n", "output": "101010101010101 50505050505051 50505050505051\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
77_A. Heroes
Solve the following coding problem using the programming language python: The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave...
```python from itertools import product, permutations, combinations n = int(input()) names = {} nex = 0 mama = 128 liking = [0]*mama likes = [[0]*7 for _ in range(7)] def getName(name): global nex if name in names: return names[name] names[name] = nex nex += 1 return names[name] for _ in...
vfc_54001
{ "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\nAnka likes Chapay\nChapay likes Anka\n10000 50 50\n", "output": "1950 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nTroll likes Dracul\nDracul likes Anka\nSnowy likes Hexadecimal...
code_contests
verifiable_code
802_O. April Fools' Problem (hard)
Solve the following coding problem using the programming language python: The plans for HC2 are rather far-fetched: we are just over 500 000 days away from HC2 3387, for example, and accordingly we are planning to have a couple hundred thousand problems in that edition (we hope that programming contests will become wi...
vfc_54005
{ "difficulty": "22", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 10, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 4\n3 8 7 9 9 4 6 8\n2 5 9 4 3 8 9 1\n", "output": " 32\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12 1\n49 49 4 16 79 20...
code_contests
verifiable_code
871_A. Maximum splitting
Solve the following coding problem using the programming language python: You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such split...
```python t = int(input()) for i in range(t): n = int(input()) if n in [1, 2, 3, 5, 7, 11]: print(-1) else: print((n // 4) - (n % 2)) ```
vfc_54017
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n2\n3\n", "output": "-1\n-1\n-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
898_A. Rounding
Solve the following coding problem using the programming language python: Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded. For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to ...
```python n=int(input()) if(n%10==0): print(n) elif(n%10>5): print(n+(10-(n%10))) else: print(n-(n%10)) ```
vfc_54021
{ "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", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5432359\n", "output": "5432360\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
946_A. Partition
Solve the following coding problem using the programming language python: You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences. Let B be the sum of elements belonging to b, and C be t...
```python n = int(input()) a = list(map(int, input().split())) res = 0 for i in range(n): if a[i] > 0: res += a[i] else: res -= a[i] print(res) ```
vfc_54029
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 -2 0\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n16 23 16 15 42 8\n", "output": "120\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
96_D. Volleyball
Solve the following coding problem using the programming language python: Petya loves volleyball very much. One day he was running late for a volleyball match. Petya hasn't bought his own car yet, that's why he had to take a taxi. The city has n junctions, some of which are connected by two-way roads. The length of ea...
```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_54033
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n1 3\n1 2 3\n1 4 1\n2 4 1\n2 3 5\n2 7\n7 2\n1 2\n7 7\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n1 3\n1 2 1\n1 3 3\n1 5 1\n1 4 2\n5 4 3\n3 5 2\n2 3 8\n2 7\n10...
code_contests
verifiable_code
baahubali-and-the-closest-strategy
Solve the following coding problem using the programming language python: Given N numbers and M queries, for each query Mi, find the sum of two distinct numbers closest to the query number, if more than one such sum exists print the smallest one. Input: First line contains the value of N and M Second line contains ...
```python n,k=(int(i) for i in raw_input().split()) l=[int(i) for i in raw_input().split()] l.sort() for kkk in range(0,k): q=input() i=0 j=n-1 ans=99999999 soln=0 while i<j: s=l[i]+l[j] if s>q: j-=1 elif s<q: i+=1 else: soln=q ...
vfc_54041
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n3 12 17 33 34\n1\n51\n30\n\nSAMPLE", "output": "15\n51\n29", "type": "stdin_stdout" }, { "fn_name": null, "input": "792 2\n63 51 1224781 138576 251640 45 817 1 46 54473721 29806960 299 504645 33...
code_contests
verifiable_code
chotu-and-distinct-elements
Solve the following coding problem using the programming language python: Valentine week has started and Chotu wants to impress his crush. On this rose day Chotu plans to give his crush a bouquet of roses. Chotu visits a rose shop which has N number of roses and each rose has a certain love factor. Now Chotu wants to ...
```python t = int(raw_input()) for i in range(t): s = int(input()) num1 = set(map(int, raw_input().split())) num = list(num1) res = list() c = 0 for j in range(len(num)): if c == 0: temp = max(num) if temp not in res: res.append(temp) ...
vfc_54045
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n1000\n4913 1000 405224 328509 512 592704 343 857375 39304 8000 614125 79507 287496 373248 39304 250047 5832 68921 1728 12167 493039 29791 614125 2744 287496 79507 2197 343 389017 704969 262144 287496 35937 373248 884736 753571 ...
code_contests
verifiable_code
e-musical-sequences
Solve the following coding problem using the programming language python: Valentina had a birthday recently. She got a special piano from parents. They told her about the piano melodies and the connection with the mathematical sequences. She got amazed and started to use piano keys to create her own musical sequences...
```python for x in range(input()): line = raw_input().split() n,m,z = map(int, line) l = raw_input().split() arr = map(int, l) ans = 0 tp=-1 for i in range(n-1,-1,-1): tp*=-1 ans+= (tp)*arr[i] arr.append(ans) if n%2==1: arr+=arr else: arr+=[-p for p in arr] print arr[z%(2*(n+1))]%m ```
vfc_54049
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 10 4\n1 3 3 7\n4 10 5\n1 3 3 7\n1 2 12345678987654321\n1\n\nSAMPLE", "output": "6\n9\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 5 4\n1 3 3 7\n4 10 5\n1 3 3 7\n1 2 1234567...
code_contests
verifiable_code
handshake
Solve the following coding problem using the programming language python: At the annual meeting of Board of Directors of Biana Inc, every one starts shaking hands with everyone else in the room. Given the fact that any two persons shake hand exactly once, Can you tell the total count of handshakes? Input Format The ...
```python #@author:debverine | 20-Feb-2016 | 9:32:50 am for _ in range(int(input())): n=long(input()) print (long((n-1)*n/2)) ```
vfc_54053
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n2\n\nSAMPLE", "output": "0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "557\n9348\n5674\n5769\n5089\n1900\n9568\n794\n8029\n7034\n8453\n5791\n9215\n8697\n4124\n2004\n7681\n6058...
code_contests
verifiable_code
lottery-tickets-1
Solve the following coding problem using the programming language python: Raju is very much interested in winning money through lotteries. Lottery Association is organising lottery matches quite frequently. A lottery match begins at certain time and ends at a certain time. Raju can buy ticket of certain match if he w...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' numCases=int(raw_input()) for iCase in xrange(numCases): numMatches=int(raw_input()) matches=[] for i in xrange(numMatches): st,et,wp=map(int, raw_input().split()) ...
vfc_54057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n1 10 100\n10 20 100\n20 30 100\n30 40 100\n4\n1 10 50\n10 20 100\n20 30 100\n30 40 100\n\nSAMPLE", "output": "4.00\n3.50", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n45\n2698768...
code_contests
verifiable_code
mystery-7-1
Solve the following coding problem using the programming language python: Solve The Mystery Input: First line contains T - number of test cases. Following T lines each contains a string of characters in the range [a-z] only Output: Print a numeric string for each test case. Constraints: 1 ≤ T ≤ 100 1 ≤ Length o...
```python a={'a':2,'b':2,'c':2,'d':3,'e':3,'f':3,'g':4,'h':4,'i':4,'j':5,'k':5,'l':5,'m':6,'n':6,'o':6,'p':7,'q':7,'r':7,'s':7,'t':8,'u':8,'v':8,'w':9,'x':9,'y':9,'z':9} t=input() for _ in range(t): s=str(raw_input()) l=len(s) ans='' for i in range(l): ans=ans+str(a[s[i]]) print ans ```
vfc_54061
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\nkey\nto\ncontrol\nnine\ntails\nis\nin\nyour\nhand\nphone\n\nSAMPLE", "output": "539\n86\n2668765\n6463\n82457\n47\n46\n9687\n4263\n74663\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
problem-2-10
Solve the following coding problem using the programming language python: Apples and Oranges. You thought this question was gone when you passed class 6th. WELL YOU ARE WRONG. It's back. See we have n apples and m oranges. You need to put these apples and oranges into some boxes. Though we've put some terms&condition...
```python num1,num2=map(int,raw_input().split()) d,b=num1,num2 while d>0: r=b%d b=d d=r print str(num1/b) + " " + str(num2/b) ```
vfc_54065
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "12028 12772", "output": "97 103\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12028 12772\n\nSAMPLE", "output": "97 103\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
security-breach-1
Solve the following coding problem using the programming language python: Statement: Security is the major factor, which is prohibiting hackers letting into bank accounts online. But still, we have breached 2nd level security of SBIS bank and a final level is kept for you. Your task is simple, we are receiving an inte...
```python t=input() for _ in range(t): a=map(list,raw_input().split()) a=a[0] z=len(a) b=[] for i in range(z): if a[i]=='2': b.append('cde') q=1 if a[i]=='6': b.append('b3') if a[i]=='7': b.append('acf') if a[i]=='9': b.append ('c6a') #print b if len(b)==0: print ' ' else: print ''.jo...
vfc_54069
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n23695632789\n\nSAMPLE", "output": "cdeb3c6ab3cdeacfc6a\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n80875509139150\n95430550654418\n25016833771952\n78883205819874\n46384481177665...
code_contests
verifiable_code
test-152
Solve the following coding problem using the programming language python: Pati's girlfriend dumped him because he couldn't even solve a simple string puzzle. Puzzle is, given a string of lowercase alphabets and you are supposed to check whether the frequency of the most frequent character is even or not. Even after...
```python t=int(raw_input()) for x in range(t): n=int(raw_input()) s=raw_input() ar=[] for y in s: ar.append(y) l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',] c=[] for z in ar: if z in l: l.remove(z) c.append(ar.count(z)) if max(c)%2=...
vfc_54073
{ "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\naabcd\n6\nxyzzdz\n\nSAMPLE", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n5\naabcd\n6\nxyzzdz\n1\nb\n3\nacd\n4\naaaa\n2\nbb", "output": "Yes\nNo\nNo\nN...
code_contests
verifiable_code
writing-in-shorthand
Solve the following coding problem using the programming language python: Alice and Bob text each other everyday. Bob, tired of writing long messages has come up with a way to reduce their size. Alice and Bob are both fluent in 2 languages, L1 and L2. A language consists of a collection of distinct words, where each w...
```python d=dict() n,m=ms=map(int,raw_input().split()) for i in xrange(m): s=raw_input().split() d[s[0]]=s[1] s=raw_input().split() for i in s: if len(i)>len(d[i]): print d[i], else: print i, ```
vfc_54077
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\namit am\namit\n\nSAMPLE", "output": "am\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\na c\nb d\na", "output": "a\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
p03971 CODE FESTIVAL 2016 qual B - Qualification simulator
Solve the following coding problem using the programming language python: There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contes...
```python N,A,B = map(int,input().split()) S = input() countA = 0 countB = 0 for i in range(len(S)): if S[i] == 'a' and countA + countB < A + B: countA += 1 print('Yes') elif S[i] == 'b' and countA + countB < A + B and countB < B: countB += 1 print('Yes') else: print('No') ```
vfc_54117
{ "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": "12 5 2\ncabbabaacaba", "output": "No\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2 2\nccccc", "output": "No\nNo\nNo\nNo\nNo", ...
code_contests
verifiable_code
p00060 Card Game
Solve the following coding problem using the programming language python: There is one card each with the numbers from "1" to "10", for a total of 10 cards. This card has numbers on the front and nothing on the back. Using this card, you and your opponent will play the game according to the following rules. 1. You an...
```python while 1: a=[i+1 for i in range(10)] try:b=list(map(int,input().split())) except:break for i in b:a.remove(i) print('YES' if sum([1 for i in a if i<=20-sum(b[:2])])/7>=0.5 else 'NO') ```
vfc_54121
{ "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\n5 6 9\n8 9 10", "output": "YES\nYES\nNO", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 3\n5 6 8\n8 9 10", "output": "YES\nYES\nNO\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
p00542 Selecting Subjects
Solve the following coding problem using the programming language python: problem JOI took six subjects: physics, chemistry, biology, earth science, history, and geography. Each test was scored on a 100-point scale. JOI chooses 3 subjects from 4 subjects of physics, chemistry, biology, and earth science, and 1 subje...
```python lst=[] for i in range(6): n=int(input()) lst.append(n) lst1=lst[0:4] lst2=lst[4:6] lst1.sort(reverse=True) lst3=lst1[0:3] a=sum(lst3) b=max(lst2) print(a+b) ```
vfc_54133
{ "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": "100\n34\n76\n42\n10\n0", "output": "228", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n34\n76\n67\n10\n0", "output": "253\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
p00706 Get Many Persimmon Trees
Solve the following coding problem using the programming language python: Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of Aizu, h...
```python def main(): while True: N = int(input()) if N==0: exit() (W, H) = [int(x) for x in input().split()] persimmon = [[0 for j in range(100)] for i in range(100)] for _ in range(N): (x, y) = [int(x) for x in input().split()] persimmon...
vfc_54137
{ "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": "16\n10 8\n2 2\n2 5\n2 7\n3 3\n3 8\n4 2\n4 5\n4 8\n6 4\n6 7\n7 5\n7 8\n8 1\n8 4\n9 6\n10 3\n4 3\n8\n6 4\n1 2\n2 1\n2 4\n3 4\n4 2\n5 3\n6 1\n6 2\n3 2\n0", "output": "4\n3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00977 Colorful Tree
Solve the following coding problem using the programming language python: Colorful Tree A tree structure with some colors associated with its vertices and a sequence of commands on it are given. A command is either an update operation or a query on the tree. Each of the update operations changes the color of a specif...
vfc_54145
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2\n2 3\n3 4\n2 5\n1 2 1 2 3\n11\nQ 1\nQ 2\nQ 3\nQ 4\nU 5 1\nQ 1\nU 3 2\nQ 1\nQ 2\nU 5 4\nQ 1", "output": "2\n2\n0\n-1\n3\n2\n2\n0", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2\...
code_contests
verifiable_code
p01562 Area Folding
Solve the following coding problem using the programming language python: You are given one polygonal line, which is a collection of line segments. Your task is to calculate the sum of areas enclosed by the polygonal line. A point is defined to be "enclosed" if and only if the point is unreachable without crossing at...
vfc_54161
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 0\n1 1\n1 0\n0 1\n1 0", "output": "0.25", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n26 52\n33 12\n-51 68\n16 61\n43 -26\n87 24\n12 10", "output": "2714.840579710", "t...
code_contests
verifiable_code
p01724 Phutball
Solve the following coding problem using the programming language python: Ikta, who hates to lose, has recently been enthusiastic about playing games using the Go board. However, neither Go nor Gomoku can beat my friends at all, so I decided to give a special training to the lesser-known game Phutball. This game is a...
```python def main(): N = 20; M = 15 MP = [[-1]*M for i in range(N)] L = 0 for i in range(N-1): s = input() for j in range(M): c = s[j] if c == 'O': sx = j; sy = i elif c == 'X': MP[i][j] = L L += 1 ...
vfc_54165
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n.............
code_contests
verifiable_code
p01862 How To Make Stars
Solve the following coding problem using the programming language python: E: How To Make Stars- story Kitano Kisaka Gakuin 1st grade stardust bell! I like the stars of the bells! At night, I'm always secretly watching the stars on the roof of the school with my childhood friend Hanayo-chin! But unfortunately the wea...
vfc_54169
{ "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": "2\n10 5", "output": "1\n-10.00 -6.48\n-10.79 -8.91\n-13.34 -8.91\n-11.28 -10.41\n-12.07 -12.84\n-10.00 -11.34\n-7.93 -12.84\n-8.72 -10.41\n-6.66 -8.91\n-9.21 -8.91\n2\n10.00 12.34\n9.47 10.72\n7.77 10.72\n9.15 9.72\n8.62 8.10...
code_contests
verifiable_code
p01997 Right triangle
Solve the following coding problem using the programming language python: problem Given the lengths of $ 2 $ sides that are not the hypotenuse of a right triangle, $ A $ and $ B $. The side of length $ A $ overlaps the $ x $ axis, and the side of length $ B $ overlaps the $ y $ axis. Do the following: 1. Rotate the...
```python import math a,b=map(int,input().split()) print(b**3*math.pi*(4/3)) ```
vfc_54173
{ "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": "1 2", "output": "33.510322", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2", "output": "33.510321638\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
p02284 Binary Search Tree II
Solve the following coding problem using the programming language python: Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node ...
```python class Node(object): root = None def __init__(self, key, parent=None, left=None, right=None): self.key = key self.parent = parent self.left = left self.right = right self.height = None @classmethod def insert(cls, z): y = None x = cls.ro...
vfc_54181
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint", "output": "yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
cdva1504
Solve the following coding problem using the programming language python: Many years ago there was a kingdom called 'sentence', which comprises of two groups namely strings and integers. Strings consists of all the characters and alphabets(both capital and small) whereas the integers consists of all the kinds of numb...
```python for ii in range(input()): string=raw_input() ans="" k=len(string) for ii in range(k): if not string[ii].isdigit(): ans=ans+string[ii] print ans ```
vfc_54189
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nCodeVaitam 2015@Nit agartala.\nCodechef", "output": "CodeVaitam @Nit agartala.\nCodechef", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nCodeVaitam 2115@Nit agartala.\nCodechef", ...
code_contests
verifiable_code
dbz16xs1
Solve the following coding problem using the programming language python: Shil has a number X.He challenges you to find minimum positive number K such that F(K) is equal to X. F(x) is defined as 1^2^3^....x. ^ denotes the bitwise Xor operation   Input First line of input will consists of total number of test cas...
```python def main(): for _ in xrange(input()): X = input() if X == 0: print 3 else: if X == 1: print 1 else: if X % 4 == 0: print X elif (X - 3) % 4 == 0: print X - 1...
vfc_54193
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n2\n100", "output": "1\n-1\n100", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
igame
Solve the following coding problem using the programming language python: After a long period of relaxation Alice and Bob decided to play a game. This time of course not a number game. The rules of the game are as follows: There is a vehicle situated at the point (m, n) of a rectangular grid. Only one corner of the re...
```python a=[[0 for i in xrange(1001)] for y in range(1001)] def row(i,j): for k in xrange(1001-j-1): a[i][k+j+1]=2 def col(i,j): for k in xrange(1001-i-1): a[k+i+1][j]=2 def diag(i,j): i=i+1 j=j+1 while(i<1001)and(j<1001): a[i][j]=2 i=i+1 j=j+1 def ma...
vfc_54197
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1 0 0\n2 4 1 2", "output": "Alice\nBob", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 0 0 0\n2 4 1 2", "output": "Alice\nBob\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
muldiv
Solve the following coding problem using the programming language python: You are given integers N,K and M and operation F. Operation F is defined for an integer as follows: F: for i from 1 to M inclusive, do if N is a multiple of K, divide N by K else, multiply N by K print N Perform the operation F on N.   ...
```python def fun(n,k,m): if k==1: return n while m>0 and n%k==0: m = m-1 n = n/k if m==0: return n if m%2==0: return n return n*k t= int(raw_input()) for i in range(t): n,k,m= map(int,raw_input().split()) print fun(n,k,m) ```
vfc_54201
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n42 3 2\n6 7 1", "output": "42\n42", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n42 3 2\n6 7 2", "output": "42\n6\n", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
rrcopy
Solve the following coding problem using the programming language python: You had an array of integer numbers. You also had a beautiful operations called "Copy-Paste" which allowed you to copy any contiguous subsequence of your array and paste it in any position of your array. For example, if you have array [1, 2, 3, ...
```python t=input() for _ in xrange(t): raw_input() print len(set(raw_input().split())) ```
vfc_54205
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 1 1 1 1\n5\n1 2 3 1 2", "output": "1\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5\n1 1 1 1 1\n5\n1 2 6 1 2", "output": "1\n3\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
1043_B. Lost Array
Solve the following coding problem using the programming language python: Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Bajtek...
```python arr_len = int(input()) a = [0] + [int(x) for x in input().split(" ")] x = [0] * arr_len res = [] for i in range(1, arr_len + 1): x[i-1] = a[i]-a[i-1] def ok(k, x ,a): for i in range(0, arr_len): tmp = x[i%k] + a[i] if tmp != a[i + 1]: return False return True ...
vfc_54217
{ "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\n1 2 3 4 5\n", "output": "5\n1 2 3 4 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 3 5 6 8\n", "output": "2\n3 5 ", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
1065_G. Fibonacci Suffix
Solve the following coding problem using the programming language python: Let's denote (yet again) the sequence of Fibonacci strings: F(0) = 0, F(1) = 1, F(i) = F(i - 2) + F(i - 1), where the plus sign denotes the concatenation of two strings. Let's denote the lexicographically sorted sequence of suffixes of strin...
vfc_54221
{ "difficulty": "13", "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 3 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5 3\n", "output": "110\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1...
code_contests
verifiable_code
1088_E. Ehab and a component choosing problem
Solve the following coding problem using the programming language python: You're given a tree consisting of n nodes. Every node u has a weight a_u. You want to choose an integer k (1 ≤ k ≤ n) and then choose k connected components of nodes that don't overlap (i.e every node is in at most 1 component). Let the set of n...
vfc_54225
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n-1 -2 -1\n1 2\n1 3\n", "output": "-2 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n1 2\n1 3\n", "output": "6 1\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
1107_E. Vasya and Binary String
Solve the following coding problem using the programming language python: Vasya has a string s of length n consisting only of digits 0 and 1. Also he has an array a of length n. Vasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from...
```python n = int(input()) s = input() ai = [0] + list(map(int,input().split())) ar = [ai[i] for i in range(n+1)] for i in range(1,n): num = 0 for j in range(0,(i+1) // 2 + 1): ar[i] = max(ar[i],ar[j] + ar[i-j]) ar2 = [] num = 1 for i in range(1,n): if s[i] == s[i-1]: num += 1 else: ...
vfc_54229
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1101001\n3 4 9 100 1 2 3\n", "output": "109\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n10101\n3 10 15 15 15\n", "output": "23\n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
1136_E. Nastya Hasn't Written a Legend
Solve the following coding problem using the programming language python: In this task, Nastya asked us to write a formal statement. An array a of length n and an array k of length n-1 are given. Two types of queries should be processed: * increase a_i by x. Then if a_{i+1} < a_i + k_i, a_{i+1} becomes exactly a_...
vfc_54233
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 6 7\n3 1\n3\n+ 1 3\n+ 2 4\ns 1 3\n", "output": "33\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n1 -1\n5\ns 2 3\n+ 1 2\ns 1 2\n+ 3 1\ns 2 3\n", "output": "5\n7\n8\n"...