description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | for _ in range(int(input())):
n = int(input())
ai = [*map(int, input().split())]
bi = [1000000000.0 + 1] * n
ok = "Yes"
for i in range(n):
new = (i + (ai[i] % n + n) % n) % n
if bi[new] != 1000000000.0 + 1:
ok = "No"
break
bi[new] = ai[i]
if 100000... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR ... |
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
b = [0] * len(a)
for i in range(len(a)):
b[i] = a[i] + i
c = True
for i in range(len(b)):
for j in range(len(a)):
if i != j and i != b[i] - a[j]:
if a[j] == a[(b[i] - a[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FU... |
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | import sys
try:
sys.stdin = open("Input.txt", "r")
sys.stdout = open("Output.txt", "w")
except:
pass
input = sys.stdin.readline
for testCases in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
l[i] += i
d = {}
for i in range(n):
... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR DICT FOR VAR FU... |
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | import sys
class CHilbertsHotel:
def solve(self, tc=0):
for _ in range(int(input())):
n = int(input())
a = [int(_) for _ in input().split()]
s = set()
for i in range(n):
s.add(a[i] + i)
xs = set()
for c in s:
... | IMPORT CLASS_DEF FUNC_DEF NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER E... |
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | def main():
t = int(input())
for c in range(t):
n = int(input())
shift = [int(s) for s in input().split(" ")]
print(solve(n, shift))
def solve(n, shift):
a = [i for i in range(n)]
for i in range(n):
a[i] = (a[i] + shift[i]) % n
a.sort()
for i in range(n):
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP V... |
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | from sys import stdin
def solve():
return
def main():
inp = stdin.readline
for _ in range(int(inp())):
n = int(inp())
a = list(map(int, inp().split()))
d = set()
ans = True
for i in range(n):
k = (i + a[i] % n) % n
if k in d:
... | FUNC_DEF RETURN FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR IF ... |
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
if sum(a) % n != 0:
print("NO")
continue
set_ = set()
for i in range(n):
set_.add((a[i] + i) % n)
if len(set_) != n:
print("NO")
els... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_C... |
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | t = int(input())
for w in range(t):
n = int(input())
l = input().split()
a = []
for i in range(n):
a.append(int(l[i]))
c = []
for i in range(n):
c.append((i + a[i]) % n)
c.sort()
band = True
for i in range(n):
band = band * (i == c[i])
if band:
pri... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR EXPR FU... |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, arr):
n = len(arr)
arr.sort(key=lambda x: x[1])
ans = 1
curr = 0
for i in range(1, n):
if arr[i][0] >= arr[curr][1]:
ans += 1
curr = i
return ans | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges = sorted(ranges, key=lambda x: x[1])
b = 1
a = ranges[0]
for i in range(1, len(ranges)):
if ranges[i][0] >= a[1]:
b += 1
a = ranges[i]
return b | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort()
ans = 1
end = ranges[0][1]
for i in range(len(ranges)):
if ranges[i][0] < end:
end = min(end, ranges[i][1])
else:
ans += 1
end = ranges[i][1]
... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
c = 0
ranges.sort(key=lambda x: x[1])
ve = -1000000
for i in ranges:
cs = i[0]
ce = i[1]
if cs >= ve:
c += 1
ve = ce
return c | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort(key=lambda x: x[1])
end = -1
c = 0
for i in ranges:
if end <= i[0]:
c += 1
end = i[1]
return c | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | import sys
class Solution:
def max_non_overlapping(self, ranges):
count = 0
curr_max = -1
ranges = sorted(ranges, key=lambda x: x[1])
for i in ranges:
if i[0] >= curr_max and i[1] > curr_max:
count += 1
curr_max = i[1]
return cou... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges: list):
ranges.sort(key=lambda r: r[1])
ans, lst = 1, ranges[0]
for i in range(1, len(ranges)):
l1, r1 = lst
l2, r2 = ranges[i]
if r1 <= l2:
ans += 1
lst = ranges[i]
... | CLASS_DEF FUNC_DEF VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges = sorted(ranges, key=lambda x: [x[1], -x[0]])
count, rear = 0, 0
for st, ed in ranges:
if rear <= st:
count += 1
rear = ed
return count | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
count = 0
ranges.sort(key=lambda x: x[1])
prev = -1
for i in ranges:
st, ed = i
if st >= prev:
prev = ed
count += 1
return count | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort(key=lambda x: x[1])
st = ranges[0][0]
en = ranges[0][1]
i = 1
ct = 1
while i < len(ranges):
if ranges[i][0] >= en and ranges[i][0] > st:
st = ranges[i][0]
e... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, arr):
arr.sort(key=lambda x: x[1])
arr.sort(key=lambda x: x[0])
ans = []
for i, j in arr:
while ans and ans[-1] > j:
ans.pop()
if not ans or i >= ans[-1]:
ans.append(j)
retu... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR WHILE VAR VAR NUMBER VAR EXPR FUNC_CALL VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort()
total_count = 0
current_range = None
for range in ranges:
if current_range == None:
current_range = range
total_count += 1
elif range[0] > current_range[0] an... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR VAR IF VAR NONE ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort()
s = []
for i, j in ranges:
while s and s[-1] > j:
s.pop()
if not s or i >= s[-1]:
s.append(j)
return len(s) | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR VAR WHILE VAR VAR NUMBER VAR EXPR FUNC_CALL VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort(key=lambda x: x[1])
count = 1
ending = ranges[0][1]
for pair in ranges[1:]:
if pair[0] >= ending:
count = count + 1
ending = pair[1]
return count | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
result = 1
r = sorted(ranges, key=lambda x: x[1])
prev = r[0]
for i in range(1, len(r)):
if r[i][0] >= prev[1]:
result = result + 1
prev = r[i]
return result | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort(key=lambda x: x[1])
courses = []
for strt, end in ranges:
if not courses or strt >= courses[-1][1]:
courses.append([strt, end])
return len(courses) | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR VAR RETURN FUNC_CALL VAR VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort(key=lambda x: x[1])
ma = 0
le = len(ranges)
cnt = 0
for i in range(le):
if ranges[i][0] >= ma:
ma = ranges[i][1]
cnt += 1
return cnt | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
ranges.sort(key=lambda x: x[1])
m = ranges[0][1]
count = 1
for i in range(1, n):
if m <= ranges[i][0]:
m = ranges[i][1]
count += 1
else:
continue
re... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
count = 1
ranges.sort(key=lambda x: (x[1], x[0]))
end = ranges[0][1]
for i in range(1, n):
if ranges[i][0] >= end:
count += 1
end = ranges[i][1]
return count | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR |
Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek wants to select the maximum number of course bundles at the Geek Summer Carnival.
You are given a finite number of courses and N range of n... | class Solution:
def max_non_overlapping(self, ranges):
n = len(ranges)
if n <= 1:
return n
ranges.sort(key=lambda ranges: ranges[0])
end = ranges[0][1]
max = 1
for i in range(n):
if ranges[i][0] < end:
end = min(end, ranges[i][... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | def trailingZeroes(n):
cnt = 0
while n > 0:
n = int(n / 5)
cnt += n
return cnt
def binarySearch(n):
low = 0
high = 1000000.0
while low < high:
mid = int((low + high) / 2)
count = trailingZeroes(mid)
if count < n:
low = mid + 1
else:
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def number_of_zeroes(self, n):
res = 0
value = 5
while value <= n:
res += n // value
value *= 5
return res
def countZeroes(self, n):
low = 0
high = 5 * n
while low < high:
mid = (low + high) // 2
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBE... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def count_fives(self, num):
result = 0
i = 5
while num // i > 0:
result += num // i
i *= 5
return result
def countZeroes(self, n):
l = 0
r = n * 5
while l <= r:
mid = (l + r) // 2
cnt = self... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def countZeroes(self, n):
smallestnumwithatleastnzeros = self.Helper(n)
smallestnumwithatleastnplusonezeros = self.Helper(n + 1)
return smallestnumwithatleastnplusonezeros - smallestnumwithatleastnzeros
def Helper(self, n):
low = 0
high = 5 * n
w... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RET... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def count(self, a):
c = 0
while a:
a = a // 5
c += a
return c
def solve(self, n):
i = 1
e = 5 * n
ans = 0
while i <= e:
mid = (i + e) // 2
if self.count(mid) >= n:
ans = mid
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def countZeroes(self, n):
if n == 1:
return 5
count = 0
def zerocount(k):
zc = 0
while k != 0:
k = k // 5
zc += k
return zc
low = 0
high = 1000000.0
while low < high:
... | CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP ... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | def zero_cnt(a):
i = 5
cnt = 0
while a >= i:
cnt += a // i
i *= 5
return cnt
class Solution:
def countZeroes(self, n):
i = 0
j = 100000000
while i <= j:
mid = (i + j) // 2
if zero_cnt(mid) == n:
return 5
e... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP ... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def trailing_zeros(self, n):
num = 1
res = 0
while num:
ans = 0
i = 1
power = 5**i
while power <= num:
ans += num // power
i += 1
power = 5**i
if ans == n:
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def cal(self, n):
count = 0
i = 5
while True:
if n // i >= 1:
count = count + n // i
i = i * 5
else:
break
return count
def countZeroes(self, n):
obj = Solution()
low = 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP V... |
Given an integer n, find the number of positive integers whose factorial ends with n zeros.
Example 1:
Input:
N = 1
Output: 5
Explanation:
5! = 120, 6! = 720, 7! = 5040,
8! = 40320 and 9! = 362880.
Example 2:
Input:
N = 5
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to compl... | class Solution:
def countZeroes(self, n):
low = 1
high = 1000000.0
result = 0
while low <= high:
mid = int(low + (high - low) / 2)
trailZeroes = self.trailingZeroes(mid)
if trailZeroes == n:
result = 5
high = mid - ... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR F... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
entry_i, exit_i = 0, 0
max_guest = [0, 0]
cnt = 0
while entry_i < N:
if exit_i == N or Entry[entry_i] <= Exit[exit_i]:
cnt += 1
if cnt > max_... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
res = []
Entry.sort()
Exit.sort()
guest = 1
max_gst = 1
time = Entry[0]
i = 1
j = 0
while i < N and j < N:
if Entry[i] <= Exit[j]:
guest += 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
maxEntry = max(Entry)
maxExit = max(Exit)
count = [0] * (max(maxEntry, maxExit) + 2)
for i in range(len(Entry)):
count[Entry[i]] += 1
count[Exit[i] + 1] -= 1
maxGuests, maxGuestsAt = -1, 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VA... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
A = [(v, 1) for v in Entry]
A.extend([(v + 1, -1) for v in Exit])
A.sort()
curtm, hc, mxhc, mntm = 0, 0, 0, 0
for tm, off in A:
if tm > curtm:
if hc > mxhc:
mxhc = hc
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR VAR VAR IF VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR VAR |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
i = 0
j = 0
time = 0
maxi = 0
count = 0
while i < N and j < N:
if Entry[i] <= Exit[j]:
count += 1
if count > maxi:
... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN LIST VAR VAR |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
maxi = float("-inf")
Entry.sort()
Exit.sort()
guest = 0
p1 = 0
p2 = 0
while p1 < len(Entry):
if Entry[p1] <= Exit[p2]:
guest += 1
if guest > maxi:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
h = [0] * (max(exit) + 2)
for i in range(N):
h[Entry[i]] += 1
h[Exit[i] + 1] -= 1
curr = 0
ans = 0, -1
for i in range(max(exit) + 1):
curr += h[i]
h[i] = curr
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR ... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
mx = max(max(Entry), max(Exit))
arr = [0] * (mx + 2)
for i in range(N):
arr[Entry[i]] += 1
arr[Exit[i] + 1] -= 1
curr = 0
ans = float("-inf")
for i in range(len(arr)):
curr +... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR A... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
guestsIn, maxGuests, maxGuestsAt = 1, 1, Entry[0]
i, j = 1, 0
while i < len(Entry) and j < len(Exit):
if Entry[i] <= Exit[j]:
guestsIn += 1
if guests... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN LIST VAR VAR |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
{1, 2, 5, 5, 10}
{4, 5, 9, 12, 12}
Entry.sort()
Exit.sort()
ent, ex = 0, 0
time, maxGuest = 0, 0
curGuest = 0
while ent < N:
if Entry[ent] <= Exit[ex]:
curGuest += 1
... | CLASS_DEF FUNC_DEF EXPR NUMBER NUMBER NUMBER NUMBER NUMBER EXPR NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUM... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
max_guests = 0
c_time = -1
temp_entry = Entry
temp_entry.sort()
Exit.sort()
k = i = 0
temp = 0
while i < N:
if temp_entry[i] <= Exit[k]:
temp += 1
if ... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR IF VAR STRING ASSIGN VAR FUNC_CALL ... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry = sorted(Entry)
Exit = sorted(Exit)
i = 0
j = 0
maxi = 0
addi = 0
index = 0
while i < N and j < N:
en = Entry[i]
dep = Exit[j]
if en <= dep:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR A... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, n):
end = max(Exit) + 3
count = [0] * end
for i in range(n):
count[Entry[i]] += 1
count[Exit[i] + 1] -= 1
max_ocrr = float("-inf")
ans = 0
for i in range(1, end):
count[i] += cou... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
ans, f = 0, 0
j = 0
for i in range(N):
while Exit[j] < Entry[i]:
j += 1
d = i + 1 - j
if d > f:
f = d
ans = E... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR RETURN LIST VAR VAR |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
lb = Entry
lp = Exit
lb.sort()
lp.sort()
lb.reverse()
lp.reverse()
i = len(lb) - 1
c = len(lp) - 1
soma = 0
max = -1
p = 0
while i >= 0 and c >= 0:
m ... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VA... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
guests = []
for i in range(N):
guests.append([Entry[i], False])
guests.append([Exit[i], True])
guests.sort()
maxgst = -1
attgst = 0
tmpgst = 0
for i in range(len(guests)):
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR AS... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, arrl, exit, n):
arrl.sort()
exit.sort()
guests_in = 1
max_guests = 1
time = arrl[0]
i = 1
j = 0
while i < n and j < n:
if arrl[i] <= exit[j]:
guests_in = guests_in + 1
... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUM... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, entry, exit, n):
maxi = max(exit)
arr = [0] * (maxi + 2)
for i in range(n):
arr[entry[i]] += 1
arr[exit[i] + 1] += -1
prefix = arr[0]
for i in range(1, len(arr)):
prefix += arr[i]
arr[i] ... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VA... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
max_g = 0, 0
count = 0
i, j = 0, 0
while i < len(Entry):
if j >= len(Exit) or Entry[i] <= Exit[j]:
count += 1
if max_g[0] < count:
... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR NUMBER R... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
i = 0
j = 0
p = 0
t = 0
m = 0
arr = []
while i < len(Exit) and i >= j:
l = i
if Entry[i] <= Exit[j]:
p += 1
... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VA... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
ans = 0
count = 0
data = []
time = 0
for i in range(N):
data.append([Entry[i], "x"])
data.append([Exit[i], "y"])
data = sorted(data)
for i in range(len(data)):
if dat... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER STRING VAR NUMBER IF VAR VAR NUMBER STRI... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
if len(Exit) == 1:
return [1, Entry[0]]
Entry.sort(reverse=False)
Exit.sort(reverse=False)
i = 0
j = 0
maxcount = float("-inf")
count = 0
while i < len(Entry):
if Entry[i... | CLASS_DEF FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN LIST NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VA... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, start, end, N):
m1 = max(start)
m2 = max(end)
arr = [(0) for i in range(max(m1, m2) + 2)]
for i in start:
arr[i] += 1
for j in end:
arr[j + 1] += -1
c = 0
ms = 0
time = 0
for i in... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR V... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
ent = sorted(Entry)
exit = sorted(Exit)
i = 1
j = 0
curr = 1
res = 1
min_time = ent[0]
li = []
while i < N and j < N:
if ent[i] <= exit[j]:
curr += 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP ... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
cou = 1
ma = 1
time = Entry[0]
i = 1
j = 0
while i < N and j < N:
if Exit[j] >= Entry[i]:
cou = cou + 1
if ma < cou:
... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUM... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
total = Entry + Exit
entry = [[e, "A"] for e in Entry]
exit = [[e, "B"] for e in Exit]
total = entry + exit
total.sort()
c = 0
m = 0
t = -1
for i in range(len(total)):
if tot... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR STRING VAR VAR ASSIGN VAR LIST VAR STRING VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR A... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
l = []
for i in range(N):
l.append([Entry[i], 0])
l.append([Exit[i], 1])
l.sort()
c = 0
m = 0
for i in l:
if i[1] == 0:
c += 1
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER RETURN LIST VAR VAR |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
d = {}
for i in range(N):
if Entry[i] not in d:
d[Entry[i]] = 1
else:
d[Entry[i]] += 1
if Exit[i] + 1 not in d:
d[Exit[i] + 1] = -1
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR VAR VAR B... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
dp = [0] * int(100000.0 + 2)
for i in range(N):
dp[Entry[i]] += 1
dp[Exit[i] + 1] -= 1
c = 0
t = 0
for i in range(1, len(dp)):
dp[i] += dp[i - 1]
if c < dp[i]:
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR ... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
i, j = 0, 0
count = 0
max_g = 0, 0
while i < len(Entry) and j <= len(Exit):
if j == len(Exit) or Entry[i] <= Exit[j]:
count += 1
if count > m... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR IF V... |
Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.
Note: Guests are leaving after the exit times.
Example 1:
Input:
N = 5
Entry= ... | class Solution:
def findMaxGuests(self, Entry, Exit, N):
Entry.sort()
Exit.sort()
count = 0
maxi = 0
time = 0
j = 0
for i in range(N):
count += 1
if count > maxi:
maxi = count
time = Entry[i]
... | CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR |
In 2N - 1 boxes there are apples and oranges. Your task is to choose N boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges.
Input
The first input line contains one number T — amount of tests. The description of each test starts with a natural number N — amou... | t = int(input())
for _ in range(t):
n = int(input())
nums = []
for i in range(2 * n - 1):
a, b = map(int, input().split())
nums.append([b, a, i + 1])
nums = sorted(nums)[::-1]
vals = [nums[0][2]]
i = 1
while i + 1 < len(nums):
c = i
if nums[i][1] < nums[i + 1]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASS... |
In 2N - 1 boxes there are apples and oranges. Your task is to choose N boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges.
Input
The first input line contains one number T — amount of tests. The description of each test starts with a natural number N — amou... | t = int(input())
while t:
t = t - 1
boxes = []
n = int(input())
num_box = 2 * n - 1
for i in range(num_box):
pair = input().split()
apples = int(pair[0])
oranges = int(pair[1])
boxes.append((apples, oranges, i + 1))
print("YES")
boxes.sort(reverse=True)
or... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_C... |
In 2N - 1 boxes there are apples and oranges. Your task is to choose N boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges.
Input
The first input line contains one number T — amount of tests. The description of each test starts with a natural number N — amou... | import sys
input = sys.stdin.readline
t = int(input())
for cs in range(t):
n = int(input())
arr = []
for i in range(2 * n - 1):
a, b = map(int, input().split())
arr.append((a, b, i))
arr.sort()
res = []
for i in range(0, len(arr), 2):
if i + 1 < len(arr):
if ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST F... |
A famous casino is suddenly faced with a sharp decline of their revenues. They decide to offer Texas hold'em also online. Can you help them by writing an algorithm that can rank poker hands?
Task:
Create a poker hand that has a constructor that accepts a string containing 5 cards:
```python
hand = PokerHand("KS 2H ... | class PokerHand(object):
VALUES = "A23456789TJQKA"
def __repr__(self):
return self.hand
def __init__(self, hand):
self.hand = hand
values = "".join(sorted(hand[::3], key=self.VALUES[1:].index))
suits = set(hand[1::3])
hi_straight = values in self.VALUES
lo_s... | CLASS_DEF VAR ASSIGN VAR STRING FUNC_DEF RETURN VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER... |
A famous casino is suddenly faced with a sharp decline of their revenues. They decide to offer Texas hold'em also online. Can you help them by writing an algorithm that can rank poker hands?
Task:
Create a poker hand that has a constructor that accepts a string containing 5 cards:
```python
hand = PokerHand("KS 2H ... | class PokerHand(object):
CARD = "23456789TJQKA"
def __repr__(self):
return str(self.hand)
def __init__(self, hand):
self.hand = hand
values = "".join(sorted(hand[::3], key=self.CARD.index))
suits = set(hand[1::3])
is_straight = values in self.CARD or values == "2345... | CLASS_DEF VAR ASSIGN VAR STRING FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL V... |
A famous casino is suddenly faced with a sharp decline of their revenues. They decide to offer Texas hold'em also online. Can you help them by writing an algorithm that can rank poker hands?
Task:
Create a poker hand that has a constructor that accepts a string containing 5 cards:
```python
hand = PokerHand("KS 2H ... | class PokerHand(object):
CARD = "23456789TJQKA"
RESULT = ["Loss", "Tie", "Win"]
def __repr__(self):
return self.hand
def __lt__(self, other):
res = self.compare_with(other)
return res == self.RESULT[2]
def __init__(self, hand):
self.hand = hand
values = "".... | CLASS_DEF VAR ASSIGN VAR STRING ASSIGN VAR LIST STRING STRING STRING FUNC_DEF RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR LIST STRING S... |
A famous casino is suddenly faced with a sharp decline of their revenues. They decide to offer Texas hold'em also online. Can you help them by writing an algorithm that can rank poker hands?
Task:
Create a poker hand that has a constructor that accepts a string containing 5 cards:
```python
hand = PokerHand("KS 2H ... | class PokerHand(object):
def __init__(self, hand):
self.hand = hand
self.hand_value = self.value(hand)
def __repr__(self):
return self.hand
def __lt__(self, other):
return self.hand_value > other.hand_value
def __eq__(self, other):
return self.hand_value == ot... | CLASS_DEF VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR FUNC_DEF RETURN VAR VAR FUNC_DEF RETURN VAR VAR FUNC_DEF IF VAR VAR RETURN STRING IF VAR VAR RETURN STRING IF VAR VAR RETURN STRING FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMB... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
a = input().split(" ")
x1 = int(a[0])
x2 = int(a[1])
coor1 = []
coor2 = []
eps = 1e-09
for i in range(n):
a = input().split(" ")
k = int(a[0])
b = int(a[1])
coor1.append((k * (x1 + eps) + b, i))
coor2.append((k * (x2 - eps) + b, i))
coor1.sort()
coor2.sort()
s = "NO"
for i in range(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FU... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | def byfirst(a):
return a[0]
n = int(input())
x1, x2 = [int(i) for i in input().split()]
a = {}
for i in range(n):
k, b = [int(i) for i in input().split()]
x, y = k * x1 + b, k * x2 + b
if x in a:
a[x] += [y]
else:
a[x] = [y]
b = list(a.keys())
b.sort()
m = max(a[b[0]])
flag = 0
for... | FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR LIST... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | import sys
input = sys.stdin.buffer.readline
n = int(input())
l, r = map(int, input().split())
ly = []
ry = []
for i in range(n):
k, m = map(int, input().split())
ly.append([k * (l + 10**-8) + m, i])
ry.append([k * (r - 10**-8) + m, i])
ly.sort(key=lambda x: (x[0], x[1]))
ry.sort(key=lambda x: (x[0], x[1])... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR BIN_OP VAR BIN_OP NUMBER NUMBER VAR VAR EXPR ... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | def main():
n = int(input())
x1, x2 = map(int, input().split())
res = []
for _ in range(n):
k, b = map(int, input().split())
res.append((k * x1 + b, k * x2 + b))
res.sort()
print(("NO", "YES")[any(y1[1] > y2[1] for y1, y2 in zip(res, res[1:]))])
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING ... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | from sys import stdin
n = int(stdin.readline())
x1, x2 = map(int, stdin.readline().split())
ys = []
for i in range(n):
m, b = map(int, stdin.readline().split())
ys.append([x1 * m + b, x2 * m + b])
ys.sort()
intersect = False
for i in range(1, n):
if ys[i - 1][1] > ys[i][1]:
intersect = True
if inte... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | def rline():
return [int(i) for i in input().split()]
N = int(input())
L, R = rline()
l = [rline() for i in range(N)]
atL = []
atR = []
for i in range(N):
k, b = l[i]
atL.append((k * L + b, k, i))
atR.append((k * R + b, -k, i))
atL.sort()
atR.sort()
atL = [i[2] for i in atL]
atR = [i[2] for i in atR]
... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | ertekek = []
n = int(input())
x1, x2 = [int(i) for i in input().split()]
for i in range(n):
k, b = [int(i) for i in input().split()]
bal = k * x1 + b
jobb = k * x2 + b
ertekek.append([bal, jobb])
ertekek.sort()
szamlalo = 0
for i in range(len(ertekek) - 1):
if ertekek[i][0] < ertekek[i + 1][0] and e... | ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_C... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
points = []
flag = False
x1, x2 = map(int, input().split())
for i in range(n):
a, b = map(int, input().split())
points.append((a, b))
p = []
for i in range(n):
p.append((points[i][0] * x1 + points[i][1], points[i][0] * x2 + points[i][1]))
p.sort()
for i in range(n - 1):
if p[i][0] != p[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR V... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
X, Y = input().split()
X, Y = float(X) + 1e-10, float(Y) - 1e-10
L = [list(map(float, input().split())) for _ in range(n)]
print(
"NO"
if [i for x, i in sorted((k * X + b, i) for i, (k, b) in enumerate(L))]
== [i for x, i in sorted((k * Y + b, i) for i, (k, b) in enumerate(L))]
else "YE... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
b = [(0) for i in range(n)]
k = [(0) for i in range(n)]
x1, x2 = (int(x) for x in input().split())
for i in range(n):
k[i], b[i] = (int(x) for x in input().split())
y1 = [(x1 * k[i] + b[i]) for i in range(n)]
y2 = [(x2 * k[i] + b[i]) for i in range(n)]
y3 = [(y1[i], y2[i], i) for i in range(n)]
y3.... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | import sys
n = int(input())
x1, x2 = [int(tmp) for tmp in input().split()]
k = []
b = []
kek = 0
lel = 0
for i in range(n):
tmpk, tmpb = [int(tmp) for tmp in input().split()]
k.append(tmpk)
b.append(tmpb)
up = [([0] * 3) for i in range(n)]
down = [([0] * 3) for i in range(n)]
for i in range(n):
up[i][0... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR B... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | def cross(l1, l2, x2):
return l2[0] * x2 + l2[1] < l1[0] * x2 + l1[1]
def __starting_point():
n = int(input())
x1, x2 = list(map(int, input().split()))
data = [tuple(map(int, input().split())) for i in range(n)]
data = list(sorted(data, key=lambda x: (x[0] * x1 + x[1], x[0] * x2 + x[1])))
for ... | FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
eps = 1e-09
x1, x2 = [int(i) for i in input().split()]
x1 += eps
x2 -= eps
area1 = []
area2 = []
for i in range(n):
k, b = [int(i) for i in input().split()]
y1 = x1 * k + b
y2 = x2 * k + b
area1.append([y1, i])
area2.append([y2, i])
area1.sort(key=lambda a: a[0])
area2.sort(key=lamb... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR V... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
x1, x2 = map(int, input().split())
k, b = [], []
for _ in range(n):
kk, bb = map(int, input().split())
k.append(kk)
b.append(bb)
at1 = sorted(range(n), key=lambda i: k[i] * (x1 + 1e-08) + b[i])
at2 = sorted(range(n), key=lambda i: k[i] * (x2 - 1e-08) + b[i])
print(["YES", "NO"][at1 == at2]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_O... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
x, y = map(int, input().split())
u, v = [], []
x += 1e-07
y -= 1e-07
for i in range(n):
k, m = map(int, input().split())
u += [(k * x + m, i)]
v += [(k * y + m, i)]
u, v = sorted(u), sorted(v)
for i in range(n):
if u[i][1] != v[i][1]:
print("YES")
break
else:
print("... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST BIN_OP BIN_OP VAR VAR VAR VAR VAR LIST BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR F... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
x1, x2 = map(int, input().split())
x1 += 10**-8
x2 -= 10**-8
lines = []
for i in range(n):
lines.append(list(map(int, input().split())))
ord_left = []
ord_right = []
for i in range(n):
ord_left.append(lines[i][0] * x1 + lines[i][1])
ord_right.append(lines[i][0] * x2 + lines[i][1])
enum_l = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
l, r = map(int, input().split())
i = 0
s = []
while i < n:
k, b = map(int, input().split())
s.append([l * k + b, r * k + b])
i += 1
s.sort()
y = 0
i = 1
while i < n:
if s[i - 1][1] > s[i][1]:
y = 1
i += 1
print(["NO", "YES"][y]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NU... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | k = []
x = int(input())
c, d = list(map(int, input().split(" ")))
for i in range(x):
a, b = list(map(int, input().split(" ")))
k.append([c * a + b, d * a + b])
k.sort()
for i in range(len(k) - 1):
if k[i + 1][1] < k[i][1]:
print("YES")
quit()
print("NO") | ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FU... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
a = list()
x1, x2 = map(int, input().split())
for i in range(n):
k, b = map(int, input().split())
y1 = k * x1 + b
y2 = k * x2 + b
a.append((y1, y2))
a.sort()
fl = "NO"
y1m = a[0][0]
y2m = a[0][1]
for y1, y2 in a:
if y2 < y2m:
fl = "YES"
else:
y2m = max(y2m, y2)
p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL ... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | a = []
n = int(input())
x1, x2 = map(int, input().split())
for i in range(n):
k, b = map(int, input().split())
c, d = k * x1 + b, k * x2 + b
a.append([c, d])
def f(a):
return a[1]
a.sort()
for i in range(1, len(a)):
if a[i][0] > a[i - 1][0] and a[i][1] < a[i - 1][1]:
print("Yes")
... | ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR FUNC_DEF RETURN VAR NUMBER... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | import sys
from sys import stdin, stdout
n = int(input())
x1, x2 = [int(x) for x in input().split()]
cuts = []
for i in range(n):
k, b = [int(x) for x in input().split()]
cuts.append([k * x1 + b, k * x2 + b])
res = sorted(cuts, key=lambda x: (x[0], x[1]))
max1_e = res[0][0]
max2_e = res[0][1]
ok = True
for i i... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR N... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
x1, x2 = map(int, input().split())
seg = []
for _ in range(0, n):
k, b = map(int, input().split())
y1 = k * x1 + b
y2 = k * x2 + b
seg.append((y1, y2))
seg.sort()
for i in range(1, n):
if seg[i][1] < seg[i - 1][1]:
print("Yes")
exit(0)
print("No") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VA... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | def equation(k, x, b):
return k * x + b
num = int(input())
ans = []
x1, x2 = map(int, input().split())
for i in range(0, num):
k, b = map(int, input().split())
ans.append((equation(k, x1, b), equation(k, x2, b)))
ans.sort()
for i in range(1, num):
if (
ans[i][0] > ans[i - 1][0]
and ans... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR ... |
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these ... | n = int(input())
x1, x2 = list(map(float, input().split()))
x1 += 1e-10
x2 -= 1e-10
lines = [tuple(map(float, input().split())) for _ in range(n)]
l1 = sorted((k * x1 + b, i) for i, (k, b) in enumerate(lines))
l2 = sorted((k * x2 + b, i) for i, (k, b) in enumerate(lines))
if [i for x, i in l1] == [i for x, i in l2]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.