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 | 510 | Solve the following coding problem using the programming language python:
Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*-th cell of *r*-th row a... | def Fox_and_Snake(r,c):
next_ = 3
next_2 = 1
for i in range(r):
for j in range(c):
if i %2 == 0:
print('#', end = '')
else:
if i == next_2 and j == (c-1):
print('#', end = '')
next_2 +=4
... | vfc_83341 | {
"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 3",
"output": "###\n..#\n###",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 618 | Solve the following coding problem using the programming language python:
Your friend recently gave you some slimes for your birthday. You have *n* slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other *n*<... | N = int(input())
ans = []
i = 0
while N >> i:
if (N >> i) & 1:
ans.append(i + 1)
i += 1
print(*ans[::-1]) | vfc_83345 | {
"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",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3",
"output":... |
codeforces | verifiable_code | 621 | Solve the following coding problem using the programming language python:
Today, Wet Shark is given *n* integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from... | def isOdd (x):
return x%2==1
def isEven (x):
return x%2==0
input()
arr = [int(z) for z in input().split()]
oddA = list(filter(isOdd,arr))
oddA.sort()
evenSum = sum(filter(isEven,arr))
if(isOdd(len(oddA))):
print(evenSum+sum(oddA[1:]))
else:
print(evenSum+sum(oddA))
| vfc_83349 | {
"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 3",
"output": "6",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 748 | Solve the following coding problem using the programming language python:
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place... | s = input()
t = input()
w1, w2 = set(), set()
for i in range(len(s)):
l1, l2 = min(s[i], t[i]), max(s[i], t[i])
if (s[i] in w2 or t[i] in w2) and (l1, l2) not in w1:
print(-1)
exit()
else:
w2.add(s[i])
w2.add(t[i])
w1.add((l1, l2))
result = [elem for elem ... | vfc_83357 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "helloworld\nehoolwlroz",
"output": "3\nh e\nl o\nd z",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "hastalavistababy\nhastalavistababy",
"output": "0",
"type": "stdin_stdout"
... |
codeforces | verifiable_code | 235 | Solve the following coding problem using the programming language python:
Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.
But I also don't want to use many numbers, so I'll choose three positive integers (they don't ha... | import math
def main():
n = int(input())
if n <= 3:
ans = 1
for i in range(1,n+1):
ans *= i
print(ans)
return
if n%2 == 0:
#print(n,n-1,n-3)
if n%3 == 0:
print((n-3)*(n-1)*(n-2))
else:
print(n*(n-1)*(... | vfc_83361 | {
"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",
"output": "504",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7",
"output": "210",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1",
"outp... |
codeforces | verifiable_code | 239 | Solve the following coding problem using the programming language python:
Valera had two bags of potatoes, the first of these bags contains *x* (*x*<=≥<=1) potatoes, and the second — *y* (*y*<=≥<=1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains *x* potatoes) Valera lost. Valera remem... | y,k,n=map(int,input().split())
x=k*(1+y//k)-y
flag=0
while x+y<=n:
flag=1
print(x,end=" ")
x+=k
if flag==0:
print(-1) | vfc_83365 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 1 10",
"output": "-1",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 687 | Solve the following coding problem using the programming language python:
Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.
Suppose the graph *G* is given. Subset *A* of its vertices is called a vertex cover of this graph, if for each ed... | n,m = list(map(int,input().split()))
graph = [[]for _ in range(n)]
color = [0]*n
for i in range(m):
a,b = list(map(int,input().split()))
graph[a-1].append(b-1)
graph[b-1].append(a-1)
for i in range(n):
if color[i]:
continue
color[i] = 1
queue = [i]
while queue:
u... | vfc_83369 | {
"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\n1 2\n2 3",
"output": "1\n2 \n2\n1 3 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 2\n2 3\n1 3",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name"... |
codeforces | verifiable_code | 644 | Solve the following coding problem using the programming language python:
In this problem you have to simulate the workflow of one-thread server. There are *n* queries to process, the *i*-th will be received at moment *t**i* and needs to be processed for *d**i* units of time. All *t**i* are guaranteed to be distinct.
... | n, b = [int(i) for i in input().split()]
q = [0] * n
bg = 0
en = 0
time = 0
res = [-1] * n
for it in range(n):
ev = [int(i) for i in input().split()]
ev.append(it)
while bg < en and max(time, q[bg][0]) <= ev[0]:
time = max(time, q[bg][0])
res[q[bg][2]] = time + q[bg][1]
t... | vfc_83373 | {
"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 1\n2 9\n4 8\n10 9\n15 2\n19 1",
"output": "11 19 -1 21 22 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n2 8\n4 8\n10 9\n15 2",
"output": "10 18 27 -1 ",
"type": "stdin_... |
codeforces | verifiable_code | 975 | Solve the following coding problem using the programming language python:
Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.
Ivar has $n$ warriors, he places them on a straight line in front of the main gate... | def get_pos(curr, strength_left, arrow):
l = curr
h = n - 1
while (l < h):
m = (l + h) // 2
strength_req = strength[m] - strength[curr] + strength_left
if strength_req > arrow:
h = m
elif strength_req == arrow:
return m
else:
if m ... | vfc_83377 | {
"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\n1 2 1 2 1\n3 10 1 1 1",
"output": "3\n5\n4\n4\n3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n1 2 3 4\n9 1 10 6",
"output": "1\n4\n4\n1",
"type": "stdin_stdout"
... |
codeforces | verifiable_code | 119 | Solve the following coding problem using the programming language python:
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* stones. The players tak... | import math
a , b, n= [int(i) for i in input().split()]
ans = False
while True:
if ans == False:
g = math.gcd(a,n)
n -=g
if n <=0:
print(int(ans))
break
ans = not ans
else:
g = math.gcd(b,n)
n -=g
if n <=0:
... | vfc_83381 | {
"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 5 9",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 100",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "23 12 16"... |
codeforces | verifiable_code | 448 | Solve the following coding problem using the programming language python:
Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team.
At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), *s* and *t*. You need to transform word ... | def main():
s = input()
t = input()
ans_list = ['automaton', 'array', 'both', 'need tree']
ans = ''
if s == t:
ans = ans_list[0]
elif sorted(s) == sorted(t):
ans = ans_list[1]
elif len(s) < len(t):
ans = ans_list[3]
if ans != '':
print(ans)
return
ls = [0 for _ in range(26)]
lt = ls.copy()
for... | vfc_83385 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "automaton\ntomat",
"output": "automaton",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "array\narary",
"output": "array",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
codeforces | verifiable_code | 930 | Solve the following coding problem using the programming language python:
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are *n* inflorescences, numbered from 1 to *n*. Inflorescence number 1 is situated near base of tree and... | n = int(input())
a = [int(e) for e in input().split()]
d = {1:0}
for k, v in enumerate(a):
d[k+2] = d[v] + 1
d2 = {}
for k, v in d.items():
d2[v] = d2.get(v,0) + 1
s = sum([v%2 for v in d2.values()])
print(s) | vfc_83389 | {
"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\n1 1",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 2 2 2",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "18\n1... |
codeforces | verifiable_code | 558 | Solve the following coding problem using the programming language python:
Amr has got a large array of size *n*. Amr doesn't like large arrays so he intends to make it smaller.
Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th... | def bin_search(n,a):
l = 0
r = len(a)-1
while l<=r:
m = (l+r)//2
if n>a[m][0]:
l = m+1
if n<a[m][0]:
r = m-1
if n == a[m][0]:
return m
return -1
n = int(input())
a = input().split()
def ke(n):
return n[1]
def f(n):
... | vfc_83393 | {
"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 1 2 2 1",
"output": "1 5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 2 2 3 1",
"output": "2 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
codeforces | verifiable_code | 388 | Solve the following coding problem using the programming language python:
Fox Ciel has *n* boxes in her room. They have the same size and weight, but they might have different strength. The *i*-th box can hold at most *x**i* boxes on its top (we'll call *x**i* the strength of the box).
Since all the boxes have the s... | n = int(input())
a = list(map(int, input().split()))
a.sort()
h = [0] * 101
for i in range(n):
for j in range(101):
if(a[i] >= h[j]):
h[j] += 1
break
c = 101 - h.count(0)
print(c)
| vfc_83397 | {
"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\n0 0 10",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n0 1 2 3 4",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "... |
codeforces | verifiable_code | 688 | Solve the following coding problem using the programming language python:
Arya has *n* opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means i... | n,d=map(int,input().split())
m=[]
a=0
for i in range(d):
l=input()[:n]
if "0" in l:
a=a+1
else:
m.append(a)
a=0
if i==d-1:
m.append(a)
print(max(m))
| vfc_83401 | {
"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\n10\n00",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n0100",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4... |
codeforces | verifiable_code | 160 | Solve the following coding problem using the programming language python:
Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it... | n = int(input())
coins = list(map(int, input().split()))
coins.sort(reverse=True)
total_sum = sum(coins)
my_sum = 0
count = 0
for i in range(n):
my_sum += coins[i]
count += 1
if my_sum > total_sum - my_sum:
break
print(count) | vfc_83405 | {
"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\n3 3",
"output": "2",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 27 | Solve the following coding problem using the programming language python:
«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will ... |
def main():
n = int(input())
arr = list(map(int, input().split()))
count = 1
arr.sort()
for i in arr:
if i != count:
print(count)
exit()
count += 1
print(count)
main()
| vfc_83409 | {
"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": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2 1",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3 4 1",
... |
codeforces | verifiable_code | 916 | Solve the following coding problem using the programming language python:
Jamie loves sleeping. One day, he decides that he needs to wake up at exactly *hh*:<=*mm*. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every *... | import datetime
n = int(input())
a , b = input().split()
x = datetime.timedelta(hours= int(a) , minutes=int(b))
c = 0
while '7' not in str(x):
x -= datetime.timedelta(hours= 0 , minutes=n)
c +=1
print(c) | vfc_83413 | {
"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\n11 23",
"output": "2",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 821 | Solve the following coding problem using the programming language python:
Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an *n* by *n* square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be express... | n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
flag=0
for i in range(n):
for j in range(n):
if( l[i][j]==1 )or any(l[i][j]-l[x][j] in l[i] for x in range(n)):
continue
else:
print('No')
flag=1
break
if(flag==1):
... | vfc_83417 | {
"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 1 2\n2 3 1\n6 4 1",
"output": "Yes",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 221 | Solve the following coding problem using the programming language python:
The Little Elephant enjoys recursive functions.
This time he enjoys the sorting function. Let *a* is a permutation of an integers from 1 to *n*, inclusive, and *a**i* denotes the *i*-th element of the permutation. The Little Elephant's recursiv... | # Bismillahir Rahmanir Rahim
# Abu Hurayra - Handle: HurayraIIT
import sys
import math
def mp(): return map(int, sys.stdin.readline().split())
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.s... | vfc_83421 | {
"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"
}
]
} |
codeforces | verifiable_code | 342 | Solve the following coding problem using the programming language python:
A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius *r* (the cupboard's top) and two walls of height *h* (the cupboard's sides). The cupboard's depth is *r*, that is, it looks like a r... | r, h = map(int, input().split())
a = 1 + 2 * h // r
if h % r >=3 ** 0.5 * r / 2:
a += 1
print(a)
| vfc_83425 | {
"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",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1",
"ou... |
codeforces | verifiable_code | 887 | Solve the following coding problem using the programming language python:
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way,... | a=int(input())
s=str(a)
count=0
for i in s:
if i=="0":
count+=1
if (count>=6):
print("yes")
else:
print("no")
| vfc_83429 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100010001",
"output": "yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100",
"output": "no",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "000000... |
codeforces | verifiable_code | 837 | Solve the following coding problem using the programming language python:
You are given a text of single-space separated words, consisting of small and capital Latin letters.
Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.
Calculate the volu... | a = set()
a.add(0)
n = int(input())
s = input().split()
c = 0
for i in s:
for j in i:
if j.isupper():
c+=1
a.add(c)
c = 0
a = sorted(a)
print(a[-1]) | vfc_83433 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\nNonZERO",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "24\nthis is zero answer text",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
codeforces | verifiable_code | 578 | Solve the following coding problem using the programming language python:
You are given *n* numbers *a*1,<=*a*2,<=...,<=*a**n*. You can perform at most *k* operations. For each operation you can multiply one of the numbers by *x*. We want to make as large as possible, where denotes the bitwise OR.
Find the maximum... | n, k, x = map(int, input().split())
x = x**k
left_or = [None]*(n)
right_or = [None]*(n)
a = list(map(int, input().split()))
current_or = 0
for i in range(n):
current_or |= a[i]
left_or[i] = current_or
current_or = 0
for i in range(n-1, -1, -1):
current_or |= a[i]
right_or[i] = current_or
be... | vfc_83437 | {
"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 1 2\n1 1 1",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2 3\n1 2 4 8",
"output": "79",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 569 | Solve the following coding problem using the programming language python:
Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the tra... | n = int(input())
a = list(map(int, input().split()))
s = set(a)
k = set(range(1, n+1))
need = k-s
vis = set()
for i in range(n):
if a[i] in vis:
a[i] = need.pop()
else:
if a[i] not in k:
a[i] = need.pop()
vis.add(a[i])
else:
vis.add(a[i... | vfc_83445 | {
"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 3 2",
"output": "1 3 2 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 2 3 3",
"output": "2 1 3 4 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
codeforces | verifiable_code | 629 | Solve the following coding problem using the programming language python:
Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a *n*<=×<=*n* square consisting of equal squares with side length 1. Each square is either emp... | import math
size = int(input())
matrix = []
def ncr(x):
if x>=2:
y = math.factorial(x)
y = y/((math.factorial(x-2))*2)
return y
else:
return 0
for i in range(0,size):
array = list(str(input()))
matrix.append(array)
rows = 0
cols = 0
for i in r... | vfc_83449 | {
"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\n.CC\nC..\nC.C",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\nCC..\nC..C\n.CC.\n.CC.",
"output": "9",
"type": "stdin_stdout"
},
{
"fn_name": nu... |
codeforces | verifiable_code | 205 | Solve the following coding problem using the programming language python:
The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. "Rozdil").
However, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn't like to spend much time on... | n=int(input())
l=input().split(" ")
l=[int(x) for x in l]
square_dict = {n: 1 for n in l}
s={}
minNum=min(l)
for i in l:
# for j in range(len(l[i])):
if i in s:
key=i
s[key]=s.setdefault(key, 0) + 1
else:
key=i
s[key]=s.setdefault(key, 1)
k=minNum
if(s.get(k)>1):
prin... | vfc_83453 | {
"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\n7 4",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n7 4 47 100 4 9 12",
"output": "Still Rozdil",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
codeforces | verifiable_code | 681 | Solve the following coding problem using the programming language python:
Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his r... | n = int(input())
flag = False
for i in range(n):
name, before, after = map(str, input().split())
if flag is False:
if int(before) >= 2400 and int(after) > int(before):
flag = True
continue
print('YES' if flag is True else 'NO')
| vfc_83457 | {
"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\nBurunduk1 2526 2537\nBudAlNik 2084 2214\nsubscriber 2833 2749",
"output": "YES",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 994 | Solve the following coding problem using the programming language python:
You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.
Some keys on the keypad have fingerprints. Y... | n,m=[int(x) for x in input().split()]
num=[int(x) for x in input().split()]
op=[int(x) for x in input().split()]
fin=[]
for x in num:
if x in op:
fin.append(str(x))
print(' '.join(fin)) | vfc_83461 | {
"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 3\n3 5 7 1 6 2 8\n1 2 7",
"output": "7 1 2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n3 4 1 0\n0 1 7 9",
"output": "1 0",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 967 | Solve the following coding problem using the programming language python:
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts $1$ minute.
He w... | def next(h1, m1, minutes):
return (h1 + (m1 + minutes) // 60, (m1 + minutes) % 60)
n, s = map(int, input().split())
schedule = []
for i in range(n):
schedule.append(tuple(map(int, input().split())))
if schedule[0][0] * 60 + schedule[0][1] >= s + 1:
print('0 0')
else:
for i in range(1, len... | vfc_83465 | {
"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 60\n0 0\n1 20\n3 21\n5 0\n19 30\n23 40",
"output": "6 1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16 50\n0 30\n1 20\n3 0\n4 30\n6 10\n7 50\n9 30\n11 10\n12 50\n14 30\n16 10\n17 50\n1... |
codeforces | verifiable_code | 596 | Solve the following coding problem using the programming language python:
Wilbur the pig is tinkering with arrays again. He has the array *a*1,<=*a*2,<=...,<=*a**n* initially consisting of *n* zeros. At one step, he can choose any index *i* and either add 1 to all elements *a**i*,<=*a**i*<=+<=1,<=... ,<=*a**n* or subt... | a=int(input())
x=list(map(int,input().split()))
t=abs(x[0])
if a>1:
for i in range(1,a):
t+=abs(x[i-1]-x[i])
print(t)
| vfc_83469 | {
"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\n1 2 3 4 5",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 2 1",
"output": "3",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 984 | Solve the following coding problem using the programming language python:
Two players play a game.
Initially there are $n$ integers $a_1, a_2, \ldots, a_n$ written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i. e. $... |
n = int(input())
l = list(map(int,input().split()))
l.sort()
for i in range(n-1):
if i % 2 == 0:
l.pop()
else:
l.pop(0)
for i in l:
print(i) | vfc_83473 | {
"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 1 3",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 2 2",
"output": "2",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 389 | Solve the following coding problem using the programming language python:
Fox Ciel has a board with *n* rows and *n* columns. So, the board consists of *n*<=×<=*n* cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like... | def check(a, b, n):
return a>=0 and b>=0 and a<n and b<n
def solve():
n = int(input())
ar = []
for i in range(n):
ar.append(input())
cross = [[0]*n for _ in range(n)]
addc = [(1, 0), (2, 0), (1, -1), (1, 1)]
for i in range(n):
for j in range(n):
if ar[i][j] == "#" and cross[i][j] == 0:
cross[i][j]... | vfc_83477 | {
"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\n####\n####\n####\n####",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n.#....\n####..\n.####.\n.#.##.\n######\n.#..#.",
"output": "YES",
"type": "stdin_stdo... |
codeforces | verifiable_code | 180 | Solve the following coding problem using the programming language python:
Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.
... | s=input()
mina=c=0
for i in range(len(s)):
if ord(s[i])>=97:
mina=min(c+1,mina)
c+=1
else:
mina=min(mina+1,c)
print(mina)
| vfc_83481 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "PRuvetSTAaYA",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "OYPROSTIYAOPECHATALSYAPRIVETSTASYA",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name... |
codeforces | verifiable_code | 631 | Solve the following coding problem using the programming language python:
Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following probl... | n = int(input())
a = input().split()
b = input().split()
or_a = 0
or_b = 0
for i in range(n):
or_a |= int(a[i])
or_b |= int(b[i])
print(or_a + or_b)
| vfc_83485 | {
"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\n1 2 4 3 2\n2 3 3 12 1",
"output": "22",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n13 2 7 11 8 4 9 8 5 1\n5 7 18 9 2 3 0 11 8 6",
"output": "46",
"type": "stdin_stdout"... |
codeforces | verifiable_code | 883 | Solve the following coding problem using the programming language python:
Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:
- start the race from some point of a field, - go around the flag, - close cycle returning back to the starting point.
Polycarp knows the coordin... | x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
a, b = abs(x2-x1), abs(y2-y1)
if a == 0:
print(4 + 2 * (b + 1))
elif b == 0:
print(2 * (a + 1) + 4)
else:
print(2*(a+1)+2*(b+1))
| vfc_83489 | {
"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 5\n5 2",
"output": "18",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 1\n0 0",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-100... |
codeforces | verifiable_code | 109 | Solve the following coding problem using the programming language python:
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya wonders eagerly wha... | a=int(input())
for i in range(a):
for x in range(a):
if 4*i+7*x==a:
print('4'*i+'7'*x)
exit()
print(-1) | vfc_83497 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11",
"output": "47",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "64",
"out... |
codeforces | verifiable_code | 722 | Solve the following coding problem using the programming language python:
You are given a text consisting of *n* lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of c... | vowels = ['a','e','i','o','u','y']
N = int(input())
P = list(map(int, input().split()))
ans = True
for n in range(N):
s = input()
vc = len(list(True for c in s if c in vowels))
if vc != P[n]:
ans = False
print("YES" if ans else "NO") | vfc_83501 | {
"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 2 3\nintel\ncode\nch allenge",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 3 1\na\nbcdefghi\njklmnopqrstu\nvwxyz",
"output": "NO",
"type": "stdin_s... |
codeforces | verifiable_code | 767 | Solve the following coding problem using the programming language python:
According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time *n* snacks of distinct sizes will fall on the city, and the residents should build a Snacktow... | n = int(input())
snacks = {int(num): day for day, num in enumerate(input().split(" "))}
days = [[] for _ in range(n)]
sorted_snacks = sorted(snacks, reverse=True)
current_day = None
for snack in sorted_snacks:
snack_day = snacks[snack]
if current_day is None:
current_day = snack_day
if sn... | vfc_83505 | {
"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\n3 1 2",
"output": "3 \n\n2 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n4 5 1 2 3",
"output": "5 4 \n\n\n3 2 1 ",
"type": "stdin_stdout"
},
{
"fn_name":... |
codeforces | verifiable_code | 660 | Solve the following coding problem using the programming language python:
You are given an array of *n* elements, you must make it a co-prime array in as few moves as possible.
In each move you can insert any positive integral number you want not greater than 109 in any place in the array.
An array is co-prime if an... | def primeFactors(n):
factors = []
i = 2
while n > 1:
while n % i == 0:
factors.append(i)
n //= i
i += 1
if i * i > n : break
if n > 1:
factors.append(n)
return factors
def areCoprime(n1,n2):
n1Factors = primeFactors(n1)
areCoprime = ... | vfc_83509 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "4000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 7 28",
"output": "1\n2 7 1 28",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1",
"output": "0\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
codeforces | verifiable_code | 666 | Solve the following coding problem using the programming language python:
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, whic... | t = input()
s, d = set(), set()
p = {(len(t), 2)}
while p:
m, x = p.pop()
r = m + x
for y in [x, 5 - x]:
l = m - y
q = (l, y)
if q in d or l < 5 or t[l:m] == t[m:r]: continue
s.add(t[l:m])
d.add(q)
p.add(q)
print(len(s))
print('\n'.join... | vfc_83513 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "abacabaca",
"output": "3\naca\nba\nca",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abaca",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
codeforces | verifiable_code | 62 | Solve the following coding problem using the programming language python:
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting the ma... | al, ar = list(map(int, input().split()))
bl, br = list(map(int, input().split()))
if (br >= al-1 and br <= (al+1)*2) or (bl <= (ar+1)*2 and bl >= ar-1):
print('YES')
else:
print('NO') | vfc_83517 | {
"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 1\n10 5",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5\n3 3",
"output": "YES",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 391 | Solve the following coding problem using the programming language python:
You will receive 3 points for solving this problem.
Manao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is rep... | R = lambda: map(int, input().split())
s = input()
cc, c = 0, 0
for r in range(len(s)):
if r == 0 or s[r] == s[r - 1]:
c += 1
else:
cc += (c % 2 == 0)
c = 1
cc += (c % 2 == 0)
print(cc) | vfc_83521 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "3000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "GTTAAAG",
"output": "1",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 828 | Solve the following coding problem using the programming language python:
In a small restaurant there are *a* tables for one person and *b* tables for two persons.
It it known that *n* groups of people come today, each consisting of one or two people.
If a group consist of one person, it is seated at a vacant one-... | n, a, b = map(int, input().split())
c = 0
ans = 0
for v in map(int, input().split()):
if v == 1:
if a:
a -= 1
elif b:
b -= 1
c += 1
elif c:
c -= 1
else:
ans += 1
else:
if b:
b -= 1
else:
ans += 2
print(ans) | vfc_83525 | {
"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 1 2\n1 2 1 1",
"output": "0",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 817 | Solve the following coding problem using the programming language python:
After returning from the army Makes received a gift — an array *a* consisting of *n* positive integer numbers. He hadn't been solving problems for a long time, so he became interested to answer a particular question: how many triples of indices ... | n = int(input())
a = list(map(int, input().strip().split()))
d = dict()
for i in range(n):
try: d[a[i]] += 1
except: d[a[i]] = 1
l = list(d.keys())
l.sort()
n = len(l)
if n == 1:
a = d[l[0]]
print(a*(a-1)*(a-2) // 6)
elif n == 2:
a, b = d[l[0]], d[l[1]]
if a >= 3:
pr... | vfc_83529 | {
"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 1 1 1",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 3 2 3 4",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
codeforces | verifiable_code | 459 | Solve the following coding problem using the programming language python:
Pashmak has fallen in love with an attractive girl called Parmida since one year ago...
Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the g... | #https://codeforces.com/contest/459/problem/A
x1,y1,x2,y2 = [int(elem) for elem in input().split()]
if y1 == y2:
print(x1, y1+(x2-x1), x2, y2+(x2-x1))
elif x1 == x2:
print(x1+(y2-y1), y1, x2+(y2-y1), y2)
elif abs(y2 - y1) != abs(x2 - x1):
print(-1)
else:
print(x1,y2,x2,y1)
| vfc_83533 | {
"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 0 1",
"output": "1 0 1 1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 1 1",
"output": "0 1 1 0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
codeforces | verifiable_code | 22 | Solve the following coding problem using the programming language python:
Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics of the given sequence. In... | n = int(input())
a = list(map(int,input().split()))
a = set(a)
a = list(a)
a.sort()
if not len(a) ==1:
print(a[1])
else:
print('NO') | vfc_83537 | {
"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": "5\n1 2 3 1 1",
"output": "2",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 346 | Solve the following coding problem using the programming language python:
It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of *n* distinct integers. And then they take turns to make the following moves. During each move,... | from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = a[0]
max = a[0]
for i in a:
if i > max:
max = i
g = gcd(g, i)
ans = (max // g) - n
if ans % 2 == 0:
print("Bob")
else:
print("Alice") | vfc_83541 | {
"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\n2 3",
"output": "Alice",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 957 | Solve the following coding problem using the programming language python:
Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.
Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into ... | n=int(input())
s=list(input())
if s.count("?")==0:
print("No")
exit(0)
f=0
a=s[0]
for i in range(1,n):
if s[i]==s[i-1] and s[i]!="?":
f=1
print("No")
exit(0)
s=["*"]+s+["&"]
#print(s)
y=list("CMY")
#print(y)
for i in range(1,n+1):
g=0
if (s[i-1] in y) and... | vfc_83545 | {
"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\nCY??Y",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\nC?C?Y",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5... |
codeforces | verifiable_code | 76 | Solve the following coding problem using the programming language python:
You are given *N* points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
The input will be provided via standard input and looks as follows:
The first line of input contains one integer n... | """**************************************************************\
BISMILLAHIR RAHMANIR RAHIM
****************************************************************
AUTHOR NAME: MD. TAHURUZZOHA TUHIN
\**************************************************************"""
T = int(inpu... | vfc_83549 | {
"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 1\n-1 -1\n1 -1\n-1 1",
"output": "32",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n6 3",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
codeforces | verifiable_code | 337 | Solve the following coding problem using the programming language python:
The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her *n* students and give each of them a jigsaw puzzle (which, as wikipedia states... | n, m = map(int, input().split())
puzzles = sorted(list(map(int, input().split())))
min_diff = float('inf')
diff = 0
for a, _ in enumerate(range(m - n + 1 )):
diff = puzzles[n-1] - puzzles[a]
min_diff = min(min_diff, diff)
# print(diff)
n+=1
min_diff = min(min_diff, diff)
print(min_diff)
... | vfc_83553 | {
"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 6\n10 12 10 7 5 22",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n4 4",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
codeforces | verifiable_code | 122 | Solve the following coding problem using the programming language python:
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almo... | n=int(input(""))
while not(1<=n<=1000):
n=int(input(""))
l=[4,7,47,74,477,447,444,44,77,777,774,744,474]
p=len(l)
i=0
test=False
while not test and i<p:
if n%l[i]==0:
test=True
else:
i+=1
if test:
print("YES")
else:
print("NO")
| vfc_83557 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "47",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "78",
"o... |
codeforces | verifiable_code | 997 | Solve the following coding problem using the programming language python:
You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones.
Let's call a sequence of consecutive elements $a_i, a_{i<=+<=1}, \ldots,<=a_j$ ($1\leq<=i\leq<=j\leq<=n$) a substring of string $a$.
You can apply the following operati... | import math
import sys
import queue
def solve():
n, x, y = map(int, input().split())
s = str(input())
subsq = 1
zeros = int(s[0] == "0")
for i in range(1, n):
if s[i] != s[i - 1]:
subsq += 1
if s[i] == "0":
zeros += 1
res = 0
... | vfc_83561 | {
"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 1 10\n01000",
"output": "11",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 10 1\n01000",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
codeforces | verifiable_code | 549 | Solve the following coding problem using the programming language python:
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular ... | n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
d=set(['f','a','c','e'])
k=0
for i in range(n-1):
for j in range(m-1):
if a[i][j] in d:
s=set()
s.add(a[i][j])
s.add(a[i+1][j])
s.add(a[i+1][j+1])
s.add(a[i][j+1])
if s==d:
k+=1
print(k) | vfc_83565 | {
"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 4\nxxxx\nxfax\nxcex\nxxxx",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\nxx\ncf\nae\nxx",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name... |
codeforces | verifiable_code | 765 | Solve the following coding problem using the programming language python:
There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konsta... | n = int(input())
home = input()
flights = []
be_in_home = 0
not_in_home = 0
for i in range(n):
airport_from, airport_to = map(str, input().split('->'))
flights.append([airport_from, airport_to])
for x in flights:
if x[1] == home:
be_in_home += 1
else:
not_in_home += 1
if be_in_home !=... | vfc_83569 | {
"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\nSVO\nSVO->CDG\nLHR->SVO\nSVO->LHR\nCDG->SVO",
"output": "home",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nSVO\nSVO->HKT\nHKT->SVO\nSVO->RAP",
"output": "contest",
"type... |
codeforces | verifiable_code | 475 | 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 horizonta... | n, m = map(int, input("").split())
row_order = [ char for char in input("")]
col_order = [char for char in input("")]
class Node():
def __init__(self, id):
self.row_id, self.col_id = id
self.children = []
def add_child(self, child_node_id):
self.children.append(child_node_id... | vfc_83573 | {
"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 3\n><>\nv^v",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 6\n<><>\nv^v^v^",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
codeforces | verifiable_code | 131 | Solve the following coding problem using the programming language python:
wHAT DO WE NEED cAPS LOCK FOR?
Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage.
L... | inp = input()
if inp[0]==inp[0].lower() and inp[1:]==inp[1:].upper():
print(inp.title())
elif inp==inp.upper():
print(inp.lower())
else:
print(inp) | vfc_83577 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "cAPS",
"output": "Caps",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Lock",
"output": "Lock",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "cAPSlOC... |
codeforces | verifiable_code | 296 | Solve the following coding problem using the programming language python:
Yaroslav has an array that consists of *n* integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time.
Help... | n = int(input())
a = list(map(int, input().split()))
ok = True
for val in a:
if a.count(val) > (n+1)//2:
ok = False
break
print('YES' if ok else 'NO') | vfc_83581 | {
"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": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 2",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n7 ... |
codeforces | verifiable_code | 14 | Solve the following coding problem using the programming language python:
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with *n* rows and *m* columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives... | def main():
n, m = list(map(int, input().split()))
arr = []
for _ in range(n):
arr.append(input())
mn_i, mx_i, mx_j, mn_j = n, -1, -1, m
for i in range(n):
for j in range(m):
if arr[i][j] == "*":
mn_i = min(mn_i, i)
mx_i = max(m... | vfc_83585 | {
"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 7\n.......\n..***..\n..*....\n..***..\n..*....\n..***..",
"output": "***\n*..\n***\n*..\n***",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n***\n*.*\n***",
"output": "***\n*.*\... |
codeforces | verifiable_code | 954 | Solve the following coding problem using the programming language python:
Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by chara... | n=int(input())
s=input()
c=[]
for i in range(n):
c.append(s[i])
for i in range(n-1):
if c[i]=="U" and c[i+1]=="R":
c[i]="D"
c[i+1]="D"
if c[i]=="R" and c[i+1]=="U":
c[i]="D"
c[i+1]="D"
print(n-((c.count("D"))//2))
| vfc_83589 | {
"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\nRUURU",
"output": "3",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 143 | Solve the following coding problem using the programming language python:
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she ca... | row1 , row2 = map(int,input().split())
col1 , col2 = map(int,input().split())
dia1 , dia2 = map(int,input().split())
message=1
b1 , b2 = 0,0
b3 , b4 = 0,0
for a in range(1,10):
b1 = a
for b in range(1,10):
b2 = b
for c in range(1,10):
b3 = c
for d in range(1,1... | vfc_83593 | {
"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 7\n4 6\n5 5",
"output": "1 2\n3 4",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 609 | Solve the following coding problem using the programming language python:
Sean is trying to save a large file to a USB flash drive. He has *n* USB flash drives with capacities equal to *a*1,<=*a*2,<=...,<=*a**n* megabytes. The file size is equal to *m* megabytes.
Find the minimum number of USB flash drives needed to... | n = int(input())
m = int(input())
l = []
for i in range(n):
s = int(input())
l.append(s)
a =0
while(m>0):
a+=1
k = max(l)
c = l.index(k)
m -=k
l.pop(c)
if(m<=0):
break
print(a) | vfc_83597 | {
"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\n5\n2\n1\n3",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n6\n2\n3\n2",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
codeforces | verifiable_code | 386 | Solve the following coding problem using the programming language python:
In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction *n* bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs ... | n=int(input())
lst=list(map(int,input().split()))
q=lst.index(max(lst))+1
lst.sort()
p=lst[-2]
print(q,p) | vfc_83601 | {
"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\n5 7",
"output": "2 5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n10 2 8",
"output": "1 8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\... |
codeforces | verifiable_code | 518 | Solve the following coding problem using the programming language python:
Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.
During the last lesson the teacher has provided two strings *s* and *t* t... | from bisect import bisect_left, bisect_right
from collections import Counter, deque
from functools import lru_cache
from math import factorial, comb, sqrt, gcd, lcm
from copy import deepcopy
import heapq
def num_to_str(n):
chushu = (n - 1) // 26
yushu = (n - 1) % 26
if chushu == 0:
retur... | vfc_83605 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "a\nc",
"output": "b",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaa\nzzz",
"output": "kkk",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abcdefg... |
codeforces | verifiable_code | 603 | Solve the following coding problem using the programming language python:
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length *n*. Each character of Kevin's string represents Kevin's score on one of the *n* questions of the olym... | n,s=int(input()),input()
print(min(n,s.count('01')+s.count('10')+3))
| vfc_83617 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n10000011",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n01",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n10... |
codeforces | verifiable_code | 399 | Solve the following coding problem using the programming language python:
User ainta is making a web site. This time he is going to make a navigation of the pages. In his site, there are *n* pages numbered by integers from 1 to *n*. Assume that somebody is on the *p*-th page now. The navigation will look like this:
W... | n, p, k = map(int, input().split())
string = ''
if p != 1 and p != n:
if p - k <= 1:
string += ' '.join(map(str, [i for i in range(1, p)]))
string += ' ({}) '.format(p)
else:
string += '<< '
string += ' '.join(map(str, [i for i in range(p - k, p)]))
string += ' (... | vfc_83621 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "500"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "17 5 2",
"output": "<< 3 4 (5) 6 7 >> ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 5 2",
"output": "<< 3 4 (5) 6 ",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 602 | Solve the following coding problem using the programming language python:
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers *X* and *Y* realised that they have different bases, which complicated their relations.
You're given a number *X* represented in base *b**x* and a number *Y* rep... | # import sys
# sys.stdin = open('cf602a.in')
n, bx = map(int, input().split())
x = list(map(int, input().split()))
m, by = map(int, input().split())
y = list(map(int, input().split()))
xx = sum(v * bx**(len(x) - i - 1) for i, v in enumerate(x))
yy = sum(v * by**(len(y) - i - 1) for i, v in enumerate(y))
... | vfc_83625 | {
"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 2\n1 0 1 1 1 1\n2 10\n4 7",
"output": "=",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 0 2\n2 5\n2 4",
"output": "<",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 958 | Solve the following coding problem using the programming language python:
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign *R* Rebel spaceships to guard *B* bases so that every base has exactly one guardian and each spaceship has exactl... | def ccw(A, B, C):
return (C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0])
def intersect(A, B, C, D):
return ccw(A, C, D) != ccw(B, C, D) and ccw(A, B, C) != ccw(A, B, D)
R, B = map(int, input().split())
rs = []
bs = []
for r in range(R):
rs.append(list(map(int, input().split())))
for r in ... | vfc_83633 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2500"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\n1 0\n2 2\n3 1",
"output": "No",
"type": "stdin_stdout"
},
{
... |
codeforces | verifiable_code | 466 | Solve the following coding problem using the programming language python:
Ann has recently started commuting by subway. We know that a one ride subway ticket costs *a* rubles. Besides, Ann found out that she can buy a special ticket for *m* rides (she can buy it several times). It costs *b* rubles. Ann did the math; s... | import math
numbers = input('')
numbers = numbers.split(' ')
numbers = [int(i) for i in numbers]
n = numbers[0]
m = numbers[1]
a = numbers[2]
b = numbers[3]
without_special = n * a
with_special = ((math.ceil(n / m) * m) / m) * b
hybrid = (math.floor(n / m) * b) + ((n % m) * a)
print(int(min(without_s... | vfc_83637 | {
"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 2 1 2",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2 2 3",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 3 5 ... |
codeforces | verifiable_code | 985 | Solve the following coding problem using the programming language python:
You are given *n* switches and *m* lamps. The *i*-th switch turns on some subset of the lamps. This information is given as the matrix *a* consisting of *n* rows and *m* columns where *a**i*,<=*j*<==<=1 if the *i*-th switch turns on the *j*-th l... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 21 22:31:07 2018
@author: thomas
"""
integers=input()
[n,m]=[int(x) for x in integers.split()]
a=[]
for i in range(n):
row_i=input()
a_i=[]
for j in range(m):
a_i.append(int(row_i[j]))
a.append(a_i)
indicator=False
#all_... | vfc_83641 | {
"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 5\n10101\n01000\n00111\n10000",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5\n10100\n01000\n00110\n00101",
"output": "NO",
"type": "stdin_stdout"
},
... |
codeforces | verifiable_code | 209 | Solve the following coding problem using the programming language python:
Polycarpus plays with red and blue marbles. He put *n* marbles from the left to the right in a row. As it turned out, the marbles form a zebroid.
A non-empty sequence of red and blue marbles is a zebroid, if the colors of the marbles in this se... | import sys
input = lambda: sys.stdin.readline().rstrip()
MOD = 10**9+7
N = int(input())
dp = [[0,0] for _ in range(N+1)]
for i in range(N):
dp[i+1][0]=dp[i][0]
dp[i+1][1]=dp[i][1]
if i%2:
dp[i+1][1]+=dp[i][0]+1
else:
dp[i+1][0]+=dp[i][1]+1
dp[i+1][0]%=MOD
dp[i+1]... | vfc_83645 | {
"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": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4",
"output": "11",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1",
"output"... |
codeforces | verifiable_code | 892 | Solve the following coding problem using the programming language python:
Jafar has *n* cans of cola. Each can is described by two integers: remaining volume of cola *a**i* and can's capacity *b**i* (*a**i* <=≤<= *b**i*).
Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or no... | n=int(input())
left=[int(x) for x in input().split()]
cap=[int(x) for x in input().split()]
m1=max(cap)
l=cap;l.remove(m1);
m2=max(l)
if m1+m2>=sum(left):
print("YES")
else:
print('NO')
| vfc_83653 | {
"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\n3 5\n3 6",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n6 8 9\n6 10 12",
"output": "NO",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 357 | Solve the following coding problem using the programming language python:
At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to the results, each student... | estudiantes = int(input())
calificaciones = list(str(input()).split())
xy = list(str(input()).split())
contador1 = 0
contador2 = 0
partitura = 0
entro = False
for i in range(len(calificaciones)):
calificaciones[i] = int(calificaciones[i])
xy[0] = int(xy[0])
xy[1] = int(xy[1])
for j in range(len(calificaciones)):
... | vfc_83657 | {
"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\n3 4 3 2 1\n6 8",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n0 3 3 4 2\n3 10",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
codeforces | verifiable_code | 851 | Solve the following coding problem using the programming language python:
Arpa is researching the Mexican wave.
There are *n* spectators in the stadium, labeled from 1 to *n*. They start the Mexican wave at time 0.
- At time 1, the first spectator stands. - At time 2, the second spectator stands. - ... - At tim... | mass = input().split()
n = int(mass[0])
k = int(mass[1])
t = int(mass[2])
'''for i in range(1, t + 1):
if i <= k:
result = result + 1
elif i <= n:
result = result
else:
result = result - 1
'''
if t <= k:
print(t)
elif t <= n:
print(k)
else:
print(... | vfc_83661 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 5 3",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5 7",
"output": "5",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 453 | Solve the following coding problem using the programming language python:
Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.
The dice has *m* faces: ... | def prob(m, n):
ans = 0.0
i = m
while (i):
ans += (pow(i / m, n) - pow((i - 1) / m, n)) * i
i = i - 1
return ans
m, n = map(int, input().split())
print(prob(m, n))
| vfc_83665 | {
"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 1",
"output": "3.500000000000",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 768 | Solve the following coding problem using the programming language python:
"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the... | x = int(input())
s = list(map(int,input().split()))
c = 0
max = max(s)
min = min(s)
for i in range(0,x):
if s[i] != max and s[i]!=min:
c = c + 1
print(c) | vfc_83669 | {
"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 5",
"output": "0",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 344 | Solve the following coding problem using the programming language python:
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together ... | n=int(input())
m_o=[input() for _ in range(n)]
grp=1
for i in range(1,n):
if m_o[i]!=m_o[i-1]:
grp+=1
print(grp)
| vfc_83673 | {
"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\n10\n10\n10\n01\n10\n10",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n01\n01\n10\n10",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": n... |
codeforces | verifiable_code | 779 | Solve the following coding problem using the programming language python:
Igor found out discounts in a shop and decided to buy *n* items. Discounts at the store will last for a week and Igor knows about each item that its price now is *a**i*, and after a week of discounts its price will be *b**i*.
Not all of sellers... | import sys
from os import path
if (path.exists('input.txt') and path.exists('output.txt')):
sys.stdout = open('output.txt', 'w')
sys.stdin = open('input.txt', 'r')
def main():
n, k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
di... | vfc_83677 | {
"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 1\n5 4 6\n3 1 5",
"output": "10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\n3 4 7 10 3\n4 5 5 12 5",
"output": "25",
"type": "stdin_stdout"
},
{
"fn_name... |
codeforces | verifiable_code | 1000 | Solve the following coding problem using the programming language python:
You are given $n$ segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide.
Your task is the ... | import collections
if __name__ == '__main__':
n = int(input())
ans = collections.defaultdict(int)
for i in range(n):
l, r = list(map(int, input().strip().split()))
ans[l] += 1; ans[r + 1] -= 1
ans = dict(sorted(ans.items(), key=lambda k: k[0]))
keys = list(ans.keys())
... | vfc_83681 | {
"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\n0 3\n1 3\n3 8",
"output": "6 2 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 3\n2 4\n5 7",
"output": "5 2 0 ",
"type": "stdin_stdout"
},
{
"fn_name": n... |
codeforces | verifiable_code | 865 | Solve the following coding problem using the programming language python:
Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original pro... | n=int(input())
print(2*n-1, 2)
print(1, 2) | vfc_83689 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "18",
"output": "30 4\n1 5 10 25",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3",
"output": "20 2\n5 2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
codeforces | verifiable_code | 161 | Solve the following coding problem using the programming language python:
The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.
The Two-dimens... | # 161A-sua bai >> accepted
# n: num of solder
# m: num of vest
# x: margin duoi
# y: margin tren
# chu giai giai thuat: i chay tu 0>>n, neu ao vest b[j] nho hon (a[i]-x), thi tang j (xet bo ao vest tiep theo) cho toi khi tim
# thay j phu hop, sau do xet xem ung voi j do, ao vest co phu hop voi soldier i ko (b[j]<(a[i]+... | vfc_83693 | {
"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 3 0 0\n1 2 3 3 4\n1 3 5",
"output": "2\n1 1\n3 2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 2 2\n1 5 9\n3 5 7",
"output": "3\n1 1\n2 2\n3 3",
"type": "stdin_stdout"
... |
codeforces | verifiable_code | 812 | Solve the following coding problem using the programming language python:
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off.
Th... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,m=map(int,input().strip().split())
a=[]
L=[]
R=[]
t={}
for i in range(n):
b=input()
a.append(b)
L.append(9000000)
R.append(0)
t[i]=0
a.reverse()
for i in range(n):
for j in range(m+2):
if a[i][j]=='1':
L[i]=min... | vfc_83697 | {
"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 2\n0010\n0100",
"output": "5",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 355 | Solve the following coding problem using the programming language python:
Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you.
Let's assume that *S*(*n*) is the sum of digits of number *n*, for example, *S*(4098)<==<=4<=+<=0<=+<=9<=+<=8<==<=21. Then the digit... | k,d = input().split()
k,d = int(k), int(d)
if k==1:
print(d)
elif d!=0:
s = '1'*(k-1)
m = int(s)
m = 9*m + d
print(m)
else:
print("No solution")
| vfc_83701 | {
"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 4",
"output": "5881",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1",
"output": "36172",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0",
... |
codeforces | verifiable_code | 414 | Solve the following coding problem using the programming language python:
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.
In this game Mashmokh writes sequence of *n* distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes th... | # 414A
from sys import stdin
__author__ = 'artyom'
n, k = list(map(int, stdin.readline().strip().split()))
if n == 1:
if k == 0:
print(1)
else:
print(-1)
exit()
pairs = n // 2
if k < pairs:
print(-1)
exit()
x, y = 1, 2
if k > pairs:
x = k - pairs + 1
y = x * 2
print... | vfc_83705 | {
"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": "1 2 3 4 5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3",
"output": "2 4 5 6 7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
codeforces | verifiable_code | 195 | Solve the following coding problem using the programming language python:
After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has *n* balls and *m* baskets. The baskets are positioned in a row from left... | #----------------------------
# Matheus de Souza Oliveira |
# RA: 203407 |
#----------------------------
n, m = list(map(int, input().split()))
for index in range(0, n):
factor = m+index%m
isFactorEven = not(bool(factor%2))
if isFactorEven:
result = int((m-(index%m))/2)
pr... | vfc_83709 | {
"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 3",
"output": "2\n1\n3\n2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1",
"output": "1\n1\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "... |
codeforces | verifiable_code | 304 | Solve the following coding problem using the programming language python:
Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap yea... | import datetime
d1=datetime.datetime.strptime(input(),"%Y:%m:%d")
d2=datetime.datetime.strptime(input(),"%Y:%m:%d")
print(abs((d2-d1).days)) | vfc_83713 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "3000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1900:01:01\n2038:12:31",
"output": "50768",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1996:03:09\n1991:11:12",
"output": "1579",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 15 | Solve the following coding problem using the programming language python:
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» *n* square houses with the centres on the *Оx*-axis. The houses' sides are parallel to the coordinate axes. It's known that no two... | from collections import deque
lst = [w.rstrip() for w in open(0).readlines()]
n, t = map(int, lst[0].split())
data = [tuple(map(int, x.split())) for x in lst[1:]]
L, R = [], []
for x in data:
L.append(x[0] - x[1] / 2)
R.append(x[0] + x[1] / 2)
L.sort()
R.sort()
d = deque()
for a, b in zip(L, R):
... | vfc_83717 | {
"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\n0 4\n6 2",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n0 4\n5 2",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
codeforces | verifiable_code | 651 | Solve the following coding problem using the programming language python:
Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at *a*1 percent and second one is charged at *a*2 percent. You can connect charger to a joystick only at the beginning ... | a,b = [int(x) for x in input().split(" ")]
time = 0
while a and b:
if a==1 and b==1:
break
if a<b:
a += 1
b -= 2
else:
b += 1
a -= 2
time+=1
print(time) | vfc_83721 | {
"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 5",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 100",
... |
codeforces | verifiable_code | 378 | Solve the following coding problem using the programming language python:
Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.
The fi... | m=list(map(int,input().split()))
result_a_win=result_draw=result_b_win=0
for i in range(1,7):
if abs(m[0]-i)<abs(m[1]-i):
result_a_win += 1
if abs(m[0]-i)==abs(m[1]-i):
result_draw += 1
if abs(m[0]-i)>abs(m[1]-i):
result_b_win += 1
print(result_a_win,result_draw,result_b_... | vfc_83725 | {
"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 5",
"output": "3 0 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 4",
"output": "2 1 3",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 513 | Solve the following coding problem using the programming language python:
You are given a permutation *p* of numbers 1,<=2,<=...,<=*n*. Let's define *f*(*p*) as the following sum:
Find the lexicographically *m*-th permutation of length *n* in the set of permutations having the maximum possible value of *f*(*p*).
The... | import itertools
n, m = tuple(int(x) for x in input().split())
lstN = [x for x in range(1,n+1)]
def funcP(seq):
res = 0
for i in range(len(seq)):
for j in range(i, len(seq)):
res += min(seq[i:j+1])
return res
allPerm = [(perm,funcP(perm)) for perm in itertools.permutations(lstN)]
allPerm.sort(key = lambda x: ... | vfc_83729 | {
"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 2",
"output": "2 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2",
"output": "1 3 2 ",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 287 | Solve the following coding problem using the programming language python:
In the city of Ultima Thule job applicants are often offered an IQ test.
The test is as follows: the person gets a piece of squared paper with a 4<=×<=4 square painted on it. Some of the square's cells are painted black and others are painted ... | from copy import deepcopy
zoz=[]
for i in range(4):
zoz.append(list(input()))
def check(zoz):
for i in range(3):
for j in range(3):
if zoz[i][j]==zoz[i][j+1] and zoz[i+1][j]==zoz[i+1][j+1] and zoz[i+1][j]==zoz[i][j]:
return True
return False
def chan... | vfc_83733 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "400"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "###.\n...#\n###.\n...#",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ".##.\n#..#\n.##.\n#..#",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name... |
codeforces | verifiable_code | 961 | Solve the following coding problem using the programming language python:
Your friend Mishka and you attend a calculus lecture. Lecture lasts *n* minutes. Lecturer tells *a**i* theorems during the *i*-th minute.
Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. Y... | n, k = map(int, input().split())
lectures = list(map(int, input().split()))
sleeping = list(map(int, input().split()))
dp_ok = [0] * (n - k + 1)
dp_magic = [0] * (n - k + 1)
s1, s2 = 0, 0
for i in range(k):
s1 += lectures[i] * sleeping[i]
s2 += lectures[i]
dp_ok[0] = s1
dp_magic[0] = s2
max_diff, m... | vfc_83737 | {
"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 3\n1 3 5 2 5 4\n1 1 0 1 0 0",
"output": "16",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\n1 9999 10000 10000 10000\n0 0 0 0 0",
"output": "30000",
"type": "stdin_stdout"... |
codeforces | verifiable_code | 53 | Solve the following coding problem using the programming language python:
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the following order: *a*1,<=*a*2,<=...,<=*a**n*, where *a**i*... | def vasya_and_physcult(count, a_str, b_str):
size = int(count)
a = list(map(int, a_str.split()))
b = list(map(int, b_str.split()))
changes_count = 0
result = ""
for i in range(size):
current_index = i
for j in range(i,size):
if b[j] == a[i]:
c... | vfc_83741 | {
"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 2 3 2\n3 2 1 2",
"output": "4\n2 3\n1 2\n3 4\n2 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 100500\n1 100500",
"output": "0",
"type": "stdin_stdout"
},
{
... |
codeforces | verifiable_code | 707 | Solve the following coding problem using the programming language python:
Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.
As you may know, the coolest photos are on th... | n,m=map(int, input().split())
temp=""
for i in range(n):
temp=temp+input()
if temp.count('C')>0 or temp.count('M')>0 or temp.count('Y')>0:
print('#Color')
else:
print("#Black&White") | vfc_83745 | {
"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 2\nC M\nY Y",
"output": "#Color",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\nW W\nW W\nB B",
"output": "#Black&White",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 724 | Solve the following coding problem using the programming language python:
You are given a table consisting of *n* rows and *m* columns.
Numbers in each row form a permutation of integers from 1 to *m*.
You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more th... | from sys import stdin
from sys import stdout
from sys import exit
nm = [int(x) for x in stdin.readline()[:-1].split(' ')]
n = nm[0]
m = nm[1]
matrice = [[] for z in range(n)]
for i in range(n):
matrice[i] = [int(x) for x in stdin.readline()[:-1].split(' ')]
cancomplete = False
a = [[0 for i in range(n)] for j in ra... | vfc_83749 | {
"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 4\n1 3 2 4\n1 3 4 2",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n1 2 3 4\n2 3 4 1\n3 4 1 2\n4 1 2 3",
"output": "NO",
"type": "stdin_stdout"
},
... |
codeforces | verifiable_code | 526 | Solve the following coding problem using the programming language python:
One day Om Nom found a thread with *n* beads of different colors. He decided to cut the first several beads from this thread to make a bead necklace and present it to his girlfriend Om Nelly.
Om Nom knows that his girlfriend loves beautiful pat... |
def prefix_function(s: str):
n = len(s)
pi = [0] * n
k = 0
for i in range(1, n):
while k > 0 and s[i] != s[k]:
k = pi[k - 1]
if s[i] == s[k]:
k += 1
pi[i] = k
return pi
def z_function(s: str):
n = len(s)
z = [0] * n
l, r = 0, 0
for i in range(1, n):
z[i] = 0 if i >= r els... | vfc_83753 | {
"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 2\nbcabcab",
"output": "0000011",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "21 2\nababaababaababaababaa",
"output": "000110000111111000011",
"type": "stdin_stdout"
},
... |
codeforces | verifiable_code | 813 | Solve the following coding problem using the programming language python:
Unlucky year in Berland is such a year that its number *n* can be represented as *n*<==<=*x**a*<=+<=*y**b*, where *a* and *b* are non-negative integer numbers.
For example, if *x*<==<=2 and *y*<==<=3 then the years 4 and 17 are unlucky (4<==<=... | def parser():
while 1:
data = list(input().split(' '))
for number in data:
if len(number) > 0:
yield(number)
input_parser = parser()
def get_word():
global input_parser
return next(input_parser)
def get_number():
data = get_word()
try:... | vfc_83757 | {
"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 3 1 10",
"output": "1",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 48 | Solve the following coding problem using the programming language python:
Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case it is hard to determine to... | F=input()
M=input()
S=input()
Beater={"paper":"scissors","scissors":"rock","rock":"paper"}
if S==Beater[F] and F==M:
print("S")
elif F==Beater[S] and S==M:
print("F")
elif M==Beater[F] and F==S:
print("M")
else:
print("?")
| vfc_83761 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "rock\nrock\nrock",
"output": "?",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "paper\nrock\nrock",
"output": "F",
"type": "stdin_stdout"
}
]
} |
codeforces | verifiable_code | 960 | Solve the following coding problem using the programming language python:
You are given two arrays *A* and *B*, each of size *n*. The error, *E*, between these two arrays is defined . You have to perform exactly *k*1 operations on array *A* and exactly *k*2 operations on array *B*. In one operation, you have to choose... | n, k1, k2 = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0]*n
for i in range(n):
c[i] = abs(a[i] - b[i])
k = k1 + k2
while k != 0:
max_value = c[0]
max_index = 0
for i, v in enumerate(c):
if v > max_value:
max_valu... | vfc_83765 | {
"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 0 0\n1 2\n2 3",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1 0\n1 2\n2 2",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
codeforces | verifiable_code | 437 | Solve the following coding problem using the programming language python:
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correc... | a=['0']*4
b=[""]*4
c=[0]*4
for i in range(4):
a[i],b[i]=map(str,input().split('.'))
c[i]=len(b[i])
c=sorted(c)
x=0
if(c[0]*2<=c[1]):
x=1
if(c[2]*2<=c[3]):
if(x==0):
x=2
else:
x=0
if(x==1):
for i in range(4):
if(len(b[i])==c[0]):
print(a[i])
... | vfc_83769 | {
"difficulty": "N/A",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1000"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A.VFleaKing_is_the_author_of_this_problem\nB.Picks_is_the_author_of_this_problem\nC.Picking_is_the_author_of_this_problem\nD.Ftiasch_is_cute",
"output": "D",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.