This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("input.txt", "r") as fi: | |
k, n, p, s = map(int, fi.readline().split(" ")) | |
i = 0 | |
while True: | |
if (i + 1) * k > n or (i + 1) * k * p > s: | |
break | |
else: | |
i += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("input.txt", "r") as fi: | |
n = int(fi.readline()) | |
boys = list(map(int, fi.readline().split(" "))) | |
m = int(fi.readline()) | |
girls = list(map(int, fi.readline().split(" "))) | |
boys.sort() | |
girls.sort() | |
j = m - 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int find_mth_max(int tree[], int m, int n_max) { | |
int x = 1; | |
while (2 * x < n_max) { | |
if (tree[x * 2] >= m) { | |
x *= 2; | |
} else { | |
m -= tree[x * 2]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
n = int(input()) | |
numbers = [int(input()) for _ in range(n)] | |
for j in range(n): | |
i = numbers[j] | |
if (math.sqrt(8 * i - 7)).is_integer(): | |
print(1) | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("input.txt") as fi: | |
a = [int(s) for s in fi.readline().split()] | |
a.sort() | |
max_sum = -1 | |
max_index = -1 | |
for i in range(0, 3): | |
n = a[i] % 10 + (a[i] // 10) % 10 | |
if n > max_sum: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
k = 0 | |
for _ in range(n): | |
for j in input().split(): | |
if j == "1": | |
k += 1 | |
print(k // 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import sys | |
def prefix(s): | |
v = [0] * len(s) | |
for i in range(1, len(s)): | |
k = v[i - 1] | |
while k > 0 and s[k] != s[i]: | |
k = v[k - 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = input() | |
print("".join(map(str, range(int(n) + 1))).find(n)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = input() | |
t = input() | |
k = "".join(reversed(t)) | |
i = 0 | |
while s[i] == k[i]: | |
if s[i:len(s)] == t[0:len(s) - i]: | |
break | |
i += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <map> | |
#include <iostream> | |
#include <vector> | |
#include <stdlib.h> | |
struct Point { | |
int x; | |
int y; | |
}; |