message stringlengths 2 65.1k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 0 108k | cluster float64 14 14 | __index_level_0__ int64 0 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1 | instruction | 0 | 94,994 | 14 | 189,988 |
Tags: binary search, data structures
Correct Solution:
```
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
import os
import sys
from io import BytesIO, IOBase
import heapq as h
import bisect
from types import GeneratorType
BUFSIZE = 8192
class SortedList:
def __init__(self, iterable=[], _load=200):
"""Initialize sorted list instance."""
values = sorted(iterable)
self._len = _len = len(values)
self._load = _load
self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
self._list_lens = [len(_list) for _list in _lists]
self._mins = [_list[0] for _list in _lists]
self._fen_tree = []
self._rebuild = True
def _fen_build(self):
"""Build a fenwick tree instance."""
self._fen_tree[:] = self._list_lens
_fen_tree = self._fen_tree
for i in range(len(_fen_tree)):
if i | i + 1 < len(_fen_tree):
_fen_tree[i | i + 1] += _fen_tree[i]
self._rebuild = False
def _fen_update(self, index, value):
"""Update `fen_tree[index] += value`."""
if not self._rebuild:
_fen_tree = self._fen_tree
while index < len(_fen_tree):
_fen_tree[index] += value
index |= index+1
def _fen_query(self, end):
"""Return `sum(_fen_tree[:end])`."""
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
x = 0
while end:
x += _fen_tree[end - 1]
end &= end - 1
return x
def _fen_findkth(self, k):
"""Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`)."""
_list_lens = self._list_lens
if k < _list_lens[0]:
return 0, k
if k >= self._len - _list_lens[-1]:
return len(_list_lens) - 1, k + _list_lens[-1] - self._len
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
idx = -1
for d in reversed(range(len(_fen_tree).bit_length())):
right_idx = idx + (1 << d)
if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
idx = right_idx
k -= _fen_tree[idx]
return idx + 1, k
def _delete(self, pos, idx):
"""Delete value at the given `(pos, idx)`."""
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len -= 1
self._fen_update(pos, -1)
del _lists[pos][idx]
_list_lens[pos] -= 1
if _list_lens[pos]:
_mins[pos] = _lists[pos][0]
else:
del _lists[pos]
del _list_lens[pos]
del _mins[pos]
self._rebuild = True
def _loc_left(self, value):
"""Return an index pair that corresponds to the first position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
lo, pos = -1, len(_lists) - 1
while lo + 1 < pos:
mi = (lo + pos) >> 1
if value <= _mins[mi]:
pos = mi
else:
lo = mi
if pos and value <= _lists[pos - 1][-1]:
pos -= 1
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value <= _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def _loc_right(self, value):
"""Return an index pair that corresponds to the last position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
pos, hi = 0, len(_lists)
while pos + 1 < hi:
mi = (pos + hi) >> 1
if value < _mins[mi]:
hi = mi
else:
pos = mi
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value < _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def add(self, value):
"""Add `value` to sorted list."""
_load = self._load
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len += 1
if _lists:
pos, idx = self._loc_right(value)
self._fen_update(pos, 1)
_list = _lists[pos]
_list.insert(idx, value)
_list_lens[pos] += 1
_mins[pos] = _list[0]
if _load + _load < len(_list):
_lists.insert(pos + 1, _list[_load:])
_list_lens.insert(pos + 1, len(_list) - _load)
_mins.insert(pos + 1, _list[_load])
_list_lens[pos] = _load
del _list[_load:]
self._rebuild = True
else:
_lists.append([value])
_mins.append(value)
_list_lens.append(1)
self._rebuild = True
def discard(self, value):
"""Remove `value` from sorted list if it is a member."""
_lists = self._lists
if _lists:
pos, idx = self._loc_right(value)
if idx and _lists[pos][idx - 1] == value:
self._delete(pos, idx - 1)
def remove(self, value):
"""Remove `value` from sorted list; `value` must be a member."""
_len = self._len
self.discard(value)
if _len == self._len:
raise ValueError('{0!r} not in list'.format(value))
def pop(self, index=-1):
"""Remove and return value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
value = self._lists[pos][idx]
self._delete(pos, idx)
return value
def bisect_left(self, value):
"""Return the first index to insert `value` in the sorted list."""
pos, idx = self._loc_left(value)
return self._fen_query(pos) + idx
def bisect_right(self, value):
"""Return the last index to insert `value` in the sorted list."""
pos, idx = self._loc_right(value)
return self._fen_query(pos) + idx
def count(self, value):
"""Return number of occurrences of `value` in the sorted list."""
return self.bisect_right(value) - self.bisect_left(value)
def __len__(self):
"""Return the size of the sorted list."""
return self._len
def __getitem__(self, index):
"""Lookup value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
return self._lists[pos][idx]
def __delitem__(self, index):
"""Remove value at `index` from sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
self._delete(pos, idx)
def __contains__(self, value):
"""Return true if `value` is an element of the sorted list."""
_lists = self._lists
if _lists:
pos, idx = self._loc_left(value)
return idx < len(_lists[pos]) and _lists[pos][idx] == value
return False
def __iter__(self):
"""Return an iterator over the sorted list."""
return (value for _list in self._lists for value in _list)
def __reversed__(self):
"""Return a reverse iterator over the sorted list."""
return (value for _list in reversed(self._lists) for value in reversed(_list))
def __repr__(self):
"""Return string representation of sorted list."""
return 'SortedList({0})'.format(list(self))
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
import os
self.os = os
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
self.os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
import collections as col
import math, string
def getInts():
return [int(s) for s in input().split()]
def getInt():
return int(input())
def getStrs():
return [s for s in input().split()]
def getStr():
return input()
def listStr():
return list(input())
MOD = 10**9+7
mod=10**9+7
#t=int(input())
t=1
p=10**9+7
def ncr_util():
inv[0]=inv[1]=1
fact[0]=fact[1]=1
for i in range(2,300001):
inv[i]=(inv[i%p]*(p-p//i))%p
for i in range(1,300001):
inv[i]=(inv[i-1]*inv[i])%p
fact[i]=(fact[i-1]*i)%p
def solve():
l1=[]
x=l[len(l)-1]
l1.append(x)
d={}
d[x]=len(l)-1
for i in range(len(l)-1,-1,-1):
if x>l[i]:
x=l[i]
d[x]=i
l1.append(x)
else:
l1.append(l1[-1])
ans=[]
l1.reverse()
#print(l,l1)
for i in range(len(l)):
if l1[i]<l[i]:
pos=bisect.bisect_left(l1,l[i])
#print(l[i],pos)
ans.append(d[l1[pos-1]]-i-1)
else:
ans.append(-1)
return ans
for _ in range(t):
n=int(input())
#n=int(input())
#n,m,k,p=(map(int,input().split()))
#n1=n
#x=int(input())
#b=int(input())
#n,m,k=map(int,input().split())
#r,g=map(int,input().split())
#n=int(input())
#s=input()
#p=input()
l=list(map(float,input().split()))
#l.sort()
#l.sort(revrese=True)
#l2=list(map(int,input().split()))
#l=str(n)
#l.sort(reverse=True)
#l2.sort(reverse=True)
#l1.sort(reverse=True)
print(*solve())
``` | output | 1 | 94,994 | 14 | 189,989 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1 | instruction | 0 | 94,995 | 14 | 189,990 |
Tags: binary search, data structures
Correct Solution:
```
n = int(input())
from bisect import bisect_left as br
a = [int(x) for x in input().split()]
mn = [10 ** 10 for i in range(n)]
mn[-1] = a[-1]
for i in range(n - 2, -1 , -1):
mn[i] = min(mn[i + 1], a[i])
ans = [0] * n
for i in range(n):
pos = br(mn, a[i])
#print(pos)
if a[pos - 1] < a[i]:
ans[i] = max(-1, pos - 1- i - 1)
else:
ans[i] = -1
print(*ans)
``` | output | 1 | 94,995 | 14 | 189,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1 | instruction | 0 | 94,996 | 14 | 189,992 |
Tags: binary search, data structures
Correct Solution:
```
n=int(input())
x=[int(q) for q in input().split()]
l=[0]*n
def search(i,l,h):
pos=-1
while(h>=l):
mid=(l+h)//2
if x[mid]<x[i]:
pos=mid
l=mid+1
else:
h=mid-1
if pos!=-1:
return pos-i-1
else:
return -1
for i in range(n-1,-1,-1):
l[i]=search(i,i+1,n-1)
if i!=n-1:
x[i]=min(x[i+1],x[i])
print(" ".join(map(str,l)))
``` | output | 1 | 94,996 | 14 | 189,993 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1 | instruction | 0 | 94,997 | 14 | 189,994 |
Tags: binary search, data structures
Correct Solution:
```
n = int(input())
import bisect
arr = list(map(int,input().strip().split()))[:n]
mins = [0]*n
mins[n-1] = arr[-1]
for i in range(n-2,-1,-1):
mins[i] = min(mins[i+1],arr[i])
ans = []
for i in range(n-1):
if arr[i] <= mins[i+1]:
ans.append(-1)
else:
ind = bisect.bisect_right(mins,arr[i]-1)
ans.append(ind-i-2)
ans.append(-1)
for num in ans:
print(num,end=" ")
``` | output | 1 | 94,997 | 14 | 189,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1 | instruction | 0 | 94,998 | 14 | 189,996 |
Tags: binary search, data structures
Correct Solution:
```
from bisect import *
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
b[i] = bisect_left(a, a[i], i + 1, n) - i - 2
a[i] = min(a[i + 1], a[i]) if i != n - 1 else a[i]
print (*b)
``` | output | 1 | 94,998 | 14 | 189,997 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
def f(u, low, high):
poss = -1
while high >= low:
mid = (low + high) // 2
if a[mid] < a[u]:
poss = mid
low = mid + 1
else:
high = mid - 1
return poss - u - 1 if poss != -1 else -1
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
ans[i] = f(i, i + 1, n - 1)
if i != n - 1:
a[i] = min(a[i + 1], a[i])
print (' '.join(map(str, ans)))
``` | instruction | 0 | 94,999 | 14 | 189,998 |
Yes | output | 1 | 94,999 | 14 | 189,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
from collections import defaultdict
mod=10**9+7
for _ in range(1):
n=int(input())
l=list(map(int,input().split()))
l=l[::-1]
a=[l[0]]
pos=[0]
ans=[]
for i in range(1,n):
if a[-1]>l[i]:
pos.append(i)
else:
pos.append(pos[-1])
a.append(min(a[-1],l[i]))
#print(a)
#print(pos)
for i in range(n):
j=pos[i]
x=i
while(j>=0 and a[j]<l[i]):
x=j
if j==0:
break
j=pos[j-1]
if l[i]==a[x]:
ans.append(-1)
else:
ans.append(i-pos[x]-1)
print(*ans[::-1])
``` | instruction | 0 | 95,000 | 14 | 190,000 |
Yes | output | 1 | 95,000 | 14 | 190,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
# It's never too late to start!
from bisect import bisect_left, bisect_right
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq
import re
def sin():
return input()
def ain():
return list(map(int, sin().split()))
def sain():
return input().split()
def iin():
return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007
def sieve(n):
prime = [True for i in range(n+1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
s = set()
for p in range(2, n+1):
if prime[p]:
s.add(p)
return s
def readTree(n, m):
adj = [deque([]) for _ in range(n+1)]
for _ in range(m):
u,v = ain()
adj[u].append(v)
adj[v].append(u)
return adj
# Stay hungry, stay foolish!
def main():
n = iin()
d = deque([])
l = ain()
for i in range(n):
d.append([l[i], i])
k = sorted(d)
maxi = MIN
ans = [0]*n
for i in range(n):
maxi = max(maxi, k[i][1])
ans[k[i][1]] = maxi - k[i][1] - 1
print(*ans)
# Fast IO Template starts
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
if os.getcwd() == 'D:\\code':
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# Fast IO Template ends
if __name__ == "__main__":
main()
# Never Give Up - John Cena
``` | instruction | 0 | 95,001 | 14 | 190,002 |
Yes | output | 1 | 95,001 | 14 | 190,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
from collections import deque
def bs(l,k):
lo=0
ans=-1
hi=len(l)-1
while lo<=hi:
mi=(lo+hi)>>1
if l[mi]<k:
ans=l[mi]
lo=mi+1
else:
hi=mi-1
return ans
for _ in range(1):
n=int(input())
ind={}
suff=[int(i) for i in input().split()]
search=deque()
ans=[0]*n
for i in range(n-1,-1,-1):
if not search:
search.append(suff[i])
ind[suff[i]]=i
else:
if suff[i]<search[0]:
search.appendleft(suff[i])
ind[suff[i]]=i
z=bs(search,suff[i])
if z==-1:
ans[i]=-1
else:
ans[i]=(ind[z]-i-1)
print(' '.join(str(i) for i in ans))
``` | instruction | 0 | 95,002 | 14 | 190,004 |
Yes | output | 1 | 95,002 | 14 | 190,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
#!/usr/bin/env python3
num_lines = input()
raw = input()
items = raw.split(" ")
temp = []
for i in range(len(items)):
count = len(items) - i - 2
j = len(items) - 1
while (j > i):
if(int(items[j]) < int(items[i])):
break
count = count - 1
j = j - 1
temp.append(count)
print(temp)
``` | instruction | 0 | 95,003 | 14 | 190,006 |
No | output | 1 | 95,003 | 14 | 190,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
from math import gcd
input=__import__('sys').stdin.readline
n = int(input())
lis = list(map(int,input().split()))
ans=[0]*n
for i in range(n):
l=i+1
r=n-1
while l<=r:
mid= l + (r-l)//2
a=lis[mid]
if a<lis[i]:
l=mid+1
else:
r=mid-1
if r<i:
ans[i]=-1
else:
ans[i]+=(r-i-1)
print(*ans)
``` | instruction | 0 | 95,004 | 14 | 190,008 |
No | output | 1 | 95,004 | 14 | 190,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
n = int(input())
l = [int(x) for x in input().split()]
stack = [-1]
l = l[-1::-1]
mini = l[0]
maxi= l[0]
minin = 0
maxin = 0
for i in range(1,n):
if l[i]<mini:
mini = l[i]
minin = i
stack.append(-1)
elif l[i]>maxi:
maxi = l[i]
maxin = i
stack.append(i-1)
else:
for j in range(0, len(stack)):
if stack[j]==-1 and l[j]<l[i]:
stack.append(i-j-1)
break
stack = stack[-1::-1]
for i in stack:
print(i, end=' ')
``` | instruction | 0 | 95,005 | 14 | 190,010 |
No | output | 1 | 95,005 | 14 | 190,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.
The airport manager asked you to count for each of n walruses in the queue his displeasure.
Input
The first line contains an integer n (2 β€ n β€ 105) β the number of walruses in the queue. The second line contains integers ai (1 β€ ai β€ 109).
Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.
Output
Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.
Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
c=[]
c1=0
for i in range(n-1,-1,-1):
if c==[] or a[i]<c[c1-1][0]:
c.append([a[i],i])
c1+=1
if i==n-1 or a[i]<a[i+1] and b[i+1]==-1:
b[i]=-1
elif a[i]==a[i+1]:
b[i]=b[i+1]
elif a[i]==c[c1-1][0]:
b[i]=-1
else:
m=round(c1/2)
k=m
while round(k)>0:
if c[m][0]>a[i]:
m+=round(k/2)
else:
m-=round(k/2)
k/=2
while m<c1-1 and c[m][0]>=a[i]:
m+=1
while m>0 and c[m-1][0]<a[i]:
m-=1
b[i]=c[m][1]-i-1
print(*b)
``` | instruction | 0 | 95,006 | 14 | 190,012 |
No | output | 1 | 95,006 | 14 | 190,013 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,823 | 14 | 191,646 |
Tags: greedy
Correct Solution:
```
n = int(input())
S = [input() for i in range(3)]
bu = []
for s in S:
cnt = {}
mx = 0
for c in s:
if c not in cnt:
cnt[c] = 0
cnt[c] += 1
mx = max(mx, cnt[c])
if mx == len(s) and n == 1:
bu.append(mx - 1)
else:
bu.append(min(len(s), mx + n))
ans = -1
ansmx = -1
for i in range(3):
if bu[i] > ansmx:
ans = i
ansmx = bu[i]
elif bu[i] == ansmx:
ans = -1
if ans == -1:
print('Draw')
elif ans == 0:
print('Kuro')
elif ans == 1:
print('Shiro')
else:
print('Katie')
``` | output | 1 | 95,823 | 14 | 191,647 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,824 | 14 | 191,648 |
Tags: greedy
Correct Solution:
```
n = int(input())
s1 = input()
s2 = input()
s3 = input()
s = len(s1)
d1, d2, d3 = dict(), dict(), dict()
for i in s1:
if i not in d1:
d1[i] = 1
else:
d1[i] += 1
for i in s2:
if i not in d2:
d2[i] = 1
else:
d2[i] += 1
for i in s3:
if i not in d3:
d3[i] = 1
else:
d3[i] += 1
max1, max2, max3 = 0, 0, 0
for i in d1:
if d1[i] > max1:
max1 = d1[i]
for i in d2:
if d2[i] > max2:
max2 = d2[i]
for i in d3:
if d3[i] > max3:
max3 = d3[i]
a = []
a.append([s - max1, "Kuro"])
a.append([s - max2, "Shiro"])
a.append([s - max3, "Katie"])
a.sort()
#print(a)
if a[0][0] > n:
if a[0][0] < a[1][0]:
print(a[0][1])
else:
print("Draw")
else:
for j in a:
q = n - j[0]
if q < 0:
j[0] -= n
else:
if n == 1:
j[0] = q % 2
else:
j[0] = 0
a.sort()
#print(a)
if a[0][0] < a[1][0]:
print(a[0][1])
else:
print("Draw")
``` | output | 1 | 95,824 | 14 | 191,649 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,825 | 14 | 191,650 |
Tags: greedy
Correct Solution:
```
def ct(s):
a=[0]*26*2
for i in s:
if ord(i)<97:
a[ord(i)-65]+=1
else:
a[ord(i)-97+26]+=1
return max(a)
n=int(input())
s1=input()
ln=len(s1)
s1=ct(s1)
s2=ct(input())
s3=ct(input())
s=[s1,s2,s3]
for i in range(len(s)):
if s[i]==ln and n==1: s[i]=ln-1
else:s[i]=s[i]+n
if s[i]>ln: s[i]=ln
s1=s[0]
s2=s[1]
s3=s[2]
#print(s)
s.sort()
if s[2]==s[1]:
print('Draw')
elif s[-1]==s1:
print('Kuro')
elif s[-1]==s2:
print('Shiro')
elif s[-1]==s3:
print('Katie')
##//////////////// ////// /////// // /////// // // //
##//// // /// /// /// /// // /// /// //// //
##//// //// /// /// /// /// // ///////// //// ///////
##//// ///// /// /// /// /// // /// /// //// // //
##////////////// /////////// /////////// ////// /// /// // // // //
``` | output | 1 | 95,825 | 14 | 191,651 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,826 | 14 | 191,652 |
Tags: greedy
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]
#-------------------------code---------------------------#
#vsInput()
n=Int()
p1=input()
p2=input()
p3=input()
l=len(p1)
a=l-max(Counter(p1).values())
b=l-max(Counter(p2).values())
c=l-max(Counter(p3).values())
#print(a,b,c)
if(n<=a): a-=n
else: a=0 if n>1 else 1
if(n<=b): b-=n
else: b=0 if n>1 else 1
if(n<=c): c-=n
else: c=0 if n>1 else 1
# print(a,b,c,l)
# print(Counter(p1))
# print(Counter(p2))
# print(Counter(p3))
if(a<b and a<c):
print("Kuro")
elif(b<a and b<c):
print("Shiro")
elif(c<a and c<b):
print("Katie")
else:
print("Draw")
``` | output | 1 | 95,826 | 14 | 191,653 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,827 | 14 | 191,654 |
Tags: greedy
Correct Solution:
```
n = int(input())
s1 = input().strip()
s2 = input().strip()
s3 = input().strip()
d1 = [0 for _ in range(52)]
d2 = [0 for _ in range(52)]
d3 = [0 for _ in range(52)]
maxi1 = 0
maxi2 = 0
maxi3 = 0
for i in s1:
if ord(i) <= 90:
j = ord(i) - 65
else:
j = ord(i) - 97 + 26
d1[j] += 1
maxi1 = max(d1)
for i in s2:
if ord(i) <= 90:
j = ord(i) - 65
else:
j = ord(i) - 97 + 26
d2[j] += 1
maxi2 = max(d2)
for i in s3:
if ord(i) <= 90:
j = ord(i) - 65
else:
j = ord(i) - 97 + 26
d3[j] += 1
maxi3 = max(d3)
if maxi1 + n <= len(s1):
maxi1 += n
else:
if n == 1:
maxi1 = len(s1) - 1
else:
maxi1 = len(s1)
if maxi2 + n <= len(s1):
maxi2 += n
else:
if n == 1:
maxi2 = len(s1) - 1
else:
maxi2 = len(s1)
if maxi3 + n <= len(s1):
maxi3 += n
else:
if n == 1:
maxi3 = len(s1) - 1
else:
maxi3 = len(s1)
if maxi1 > maxi2 and maxi1 > maxi3:
print('Kuro')
elif maxi2 > maxi1 and maxi2 > maxi3:
print('Shiro')
elif maxi3 > maxi1 and maxi3 > maxi2:
print('Katie')
else:
print('Draw')
``` | output | 1 | 95,827 | 14 | 191,655 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,828 | 14 | 191,656 |
Tags: greedy
Correct Solution:
```
n = int(input())
a = input()
b = input()
c = input()
def count(s, n):
cnt = {}
for c in s:
cnt[c] = cnt.get(c, 0) + 1
maxc = 0
for c in cnt:
if cnt[c] > maxc: maxc = cnt[c]
if len(s) == maxc and n == 1:
return maxc - 1
else:
return min(maxc+n, len(s))
ac = count(a, n)
bc = count(b, n)
cc = count(c, n)
if ac > bc and ac > cc:
print("Kuro")
elif bc > ac and bc > cc:
print("Shiro")
elif cc > bc and cc > ac:
print("Katie")
else:
print("Draw")
``` | output | 1 | 95,828 | 14 | 191,657 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,829 | 14 | 191,658 |
Tags: greedy
Correct Solution:
```
n = int(input())
ku = input()
si = input()
ka = input()
def bu2num(bu):
dif = ord(bu) - ord('a')
if dif >= 0 and dif < 26:
return dif
else:
return ord(bu) - ord('A') + 26
def num2bu(num):
return chr(ord('a') + num if num < 26 else ord('a') + num - 26)
def bus(s):
x = [0] * 26 * 2
for bu in s:
x[bu2num(bu)] += 1
return x
def mabus(arr):
max = 0
for a in arr:
if a > max:
max = a
return max
def calc(s):
l = len(s)
m = mabus(bus(s))
d = m + n
if m == l and n == 1:
return l - 1
elif d <= l:
return d
else:
return l
kun = calc(ku)
sin = calc(si)
kan = calc(ka)
if kun > sin and kun > kan:
print('Kuro')
elif sin > kun and sin > kan:
print('Shiro')
elif kan > kun and kan > sin:
print('Katie')
else:
print('Draw')
``` | output | 1 | 95,829 | 14 | 191,659 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw. | instruction | 0 | 95,830 | 14 | 191,660 |
Tags: greedy
Correct Solution:
```
# your code goes here
# your code goes here
import collections
n = int(input())
kuro = input()
shiro = input()
katie = input()
lkuro, lshiro, lkatie = len(kuro), len(shiro), len(katie)
ckuro = collections.Counter(kuro).most_common(1)[0][1]
cshiro = collections.Counter(shiro).most_common(1)[0][1]
ckatie = collections.Counter(katie).most_common(1)[0][1]
if n <= lkuro - ckuro :
kuroscore = ckuro + n
else:
kuroscore = lkuro
if n == 1 and lkuro == ckuro:
kuroscore -= 1
if n <= lshiro - cshiro :
shiroscore = cshiro + n
else:
shiroscore = lshiro
if n == 1 and lshiro == cshiro:
shiroscore -= 1
if n <= lkatie - ckatie :
katiescore = ckatie + n
else:
katiescore = lkatie
if n == 1 and lkatie == ckatie:
katiescore -= 1
b = ['Kuro', 'Shiro', 'Katie']
s = [kuroscore, shiroscore, katiescore]
ss = sorted(s)
if ss[-1] == ss[-2]:
print('Draw')
else:
print(b[s.index(max(s))])
``` | output | 1 | 95,830 | 14 | 191,661 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
n = int(input())
ku, sh, ka = input(), input(), input()
l_ku, l_sh, l_ka = max([ku.count(i) for i in list(set(ku))]), max([sh.count(i) for i in list(set(sh))]), max([ka.count(i) for i in list(set(ka))])
if len(ku) - l_ku > n:
l_ku += n
elif l_ku == len(ku) and n == 1:
l_ku -= 1
else:
l_ku = len(ku)
if len(sh) - l_sh > n:
l_sh += n
elif l_sh == len(sh) and n == 1:
l_sh -= 1
else:
l_sh = len(sh)
if len(ka) - l_ka > n:
l_ka += n
elif l_ka == len(ka) and n == 1:
l_ka -= 1
else:
l_ka = len(ka)
ma = max([l_sh, l_ku, l_ka])
if (l_ka == l_sh and l_ka == ma) or (l_ku == l_sh and l_ku == ma) or (l_ka == l_ku and l_ka == ma):
print('Draw')
elif ma == l_ka:
print('Katie')
elif ma == l_sh:
print('Shiro')
elif ma == l_ku:
print('Kuro')
``` | instruction | 0 | 95,831 | 14 | 191,662 |
Yes | output | 1 | 95,831 | 14 | 191,663 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
import collections
n = int(input())
s = []
for i in range(3):
s.append(input())
max_val = [0, 0, 0]
ans = ['Kuro', 'Shiro', 'Katie']
for i in range(3):
cnt = collections.Counter(s[i])
rr = max(cnt.values())
changed = min(len(s[i]) - rr, n)
moves = n - changed
max_val[i] = rr + changed - (moves == 1 and rr == len(s[i]))
if max_val.count(max(max_val)) > 1:
print('Draw')
else:
print(ans[max_val.index(max(max_val))])
``` | instruction | 0 | 95,832 | 14 | 191,664 |
Yes | output | 1 | 95,832 | 14 | 191,665 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
n=int(input())
s1=str(input())
s2=str(input())
s3=str(input())
l1=list(set(s1))
l2=list(set(s2))
l3=list(set(s3))
m1=0
m2=0
m3=0
for i in l1:
m1=max(m1,s1.count(i))
for i in l2:
m2=max(m2,s2.count(i))
for i in l3:
m3=max(m3,s3.count(i))
if(len(s1)==m1 and n==1):
x=len(s1)-1
elif(n>=(len(s1)-m1)):
x=len(s1)
else:
x=m1+n
if(len(s2)==m2 and n==1):
y=len(s2)-1
elif(n>=(len(s2)-m2)):
y=len(s2)
else:
y=m2+n
if(len(s3)==m3 and n==1):
z=len(s3)-1
elif(n>=(len(s3)-m3)):
z=len(s3)
else:
z=m3+n
lm=[]
lm.append(x)
lm.append(y)
lm.append(z)
#print(x,y,z)
if(lm.count(max(lm))>=2):
print("Draw")
else:
if(x>y and x>z):
print("Kuro")
elif(y>x and y>z):
print("Shiro")
elif(z>x and z>y):
print("Katie")
``` | instruction | 0 | 95,833 | 14 | 191,666 |
Yes | output | 1 | 95,833 | 14 | 191,667 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
n=int(input())
s1=input()
s2=input()
s3=input()
k1=len(s1)
k2=len(s2)
k3=len(s3)
a=0
val1=[0 for i in range(1000)]
val2=[0 for i in range(1000)]
val3=[0 for i in range(1000)]
for i in range(k1):
val1[ord(s1[i])-ord('a')]+=1
for i in range(k2):
val2[ord(s2[i])-ord('a')]+=1
for i in range(k3):
val3[ord(s3[i])-ord('a')]+=1
if n==1 :
if max(val1)==k1:
l1=k1-1
else:
l1=min(max(val1)+n,k1)
if max(val2)==k2:
l2=k2-1
else:
l2=min(max(val2)+n,k2)
if max(val3)==k3:
l3=k3-1
else:
l3=min(max(val3)+n,k3)
else:
l1=min(max(val1)+n,k1)
l2=min(max(val2)+n,k2)
l3=min(max(val3)+n,k3)
if l1>max(l2,l3):
print("Kuro")
elif l2>max(l1,l3):
print("Shiro")
elif l3>max(l1,l2):
print("Katie")
else:
print("Draw")
``` | instruction | 0 | 95,834 | 14 | 191,668 |
Yes | output | 1 | 95,834 | 14 | 191,669 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
from collections import Counter
n = int(input())
def score(s):
return Counter(s).most_common()[0][1];
a = [input() for i in range(3)]
l = len(a[0])
a = list(map(score, a))
if n == 1:
a = list(map(lambda x: x - 1 if x == l else x + 1, a))
else:
a = list(map(lambda x: x + 1, a))
print('Draw' if a.count(max(a)) > 1 else [['Kuro', 'Shiro', 'Katie'][i] for i in range(3) if a[i] == max(a)][0])
``` | instruction | 0 | 95,835 | 14 | 191,670 |
No | output | 1 | 95,835 | 14 | 191,671 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
# n,x,y=[int(x)for x in input().split()]
#
# adj=[[]for i in range(n+1)]
# for i in range(n-1):
# a,b = [int(x) for x in input().split()]
# adj[a].append(b)
# adj[b].append(a)
#
# fa=[None]*(n+1)
# sns=[[]for i in range(n+1)]
#
# def conTree():
# global fa,sns
# next=[x]
# while len(next)>0:
# new_next=[]
# for s in next:
# f = fa[s]
# for ss in adj[s]:
# if ss == f:
# continue
# sns[s].append(ss)
# fa[ss] = s
# new_next.append(ss)
# next=new_next
# conTree()
# def get_root(r):
# while fa[r]!=x:
# r=fa[r]
# return r
# def get_num(r):
# next=[r]
# i=0
# while i<len(next):
# for ss in sns[next[i]]:
# next.append(ss)
# i+=1
# return len(next)
# def get_x():
# r=get_root(y)
# # print('root',r)
# ans=0
# for ss in sns[x]:
# if ss!=r:
# ans+=get_num(ss)
# return ans+1
# xx=get_x()
# yy=get_num(y)
# # print(xx,yy)
# print(n*(n-1)-xx*yy)
###################################################################################################
n=int(input())
a=input()
b=input()
c=input()
def longest(s):
d={}
for cc in s:
if cc not in d:
d[cc]=1
else:
d[cc]+=1
ans=-1
for k in d.keys():
ans=max(ans,d[k])
return ans
al=len(a)-longest(a)
bl=len(b)-longest(b)
cl=len(c)-longest(c)
al=max(0,al-n)
bl=max(0,bl-n)
cl=max(0,cl-n)
s=[al,bl,cl]
s.sort()
if s[0]==s[1]:
print('Draw')
else:
minn=min(al,bl,cl)
if al==minn:
print('Kuro')
if bl==minn:
print('Shiro')
if cl==minn:
print('Katie')
``` | instruction | 0 | 95,836 | 14 | 191,672 |
No | output | 1 | 95,836 | 14 | 191,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
def bt(s):
maxi=0
for i in alphabet:
k=s.count(i)
if k>maxi:
maxi=k
return maxi
def maxbt(s,n):
#Π·Π° len(s)-bt(s) ΡΡΡΠΎΠΊΠ° ΡΡΠ°Π½Π΅Ρ ΠΊΡΠ°ΡΠΈΠ²ΠΎΠΉ
#ΠΎΡΡΠ°Π΅ΡΡΡ n-(len(s)-bt(s)) Ρ
ΠΎΠ΄ΠΎΠ². ΠΡΠ»ΠΈ ΡΡΠΎ ΡΠ΅ΡΠ½ΠΎ, ΡΠΎ maxbt=len(s)
if n<=len(s)-bt(s):
return n+bt(s)
elif n-(len(s)-bt(s))%2==0:
return len(s)
else:
return len(s)
alphabet=['A','a','B','b','C','c','D','d','E','e','F','f','G','g','H','h','I','i','J','j','K','k','L','l','M','m','N','n','O','o','P','p','Q','q','R','r','S','s','T','t','U','u','V','v','W','w','X','x','Y','y','Z','z']
n=int(input())
s1=input()
s2=input()
s3=input()
if 1==2:
print('Draw')
else:
k1=maxbt(s1,n)
k2=maxbt(s2,n)
k3=maxbt(s3,n)
d=max(k1,k2,k3)
if (k1==k2 and k1==d) or (k2==k3 and k2==d) or (k3==k1 and k1==d):
print('Draw')
else:
if k1==max(k1,k2,k3):
print('Kuro')
if k2==max(k1,k2,k3):
print('Shiro')
if k3==max(k1,k2,k3):
print('Katie')
``` | instruction | 0 | 95,837 | 14 | 191,674 |
No | output | 1 | 95,837 | 14 | 191,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
Input
The first line contains an integer n (0 β€ n β€ 10^{9}) β the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
Output
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
Examples
Input
3
Kuroo
Shiro
Katie
Output
Kuro
Input
7
treasurehunt
threefriends
hiCodeforces
Output
Shiro
Input
1
abcabc
cbabac
ababca
Output
Katie
Input
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE
Output
Draw
Note
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
Submitted Solution:
```
n = int(input())
black = list(input())
white = list(input())
katie = list(input())
ALPHABET = [chr(i) for i in range(65, 65+26)] + [chr(i)
for i in range(97, 97+26)]
def optimal_score(LIST):
d = {char: 0 for char in ALPHABET}
for v in LIST:
d[v] += 1
max_freq = max(d.values())
L = len(LIST)
res = 0
for freq in d.values():
if L - freq >= n:
res = max(res, freq + n)
else:
if (freq + n) % 2 != L % 2:
res = max(res, L - 1)
else:
res = L
return res
score_black = optimal_score(black)
score_white = optimal_score(white)
score_katie = optimal_score(katie)
M = max(score_black, score_katie, score_white)
MAXCNT = 0
winner = "NOBODY"
if M == score_black:
winner = "Kuro"
MAXCNT += 1
if M == score_white:
winner = "Shiro"
MAXCNT += 1
if M == score_katie:
winner = "Katie"
MAXCNT += 1
if MAXCNT == 1:
print(winner)
else:
print("Draw")
``` | instruction | 0 | 95,838 | 14 | 191,676 |
No | output | 1 | 95,838 | 14 | 191,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,141 | 14 | 192,282 |
Tags: implementation
Correct Solution:
```
n = int(input())
h=[0]*n
m=[0]*n
for i in range(n):
h[i],m[i] = map(int,input().split())
k = int(input())
for i in range(n):
if k>=h[i] and k<=m[i]:
g=i
break
print(n-g)
``` | output | 1 | 96,141 | 14 | 192,283 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,142 | 14 | 192,284 |
Tags: implementation
Correct Solution:
```
n = int(input())
lr = [list(map(int, input().split())) for _ in range(n)]
k = int(input())
ans = n
for lri in lr:
if lri[0] <= k <= lri[1]:
print(ans)
break
else:
ans -= 1
``` | output | 1 | 96,142 | 14 | 192,285 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,143 | 14 | 192,286 |
Tags: implementation
Correct Solution:
```
n = int(input())
v = []
for i in range(n):
v.append(int(input().split()[1]))
p = int(input())
for pos, i in enumerate(v):
if i >= p:
print(n-pos)
break
``` | output | 1 | 96,143 | 14 | 192,287 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,144 | 14 | 192,288 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = []
for i in range(n):
l, r = map(int, input().split())
a.append(l)
a.append(r)
k = int(input())
i = 0
while a[i] < k:
i += 1
print(n - i // 2)
``` | output | 1 | 96,144 | 14 | 192,289 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,145 | 14 | 192,290 |
Tags: implementation
Correct Solution:
```
n = int(input())
tail = []
for i in range(n):
a, b = map(int, input().split())
tail.append(b)
m = int(input())
for i in range(m):
if m <= tail[i]:
print(n - i)
break
``` | output | 1 | 96,145 | 14 | 192,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,146 | 14 | 192,292 |
Tags: implementation
Correct Solution:
```
n=int(input())
lfi=[]
for i in range(n):
l=input().split()
lfi.append([int(i) for i in l])
k=int(input())
for i in range(n):
if(k>=lfi[i][0] and k<=lfi[i][1]):
ans=i
break
print(n-ans)
``` | output | 1 | 96,146 | 14 | 192,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,147 | 14 | 192,294 |
Tags: implementation
Correct Solution:
```
n = int(input())
start = []
end = []
for i in range(n):
a,b = map(int,input().split())
start.append(a)
end.append(b)
k = int(input())
for i in range(n):
if k in range(start[i],end[i]+1):
break
print(n-i)
``` | output | 1 | 96,147 | 14 | 192,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2. | instruction | 0 | 96,148 | 14 | 192,296 |
Tags: implementation
Correct Solution:
```
n = int(input())
tmp = []
for i in range(n):
tmp.append([int(x) for x in input().split(' ')])
k = int(input())
for i in range(n):
if tmp[i][0] <= k <= tmp[i][1]:
print(n - i)
``` | output | 1 | 96,148 | 14 | 192,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
n=int(input())
start=[]; end=[]
for t in range(n):
a,b=map(int, input().split())
start.append(a)
end.append(b)
k=int(input())
for i in range(n):
if k<=end[i]:
print(n-i)
break
``` | instruction | 0 | 96,149 | 14 | 192,298 |
Yes | output | 1 | 96,149 | 14 | 192,299 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
hop = []
for i in range(int(input())):
a, b = map(int, input().split())
hop.append(b)
k = int(input())
for i in range(len(hop)):
if k <= hop[i]:
print(len(hop) - i)
break
``` | instruction | 0 | 96,150 | 14 | 192,300 |
Yes | output | 1 | 96,150 | 14 | 192,301 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
n, res = int(input()), []
for i in range(n):
res.append([int(i) for i in input().split()])
k = int(input())
for i in res:
if i[0] <= k <= i[1]:
print(n - res.index(i))
``` | instruction | 0 | 96,151 | 14 | 192,302 |
Yes | output | 1 | 96,151 | 14 | 192,303 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
mi = lambda: [int(i) for i in input().split()]
n = int(input())
dat = [mi() for _ in range(n)]
k = int(input())
readed = 0
for i in dat:
l, r = i
if l <= k and r >= k:
print(n - readed)
exit()
readed += 1
print(n)
``` | instruction | 0 | 96,152 | 14 | 192,304 |
Yes | output | 1 | 96,152 | 14 | 192,305 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
x = int(input())
y = []
a = 0
for i in range(x):
y.append(list(map(int, input().split(" "))))
z = int(input())-1
for i in y:
if i[0]<z<i[1]:
a += 1
else:
pass
if len(y) == a:
print(1)
else:
print(x-a)
``` | instruction | 0 | 96,153 | 14 | 192,306 |
No | output | 1 | 96,153 | 14 | 192,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
A=[]
k=int(input())
for i in range(k):
C,D=input().split()
A.append(int(D))
Z=int(input())
Z=Z-1
tmp=0
for j in range(k):
if(Z<=A[j]):
break
else:
tmp+=1
print(k-tmp)
``` | instruction | 0 | 96,154 | 14 | 192,308 |
No | output | 1 | 96,154 | 14 | 192,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
n = int(input())
l = []
for i in range(n):
s = input().split()
l.append(s)
k = input()
for i in range(n):
if l[i][0] <= k < l[i][1]:
print(len(l) - i)
break
if k == l[i][1]:
print(len(l) - i)
``` | instruction | 0 | 96,155 | 14 | 192,310 |
No | output | 1 | 96,155 | 14 | 192,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).
The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chapters in the book.
There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i β€ r_i) β numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 β€ i β€ n-1, and also that every chapter contains at most 100 pages.
The (n+2)-th line contains a single integer k (1 β€ k β€ r_n) β the index of the marked page.
Output
Print a single integer β the number of chapters which has not been completely read so far.
Examples
Input
3
1 3
4 7
8 11
2
Output
3
Input
3
1 4
5 9
10 12
9
Output
2
Input
1
1 7
4
Output
1
Note
In the first example the book contains 11 pages and 3 chapters β [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.
The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.
Submitted Solution:
```
a = int(input())
p = 0
k = []
for i in range(a):
k.append([int(i) for i in input().split()])
b = int(input())
for i in range(a):
if(k[i].count(b)!=0):
p = i
print(a-p)
``` | instruction | 0 | 96,156 | 14 | 192,312 |
No | output | 1 | 96,156 | 14 | 192,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).
Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
Input
The first line contains an integer n (1 β€ n β€ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
Output
Print a single integer, the minimum amount of lost milk.
Please, do not write the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
0 0 1 0
Output
1
Input
5
1 0 1 0 1
Output
3
Note
In the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | instruction | 0 | 96,470 | 14 | 192,940 |
Tags: data structures, greedy
Correct Solution:
```
n = int(input())
array = list(map(int, input().split()))
cnt = 0
s = [0 for i in range(n)]
s[n - 1] = 1 * (array[n - 1] == 0)
for i in range(n - 2, -1, -1):
s[i] = s[i + 1] + 1 * (array[i] == 0)
for i in range(n):
cnt += s[i] * (array[i] == 1)
print(cnt)
``` | output | 1 | 96,470 | 14 | 192,941 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).
Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
Input
The first line contains an integer n (1 β€ n β€ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
Output
Print a single integer, the minimum amount of lost milk.
Please, do not write the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
0 0 1 0
Output
1
Input
5
1 0 1 0 1
Output
3
Note
In the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | instruction | 0 | 96,471 | 14 | 192,942 |
Tags: data structures, greedy
Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
res = 0
b = 0
for i in reversed(range(n)):
if a[i]==1: res += b
else: b += 1
print(res)
``` | output | 1 | 96,471 | 14 | 192,943 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).
Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
Input
The first line contains an integer n (1 β€ n β€ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
Output
Print a single integer, the minimum amount of lost milk.
Please, do not write the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
0 0 1 0
Output
1
Input
5
1 0 1 0 1
Output
3
Note
In the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | instruction | 0 | 96,473 | 14 | 192,946 |
Tags: data structures, greedy
Correct Solution:
```
n = int(input())
arr = list(map(int, input().split()))
zero_count = [0] * n
zero_count[n - 1] = int(arr[n - 1] == 0)
for i in reversed(range(n - 1)):
zero_count[i] = zero_count[i + 1] + int(arr[i] == 0)
res = 0
for i in range(n - 1):
if arr[i] == 1:
res += zero_count[i + 1]
print(res)
``` | output | 1 | 96,473 | 14 | 192,947 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).
Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
Input
The first line contains an integer n (1 β€ n β€ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
Output
Print a single integer, the minimum amount of lost milk.
Please, do not write the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
0 0 1 0
Output
1
Input
5
1 0 1 0 1
Output
3
Note
In the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | instruction | 0 | 96,474 | 14 | 192,948 |
Tags: data structures, greedy
Correct Solution:
```
def cows(n, lst):
zeros, result = 0, 0
for i in range(n - 1, -1, -1):
if lst[i] == 0:
zeros += 1
else:
result += zeros
return result
m = int(input())
a = [int(j) for j in input().split()]
print(cows(m, a))
``` | output | 1 | 96,474 | 14 | 192,949 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).
Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
Input
The first line contains an integer n (1 β€ n β€ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
Output
Print a single integer, the minimum amount of lost milk.
Please, do not write the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
0 0 1 0
Output
1
Input
5
1 0 1 0 1
Output
3
Note
In the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | instruction | 0 | 96,475 | 14 | 192,950 |
Tags: data structures, greedy
Correct Solution:
```
#in the name of god
#Mr_Rubick
n=int(input())
a=list(map(int,input().split()))
cnt,s=0,[0]*n
s[n-1]=1*(a[n-1]==0)
for i in range(n-2,-1,-1): s[i]=s[i+1]+1*(a[i]==0)
for i in range(n): cnt+=s[i]*(a[i]==1)
print(cnt)
``` | output | 1 | 96,475 | 14 | 192,951 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.