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
codeforces
verifiable_code
1005
Solve the following coding problem using the programming language python: You are given two strings $s$ and $t$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $1$. You can't choose a string if it is empty....
string1 = input() string2 = input() same = 0 minn = min(len(string1),len(string2)) for i in range(minn): if string1[-1-i]==string2[-1-i]: same += 2 else: break print((len(string1)+len(string2))-same)
vfc_82921
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "test\nwest", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "codeforces\nyes", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input...
codeforces
verifiable_code
144
Solve the following coding problem using the programming language python: A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all *n* squad soldiers to line up on the parade ground. By the militar...
n = int(input()) lst = list(map(int,input().split())) a=0 b=100 max_ind=0 min_ind=0 for i in range(n): if lst[i]>a: a=lst[i] max_ind = i if lst[i]<=b: b = lst[i] min_ind = i if max_ind<min_ind: print(max_ind+(n-min_ind)-1) else: print(max_ind+((n-min_ind...
vfc_82925
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n33 44 11 22", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n10 10 58 31 63 40 76", "output": "10", "type": "stdin_stdout" }, { "fn_name": null,...
codeforces
verifiable_code
741
Solve the following coding problem using the programming language python: Just to remind, girls in Arpa's land are really nice. Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight *w**i* and some beauty *b**i*. Also each Hos may have some friends. Hoses are divided in some f...
def g(x): if x == t[x]: return x t[x] = g(t[x]) return t[x] f = lambda: map(int, input().split()) hoses, pairOfFriends, weight = f() weightsAndBeauties = [(0, 0)] + list(zip(f(), f())) t = list(range(hoses + 1)) for i in range(pairOfFriends): f1, f2 = f() f1, f2 = g(f1), g(f2) i...
vfc_82929
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1 5\n3 2 5\n2 4 2\n1 2", "output": "6", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
710
Solve the following coding problem using the programming language python: The only king stands on the standard chess board. You are given his position in format "cd", where *c* is the column from 'a' to 'h' and *d* is the row from '1' to '8'. Find the number of moves permitted for the king. Check the king's moves her...
from sys import stdin, stdout def read(): return stdin.readline().rstrip() def read_int(): return int(read()) def read_ints(): return list(map(int, read().split())) def solve(): a=read() c=0 if a[0]=='a' or a[0]=='h': c+=1 if a[1]=='1' or a[1]=='8': c+=1 if c==0: print(8) elif c==1: print(5) else: ...
vfc_82933
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "e4", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "a1", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "h8", "outpu...
codeforces
verifiable_code
807
Solve the following coding problem using the programming language python: Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each par...
t = int(input()) left = [] right = [] for i in range(t): x , y = input().split() x , y = int(x) , int(y) left.append(x) right.append(y) if left != right :print('rated') elif left == right and sorted(left , reverse=True) != left and sorted(right , reverse=True) != right:print('unrated') else:...
vfc_82937
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "...
codeforces
verifiable_code
379
Solve the following coding problem using the programming language python: Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has *a* candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make *b* we...
a,b=map(int,input().split()) c=int(a-1)/(b-1) print(int(a+c))
vfc_82941
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000 1000", ...
codeforces
verifiable_code
593
Solve the following coding problem using the programming language python: The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of *n* lines defined by the equations *y*<==<=*k**i*·*x*<=+<=*b**i*. It was nece...
n = int(input()) a = list() x1, x2 = map(int, input().split()) for i in range(n): k, b = map(int, input().split()) y1 = k * x1 + b y2 = k * x2 + b a.append((y1, y2)) a.sort() fl = 'NO' y1m = a[0][0] y2m = a[0][1] for y1, y2 in a: if y2 < y2m: fl = 'YES' else: y2m ...
vfc_82945
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2\n1 2\n1 0\n0 1\n0 2", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 3\n1 0\n-1 3", "output": "YES", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
702
Solve the following coding problem using the programming language python: You are given array consisting of *n* integers. Your task is to find the maximum length of an increasing subarray of the given array. A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element...
n = int (input()) current = 1 max = 1 x = list(map(int,input().split())) for i in range(n-1): # 0 1 2 3 4 if x[i+1] > x[i]: # 1 7 2 11 15 current = current +1 else: current=1 if max<current:max=current print (max)
vfc_82949
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 7 2 11 15", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
152
Solve the following coding problem using the programming language python: One day little Vasya found mom's pocket book. The book had *n* names of her friends and unusually enough, each name was exactly *m* letters long. Let's number the names from 1 to *n* in the order in which they are written. As mom wasn't home, V...
if __name__ == "__main__": modulo=10**9+7 n,m=map(int,input().split()) names=[] for i in range(n): names.append(input().strip()) res=1 for j in range(m): unique_col_char_count=0 tmp_arr=[] for i in range(n): if names[i][j] not in tmp...
vfc_82953
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\nAAB\nBAA", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\nABABA\nBCGDG\nAAAAA\nYABSA", "output": "216", "type": "stdin_stdout" }, { "fn_name...
codeforces
verifiable_code
799
Solve the following coding problem using the programming language python: In some game by Playrix it takes *t* minutes for an oven to bake *k* carrot cakes, all cakes are ready at the same moment *t* minutes after they started baking. Arkady needs at least *n* cakes to complete a task, but he currently don't have any....
n, t, k, d = map(int, input().split()) g = int((n + k - 1) / k) o1, o2 = 0, d i = 0 while i < g: if o1 <= o2: o1 += t else: o2 += t i += 1 if max(o1, o2) < g * t: print("YES") else: print("NO")
vfc_82957
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 6 4 5", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 6 4 6", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 3...
codeforces
verifiable_code
909
Solve the following coding problem using the programming language python: The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there ...
def getprfx(s): tab = [s[0]] for i in range(1, len(s)): x = tab[i-1] + s[i] tab.append(x) return tab n, m = input().split() a, b = getprfx(n), getprfx(m) mn = a[0] + b[0] for i in a: for j in b: if i+j < mn: mn = i+j print(mn)
vfc_82961
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "harry potter", "output": "hap", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
112
Solve the following coding problem using the programming language python: Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does n...
s1 = input().lower() s2 = input().lower() if s1==s2: print(0) if s1<s2: print(-1) if s1>s2: print(1)
vfc_82965
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "aaaa\naaaA", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "abs\nAbz", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "ab...
codeforces
verifiable_code
620
Solve the following coding problem using the programming language python: Professor GukiZ makes a new robot. The robot are in the point with coordinates (*x*1,<=*y*1) and should go to the point (*x*2,<=*y*2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase...
x1, y1 = list(map(int, input().split())) x2, y2 = list(map(int, input().split())) print(max(abs(x1-x2), abs(y1-y2)))
vfc_82969
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0\n4 5", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n6 1", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0\n...
codeforces
verifiable_code
436
Solve the following coding problem using the programming language python: Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all. The park can be represented as ...
import sys input = sys.stdin.readline n, m, k = map(int, input().split()) g = [input()[:-1] for _ in range(n)] d = [0]*m for i in range(1, n): for j in range(m): if g[i][j] == 'R': if j + i < m: d[j+i] += 1 elif g[i][j] == 'L': if j - i >= 0: ...
vfc_82973
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "5000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 4\n...\nR.L\nR.U", "output": "0 2 2 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 2\n..\nRL", "output": "1 1 ", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
26
Solve the following coding problem using the programming language python: A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and *n*, inclusive. The input...
def count_primes(num): #does not consider num as a prime number count = 0 for divisor in range(2, int(num**0.5)+1): if num % divisor == 0: count += 1 while num % divisor == 0: num /= divisor if num > 1: count += 1 #num itself is prime return count ...
vfc_82977
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "5000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "21", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "1", "output...
codeforces
verifiable_code
740
Solve the following coding problem using the programming language python: Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one c...
n, a, b, c = map(int, input().split()) to_buy = (4 - (n % 4)) % 4 b = min(a * 2, b) c = min(a * 3, a + b, c) # possibilities: if to_buy == 3: print(min(3*a, a+b, c)) elif to_buy == 2: print(min(2*a, b, 2*c)) elif to_buy == 1: print(min(a, b+c, 3*c)) else: print(0)
vfc_82981
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 3 4", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
673
Solve the following coding problem using the programming language python: Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks. Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV ...
n=int(input()) tl = list(map(int, input().split())) time=cnt=0 while cnt <15 and time<90: time+=1 if tl.count(time)>0: cnt=0 else: cnt+=1 print(time)
vfc_82985
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n7 20 88", "output": "35", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n16 20 30 40 50 60 70 80 90", "output": "15", "type": "stdin_stdout" }, { "fn_name": nu...
codeforces
verifiable_code
305
Solve the following coding problem using the programming language python: A continued fraction of height *n* is a fraction of form . You are given two rational numbers, one is represented as and the other one is represented as a finite fraction of height *n*. Check if they are equal. The input will be provided via s...
from fractions import gcd p,q=map(int,input().split()) gc=gcd(p,q) p//=gc q//=gc n=int(input()) a=list(map(int,input().split())) def add(a,b): res=[] a[0]*=b[1] b[0]*=a[1] temp=b[1]*a[1] top=a[0]+b[0] gc=gcd(top,temp) temp//=gc top//=gc; res.append(top) res.append(temp) retur...
vfc_82989
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "500" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 4\n2\n2 4", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 4\n3\n2 3 1", "output": "YES", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
665
Solve the following coding problem using the programming language python: zscoder loves simple strings! A string *t* is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple. zscoder is given a string *s*. He wants to change a minimum n...
s=list(input()+'a') for i in range(len(s)-2): if s[i]==s[i+1]: s[i+1]=list({'a', 'b', 'c'}-{s[i]}-{s[i+2]})[0] print(''.join(s[:-1]))
vfc_82993
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "aab", "output": "bab", "type": "stdin_stdout" }, { "fn_name": null, "input": "caaab", "output": "cabab", "type": "stdin_stdout" }, { "fn_name": null, "input": "zscoder...
codeforces
verifiable_code
689
Solve the following coding problem using the programming language python: While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the...
n = input() s = set(map(int,input())) if all(map(lambda x: x&s!=set(),({1,4,7,0},{3,6,9,0},{7,0,9},{1,2,3}))): print("YES") else: print("NO")
vfc_82997
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n586", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n09", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n12345...
codeforces
verifiable_code
39
Solve the following coding problem using the programming language python: Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much. One can get to the shore only by hills that are situated along a straight line that connects the little i...
n, m, k = map(int, input().split()) x, y = n, [] a = map(int, input().split()) b = list(map(int, input().split())) for i, d in enumerate(a): c = 0 for t in b: if 0 == t % d: c += 1 if c < x: x = c y = [i + 1] elif c == x: y += i + 1, print(len(y)...
vfc_83001
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 5\n2 3 4\n1 2 3 4 5", "output": "2\n2 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000000000 2 3\n2 5\n999999995 999999998 999999996", "output": "1\n2", "type": "stdin_...
codeforces
verifiable_code
612
Solve the following coding problem using the programming language python: You are given the string *s* of length *n* and the numbers *p*,<=*q*. Split the string *s* to pieces of length *p* and *q*. For example, the string "Hello" for *p*<==<=2, *q*<==<=3 can be split to the two strings "Hel" and "lo" or to the two st...
n, p, q = map(int, input().split()) s = input() if p > q: p, q = q, p for i in range(0, n + 1, q): if (n - i) % p == 0: print(i // q + (n - i) // p) for j in range(0, i, q): print(s[j:j + q]) for j in range(i, n, p): print(s[j:j + p]) exit(0) p...
vfc_83005
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "4000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 3\nHello", "output": "2\nHe\nllo", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 9 5\nCodeforces", "output": "2\nCodef\norces", "type": "stdin_stdout" }, { "...
codeforces
verifiable_code
542
Solve the following coding problem using the programming language python: Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1,<=2,<=...,<=*n*} is such function , that for any the formula *g*(*g*(*x*))<==<=*g*(*x*) holds. Let's denote as *f*(*k*)(*x*) the function *f* a...
N =int(input()) inp =input().split() F =[0 for i in range(N)] for i in range(N): F[i] =int(inp[i])-1 ans_small =[0 for i in range(N+1)] for i in range(N): x =i y =i for j in range(N): x =F[x] y =F[F[y]] if x == y: ans_small[j+1] +=1 ans =-1 for i in range(1,N+1): if ans == -1: if ans_...
vfc_83009
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 2 4", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 3 3", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n...
codeforces
verifiable_code
637
Solve the following coding problem using the programming language python: After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the ph...
# -*- coding: utf-8 -*- """ Created on Sun Mar 13 19:40:03 2016 @author: Kostya S. """ from functools import cmp_to_key n = int(input()) d = {} a = [int(i) for i in input().split()] for i,e in enumerate(a): d[e] = (i+1,1,e) if d.get(e) == None else (i+1,d[e][1] + 1,e) t1 = sorted(list(d.values()),key =...
vfc_83013
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 2 2 1", "output": "2", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
908
Solve the following coding problem using the programming language python: Your friend has *n* cards. You know that each card has a lowercase English letter on one side and a digit on the other. Currently, your friend has laid out the cards on a table so only one side of each card is visible. You would like to know ...
from sys import stdin, stdout def need_to_check(card, vowels=['a','e','i','o','u']): return (ord(card) >= ord('0') and ord(card) <= ord('9') and int(card) % 2 == 1) or (card in vowels) def number_of_reveals(cards): count = 0 for card in cards: count = count+1 if need_to_check(card) else count ...
vfc_83017
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ee", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "z", "output": "0", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
625
Solve the following coding problem using the programming language python: A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000. This new device is equip...
# Description of the problem can be found at http://codeforces.com/problemset/problem/625/B x = input() s = input() print(x.count(s))
vfc_83021
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "intellect\ntell", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "google\napple", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "in...
codeforces
verifiable_code
227
Solve the following coding problem using the programming language python: Trouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point *C* and began to terrorize the residents of the surrounding villages. A brave hero decided to put an end to the dragon. He moved from poin...
xa,ya = input().split() xa = int(xa) ya = int(ya) xb,yb = input().split() xb = int(xb) yb = int(yb) xc,yc = input().split() xc = int(xc) yc = int(yc) vab_x = xb-xa vab_y = yb-ya vbc_x = xc - xb vbc_y = yc - yb produto_vetorial = (vab_x * vbc_y) - (vab_y * vbc_x) if(produto_vetorial == 0): ...
vfc_83025
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0\n0 1\n1 1", "output": "RIGHT", "type": "stdin_stdout" }, { "fn_name": null, "input": "-1 -1\n-3 -3\n-4 -4", "output": "TOWARDS", "type": "stdin_stdout" }, { "fn_name": n...
codeforces
verifiable_code
340
Solve the following coding problem using the programming language python: Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are *n* destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The *n* destinations are described ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 3 11:57:46 2020 @author: shailesh """ from math import gcd def reduce_fraction(x,y): d = gcd(x,y) x = x//d y = y//d return x,y N = int(input()) A = [int(i) for i in input().split()] A.sort() d0 = A[0] sum_val = 0 for i in r...
vfc_83029
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3 5", "output": "22 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 5 77 2", "output": "547 4", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
codeforces
verifiable_code
1006
Solve the following coding problem using the programming language python: Mishka got an integer array $a$ of length $n$ as a birthday present (what a surprise!). Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This...
n = int(input()) a = [int(s) for s in input().split(' ')] b = [str(c - ((c + 1) % 2)) for c in a] print(' '.join(b))
vfc_83033
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 4 5 10", "output": "1 1 3 5 9", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000", "output": "9999 9 50605065 1 5 89 5 ...
codeforces
verifiable_code
805
Solve the following coding problem using the programming language python: In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick. He is too selfish, so for a given *n* he wants to obtain a string of *n* characters, each of which is either 'a', ...
n = int(input()) s = 'bbaa' * (n // 4 + 1) s = s[:n] print(s)
vfc_83037
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2", "output": "aa", "type": "stdin_stdout" }, { "fn_name": null, "input": "3", "output": "aab", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
242
Solve the following coding problem using the programming language python: A coordinate line has *n* segments, the *i*-th segment starts at the position *l**i* and ends at the position *r**i*. We will denote such a segment as [*l**i*,<=*r**i*]. You have suggested that one of the defined segments covers all others. In ...
n=int(input()) L=[] aG=0; mini = 1000000000 maxi = -1000000000; for i in range(0,n): a=input().rstrip().split(' ') L.append(a) if int(a[0])<=mini and int(a[1])>=maxi: G=int(a[0]); H=int(a[1]); S=i; mini = int(a[0]) maxi = int(a[1]) #print(S,mini,maxi) f...
vfc_83041
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n2 2\n3 3", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 5\n2 3\n1 10\n7 10\n7 7\n10 10", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
946
Solve the following coding problem using the programming language python: You are given a sequence *a* consisting of *n* integers. You may partition this sequence into two sequences *b* and *c* in such a way that every element belongs exactly to one of these sequences. Let *B* be the sum of elements belonging to *b*...
n = int(input()) b, c = 0, 0 for i in map(int, input().split()): if i < 0: c += i else: b += i print(b - c)
vfc_83045
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 -2 0", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n16 23 16 15 42 8", "output": "120", "type": "stdin_stdout" }, { "fn_name": null, "...
codeforces
verifiable_code
988
Solve the following coding problem using the programming language python: There are $n$ students in a school class, the rating of the $i$-th student on Codehorses is $a_i$. You have to form a team consisting of $k$ students ($1 \le k \le n$) such that the ratings of all team members are distinct. If it is impossible ...
n,k=map(int,input().split()) l=list(map(int,input().split())) s=set() for i in range(len(l)): s.add(l[i]) l1=[i for i in s] l2=[] if len(s)>=k: print("YES") for i in range(k): if(l1[i] in l): l2.append(l.index(l1[i])+1) l2.sort() for i in range(len(l2)): pri...
vfc_83053
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n15 13 15 15 12", "output": "YES\n1 2 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n15 13 15 15 12", "output": "NO", "type": "stdin_stdout" }, { "fn_n...
codeforces
verifiable_code
544
Solve the following coding problem using the programming language python: A map of some object is a rectangular field consisting of *n* rows and *n* columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly *k* islands appear on the map. We will call a s...
import sys input = sys.stdin.readline read_tuple = lambda _type: map(_type, input().split(' ')) def solve(): n, k = read_tuple(int) grid = [['S' for _ in range(n)] for _ in range(n)] flag = True for i in range(n): for j in range(n): if k and flag: grid[i...
vfc_83057
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2", "output": "YES\nSSSSS\nLLLLL\nSSSSS\nLLLLL\nSSSSS", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 25", "output": "NO", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
793
Solve the following coding problem using the programming language python: Oleg the bank client checks share prices every day. There are *n* share prices he is interested in. Today he observed that each second exactly one of these prices decreases by *k* rubles (note that each second exactly one price changes, but at d...
import math n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() r=a[0]%k;t=0 for i in range(1,n): if a[i]%k!=r: print(-1) break else: t+=(a[i]-a[0])//k else: print(t)
vfc_83061
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n12 9 15", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n10 9", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
codeforces
verifiable_code
552
Solve the following coding problem using the programming language python: Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right. In this table, Vanya chose *n* rectangles wit...
def solve(x1, y1, x2, y2): return sum((x2[i] - x1[i] + 1) * (y2[i] - y1[i] + 1) for i in range(len(x1))) def main(): n = int(input()) x1 = [] y1 = [] x2 = [] y2 = [] for _ in range(n): x1_i, y1_i, x2_i, y2_i = map(int, input().split()) x1.append(x1_i) ...
vfc_83065
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "4000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1 2 3\n2 2 3 3", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1 3 3\n1 1 3 3", "output": "18", "type": "stdin_stdout" }, { "fn_name": nul...
codeforces
verifiable_code
831
Solve the following coding problem using the programming language python: Array of integers is unimodal, if: - it is strictly increasing in the beginning; - after that it is constant; - after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed ...
# -*- coding: utf-8 -*- """831.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1hYxPSks58iBj6lqO-ZFgsg_7bcRbm3l3 """ #https://codeforces.com/contest/831/problem/A Unimodal Array a=int(input()) b=list(map(int,input().split())) i=1 while i<a and ...
vfc_83069
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 5 5 5 4 2", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n10 20 30 20 10", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
262
Solve the following coding problem using the programming language python: Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers. Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47...
[n, k] = [int(x) for x in input().split()] L = [x for x in input().split()] c = 0 for i in L: if i.count('4') + i.count('7') <= k: c += 1 print(c)
vfc_83073
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n1 2 4", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n447 44 77", "output": "2", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
158
Solve the following coding problem using the programming language python: After the lessons *n* groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the *i*-th group consists of *s**i* friends (1<=≤<=*s**i*<=≤<=4), and they want to go to Polycarpus together. The...
def min_taxis(groups): counts = [groups.count(i) for i in range(1, 5)] return counts[3] + counts[2] + (counts[1]*2 + max(0, counts[0] - counts[2]) + 3) // 4 # Пример использования n = int(input()) groups = list(map(int, input().split())) result = min_taxis(groups) print(result)
vfc_83077
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 4 3 3", "output": "4", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
592
Solve the following coding problem using the programming language python: Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess». This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some blac...
grid = [] for k in range(8): grid.append(input()) bbc = [] #blocked black columns bwc = [] #blocked white columns #first processing : downwards white = 8 for k in range(8): for j in range(8): if grid[k][j] == "B": bbc.append(j) if grid[k][j] == "W" and not j in bbc and white == 8...
vfc_83081
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": ".BB.B.B.\nB..B..B.\n.B.BB...\nBB.....B\nBBB....B\nB..BB...\nBB.B...B\n....WWW.", "output": "B", "type": "stdin_stdout" }, { "fn_name": null, "input": "B.B.BB.B\nW.WWW.WW\n.WWWWW.W\nW.BB.WBW\n.W..BBWB...
codeforces
verifiable_code
732
Solve the following coding problem using the programming language python: Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for *k* burles. Assume that there is an unlimited number of such shovels in the shop. In his pocket Polycarp has an ...
inp = input().split() inp = [int(x) for x in inp] a=0 for i in range(15): if(i>0): if(inp[0]%10==0 or (inp[0]-inp[1])%10==0 or ((inp[0]*i)-inp[1])%10==0 or (inp[0]*i)%10==0):# : a=i break print(a)
vfc_83089
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "117 3", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input": "237 7", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "15 2", ...
codeforces
verifiable_code
441
Solve the following coding problem using the programming language python: Valera is a collector. Once he wanted to expand his collection with exactly one antique item. Valera knows *n* sellers of antiques, the *i*-th of them auctioned *k**i* items. Currently the auction price of the *j*-th object of the *i*-th seller...
a,b=map(int,input().split());k=[] for i in range(1,a+1): c,*d=map(int,input().split()) if min(d)<b:k+=[i] print(len(k),"\n",*k)
vfc_83093
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 50000\n1 40000\n2 20000 60000\n3 10000 70000 190000", "output": "3\n1 2 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 50000\n1 50000\n3 100000 120000 110000\n3 120000 110000 120000",...
codeforces
verifiable_code
10
Solve the following coding problem using the programming language python: Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes *P*1 watt per minute. *T*1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver star...
n, P1, P2, P3, T1, T2=map(int,input().split()) s=0 for i in range(n): l,r=map(int,input().split()) if i==0: t=l if T1>=(l-t): s+=(l-t)*P1 else: s+=T1*P1 if T2>=(l-T1-t): s+=(l-T1-t)*P2 else: s+=T2*P2 s+=(l-T1-T2-t)...
vfc_83097
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 3 2 1 5 10\n0 10", "output": "30", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 8 4 2 5 10\n20 30\n50 100", "output": "570", "type": "stdin_stdout" }, { "fn_na...
codeforces
verifiable_code
725
Solve the following coding problem using the programming language python: A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the l...
c=input();n,s,d=int(c[:-1]),c[-1],{'a':4,'b':5,'c':6,'d':3,'e':2,'f':1} x=(n//4*2+(n-1)%2-2*(n%4==0))*6+d[s]+n print(x-1 if (n-1)%4<2 else x-3)
vfc_83101
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1f", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2d", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "4a", "outp...
codeforces
verifiable_code
574
Solve the following coding problem using the programming language python: Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland. There are *n* candidates, including Limak. We know how many citizens are going to vote for each candidate. Now *i*-th can...
n=int(input()) arr=list(map(int,input().split())) t=ans=arr.pop(0) mx=max(arr) i=1 while (ans)<=mx: ans+=1 arr.remove(mx) arr.append(mx-1) mx=max(arr) print(ans-t)
vfc_83105
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 1 11 2 8", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 8 8 8", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input":...
codeforces
verifiable_code
266
Solve the following coding problem using the programming language python: There are *n* stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if ...
n = input() n = int(n) stones = input() ans = 0 for i in range(1, n): if stones[i] == stones[i-1]: ans = ans + 1 print(ans)
vfc_83109
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nRRG", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nRRRRR", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nBRBG...
codeforces
verifiable_code
792
Solve the following coding problem using the programming language python: *n* children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to *n*. In the beginning, the first child is considered the leader. The game is played in *k* steps. In the *i*-th step the leader co...
import sys input = sys.stdin.readline n, k = map(int, input().split()) l = sorted(list(range(1, n+1))) c = 0 t = [] for i in [int(j) for j in input().split()]: c = (c+i)%len(l) t.append(l[c]) l = l[:c]+l[c+1:] print(*t)
vfc_83113
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 5\n10 4 11 4 1", "output": "4 2 5 6 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n2 5", "output": "3 2 ", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
412
Solve the following coding problem using the programming language python: The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building. The s...
n,k=map(int,input('').split()) lozung=list(input()) if n-k<k: for i in range(k,n): print('RIGHT') for i in reversed(range(0,n)): print ('PRINT ',lozung[i]) if i!=0:print('LEFT') else: # print('2') for i in reversed(range(0,k-1)): print('LEFT')...
vfc_83117
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\nR1", "output": "PRINT 1\nLEFT\nPRINT R", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
847
Solve the following coding problem using the programming language python: Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last *n* days. Assume that the average air temperature for each day is integral. Vasya believes that if the averag...
n = int(input()) vals = list(map(int,(input().split()))) arith = True diff = vals[0]-vals[1] for i in range(n-1): if vals[i]-vals[i+1]!=diff: arith = False break if arith: print(vals[-1]-diff) else: print(vals[-1])
vfc_83121
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n10 5 0 -5 -10", "output": "-15", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 1 1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "in...
codeforces
verifiable_code
976
Solve the following coding problem using the programming language python: String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001". You are given a correct string *s*. You can perform two different operations on this st...
def solve(): size = input() s = input() print('1' * ('1' in s) + '0' * s.count('0')) if __name__ == "__main__": solve()
vfc_83125
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1001", "output": "100", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n111...
codeforces
verifiable_code
844
Solve the following coding problem using the programming language python: Calculate the minimum number of characters you need to change in the string *s*, so that it contains at least *k* different letters, or print that it is impossible. String *s* consists only of lowercase Latin letters, and it is allowed to chang...
s = input() x = int(input()) if x > len(s): print('impossible') elif x < len(set(s)): print(0) else: print(x - len(set(s)))
vfc_83129
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "yandex\n6", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "yahoo\n5", "output": "1", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
336
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 ...
n=input().split() x,y=int(n[0]),int(n[1]) if x>0 and y>0: print(0,x+y,x+y,0) elif x>0 and y<0: print(0,y-x,x-y,0) elif x<0 and y>0: print(x-y,0,0,y-x) else: print(x+y,0,0,x+y)
vfc_83133
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 5", "output": "0 15 15 0", "type": "stdin_stdout" }, { "fn_name": null, "input": "-10 5", "output": "-15 0 0 15", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
862
Solve the following coding problem using the programming language python: Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go. Dr. Evil is interested in sets, He has a set of *n* integers. Dr....
import sys, os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline n, x = map(int, input().split()) a = list(map(int, input().split())) l = 105 cnt = [0] * l for i in a: cnt[i] += 1 ans = 0 for i in range(x): if not cnt[i]: ans += 1 ans += cnt[x] print(ans)
vfc_83137
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n0 4 5 6 7", "output": "2", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
327
Solve the following coding problem using the programming language python: Iahub got bored, so he invented a game to be played on paper. He writes *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices *i* and *j* (1<=≤<=*i*<=≤...
n = int(input()) a = list(map(int, input().split())) max_ones = 0 for i in range(n): for j in range(i, n): temp = a.copy() for k in range(i, j+1): temp[k] = 1 - temp[k] max_ones = max(max_ones, temp.count(1)) print(max_ones)
vfc_83141
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 0 0 1 0", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 0 0 1", "output": "4", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
962
Solve the following coding problem using the programming language python: Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered from $1$ to $n$, beginning from the first. On the $i$-th day Polycarp will necessarily solve $a_i$ problems. O...
#k=int(input()) #n,m=map(int,input().split()) import sys #a=list(map(int,input().split())) #b=list(map(int,input().split())) import math n=int(input()) a=list(map(int,input().split())) ss=sum(a); s=0 for i in range(n): s+=a[i] if(2*s>=ss): print(i+1) sys.exit()
vfc_83145
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 2 1", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 2 2 2 2 2", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
111
Solve the following coding problem using the programming language python: Little Petya loves inequations. Help him find *n* positive integers *a*1,<=*a*2,<=...,<=*a**n*, such that the following two conditions are satisfied: - *a*12<=+<=*a*22<=+<=...<=+<=*a**n*2<=≥<=*x*- *a*1<=+<=*a*2<=+<=...<=+<=*a**n*<=≤<=*y* The ...
n,x,y=map(int,input().split()) import math an=n-1 if(x<=n-1): if(y>=n): for i in range(n): print(1) else: print(-1) else: me=math.sqrt(x-an) if(me==int(me)): me=int(me) if(me+an<=y): for i in range(n-1): print(1) ...
vfc_83149
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "5000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 15 15", "output": "11\n1\n1\n1\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 2", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
codeforces
verifiable_code
157
Solve the following coding problem using the programming language python: One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that divided the wall into several parts...
# Description of the problem can be found at http://codeforces.com/problemset/problem/157/B import math n = int(input()) l_s = list(map(int, input().split())) l_s.sort(reverse = True) t = 0 for index in range(n): t += (-1 if index % 2 == 1 else 1) * l_s[index] ** 2 print(t * math.pi)
vfc_83153
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1", "output": "3.1415926536", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 4 2", "output": "40.8407044967", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
938
Solve the following coding problem using the programming language python: Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced....
vowels = ['a', 'e', 'i', 'o', 'u', 'y'] def word_correction(s): result = [] result.append(s[0]) left = 0 right = 1 while right < len(s): if not s[left] in vowels or not s[right] in vowels: result.append(s[right]) left = right right += 1 retur...
vfc_83157
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nweird", "output": "werd", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nword", "output": "word", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
codeforces
verifiable_code
13
Solve the following coding problem using the programming language python: Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18. Now he wonders what is an average value of sum of digits o...
N = int(input()) s = 0 def gcd(a, b): while(b): a, b = b, a%b return a for i in range(2, N): n = N while(n>0): s += n%i n = n//i t = gcd(s, N-2) print(str(s//t)+"/"+str((N-2)//t))
vfc_83165
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5", "output": "7/3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
169
Solve the following coding problem using the programming language python: Petya and Vasya are brothers. Today is a special day for them as their parents left them home alone and commissioned them to do *n* chores. Each chore is characterized by a single parameter — its complexity. The complexity of the *i*-th chore eq...
n,a,b= map(int,input().split()) x = list(map(int,input().split())) x.sort() print(x[b]-x[b-1])
vfc_83169
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 3\n6 2 3 100 1", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 3 4\n1 1 9 1 1 1 1", "output": "0", "type": "stdin_stdout" }, { "fn_name": null,...
codeforces
verifiable_code
712
Solve the following coding problem using the programming language python: There are *n* integers *b*1,<=*b*2,<=...,<=*b**n* written in a row. For all *i* from 1 to *n*, values *a**i* are defined by the crows performing the following procedure: - The crow sets *a**i* initially 0. - The crow then adds *b**i* to *a**i...
n=int(input()) v=[int(i) for i in input().split()] b=[v[i]+v[i+1] for i in range(n-1)] b.append(v[-1]) for i in range(n): print(b[i],end=" ")
vfc_83173
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n6 -4 8 -2 3", "output": "2 4 6 1 3 ", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
761
Solve the following coding problem using the programming language python: On her way to programming school tiger Dasha faced her first test — a huge staircase! The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their co...
n,m=map(int,input().split()) z=abs(n-m) if((z==0 and n!=0) or z==1): print("YES") else: print("NO")
vfc_83177
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3", "output": "YES", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
20
Solve the following coding problem using the programming language python: The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equival...
print("/"+"/".join(filter(None, input().split("/"))))
vfc_83181
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "//usr///local//nginx/sbin", "output": "/usr/local/nginx/sbin", "type": "stdin_stdout" }, { "fn_name": null, "input": "////a//b/////g", "output": "/a/b/g", "type": "stdin_stdout" }, ...
codeforces
verifiable_code
199
Solve the following coding problem using the programming language python: Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers. Let's remember how Fibonacci numbers...
n = int(input()) if n == 0: print(0, 0, 0) elif n == 1: print(0, 0, 1) elif n == 2: print(0, 1, 1) else: arr = [0, 1] i = 1 while True: m = arr[i]+arr[i-1] if m <= n: arr.append(m) i += 1 else: break print(arr[-2], arr[-4], arr[-5...
vfc_83185
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3", "output": "1 1 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "13", "output": "2 3 8", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
845
Solve the following coding problem using the programming language python: Berland annual chess tournament is coming! Organizers have gathered 2·*n* chess players who should be divided into two teams with *n* people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, o...
n=int(input()) a=sorted(list(map(int,input().split()))) print('YES' if a[n-1]<a[n] else 'NO')
vfc_83189
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 3 2 4", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3 3", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\...
codeforces
verifiable_code
915
Solve the following coding problem using the programming language python: Luba thinks about watering her garden. The garden can be represented as a segment of length *k*. Luba has got *n* buckets, the *i*-th bucket allows her to water some continuous subsegment of garden of length exactly *a**i* each hour. Luba can't ...
def f(): num,k=map(int,input().split()) n=map(int, input().split()) maxi=0 ans=0 for i in n: if(k%i==0 and i>maxi): maxi=i ans=int(k/i) print(ans) f()
vfc_83193
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 6\n2 3 5", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 7\n1 2 3 4 5 6", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
codeforces
verifiable_code
540
Solve the following coding problem using the programming language python: Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. The combination lock is represented by *n* rotating...
n = int(input()) comb1 = list(map(int, ' '.join(input()).split())) comb2 = list(map(int, ' '.join(input()).split())) count = 0 for i in range(n): a = abs(comb1[i] - comb2[i]) b = 10 - a count += min(a, b) print(count)
vfc_83197
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n82195\n64723", "output": "13", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n102021090898\n010212908089", "output": "16", "type": "stdin_stdout" }, { "fn_nam...
codeforces
verifiable_code
669
Solve the following coding problem using the programming language python: Little Artem got *n* stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times ...
a = int(input()) print(a // 3 * 2 + (a % 3 > 0))
vfc_83201
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3", "output":...
codeforces
verifiable_code
192
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 , where *k* is some positive integer), and the coolest numbers are those that are representable as a sum of two tri...
import sys, os.path from collections import* from copy import* import math mod=10**9+7 if(os.path.exists('input.txt')): sys.stdin = open("input.txt","r") sys.stdout = open("output.txt","w") def bs(left,right,x): while(left<=right): mid=left+(right-left)//2 b=(mid*(mid+1))//2 ...
vfc_83205
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "256", "output": "YES", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
214
Solve the following coding problem using the programming language python: Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given...
import sys import math def function(): n, m = map(int, input().split()) ans = 0 for a in range(1001): for b in range(1001): if (a**2) + b == n and a + (b**2) == m: ans+=1 print(ans) return if __name__ == '__main__': function()
vfc_83209
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 3", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "14 28", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 20", ...
codeforces
verifiable_code
63
Solve the following coding problem using the programming language python: The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All *n* crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to *n*) and await furt...
from functools import cmp_to_key class Info: def __init__(self, _id: int, _name: str, _status: str): self.id = _id self.name = _name self.status = _status def __str__(self): return f'id: {self.id}, name: {self.name}, status: {self.status}' def customCompare(obj1:Inf...
vfc_83213
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nJack captain\nAlice woman\nCharlie man\nTeddy rat\nBob child\nJulia woman", "output": "Teddy\nAlice\nBob\nJulia\nCharlie\nJack", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
638
Solve the following coding problem using the programming language python: The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to *n*<=-...
n, a = [int(x) for x in input().split()] ans = 1 if a % 2 == 0: while n != a: n -= 2 ans += 1 else: t = 1 while t != a: t += 2 ans += 1 print(ans)
vfc_83217
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 5", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1", "ou...
codeforces
verifiable_code
659
Solve the following coding problem using the programming language python: Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent. Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance *a* and he dec...
n,a,b=map(int,input().split(' ')) z=(((a+b)%n)+n)%n if(z==0): print(n) else: print(z)
vfc_83225
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 2 -5", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 3", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 7", ...
codeforces
verifiable_code
233
Solve the following coding problem using the programming language python: A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size of pe...
# -*- coding: utf-8 -*- """ Created on Thu Apr 14 12:45:15 2022 @author: dehon """ n = int(input()) if(n%2 == 1): print(-1) else: for i in range(1,n+1): if(i%2 == 1): print(i+1, end=' ') else: print(i-1, end=' ')
vfc_83229
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2", "output": "2 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4", "outp...
codeforces
verifiable_code
714
Solve the following coding problem using the programming language python: Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya! Sonya is an owl and she sleeps during the day and stay awake from minute *l*1 to minute *r*1 inclusive. Also, during the minute *k* s...
import operator as op import re import sys from bisect import bisect, bisect_left, insort, insort_left from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from functools import reduce from itertools import ( accumulate, combinations, combinations_with_r...
vfc_83233
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 10 9 20 1", "output": "2", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
995
Solve the following coding problem using the programming language python: Allen is hosting a formal dinner party. $2n$ people come to the event in $n$ pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The $2n$ people line up, but Allen doesn't like the ordering. Allen prefers ...
n=int(input()) lst = list(map(int, input().strip().split(' '))) c=0 while(len(lst)!=0): p=lst[0] del lst[0] i=lst.index(p) c+=i del lst[i] print(c)
vfc_83237
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1 2 3 3 2 4 4", "output": "2", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
116
Solve the following coding problem using the programming language python: Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the ...
total_stop = int(input()) max = 0 current = 0 for i in range(total_stop): a,b = map(int,input().split()) if i == 0: max = b current = b else: current = (current - a) + b if current > max: max = current print(max)
vfc_83241
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 3\n2 5\n4 2\n4 0", "output": "6", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
197
Solve the following coding problem using the programming language python: You've got a rectangular table with length *a* and width *b* and the infinite number of plates of radius *r*. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but the...
A = list(map(int,input().split())) a = A[0];b = A[1];r = A[2] if 2*r <= min(a,b): print('First') else: print('Second')
vfc_83245
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5 2", "output": "First", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 7 4", "output": "Second", "type": "stdin_stdout" }, { "fn_name": null, "input": "10...
codeforces
verifiable_code
599
Solve the following coding problem using the programming language python: Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a *d*1 meter long road between his house and the first shop and a *d*2 meter lo...
def good(a,b,c): return min(a,b+c)+min(c,a+b)+min(b,a+c) a,b,c=map(int,input().split()) print(good(a, b, c))
vfc_83249
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 20 30", "output": "60", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
420
Solve the following coding problem using the programming language python: Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it? The market analysts came up with a very smart plan: the name of the company should ...
import sys def check(text): legal = 'AHIMOTUVWXY' for i in text: if i not in legal: return False rev = list(text) rev.reverse() if text != ''.join(rev): return False return True if __name__ == '__main__': text = sys.stdin.readline().split()[0] ...
vfc_83253
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "AHA", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "Z", "output": "NO", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
978
Solve the following coding problem using the programming language python: Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements. Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements shou...
no_inputs = int(input()) nums = list(map(int, input().split())) unique_nums = [] for num in nums[::-1]: if num not in unique_nums: unique_nums.append(num) print(len(unique_nums)) print(" ".join(str(item) for item in unique_nums[::-1]))
vfc_83257
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "4000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 5 5 1 6 1", "output": "3\n5 6 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 4 2 4 4", "output": "2\n2 4 ", "type": "stdin_stdout" }, { "fn_name": nul...
codeforces
verifiable_code
525
Solve the following coding problem using the programming language python: After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with *n* room located in a line and numbered starting from one from left to right. You can go...
n = int(input()) s = input() D = dict() D_mins = dict() for i in range(len(s)): if i % 2 == 0: if s[i] in D: D[s[i]] += 1 else: D[s[i]] = 1 if s[i] in D_mins: D_mins[s[i]] = min(D_mins[s[i]], D[s[i]]) else: D_mins[s[i]] =...
vfc_83261
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naAbB", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\naBaCaB", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nxY...
codeforces
verifiable_code
136
Solve the following coding problem using the programming language python: Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he org...
# N,M = map(int,input().split()) # N = int(input()) # A = list(map(int,input().split())) N = int(input()) A = list(map(int,input().split())) d = [0] * N for i in range(N): d[A[i]-1] = i+1 print(*d)
vfc_83265
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 3 4 1", "output": "4 1 2 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 3 2", "output": "1 3 2", "type": "stdin_stdout" }, { "fn_name": null, "in...
codeforces
verifiable_code
88
Solve the following coding problem using the programming language python: Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has *n* rows of keys containing *m* keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some o...
import sys from array import array # noqa: F401 from math import hypot from collections import defaultdict def input(): return sys.stdin.buffer.readline().decode('utf-8') n, m, x = map(int, input().split()) keyboard = [input().rstrip() for _ in range(n)] keys = set() inf, eps = 10**9, 1e-9 dist =...
vfc_83269
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 1\nab\ncd\n1\nA", "output": "-1", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
204
Solve the following coding problem using the programming language python: The Little Elephant very much loves sums on intervals. This time he has a pair of integers *l* and *r* (*l*<=≤<=*r*). The Little Elephant has to find the number of such integers *x* (*l*<=≤<=*x*<=≤<=*r*), that the first digit of integer *x* equ...
def f(x): if x < 10: return x if str(x)[0] > str(x)[-1]: return x // 10 + 8 else: return x // 10 + 9 l, r = map(int, input().split()) print(f(r) - f(l - 1))
vfc_83273
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 47", "output": "12", "type": "stdin_stdout" }, { "fn_name": null, "input": "47 1024", "output": "98", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1000",...
codeforces
verifiable_code
770
Solve the following coding problem using the programming language python: Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: - t...
n, k = map(int,input().split()) print(('abcdefghijklmnopqrstuvwxyz' [:k]*n )[:n])
vfc_83277
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3", "output": "abca", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 6", "output": "abcdef", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2", ...
codeforces
verifiable_code
935
Solve the following coding problem using the programming language python: Fafa owns a company that works on huge projects. There are *n* employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees. Fafa finds doing this ...
# A. Fafa and his Company n = int(input()) i = 1 cont = 0 while i <= n/2: e = n - i if e % i == 0: cont += 1 i += 1 print(cont)
vfc_83281
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "10", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3", "output"...
codeforces
verifiable_code
606
Solve the following coding problem using the programming language python: Carl is a beginner magician. He has *a* blue, *b* violet and *c* orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at le...
a,b,c = map(int, input().split()) x,y,z = map(int, input().split()) extra = max(0, a-x)//2 + max(0, b-y)//2 + max(0, c-z)//2 need = max(0, x-a) + max(0, y-b) + max(0, z-c) print("Yes" if need<=extra else "No")
vfc_83285
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4 0\n2 1 2", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6 1\n2 7 2", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, "inp...
codeforces
verifiable_code
950
Solve the following coding problem using the programming language python: You are at a water bowling training. There are *l* people who play with their left hand, *r* people, who play with their right hand, and *a* ambidexters, who can play with left or right hand. The coach decided to form a team of even number of p...
def li(): return list(map(int,input().split())) def gi(n): return [list(map(int,input().split())) for _ in range(n)] # File input # import sys # sys.stdin = open('user.txt','r') l,r,a = li() if max(l,r) - min(l,r) > a: print((min(l,r)+a) * 2) else: print((max(l,r) + (a - (max(l,r) - m...
vfc_83293
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 4 2", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 5", "output": "14", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 2 0", ...
codeforces
verifiable_code
465
Solve the following coding problem using the programming language python: Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of *n* bits. These bits are numbered from 1 to *n*. An integer is stored in the cell in the following way: the least significant bit...
n = int(input()) cells = input() if cells.find('0') == -1: print(n) else: before = int(cells[::-1], 2) after = before + 1 print(str(bin(before ^ after)).count('1'))
vfc_83297
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1100", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1111", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0", ...
codeforces
verifiable_code
745
Solve the following coding problem using the programming language python: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by ...
s = input() ans = set() for l in range(len(s)): t = s[l:] + s[:l] ans.add(t) print(len(ans))
vfc_83301
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abcd", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "bbb", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "yzyz", "...
codeforces
verifiable_code
791
Solve the following coding problem using the programming language python: Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. Right now, Limak and Bob weigh *a* and *b* respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight. ...
# -*- coding: utf-8 -*- """ Created on Tue Sep 19 15:47:18 2023 @author: lenovo """ a,b=map(int,input().split()) s=0 while a<=b: a*=3 b*=2 s=s+1 print(s)
vfc_83305
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 7", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 9", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
479
Solve the following coding problem using the programming language python: Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of operations '+' and '*...
x = int(input()) y = int(input()) z = int(input()) list_1 = [] list_1.append((x+y)*z) list_1.append(x*(y+z)) list_1.append(x+y+z) list_1.append(x*y*z) print(max(list_1))
vfc_83309
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n3", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n10\n3", "output": "60", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
519
Solve the following coding problem using the programming language python: A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its we...
#519A valW = 0 valB = 0 for _ in range(8): a = input() for i in range(8) : if a[i] == 'Q': valW = valW + 9 elif a[i] == 'R' : valW = valW + 5 elif a[i] == 'B' : valW = valW + 3 elif a[i] == 'N' : valW = valW + 3 ...
vfc_83313
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "rnbqkbnr\npppppppp\n........\n........\n........\n........\nPPPPPPPP\nRNBQKBNR", "output": "Draw", "type": "stdin_stdout" }, { "fn_name": null, "input": "....bQ.K\n.B......\n.....P..\n........\n........
codeforces
verifiable_code
705
Solve the following coding problem using the programming language python: Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings. Hulk likes the Inception so much, and like that his ...
import sys def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): return input().strip() def out(x): sys.stdout.write(str(x) + "\n") def main(): count = inp() ans = "" feelings = [" I love", " I hate"] for i in range(1, count ...
vfc_83317
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1", "output": "I hate it", "type": "stdin_stdout" }, { "fn_name": null, "input": "2", "output": "I hate that I love it", "type": "stdin_stdout" }, { "fn_name": null, "...
codeforces
verifiable_code
68
Solve the following coding problem using the programming language python: Little Petya was given this problem for homework: You are given function (here represents the operation of taking the remainder). His task is to count the number of integers *x* in range [*a*;*b*] with property *f*(*x*)<==<=*x*. It is a pity...
import sys,math,string,bisect input=sys.stdin.readline from collections import deque L=lambda : list(map(int,input().split())) Ls=lambda : list(input().split()) M=lambda : map(int,input().split()) I=lambda :int(input()) p1,p2,p3,p4,b,a=M() k=min(p1,p2,p3,p4) c=0 for i in range(b,min(k,a+1)): c+=1 print(c)
vfc_83321
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 7 1 8 2 8", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "20 30 40 50 0 100", "output": "20", "type": "stdin_stdout" }, { "fn_name": null, "i...
codeforces
verifiable_code
267
Solve the following coding problem using the programming language python: You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pai...
for _ in range(int(input())): a,b=map(int,input().split()) ans=int(0) while a and b: a,b=min(a,b),max(a,b) ans,b=ans+b//a,b%a print(ans)
vfc_83325
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 17\n7 987654321", "output": "8\n141093479", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n...
codeforces
verifiable_code
691
Solve the following coding problem using the programming language python: According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swing...
n = int(input()) lst = list(map(int, input().split())) if n == 1: if lst[0] == 1: print("YES") else: print("NO") else: zeros = lst.count(0) if zeros == 1: print("YES") else: print("NO")
vfc_83329
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 0 1", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 0 0", "output": "NO", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
898
Solve the following coding problem using the programming language python: Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded. For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5 Vasya can round it...
n=int(input()) z=int(str(n)[-1]) if z>=5: print(n+10-z) else: print(n-z)
vfc_83333
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5", "output": "0", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
706
Solve the following coding problem using the programming language python: Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known that the price of one bottle in...
import bisect N=int(input()) x=sorted(list(map(int,input().split()))) for i in range(int(input())): print(bisect.bisect(x,int(input())))
vfc_83337
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 10 8 6 11\n4\n1\n10\n3\n11", "output": "0\n4\n1\n5", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n868 987 714 168 123\n10\n424\n192\n795\n873\n117\n914\n735\n158\n631\n471", "...