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(raw_input().strip()) | |
M, S, P = range(3) | |
def show(case, sol): | |
print "Case #%s: %s" % (case, sol) | |
def transform(m, s, p, limit): |
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 collections import defaultdict as dd | |
def show(i, key, count): | |
print "Case #%s: %s %s" % (i, key, count) | |
t = int(raw_input().strip()) | |
for ct in xrange(1, t + 1): | |
s = int(raw_input().strip()) |
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 math import sqrt, ceil | |
LIMIT = 10 ** 5 | |
n = int(raw_input().strip()) | |
SLIMIT = int(ceil(sqrt(LIMIT))) | |
small = [[0] * (SLIMIT + 1) for _ in xrange(SLIMIT + 1)] | |
big = [0 for _ in xrange(LIMIT + 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
from heapq import heappop as pop, heappush as push | |
from math import floor, ceil | |
t = int(raw_input().strip()) | |
def show(i, sol): | |
print "Case #%s: %s" % (i, sol) | |
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 collections import defaultdict as dd | |
def _calc_size(tree, root, found, sizes): | |
"""Practically a dfs on the remaining nodes | |
where the size of the parent node is the sum of | |
sizes of the child nodes.""" | |
stack = [(root, 0)] | |
on_route = set([root]) |
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 <vector> | |
#include <unordered_set> | |
#include <algorithm> | |
#include <cmath> | |
#include <tuple> | |
#include <iostream> | |
using namespace std; | |
typedef long long ll; |
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(raw_input().strip()) | |
acc = [] | |
for _ in xrange(n): | |
c = int(raw_input().strip()) | |
if c >= 90: | |
acc.append(c) | |
if acc: | |
print "%.2f" % (sum(acc) / float(len(acc))) |
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
# kmp.py | |
def get_prefix(string): | |
l = len(string) | |
ret = [0] * l | |
border = 0 | |
for i in xrange(1, l): | |
while border > 0 and string[i] != string[border]: | |
border = ret[border - 1] | |
if string[i] == string[border]: | |
border += 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
import os.path | |
import os | |
def touch(fname, times=None): | |
"""via: https://stackoverflow.com/a/1160227/8785384 """ | |
with open(fname, "a"): | |
os.utime(fname, times) | |
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
symbols = [ | |
"sziv", "virag", "ora", "villanykorte", "teknos", "pok", "cica", "szmotyi", | |
"kerdojel", "sajt", "katica", "lakat", "nap", "hopehely", "tilos", | |
"napszemuveg", "felkialtojel", "emberke", "jinjang", "tuz", "pokhalo", "madar", | |
"bohoc", "kalapacs", "iglu", "dino", "gyertya", "szaj", "fa", "hoember", "ollo", "lohere", | |
"hangjegy", "sakk", "szellem", "vizcsepp", "hold", "vasmacska", "jeg", "cumi", "bomba", | |
"zebra", "kutya", "koponya", "repa", "alma", "ceruza", "villam", "kaktusz", "auto", | |
"kez", "celkereszt", "szem", "delfin", "level", "sarkany", "kulcs" ] | |
s = set(symbols) | |
print "The number of symbols are: %s" % (len(symbols), ) |