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
from decimal import Decimal, getcontext | |
getcontext().prec = 50 | |
def myPow(base: Decimal, exp: int) -> Decimal: | |
if exp == 0: | |
return Decimal(1) | |
half = myPow(base, exp // 2) | |
if exp % 2 == 0: | |
return half * half |
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 sys | |
data = sys.stdin.read().strip().split() | |
n, k = map(int, data[:2]) | |
a = list(map(int, data[2:2+n])) | |
w = [1 + x for x in a] | |
w.sort() | |
cnt = 0 |
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().strip() | |
a, b, c = map(int, s.split('?')) | |
def apply(op, x, y): | |
return x + y if op == '+' else x * y | |
best = float('-inf') | |
for op1 in ['+', '*']: | |
for op2 in ['+', '*']: | |
best = max(best, |
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
a, b = map(int, input().split()) | |
print(a % b) |
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()) | |
if n == 1: | |
print("q") | |
else: | |
print("q" + "a" * (n - 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
s = input().strip() | |
t = input().strip() | |
n = int(input()) | |
def is_valid(res): | |
return s in res and t not in res | |
if len(s) > n: | |
print(-1) | |
exit() |
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
t = int(input()) | |
for _ in range(t): | |
n = int(input()) | |
s = input().strip() | |
count_C = 0 | |
count_Q = 0 | |
for ch in s: |
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
#!/bin/bash | |
echo "Hello DevOps!" |
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
def find_dimensions(R, B): | |
total = R + B | |
for L in range(3, int(total ** 0.5) + 2): | |
if total % L == 0: | |
W = total // L | |
if (L - 2) * (W - 2) == B: | |
return max(L, W), min(L, W) | |
return None | |
R, B = map(int, input().split()) |
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
def count_square_pairs(n): | |
count = 0 | |
for x in range(1, int(n**0.5) + 1): | |
if n % x == 0: | |
y = n // x | |
if x < y and (x + y) % 2 == 0: | |
count += 1 | |
return count | |
t = int(input()) |
NewerOlder