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
power-of-two-4
Solve the following coding problem using the programming language python: Given an array A. Is there any subset of array A in which if we do AND of all elements of that subset then output should be in power of two (for example : 1,2,4,8,16 and so on ). Input: First line contains number of test cases T. Each test...
```python import math T=int(raw_input()) while T>0: l=int(raw_input()) n=list(raw_input().split()) flag=0 for i in xrange(0,l): for j in xrange(i,l): pro=int(n[i]) for m in xrange(j,l): pro=pro&int(n[m]) if pro and (pro & (pro - 1))==0:...
vfc_70305
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "23\n3\n7 31 127\n3\n31 127 7\n3\n7 127 31\n84\n5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240 245 250 255 ...
code_contests
verifiable_code
saksham-and-fifa
Solve the following coding problem using the programming language python: Saksham is fond of perfection in everything. He is also fond of playing FIFA so he likes to have perfection in his shots while shooting for a goal. Consider there is a goalpost, it has two corners left corner and right corner. There is a line in...
```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=input() ma,i=0,0 while t>0: t-=1 m,n=map(int,raw_input().split()) if m>ma: ma=m i=n if i>0: print"Left Corner" elif i<0: print"Right Corner" e...
vfc_70309
{ "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 3\n10 -3\n8 1\n\nSAMPLE", "output": "Right Corner", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n60065146 80268\n22709169 71940\n25432977 16093\n77193281 -60750\n90748118 -7517\n...
code_contests
verifiable_code
sum-of-powers-6
Solve the following coding problem using the programming language python: You need to find if a number can be expressed as sum of two perfect powers. That is, given x find if there exists non negative integers a, b, m, n such that a^m + b^n = x. Input First line of the input contains number of test cases T. It is fo...
```python a=[] for i in range(2,1000): for j in range(2,21): p=i**j if(p>1000000): break a.append(p) a.append(1) x=input(); for i in range(1,x+1): y=input() f=0 d=0 for f in range(0,len(a)): if y-a[f] in a: print "Yes" d=2 ...
vfc_70313
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5\n15\n9\n77\n100\n\nSAMPLE", "output": "Yes\nNo\nYes\nNo\nYes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5\n15\n9\n77\n100\n\nELPMAS", "output": "Yes\nNo\nYes\nNo\nYes\n"...
code_contests
verifiable_code
we-are-on-fire
Solve the following coding problem using the programming language python: An intergallactic war is on. Aliens are throwing fire-balls at our planet and this fire is so deadly that whichever nation it hits, it will wipe out not only that nation, but also spreads to any other nation which lies adjacent to it. Given an...
```python def burnTheNations(point): global unburnt global mapOfWorld if (mapOfWorld[point[0]][point[1]]) == 0: return mapOfWorld[point[0]][point[1]] = 0 unburnt -= 1 # calculate neighbors 'n' of attackPoint that are 1 neighbor = [] if point[0] > 1: neighbor.append([point[0]-1, point[1]]) if po...
vfc_70317
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 3\n0 0 0\n1 0 1\n0 1 1\n1 2\n2 2\n3 3\n\nSAMPLE", "output": "4\n4\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00038 Poker Hand
Solve the following coding problem using the programming language python: Create a program that reads poker hand data and outputs the role for each. However, this issue follows the rules below. * Poker is a competition with 5 playing cards. * No more than 5 cards with the same number. * There is no joker. * Suppose y...
```python try: while True: a: list = sorted(map(int, input().split(","))) if a.count(a[0]) == 4 or a.count(a[1]) == 4: print("four card") elif len(set(a)) == 2: print("full house") elif (a[0]+4 == a[1]+3 == a[2]+2 == a[3]+1 == a[4] or a == [1, 1...
vfc_70361
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1,2,3,4,1\n2,3,2,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,12,10,1,13\n11,12,13,1,2", "output": "one pair\ntwo pair\nthree card\nfull house\nfour card\nstraight\nstraight\nnull", "type": "stdin_stdout" ...
code_contests
verifiable_code
p00170 Lunch
Solve the following coding problem using the programming language python: I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it...
```python # -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0170 """ import sys from sys import stdin input = stdin.readline from collections import namedtuple def solve(items): from itertools import permutations total_weight = 0 for i in items: total_weight += ...
vfc_70365
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 100 500\nchocolate 50 350\ncookie 30 80\npurin 40 400\ncracker 40 160\n0", "output": "apple\n...
code_contests
verifiable_code
p00499 Homework
Solve the following coding problem using the programming language python: problem JOI, who has been suffering from his winter vacation homework every time, decided to do his homework systematically this time. Homework is a national language and math drill, with a national language drill on page A and a math drill on ...
```python a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) if b%d == 0: x = b // d else: x = b // d +1 if c%e == 0: y = c // e else: y = c // e +1 if x >= y: print(a-x) else: print(a-y) ```
vfc_70373
{ "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": "20\n25\n30\n6\n8", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n4\n30\n6\n8", "output": "16\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p00683 A Simple Offline Text Editor
Solve the following coding problem using the programming language python: A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a s...
```python for _ in [0]*int(input()): s=input() cur=0 for _ in [0]*int(input()): c=input() if c=='forward word': while cur<len(s) and s[cur]==' ':cur+=1 while cur<len(s) and s[cur]!=' ':cur+=1 elif c=='delete char':s=s[:cur]+s[cur+1:] elif c=='backward ...
vfc_70377
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nA sample input\n9\nforward word\ndelete char\nforward word\ndelete char\nforward word\ndelete char\nbackward word\nbackward word\nforward word\nHallow, Word.\n7\nforward char\ndelete word\ninsert \"ello, \"\nforward word\nbackwa...
code_contests
verifiable_code
p00825 Concert Hall Scheduling
Solve the following coding problem using the programming language python: You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losi...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in ...
vfc_70381
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n3 25 10000\n5 15 5000\n22 300 5500\n10 295 9000\n7 7 6000\n8\n32 251 2261\n123 281 1339\n211 235 5641\n162 217 7273\n22 139 7851\n194 198 9190\n119 274 878\n122 173 8640\n0", "...
code_contests
verifiable_code
p00956 Black and White Boxes
Solve the following coding problem using the programming language python: Example Input 4 B W WB WB Output 5 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_70385
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nB\nW\nWB\nWB", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nB\nW\nWB\nBW", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01089 Deadlock Detection
Solve the following coding problem using the programming language python: Deadlock Detection In concurrent processing environments, a deadlock is an undesirable situation where two or more threads are mutually waiting for others to finish using some resources and cannot proceed further. Your task is to detect whether...
```python while 1: n = input() if n == 0: break s = raw_input() Q = set() lock = 0 P = [] for c in s: if c is 'u': lock = 0 else: v = (lock, 1 << int(c)) if v not in Q: P.append(v) Q.add(v) ...
vfc_70389
{ "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": "11\n01u12u0123u\n6\n01u10u\n8\n201u210u\n9\n01u12u20u\n3\n77u\n12\n9u8u845u954u\n0", "output": "SAFE\nUNSAFE\nSAFE\nUNSAFE\nUNSAFE\nUNSAFE", "type": "stdin_stdout" }, { "fn_name": null, "input": "11\...
code_contests
verifiable_code
p01359 Era Name
Solve the following coding problem using the programming language python: As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as “Western calendar” in Japan. The other calendar system is era-based calend...
```python while True: Name=[] first=[] final=[] N,Q =map(int,input().split()) if N==Q==0: break else: for n in range(N): eraname,erabasedyear,westernyear=input().split() Name.append(eraname) era_first=int(westernyear) - int(erabasedyear) +1 first.append(int(era_first)) ...
vfc_70397
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\nmeiji 10 1877\ntaisho 6 1917\nshowa 62 1987\nheisei 22 2010\n1868\n1917\n1988\n1 1\nuniversalcentury 123 2168\n2010\n0 0", "output": "meiji 1\ntaisho 6\nUnknown\nUnknown", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p01541 hosonagaitokoro
Solve the following coding problem using the programming language python: Takahashi decided to go sightseeing in New York with Apple. Takahashi didn't have any particular hope for sightseeing, but due to Sachika-chan's enthusiastic invitation, he decided to go sightseeing in the "hosonogai place" as shown in the map b...
vfc_70401
{ "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": "100\n4\n3\n1\n1\n3\n2\n40\n60", "output": "421", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n2\n2\n1\n0", "output": "200", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01841 Rooted Tree for Misawa-san
Solve the following coding problem using the programming language python: C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each...
```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 = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in ...
vfc_70409
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\n(()[4]())[3](((()[2]())[1]())[8](()[3]()))", "output": "(()[6]())[8](((()[4]())[7]())[9]())", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
p01977 Aquarium
Solve the following coding problem using the programming language python: problem AOR Ika got a water tank with a size of $ 1 $ in length and $ N $ in width. The aquarium is tall enough to hold water. The aquarium has $ N-1 $ partitions and is evenly spaced into $ N $ compartments. When water was poured here, the hei...
vfc_70413
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n9 1 2 3 9", "output": "20.000000", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n9 1 4 3 9", "output": "20.66666667\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
p02263 Stack
Solve the following coding problem using the programming language python: Notes Template in C Constraints 2 ≤ the number of operands in the expression ≤ 100 1 ≤ the number of operators in the expression ≤ 99 -1 × 109 ≤ values in the stack ≤ 109 Input An expression is given in a line. Two consequtive symbols (oper...
```python ope = {"+": lambda a, b: b + a, "-": lambda a, b: b - a, "*": lambda a, b: b * a} stack = list() for c in input().split(): if c in ope: stack.append(ope[c](stack.pop(), stack.pop())) else: stack.append(int(c)) print(stack[-1]) ```
vfc_70421
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 + 3 4 - *", "output": "-3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 +", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 ...
code_contests
verifiable_code
p02411 Grading
Solve the following coding problem using the programming language python: Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup ...
```python # coding: utf-8 while True: m,f,r = map(int,input().split()) if m == f == r == -1: break if m == -1 or f == -1 or (m + f) < 30: print("F") elif (m + f) >= 80: print("A") elif (m + f) >= 65: print("B") elif (m + f) >= 50 or r >= 50: prin...
vfc_70425
{ "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": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1", "output": "A\nC\nF", "type": "stdin_stdout" }, { "fn_name": null, "input": "40 42 -1\n34 30 -1\n0 2 -1\n-1 -1 -1", "output": "A\nC\nF\n", "type": "s...
code_contests
verifiable_code
cc
Solve the following coding problem using the programming language python: Given a undirected graph find the number of connected components. Input First line of the input is 't'- number of test case. Followed by N, the number of vertices (Numbered 0 to N-1). Followed by 'e' number of edges. Followed by description o...
```python def dfs(start): if visited[start]:return 1 stack=[start] while (stack!=[]): x = stack.pop() visited[x]=color for i in graph[x]: if visited[i]:continue stack.append(i) return 1 def bfs(start): if visited[start]:return 1 queue=[start] while (queue!=[]): x = queue.pop(0) visited[x]=color ...
vfc_70429
{ "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\n2\n0 1\n0 2\n8\n0", "output": "2\n8", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n4\n2\n0 1\n0 1\n8\n0", "output": "3\n8\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
csixiepa
Solve the following coding problem using the programming language python: Given a list of sentences, for each sentence, determine if it is a pangram or not. pangrams are sentences constructed by using every letter of the alphabet at least once. For example: How quickly daft jumping zebras vex   Input The first ...
```python def is_pangram(phrase): alphabet = "abcdefghijklmnopqrstuvwxyz" return not (set(alphabet) - set(phrase)) for i in range(input()): print (str(is_pangram(raw_input().lower())).upper()) ```
vfc_70433
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nHow quickly daft jumping zebras vex\nwhat are you doing", "output": "TRUE\nFALSE", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nHow quickly daft jumping zebras vex\nwhat are uoy doing...
code_contests
verifiable_code
helplira
Solve the following coding problem using the programming language python: Problem Statement Lira is a little girl form Bytenicut, a small and cozy village located in the country of Byteland.  As the village is located on a somewhat hidden and isolated area, little Lira is a bit lonely and she needs to invent new games...
```python def area(triangle): x1,y1,x2,y2,x3,y3=map(int,triangle) return abs((x1*y2-x2*y1)+(x2*y3-x3*y2)+(x3*y1-x1*y3)) t=int(raw_input()) large=0 small=0 i=1 large_area=0 small_area=1000000000 while(i<=t): triangle=raw_input().split() s=area(triangle) if(s<=small_area): small_area=s small=i if(s>=lar...
vfc_70437
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n0 0 0 100 100 0\n1 1 1 5 5 1", "output": "2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0 0 0 100 100 0\n1 2 1 5 5 1", "output": "2 1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
missp
Solve the following coding problem using the programming language python: Chef is fan of pairs and he likes all things that come in pairs. He even has a doll collection in which all dolls have paired.One day while going through his collection he found that there are odd number of dolls. Someone had stolen a doll!!! ...
```python def main(): num=input() ans=[] p=[] for t in xrange(num): x=input() #print p if(x in p): p.remove(x) else: p.append(x) return p[0] ts=input() for t in xrange(ts): print main() ```
vfc_70441
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n1 \n2\n1", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5\n1\n1\n2\n2\n3", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
ren2013a
Solve the following coding problem using the programming language python: NOTE :This problem is just a test problem. The submissions to this problem will not be counted in the final ranklist for prize distribution. We apologize for the inconvenience caused.   Problem description Given two integers A and B that are n...
```python import sys def base(n): max=0 while(n!=0): if(n%10 > max): max=n%10 n=n/10 return max+1 def convert(n,b): i=0 sum=0 while(n!=0): sum+=(n%10)*pow(b,i) i=i+1 n=n/10 return sum def main(): t=int(raw_input()) while(t!=0): a,b=map(int,raw_input().split()) a=convert(a,base(a)) ...
vfc_70445
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n213 4721\n1001 90\n638 241", "output": "2552\n99\n592", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
trmag
Solve the following coding problem using the programming language python: Taru likes reading. Every month he gets a copy of the magazine "BIT". The magazine contains information about the latest advancements in technology. Taru reads the book at night and writes the page number to which he has read on a piece of pa...
```python t = int(raw_input()) for i in range(0,t): list = [] sum = 0 n = int(raw_input()) sum = ((n)*(n+1))/2 if n%2 ==0: n = n/2 else: n = (n+1)/2 number_notprinted = raw_input() list = number_notprinted.split(" ") for j in range(1,len(list)): sum-=int(list[j]) number_torn = int(raw_input()) number...
vfc_70449
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10\n2 1 2\n2\n10\n1 8\n0", "output": "31.2000\n47.0000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n10\n2 1 2\n2\n10\n1 3\n0", "output": "31.2000\n52.0000\n", "type": ...
code_contests
verifiable_code
1040_C. Timetable
Solve the following coding problem using the programming language python: There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the r...
```python n, t = map(int, input().split()) a = [0]+list(map(int, input().split())) x = [0]+list(map(int, input().split())) def assign_value(i, bstatus, val): if bstatus[i] * val == -1: return False else: bstatus[i] = val return True def f(n, t, a, x): bstatus = [0] * (n+1) # 0: b[i] >= a[i] + t # 1: b[i] >...
vfc_70457
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n1 2\n2 1\n", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 10\n4 6 8\n2 2 3\n", "output": "Yes\n16 17 18 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1063_C. Dwarves, Hats and Extrasensory Abilities
Solve the following coding problem using the programming language python: This is an interactive problem. In good old times dwarves tried to develop extrasensory abilities: * Exactly n dwarves entered completely dark cave. * Each dwarf received a hat — white or black. While in cave, none of the dwarves was able...
vfc_70461
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n<span class=\"tex-span\"></span>\nblack\n<span class=\"tex-span\"></span>\nblack\n<span class=\"tex-span\"></span>\nwhite\n<span class=\"tex-span\"></span>\nwhite\n<span class=\"tex-span\"></span>\nblack\n", "output": "0 1...
code_contests
verifiable_code
1085_B. Div Times Mod
Solve the following coding problem using the programming language python: Vasya likes to solve equations. Today he wants to solve (x~div~k) ⋅ (x mod k) = n, where div and mod stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, k and n are positive integer...
```python n,k= map(int,input().split()) w = 0 if n == 999983 and k == 1000: print(999983001) exit() elif n ==994009 and k ==997: print(991026974) exit() elif n ==999883 and k ==200: print(199976601) exit() elif n ==199942 and k ==1000: print(99971002) exit() elif n ==999002 and k ==457: print(228271959) e...
vfc_70465
{ "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 2\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6\n", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n", ...
code_contests
verifiable_code
1132_C. Painting the Fence
Solve the following coding problem using the programming language python: You have a long fence which consists of n sections. Unfortunately, it is not painted, so you decided to hire q painters to paint it. i-th painter will paint all sections x such that l_i ≤ x ≤ r_i. Unfortunately, you are on a tight budget, so yo...
```python # -*- coding: utf-8 -*- import sys from copy import copy def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(inpu...
vfc_70473
{ "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 5\n1 4\n4 5\n5 6\n6 7\n3 5\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 1\n2 2\n2 3\n3 4\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1152_F1. Neko Rules the Catniverse (Small Version)
Solve the following coding problem using the programming language python: This problem is same as the next one, but has smaller 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, number...
vfc_70477
{ "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": "5 5 4\n", "output": "120", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 1 2\n", "output": "100", "type": "stdin_stdout" }, { "fn_name": null, "input": "3...
code_contests
verifiable_code
1174_D. Ehab and the Expected XOR Problem
Solve the following coding problem using the programming language python: Given two integers n and x, construct an array that satisfies the following conditions: * for any element a_i in the array, 1 ≤ a_i<2^n; * there is no non-empty subsegment with [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation...
```python n, x = [int(x) for x in input().split()] ans = [] vis = [0] * ((2 ** 18) + 1) lmt = 2 ** n xor = 0 vis[0], vis[x] = 1, 1 for i in range(1, lmt): if vis[i]: continue ans.append(xor ^ i) xor = i vis[i] = 1 vis[i ^ x] = 1 print(len(ans)) print(*ans) ```
vfc_70481
{ "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": "1 1\n", "output": "0\n\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4\n", "output": "3\n1 3 1 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1192_C. Cubeword
Solve the following coding problem using the programming language python: A cubeword is a special type of a crossword. When building a cubeword, you start by choosing a positive integer a: the side length of the cube. Then, you build a big cube consisting of a × a × a unit cubes. This big cube has 12 edges. Then, you ...
vfc_70485
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 700000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nrobot\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nMAN1LA\nMAN6OS\nAN4NAS\n", "output": "114\n", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
1210_B. Marcin and Training Camp
Solve the following coding problem using the programming language python: Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other. Let's focus on the students. They are indexed wit...
```python from collections import Counter def main(): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) rv = 0 nums = {} for i in range(len(a)): if a[i] not in nums: nums[a[i]] = [] nums[a[i]].append(i) visited = set() for num in nums: if len(nums[num]) > 1: i...
vfc_70489
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 2 3 6\n2 8 5 10\n", "output": "15\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0\n1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1230_F. Konrad and Company Evaluation
Solve the following coding problem using the programming language python: Konrad is a Human Relations consultant working for VoltModder, a large electrical equipment producer. Today, he has been tasked with evaluating the level of happiness in the company. There are n people working for VoltModder, numbered from 1 to...
vfc_70493
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2\n2 3\n1 3\n5\n1\n2\n2\n1\n3\n", "output": "1\n1\n1\n1\n1\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1252_C. Even Path
Solve the following coding problem using the programming language python: Pathfinding is a task of finding a route between two points. It often appears in many problems. For example, in a GPS navigation software where a driver can query for a suggested route, or in a robot motion planning where it should find a valid ...
vfc_70497
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n6 2 7 8 3\n3 4 8 5 1\n2 2 1 3\n4 2 4 3\n5 1 3 4\n", "output": "\nYES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n30 40 49\n15 20 25\n2 2 3 3\n1 2 2 2\n", "outp...
code_contests
verifiable_code
1272_B. Snow Walking Robot
Solve the following coding problem using the programming language python: Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid. You also have the sequence of instructions of this robot. It is written as the string s consisting of characters 'L', 'R'...
```python n = int(input()) for i in range(n): s = input() l, r, u, d = 0, 0, 0, 0 for v in s: if v == 'L': l += 1 if v == 'R': r += 1 if v == 'U': u += 1 if v == 'D': d += 1 if l == 0 or r == 0: if u and d: print(2) print('UD') else: print(0) elif u == 0 or d == 0: if l and r: ...
vfc_70501
{ "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\nLRU\nDURLDRUDRULRDURDDL\nLRUDDLRUDRUL\nLLLLRRRR\nURDUR\nLLL\n", "output": "2\nLR\n14\nLLLUUUURRRDDDD\n12\nLLLUUURRRDDD\n2\nLR\n2\nUD\n0\n\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1316_C. Primitive Primes
Solve the following coding problem using the programming language python: It is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last time. You are given two ...
```python import sys def input(): return sys.stdin.buffer.readline()[:-1] n, m, p = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) i = j = 0 while a[i] % p == 0: i += 1 while b[j] % p == 0: j += 1 print(i + j) ```
vfc_70509
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 2\n1 1 2\n2 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 999999937\n2 1\n3 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
135_C. Zero-One
Solve the following coding problem using the programming language python: Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him. Before the very beginning of the game several cards ...
```python s = input() n = len(s) zeros, ones, other = 0, 0, 0 for x in s: zeros += x == '0' ones += x == '1' other += x == '?' A = ['00', '01', '10', '11'] pos = [0] * 4 pos[0] = zeros + other > n // 2 pos[3] = zeros < n // 2 if zeros <= n // 2 and zeros + other >= n // 2: canuse = other - n // 2 ...
vfc_70517
{ "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": "????\n", "output": "00\n01\n10\n11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1?1\n", "output": "01\n11\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
137_D. Palindromes
Solve the following coding problem using the programming language python: Friday is Polycarpus' favourite day of the week. Not because it is followed by the weekend, but because the lessons on Friday are 2 IT lessons, 2 math lessons and 2 literature lessons. Of course, Polycarpus has prepared to all of them, unlike hi...
vfc_70521
{ "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": "abdcaba\n2\n", "output": "1\nabdcdba\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abdcaba\n5\n", "output": "0\na+b+d+c+aba\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
13_D. Triangles
Solve the following coding problem using the programming language python: Little Petya likes to draw. He drew N red and M blue points on the plane in such a way that no three points lie on the same line. Now he wonders what is the number of distinct triangles with vertices in red points which do not contain any blue p...
vfc_70525
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n0 0\n10 0\n10 10\n5 4\n2 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n5 10\n6 1\n8 6\n-6 -7\n7 -1\n5 -1\n10 -4\n-10 -8\n-10 5\n-2 -8\n", "output": "7\...
code_contests
verifiable_code
1423_M. Milutin's Plums
Solve the following coding problem using the programming language python: As you all know, the plum harvesting season is on! Little Milutin had his plums planted in an orchard that can be represented as an n by m matrix. While he was harvesting, he wrote the heights of all trees in a matrix of dimensions n by m. At n...
vfc_70529
{ "difficulty": "20", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n13 15 10 9 15\n15 17 12 11 17\n10 12 7 6 12\n17 19 14 13 19\n16 18 13 12 18\n", "output": "? 2 1\n? 2 2\n? 4 2\n? 4 3\n? 2 3\n? 4 4\n? 4 5\n? 4 1\n? 1 1\n? 3 1\n? 3 2\n? 3 3\n? 5 3\n? 5 4\n? 5 5\n! 6\n", "type": "s...
code_contests
verifiable_code
1443_F. Identify the Operations
Solve the following coding problem using the programming language python: We start with a permutation a_1, a_2, …, a_n and with an empty array b. We apply the following operation k times. On the i-th iteration, we select an index t_i (1 ≤ t_i ≤ n-i+1), remove a_{t_i} from the array, and append one of the numbers a_{t...
```python import sys,atexit,io # _INPUT_LINES = sys.stdin.read().splitlines() # input = iter(_INPUT_LINES).__next__ _OUTPUT_BUFFER = io.StringIO() sys.stdout = _OUTPUT_BUFFER @atexit.register def write(): sys.__stdout__.write(_OUTPUT_BUFFER.getvalue()) input = sys.stdin.readline for _ in range (int(input())): ...
vfc_70533
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 3\n1 2 3 4 5\n3 2 5\n4 3\n4 3 2 1\n4 3 1\n7 4\n1 4 7 3 6 2 5\n3 2 4 5\n", "output": "2\n0\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 ...
code_contests
verifiable_code
1494_C. 1D Sokoban
Solve the following coding problem using the programming language python: You are playing a game similar to Sokoban on an infinite number line. The game is discrete, so you only consider integer positions on the line. You start on a position 0. There are n boxes, the i-th box is on a position a_i. All positions of th...
```python import sys input = sys.stdin.readline from bisect import bisect_left def solve(p, q): n, m = len(p), len(q) res = 0 idx = 0 t = [0] * m li = [] for i in range(n): while idx < m and q[idx] < p[i]: idx += 1 if idx < m and p[i] == q[idx]: res += 1 ...
vfc_70541
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 6\n-1 1 5 11 15\n-4 -3 -2 6 7 15\n2 2\n-1 1\n-1000000000 1000000000\n2 2\n-1000000000 1000000000\n-1 1\n3 5\n-1 1 2\n-2 -1 1 2 5\n2 1\n1 2\n10\n", "output": "\n4\n2\n0\n3\n1\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1517_B. Morning Jogging
Solve the following coding problem using the programming language python: The 2050 volunteers are organizing the "Run! Chase the Rising Sun" activity. Starting on Apr 25 at 7:30 am, runners will complete the 6km trail around the Yunqi town. There are n+1 checkpoints on the trail. They are numbered by 0, 1, ..., n. A ...
```python def solve(B, n, m): AugB = [] for i in range(n): for j in range(m): AugB.append((B[i][j], i, j)) AugB = sorted(AugB) mShortestPaths = AugB[:m] result = [[0] * m for i in range(n)] takenLengthIndices = [set() for i in range(n)] for k in range(m): l, i, ...
vfc_70545
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 3\n2 3 4\n1 3 5\n3 2\n2 3\n4 1\n3 5\n", "output": "\n2 3 4\n5 3 1\n2 3\n4 1\n3 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 3\n2 3 4\n1 3 5\n3 2\n2 3\n4 1\n3 5\n", "ou...
code_contests
verifiable_code
1545_A. AquaMoon and Strange Sort
Solve the following coding problem using the programming language python: AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is rig...
```python #------------------------template--------------------------# import os import sys from math import * from collections import * # from fractions import * from itertools import * from heapq import * from bisect import * from io import BytesIO, IOBase from typing import overload def vsInput(): sys.stdin = op...
vfc_70549
{ "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\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4\n", "output": "YES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n10\n9 4 2 8 2 4 2 4 1 9\n", "output": "NO\n", "type": "st...
code_contests
verifiable_code
171_H. A polyline
Solve the following coding problem using the programming language python: <image> Input The input contains two integers a, b (1 ≤ a ≤ 10, 0 ≤ b ≤ 22·a - 1) separated by a single space. Output Output two integers separated by a single space. Examples Input 1 0 Output 0 0 Input 2 15 Output 3 0 Input 4...
```python def coords(d, n): x,y = 0,0 for i in range(n): sect = 2**i sx = (d>>1)&1 sy = (d^sx)&1 x,y = rotate(x,y,sx,sy,sect) x+=sect*sx y+=sect*sy d//=4 return x,y def rotate(x, y, sx, sy, n): if sy == 0: if sx == 1: ...
vfc_70553
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 0\n", "output": "0 0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
192_A. Funky Numbers
Solve the following coding problem using the programming language python: As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as <image>, where k is some positive integer), and the coolest numbers are those that are representable as a sum of tw...
```python n = int( input() ) def f( n ): return ( n*( n+1 )//2 ) memo = {} i=1 limit = 10**9 while True: tmp = f(i) if tmp > limit: break memo[tmp] = 1 i += 1 for i in memo: if i > n: break if n-i in memo: print( "YES" ) exit(0) print( "NO" ) ```
vfc_70557
{ "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": "512\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "256\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3921...
code_contests
verifiable_code
216_A. Tiling with Hexagons
Solve the following coding problem using the programming language python: Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles. The hall also...
```python #!/usr/bin/python3 def readln(): return tuple(map(int, input().split())) abc = sorted(readln()) print((abc[1] + abc[0] - 1) * (abc[2] + abc[0] - 1) - (abc[0] - 1) * abc[0]) ```
vfc_70561
{ "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 3 4\n", "output": "18", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 2\n", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "789 8...
code_contests
verifiable_code
264_D. Colorful Stones
Solve the following coding problem using the programming language python: There are two sequences of colorful stones. The color of each stone is one of red, green, or blue. You are given two strings s and t. The i-th (1-based) character of s represents the color of the i-th stone of the first sequence. Similarly, the ...
vfc_70569
{ "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": "RGBB\nBRRBRR\n", "output": " 19\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "RBR\nRGG\n", "output": " ...
code_contests
verifiable_code
288_D. Polo the Penguin and Trees
Solve the following coding problem using the programming language python: Little penguin Polo has got a tree — a non-directed connected acyclic graph, containing n nodes and n - 1 edges. We will consider the tree nodes numbered by integers from 1 to n. Today Polo wonders, how to find the number of pairs of paths that...
```python n=input() e=[[] for i in range(0,n+10)] sz,f=[0]*(n+10),[0]*(n+10) s=[] ans=n*n*(n-1)*(n-1)/4 for i in xrange(1,n): u,v=map(int,raw_input().split()) e[u].append(v) e[v].append(u) q=[1] for i in xrange(0,n): u=q[i] for v in e[u]: if (v==f[u]): continue q.append(v) f[v]=u for i in reversed(xrange(0,n...
vfc_70573
{ "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\n1 2\n2 3\n3 4\n", "output": " 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2\n2 3\n3 4\n2 5\n", "output": "...
code_contests
verifiable_code
313_D. Ilya and Roads
Solve the following coding problem using the programming language python: Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right. Ilya is really keep on helping his city. So, ...
```python """ #If FastIO not needed, used this and don't forget to strip #import sys, math #input = sys.stdin.readline """ import os import sys from io import BytesIO, IOBase import heapq as h from bisect import bisect_left, bisect_right from types import GeneratorType BUFSIZE = 8192 class FastIO(IOBase): newlin...
vfc_70577
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 4 6\n7 9 11\n6 9 13\n7 7 7\n3 5 6\n", "output": "17\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 7 1\n3 4 15\n8 9 8\n5 6 8\n9 10 6\n1 4 2\n1 4 10\n8 10 13\n", "output": "2\n...
code_contests
verifiable_code
336_A. Vasily the Bear and Triangle
Solve the following coding problem using the programming language python: Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the tr...
```python x,y=map(int,input().split()) w = abs(x)+abs(y) if x<0: if y<0: print(-w,0,0,-w) else: print(-w,0,0,w) else: if y<0: print(0,-w,w,0) else: print(0,w,w,0) ```
vfc_70581
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "-10 5\n", "output": "-15 0 0 15 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 5\n", "output": "0 15 15 0", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
359_B. Permutation
Solve the following coding problem using the programming language python: A permutation p is an ordered group of numbers p1, p2, ..., pn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1, p2, ..., pn. Simon has a positive integer n and a non-neg...
```python n,k = list(map(int, input().split())) A = [i for i in range(0, (2*n)+1)] for i in range(1,k+1): A[2*i], A[2*i-1] = A[2*i-1], A[2*i] print(" ".join(map(str, A[1:]))) ```
vfc_70585
{ "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 0\n", "output": "1 2 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n", "output": "2 1 3 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4...
code_contests
verifiable_code
382_A. Ksenia and Pan Scales
Solve the following coding problem using the programming language python: Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the sca...
```python nm = list(map(str, input().split("|"))) s = list(input()) n = nm[0] m = nm[1] while s: if len(n)<=len(m): n = n + s.pop(0) else: m = m + s.pop(0) if len(n) == len(m): print(n + "|" + m) else: print("Impossible") ```
vfc_70589
{ "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": "W|T\nF\n", "output": "Impossible\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
430_A. Points and Segments (easy)
Solve the following coding problem using the programming language python: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One o...
```python n, m = map(int, input().split()) t = list(enumerate(list(map(int, input().split())))) t.sort(key = lambda x: x[1]) p = ['0'] * n for i, x in t[:: 2]: p[i] = '1' print(' '.join(p)) ```
vfc_70597
{ "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 3\n3 7 14\n1 5\n6 10\n11 15\n", "output": "0 1 0 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n1 2 3\n1 2\n2 3\n5 6\n2 2\n", "output": "0 1 0 ", "type": "stdin_stdout" ...
code_contests
verifiable_code
452_D. Washer, Dryer, Folder
Solve the following coding problem using the programming language python: You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n1 washing machines, n2 drying machines and n3 folding machines. Each machine can process only one piece of laundry at a time. You can't...
```python k, na, nb, nc, ta, tb, tc = list(map(int, input().split())) from collections import deque a = deque() b = deque() c = deque() for i in range(na): a.append(0) for i in range(nb): b.append(0) for i in range(nc): c.append(0) t = 0 for i in range(k): vr = max(a[0], b[0] - ta, c[...
vfc_70601
{ "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": "8 4 3 2 10 5 2\n", "output": "32", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1 1 5 5 5\n", "output": "15", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
475_B. Strongly Connected City
Solve the following coding problem using the programming language python: Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the ...
```python import math,sys,bisect,heapq from collections import defaultdict,Counter,deque from itertools import groupby,accumulate #sys.setrecursionlimit(200000000) int1 = lambda x: int(x) - 1 #def input(): return sys.stdin.readline().strip() input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__ ilele = l...
vfc_70605
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n&gt;&lt;&gt;\nv^v\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6\n&lt;&gt;&lt;&gt;\nv^v^v^\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
499_B. Lecture
Solve the following coding problem using the programming language python: You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes. You know two languages, and the professor is giving the lecture in the first one. The words in ...
```python l = [int(x) for x in input().split()] n = l[0] m = l[1] dic = {} for i in range(0, m): lis = [x for x in input().split()] if len(lis[1]) < len(lis[0]): dic[lis[0]] = lis[1] dic[lis[1]] = lis[1] else: dic[lis[0]] = lis[0] dic[lis[1]] = lis[0] lis1 = [x for x in input...
vfc_70609
{ "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 3\ncodeforces codesecrof\ncontest round\nletter message\ncodeforces contest letter contest\n", "output": "codeforces round letter round ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3...
code_contests
verifiable_code
522_C. Chicken or Fish?
Solve the following coding problem using the programming language python: Polycarp is flying in the airplane. Finally, it is his favorite time — the lunchtime. The BerAvia company stewardess is giving food consecutively to all the passengers from the 1-th one to the last one. Polycarp is sitting on seat m, that means,...
```python t = int(input()) for j in range(t): e = input() m, k = map(int, input().split()) arr = [int(i) for i in input().split()] sum, bfail = [0] * k, [0] * k ffail, undef = -1, 0 used = [False] * k ubfail = 0 for i in range(m - 1): c, ns = map(int, input().split()) if ...
vfc_70613
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n\n3 4\n2 3 2 1\n1 0\n0 0\n\n5 5\n1 2 1 3 1\n3 0\n0 0\n2 1\n4 0\n", "output": "YNNY\nYYYNY\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n\n2 1\n42\n0 0\n\n2 1\n2\n0 0\n\n2 1\n42\n1 ...
code_contests
verifiable_code
549_E. Sasha Circle
Solve the following coding problem using the programming language python: Berlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has n points, Sasha — m. Since their subordinates constantly had conflicts with ...
```python nm = input() nOm = nm.split() n = int(nOm[0]) m = int(nOm[1]) a = b = [] for i in range(0, n): a.append(input()) for i in range(0, m): b.append(input()) if(n == 2 and m == 2 and a[0] == '-1 0') or (n == 2 and m == 3 and a[0] == '-1 0') or (n == 3 and m == 3 and a[0] == '-3 -4') or ( n == 1000 and m == 10...
vfc_70617
{ "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 2\n-1 0\n1 0\n0 -1\n0 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 0\n0 1\n-1 0\n0 -1\n1 1\n-1 1\n-1 -1\n1 -1\n", "output": "YES\n", "type": "st...
code_contests
verifiable_code
575_G. Run for beer
Solve the following coding problem using the programming language python: People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it. Birko lives in city Beergrade, but wants to go to city Beerburg....
vfc_70621
{ "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": "8 10\n0 1 1\n1 2 5\n2 7 6\n0 3 2\n3 7 3\n0 4 0\n4 5 0\n5 7 2\n0 6 0\n6 7 7\n", "output": "32\n3\n0 3 7 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n4 1 0\n1 2 0\n2 4 0\n3 4 0\n3 0...
code_contests
verifiable_code
598_B. Queries on a String
Solve the following coding problem using the programming language python: You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. It means that you should cyclically shift the substring s[li... ri] ki times. The queries should be processed one after ...
```python s = input() for i in range(int(input())): l, r, k = map(int, input().split()) k %= r - l + 1 s = s[:l-1] + s[r-k:r] + s[l-1:r-k] + s[r:] print(s) ```
vfc_70625
{ "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": "abacaba\n2\n3 6 1\n1 4 2\n", "output": "baabcaa\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "u\n1\n1 1 1\n", "output": "u\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
667_B. Coat of Anticubism
Solve the following coding problem using the programming language python: <image> As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore. A famous sculptor Cicasso, whose self-portrait ...
```python n, l = int(input()), list(map(int, input().split())) print(2 * max(l) - sum(l) + 1) ```
vfc_70637
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 1\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
690_B3. Recover Polygon (hard)
Solve the following coding problem using the programming language python: Zombies have found out about the Zombie Contamination level checker and managed to damage it! Now detecting the shape of their main compound will be a real challenge for Heidi. As before, a lair can be represented as a strictly convex polygon on...
vfc_70641
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 19\n2 3 2 4 2 5 3 3 3 5 4 3 4 5 4 6 5 2 5 3 5 6 6 2 6 3 6 4 6 5 6 6 6 7 7 6 7 7\n5 8\n2 2 2 3 2 4 3 2 3 4 4 2 4 3 4 4\n0 0\n", "output": "4\n2 3\n2 4\n6 6\n5 2\n4\n2 2\n2 3\n3 3\n3 2\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
734_B. Anton and Digits
Solve the following coding problem using the programming language python: Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6. Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of t...
```python k2,k3,k5,k6=input().split() k2,k3,k5,k6=int(k2),int(k3),int(k5),int(k6) x=min(k2,k5,k6) #print(x) k2=k2-x k5=k5-x k6=k6-x y=min(k3,k2) print(256*x+32*y) ```
vfc_70649
{ "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 1\n", "output": "256\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 3 4\n", "output": "800\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
758_B. Blown Garland
Solve the following coding problem using the programming language python: Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland. Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required....
```python #in the name of god #Mr_Rubick and sepanta s=input() mp=[0,0,0,0] for i in range(len(s)): m=i%4 if s[i]=='R':r=m if s[i]=='B':b=m if s[i]=='Y':y=m if s[i]=='G':g=m if s[i]=='!':mp[m]=mp[m]+1 print (mp[r],mp[b],mp[y],mp[g]) ```
vfc_70653
{ "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": "!RGYB\n", "output": "0 1 0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "!!!!YGRB\n", "output": "1 1 1 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
779_F. Peterson Polyglot
Solve the following coding problem using the programming language python: Peterson loves to learn new languages, but his favorite hobby is making new ones. Language is a set of words, and word is a sequence of lowercase Latin letters. Peterson makes new language every morning. It is difficult task to store the whole ...
vfc_70657
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 c\n2 3 a\n3 4 t\n2 5 t\n", "output": "3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "16\n1 2 o\n2 3 f\n1 4 p\n4 5 i\n5 6 e\n6 7 c\n7 8 e\n4 9 r\n9 10 e\n10 11 t\n11 12 t\n12 1...
code_contests
verifiable_code
802_N. April Fools' Problem (medium)
Solve the following coding problem using the programming language python: The marmots need to prepare k problems for HC2 over n days. Each problem, once prepared, also has to be printed. The preparation of a problem on day i (at most one per day) costs ai CHF, and the printing of a problem on day i (also at most one ...
```python from collections import deque from heapq import heappop, heappush class Edge(object): __slots__ = ('x', 'y', 'cap', 'cost', 'inv') def __repr__(self): return '{e.x}-->{e.y} ({e.cap} , {e.cost})'.format(e=self) class MCFP(list): def add(G, x, y, cap, cost): n = max(x, y) + 1 ...
vfc_70661
{ "difficulty": "21", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, '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": "10 6\n60 8 63 72 1 100 23 59 71 59\n81 27 66 53 46 64 86 27 41 82\n", "output"...
code_contests
verifiable_code
827_C. DNA Evolution
Solve the following coding problem using the programming language python: Everyone knows that DNA strands consist of nucleotides. There are four types of nucleotides: "A", "T", "G", "C". A DNA strand is a sequence of nucleotides. Scientists decided to track evolution of a rare species, which DNA strand was string s in...
```python import sys range = xrange input = raw_input class segtree: def __init__(s, data): s.n = len(data) s.m = 1 while s.m < s.n: s.m *= 2 s.data = [0]*s.m s.data += data for i in reversed(range(2, s.n + s.m)): s.data[i >> 1] += s.data[i] def add(...
vfc_70665
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "GAGTTGTTAA\n6\n2 3 4 TATGGTG\n1 1 T\n1 6 G\n2 5 9 AGTAATA\n1 10 G\n2 2 6 TTGT\n", "output": "0\n3\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
849_C. From Y to Y
Solve the following coding problem using the programming language python: From beginning till end, this message has been waiting to be conveyed. For a given unordered multiset of n lowercase English letters ("multi" means that a letter may appear more than once), we treat all letters as strings of length 1, and repea...
```python from math import sqrt def readln(): return map(int, input().rstrip().split()) def possible(n): return n * (n + 1) // 2 charset = 'abcdefghijklmnopqrstuvwxyz' ci = 0 n = int(input()) rs = [] while n > 0: for i in range(int(sqrt(n) + 1), 0, -1): if n >= possible(i): n -= possible(i...
vfc_70669
{ "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\n", "output": "aaa", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n", "output": "aaaaabbcc", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
870_F. Paths
Solve the following coding problem using the programming language python: You are given a positive integer n. Let's build a graph on vertices 1, 2, ..., n in such a way that there is an edge between vertices u and v if and only if <image>. Let d(u, v) be the shortest distance between u and v, or 0 if there is no path ...
vfc_70673
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n", "output": " 44\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": " ...
code_contests
verifiable_code
897_E. Willem, Chtholly and Seniorious
Solve the following coding problem using the programming language python: — Willem... — What's the matter? — It seems that there's something wrong with Seniorious... — I'll have a look... <image> Seniorious is made by linking special talismans in particular order. After over 500 years, the carillon is now in bad...
vfc_70677
{ "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": "10 10 7 9\n", "output": "2\n1\n0\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10 9 9\n", "output": "1\n1\n3\n3\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
919_A. Supermarket
Solve the following coding problem using the programming language python: We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to care about...
```python pointer = 0 lst = [0, 0] n, m = list(map(int, input().split())) for i in range(n): a, b = list(map(int, input().split())) if (pointer == 0): lst[0], lst[1] = a, b pointer+=1 if ((m*lst[0])/lst[1]) > ((m*a)/b): lst[0], lst[1] = a, b print((m*lst[0])/lst[1]) ```
vfc_70681
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n99 100\n98 99\n", "output": "0.989898989899\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n1 2\n3 4\n1 3\n", "output": "1.66666666667\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
940_F. Machine Learning
Solve the following coding problem using the programming language python: You come home and fell some unpleasant smell. Where is it coming from? You are given an array a. You have to answer the following queries: 1. You are given two integers l and r. Let ci be the number of occurrences of i in al: r, where al: r...
vfc_70685
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 4\n1 2 3 1 1 2 2 2 9 9\n1 1 1\n1 2 8\n2 7 1\n1 2 8\n", "output": "2\n3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 3\n1 2 3 1 1 2 2 2 9 9\n1 1 1\n1 2 8\n2 7 1\n1 2 8\n", ...
code_contests
verifiable_code
96_C. Hockey
Solve the following coding problem using the programming language python: Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s...
```python n= int(input())#how many word b = [] for i in range(n): b.append(input())# put the word in a list w = input()#what we whant to change let = input()#which we change in to bad=[] for i in range(len(w)): bad.append(True) for i in range(len(w)): mx = 0 for j in range(n): if w[i:].lower()...
vfc_70689
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nbers\nucky\nelu\nPetrLoveLuckyNumbers\nt\n", "output": "PetrLovtTttttNumtttt\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\naCa\ncba\nabAcaba\nc\n", "output": "abCacba\n", ...
code_contests
verifiable_code
994_C. Two Squares
Solve the following coding problem using the programming language python: You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect. The interior of the square is considered to be part of the squar...
```python mp=[[0 for i in range(205)]for j in range(205)] ax1,ay1,ax2,ay2,ax3,ay3,ax4,ay4=map(int,input().split()) bx1,by1,bx2,by2,bx3,by3,bx4,by4=map(int,input().split()) ax1+=100;ay1+=100;ax2+=100;ay2+=100;ax3+=100;ay3+=100;ax4+=100;ay4+=100 bx1+=100;by1+=100;bx2+=100;by2+=100;bx3+=100;by3+=100;bx4+=100;by4+=100 x1=m...
vfc_70693
{ "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 6 0 6 6 0 6\n7 3 9 5 11 3 9 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0 6 0 6 6 0 6\n1 3 3 5 5 3 3 1\n", "output": "YES\n", "type": "stdin_stdou...
code_contests
verifiable_code
avoid-boredom
Solve the following coding problem using the programming language python: Exams are approaching soon and everyone tries to get ready for them. So, Omar decides to begin studying his subjects. He has N subjects and he wants to study M of them today. According to Omar, every subject has an interest level, A_i which ind...
```python for t in xrange(input()): n,m = map( int, raw_input().split() ) arr = map( int, raw_input().split() ) a = [ [0 for j in xrange(n)] for i in xrange(m) ] if m == 1 : print 0 continue for j in xrange(n): a[0][j] = 0 for i in xrange(1,m): for j in xrange(i): a[i][j] = - (1L<<62) for j in ...
vfc_70697
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 3\n100 50 3000 4000 40\n\nSAMPLE", "output": "7910", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
dushhera-special
Solve the following coding problem using the programming language python: After the death of Meghnad and Kumbhakaran, Raavan got scared. He used his mind and presented a proposal of a war of numbers instead of Bow and arrows to Ram. According to him, Laxman will select a number N, Raavan has to subtract a number whic...
```python t=int(raw_input()) while t>0: s=raw_input() li=[] li=s.split() p=int(li[0]) k=int(li[1]) for i in range(1,p+1): res=(k+1)*i; print res, print "" t=t-1 ```
vfc_70705
{ "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 4\n2 3\n\nSAMPLE", "output": "5\n4 8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 5000\n50 10000\n50 1", "output": "5001\n10001 20002 30003 40004 50005 60006 70007 80008...
code_contests
verifiable_code
hamming-distance-1
Solve the following coding problem using the programming language python: You all might have heard about hamming distance in Information Theory. The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. It measures the minimum number of error...
```python import sys t=input() while t>0: s=sys.stdin.readline().strip().split() s=map(int,s) a,b=s c=a^b print bin(c).count("1") t=t-1 ```
vfc_70709
{ "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 5\n127 126\n\nSAMPLE", "output": "1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n4 5\n127 126\n\nSANPLE", "output": "1\n1\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
lord-vaders-death-star-2
Solve the following coding problem using the programming language python: Darth Vader, the lord of the dark side has created a Death-Star (it can destroy any star). You have to deactivate the Death-star. To deactivate the death-star one must find the unique most powerful Lightsaber. Lightsaber’s power is associated w...
```python from collections import Counter n=input() l=map(int,raw_input().split()) c=Counter(l) flag=[-1] for key in c: if(c[key]==1): flag.append(key) print max(flag) ```
vfc_70713
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n9 8 8 9 5\n\nSAMPLE", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n9 8 8 9 5\n\nELPMAS", "output": "5\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
mystery-5-1
Solve the following coding problem using the programming language python: Solve the Mystery. Note There is partial marking for this question. Input The first line of each test file contains a single integer T. Then T lines follow. Each line contains a string of lowercase characters Output For each test case outp...
```python t=int(raw_input()) b=[] while t>0: x={} s=raw_input() for i in s: if i not in x: x[i]=1 else: x[i]+=1 b.append(max(x.values())) t-=1 for i in b: print i ```
vfc_70717
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naabbbcc\nppxxyz\nabcdef\n\nSAMPLE", "output": "3\n2\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
problem-1-8
Solve the following coding problem using the programming language python: Steve Jobs' ghost has come down to BITS Pilani Hyderabad Campus, since he has heard a lot about the coding culture here. Hoping to recruit talented people to work on top-secret Apple software, he keeps a strict coding test. Apple is currently w...
```python w=raw_input() n=input() l=list() for i in range(0,n): a=raw_input() l.append(a) le=0 s=-1 for j in range(0,n): if w==str(l[j]): s=j break if(str(l[j]).find(w,0,len(l[j]))==0): if(le==0): le=len(str(l[j])) s=j else: if(le>len(l[j])): le=len(l[j]); s=j if s==-1: print w els...
vfc_70721
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "find\n4\nfind\nfindfirstof\nfindit\nf", "output": "find\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "next\n2\nnextpermutation\nnextelement\n\nSAMPLE", "output": "nextelement\n", ...
code_contests
verifiable_code
second
Solve the following coding problem using the programming language python: Captain Jack loves tables. He wants to know whether you love tables or not. So he asks you to solve the following problem: Given an array A and element m, you have to find the value up to which table of m is present in the array. (example - if t...
```python n,m=map(int,raw_input().split()) lst=map(int,raw_input().split()) lst=set(lst) if m not in lst: print 0 else: i=2 while 1: if m*i in lst: i+=1 else: break print m*(i-1) ```
vfc_70725
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 2\n3 4 5 2 4 7 10 6\n\nSAMPLE", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
terrible-chandu
Solve the following coding problem using the programming language python: Chandu is a bad student. Once his teacher asked him to print the reverse of a given string. He took three hours to solve it. The teacher got agitated at Chandu and asked you the same question. Can you solve it? Input: The first line contains a...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' lst=[] no=int(raw_input()) for i in range(0,no): a=raw_input() a=a[::-1] lst.append(a) for word in lst: print word ```
vfc_70729
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nab\naba\n\nSAMPLE", "output": "ba\naba\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\na\naa\naaa\nabcdefghijklmnopqrstuvwxyz\nababababababa", "output": "a\naa\naaa\nzyxwvutsrq...
code_contests
verifiable_code
wonderful-sequence
Solve the following coding problem using the programming language python: A sequence of integers is called a wonderful sequence if all the integers in it are positive and it is a strictly increasing sequence. Given a sequence of integers, you have to make it a wonderful sequence. For that you can change any element y...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t = int(raw_input()) while t>0: n = int(raw_input()) arr = [int(i) for i in raw_input().split()] count = 0 if arr[0]>arr[1]: arr[0]= arr[1]-1 count+=1 if arr[0]<0: ...
vfc_70733
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n1 2\n3\n3 2 1\n5\n10 5 6 7 8\n\nSAMPLE", "output": "0\n2\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p03970 CODE FESTIVAL 2016 qual B - Signboard
Solve the following coding problem using the programming language python: CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct l...
```python s = input() t = 'CODEFESTIVAL2016' ans = 0 for i, j in zip(s, t): if i != j: ans += 1 print(ans) ```
vfc_70773
{ "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": "C0DEFESTIVAL2O16", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "FESTIVAL2016CODE", "output": "16", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p00059 Intersection of Rectangles
Solve the following coding problem using the programming language python: There are two rectangles whose bases are parallel to the x-axis. Read the lower left coordinates (xa1, ya1) and upper right coordinates (xa2, ya2) of rectangle A, the lower left coordinates (xb1, yb1) and upper right coordinates (xb2, yb2) of re...
```python import sys for x in sys.stdin: a,b,c,d,e,f,g,h=map(float,x.split()) print(['YES','NO'][c<e or g<a or d<f or h<b]) ```
vfc_70777
{ "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": "0.0 0.0 5.0 5.0 1.0 1.0 4.0 4.0\n0.0 0.0 4.0 5.0 1.0 1.0 5.0 5.0\n0.0 0.0 4.0 4.0 -3.0 -5.0 2.0 -1.0", "output": "YES\nYES\nNO", "type": "stdin_stdout" }, { "fn_name": null, "input": "0.0 0.0 5.0 5.0...
code_contests
verifiable_code
p00541 Rampart
Solve the following coding problem using the programming language python: Wall (Rampart) Historian Professor JOI is studying the once-existing Kingdom of IOI. According to past research, the IOI Kingdom was in the shape of a rectangle divided into squares with H rows and W columns. The capital of the IOI kingdom was...
vfc_70789
{ "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": "5 5 3 2\n2 2\n4 3", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 6 2\n2 2\n4 3", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p00705 When Can We Meet?
Solve the following coding problem using the programming language python: The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to...
```python from collections import defaultdict def main(n, m): d = defaultdict(int) for _ in range(n): M = list(map(int, input().split())) for num, i in enumerate(M): if num == 0: continue d[i] += 1 ans = 10**20 for key, value in d.items(): if value > m: ...
vfc_70793
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n2 1 4\n0\n3 3 4 8\n3 2\n4 1 5 8 9\n3 2 5 9\n5 2 4 5 7 9\n3 3\n2 1 4\n3 2 5 9\n2 2 4\n3 3\n2 1 2\n3 1 2 9\n2 2 4\n0 0", "output": "4\n5\n0\n2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00844 Shy Polygons
Solve the following coding problem using the programming language python: You are given two solid polygons and their positions on the xy-plane. You can move one of the two along the x-axis (they can overlap during the move). You cannot move it in other directions. The goal is to place them as compactly as possible, su...
vfc_70797
{ "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": "10.5235\n3\n0 0\n100 100\n0 100\n4\n0 50\n20 50\n20 80\n0 80\n10.0\n4\n120 45\n140 35\n140 65\n120 55\n8\n0 0\n100 0\n100 100\n0 100\n0 55\n80 90\n80 10\n0 45\n10.0\n3\n0 0\n1 0\n0 1\n3\n0 100\n1 101\n0 101\n10.0\n3\n0 0\n1 0\n0 10...
code_contests
verifiable_code
p00976 Ranks
Solve the following coding problem using the programming language python: Ranks A finite field F2 consists of two elements: 0 and 1. Addition and multiplication on F2 are those on integers modulo two, as defined below. | + | 0 | 1 ---|---|--- 0| 0| 1 1| 1| 0 | | $\times$ | 0 | 1 ---|---|--- 0| 0| 0 1| 0| 1 A set...
vfc_70801
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n001\n101", "output": "-0-\n-00", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n001\n001", "output": "++0\n++0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01108 Equivalent Deformation
Solve the following coding problem using the programming language python: Equivalent Deformation Two triangles T1 and T2 with the same area are on a plane. Your task is to perform the following operation to T1 several times so that it is exactly superposed on T2. Here, vertices of T1 can be on any of the vertices of ...
vfc_70805
{ "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": "0 1\n2 2\n1 0\n1 3\n5 2\n4 3\n\n0 0\n0 1\n1 0\n0 3\n0 2\n1 -1\n\n-5 -4\n0 1\n0 15\n-10 14\n-5 10\n0 -8\n\n-110 221\n-731 525\n-555 -258\n511 -83\n-1000 -737\n66 -562\n\n533 -45\n-525 -450\n-282 -667\n-439 823\n-196 606\n-768 -233\n...
code_contests
verifiable_code
p01407 Attack the Moles
Solve the following coding problem using the programming language python: Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well. Today's training is to improve reflexes and memory by performing whac-a-mole many times. I want to hit the moles...
vfc_70813
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 10, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 7 20 90\n55 5 73", "output": "73", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 2 1000 2000\n400 300 1\n600 200 1\n700 800 1\n700 500 1\n900 600 1\n1000 700 1\n1300 900 1\n1400 400 1\n...
code_contests
verifiable_code
p01561 A Two Floors Dungeon
Solve the following coding problem using the programming language python: It was the last day of the summer camp you strayed into the labyrinth on the way to Komaba Campus, the University of Tokyo. The contest has just begun. Your teammates must impatiently wait for you. So you have to escape from this labyrinth as so...
```python from collections import deque import sys def main(): readline = sys.stdin.readline write = sys.stdout.write W, H = map(int, readline().split()) MP = [readline() for i in range(H)] A = [[-1]*W for i in range(H)] B = [[-1]*W for i in range(H)] C = [[0]*W for i in range(H)] SW0 = ...
vfc_70817
{ "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": "6 6\n\n_|A%#\nB#_|#\n^BBa#\nB&A##\n\n2\n\n*|*.#\n.#.|#\n*.**#\n...##\n\n\n*|*.#\n*#.|#\n..**#\n..*##", "output": "21", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 3\n\n%||Aa&#\n\n2\n\n*|...
code_contests
verifiable_code
p01861 Myampus Sequence
Solve the following coding problem using the programming language python: D: Myampus Sequence-Myampus Sequence- story Myanpasuu. I'm a first grader who goes to a school annex in the country. Well, today's class was programming. Everyone was having a hard time, but Matsun's Nini was typing with great momentum. As ex...
vfc_70825
{ "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\n3 5 3\n3\n5 2 3\n3 3 1\n7 1 2", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 5 4\n3\n5 2 3\n3 3 1\n7 1 2", "output": "No\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
p01996 Test
Solve the following coding problem using the programming language python: problem $ M $ students will be tested in a classroom with $ N $ seats in a straight line. Seats are numbered $ 1 \ dots N $ from the front, and $ 1 $ per seat can seat $ 1 $ students. Now each student is sitting in the $ A_1, \ dots, A_M $ sea...
```python n,m = map(int, input().split()) a = list(map(int, input().split())) num = m for i in range(m): if a[i] <= m: num -= 1 print(num) ```
vfc_70829
{ "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": "6 4\n1 4 5 6", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 4\n0 4 5 6", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
p02283 Binary Search Tree I
Solve the following coding problem using the programming language python: Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees....
```python #!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 8 insert 30 insert 88 insert 12 insert 1 insert 20 insert 17 insert 25 print output: in_order + pre_order 1 12 17 20 25 30 88 30 12 1 20 17 25 88 def pre_order(node): if node is not None: print('', node.data, end='') pre_order(nod...
vfc_70837
{ "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": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint", "output": "1 12 17 20 25 30 88\n 30 12 1 20 17 25 88", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\...
code_contests
verifiable_code
cdva1501
Solve the following coding problem using the programming language python: Given a sequence of natural numbers . Find it's N'th term. a1=3, a2=9, a3=30, a4=101, a5=358, a6=1443... ...,aN Input Single line containing a natural number N Output Print N'th term of the sequence modulo 10^9+7. Constraints 1 <= N <=10...
```python import math n=input() s=math.factorial(n)+3**n-n print (s%(10**9+7)) ```
vfc_70845
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5", "output": "358", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
date
Solve the following coding problem using the programming language python: These days a lot of new coders are emerging at RJIT. One of the many programmers in RJIT thought of making a program to find the weekday for any given date. He successfully builds it but there is one problem, his program prints the day of yeste...
```python NonLeap_Months=[31,28,31,30,31,30,31,31,30,31,30,31] Leap_Months=[31,29,31,30,31,30,31,31,30,31,30,31] def is_leap(year): if(year%400==0): return 1 elif(year%100==0): return 0 elif(year%4==0): return 1 else: return 0 T=raw_input().strip('\n') T=int(T) for _ in xrange(T): ...
vfc_70849
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n16/09/2014\n17/09/2014\n5/02/2004", "output": "17/9/2014\n18/9/2014\n6/2/2004", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
ieeet02
Solve the following coding problem using the programming language python: Throughout history there have been many different interesting numbers or types of numbers. One of these types is amicable numbers. Amicable numbers are a pair of numbers with the following property: the sum of all of the proper divisors of the f...
```python import math def sumof(n): sq,su=int(math.sqrt(n)),0 for i in xrange (2,sq+1): if n%i==0: su+=i+((n/i) if i*i!=n else 0) else: continue return su+1 t=int(raw_input()) for i in xrange(t): n=int(raw_input()) s1=sumof(n) s2=sumof(s1) if s2==n: print 'Yes, amicable with %d' %s1 else: print 'N...
vfc_70853
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1184\n2620\n3550\n5020", "output": "Yes, amicable with 1210\nYes, amicable with 2924\nNo\nYes, amicable with 5564", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1712\n2620\n3550\n5020...
code_contests
verifiable_code
mtrick
Solve the following coding problem using the programming language python: Vidhi went to a magic show last week where she was astounded by a magic trick performed by the great Mandwarf, the brown. His trick was as follows : Ask a volunteer from the audience to write down a list L of N integers. Ask an...
```python #!/usr/bin/env python # coding=utf-8 T = input() for _ in xrange(T): N = input() L = map(int, raw_input().split()) A, B, C = map(int, raw_input().split()) s = raw_input() revcnt = 0 slope = 1 D = 0 offset = 0 for i in xrange(N): if s[i] == 'R': revcnt =...
vfc_70857
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 1 1\n2 3 1000\nARM\n4\n1 2 3 4\n0 1 1000\nAMAM", "output": "3 3 9 \n1 2 3 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n1 1 1\n2 3 1000\nARM\n4\n1 2 3 4\n0 1 1010\nAMAM"...
code_contests
verifiable_code
rotation
Solve the following coding problem using the programming language python: You are given an array A of N integers. You are to fulfill M queries. Each query has one of the following three types: C d : Rotate the array A clockwise by d units. A d : Rotate the array A anticlockwise by d units. R d : Query for the value o...
```python n,m=map(int,raw_input().split()) a=map(int,raw_input().split()) r=0 for q in range(m): z,x=raw_input().split() x=int(x) if (z=='R'): print a[(x-1+r)%n] elif (z=='A'): r=(r-x) else: r=(r+x) ```
vfc_70861
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n5 4 3 3 9\nR 1\nC 4\nR 5\nA 3\nR 2", "output": "5\n3\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n5 4 3 3 9\nR 1\nC 4\nR 5\nA 6\nR 2", "output": "5\n3\n9\n", "t...