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 | |
import string | |
import fileinput | |
inputs = fileinput.input() | |
numToys = int(inputs[0].replace('\n', '')) | |
toys = inputs[1].replace('\n', '') | |
toys = sorted([int(w) for w in toys.split(' ')]) | |
minus_four = [w - 4 for w in toys] | |
prev_toys = {} |
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 | |
import string | |
import fileinput | |
import pprint | |
inputs = fileinput.input() | |
coins = [int(num) for num in inputs[0].rstrip().split(', ')] | |
total = int(inputs[1]) | |
# coins = [int(num) for num in numbers[:-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 sys | |
import string | |
import fileinput | |
import pprint | |
inputs = fileinput.input() | |
# def calc_prime(N): | |
vals = [int(N.replace('\n', '')) for N in inputs] |
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 | |
import string | |
import fileinput | |
import pprint | |
inputs = fileinput.input() | |
input_vals = [] | |
for n in inputs: | |
input_vals.append(n.replace('\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
import sys | |
import string | |
import fileinput | |
import pprint | |
inputs = fileinput.input() | |
input_vals = [] | |
for n in inputs: | |
input_vals.append(n.replace('\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
long modPow(long a, long x, long p) { | |
//calculates a^x mod p in logarithmic time. | |
long res = 1; | |
while(x > 0) { | |
if( x % 2 != 0) { | |
res = (res * a) % p; | |
} | |
a = (a * a) % p; | |
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 fileinput | |
inputs = fileinput.input() | |
input_vals = [] | |
for n in inputs: | |
input_vals.append(n.replace('\n', '')) | |
numRows, numCols=[int(i) for i in input_vals[0].split(' ')] | |
countMaxWishes = {} |
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 fileinput | |
inputs = fileinput.input() | |
input_vals = [] | |
for n in inputs: | |
input_vals.append(n.replace('\n', '')) | |
numVertices, numEdges = [int(k) for k in input_vals[0].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
import fileinput | |
inputs = fileinput.input() | |
input_vals = [] | |
for n in inputs: | |
input_vals.append(n.replace('\n', '')) | |
numTestCases = int(input_vals[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
import sys | |
import numpy | |
import array | |
factors, numTraining = map(int, sys.stdin.readline().split(' ')) | |
trainSets = [] | |
for i in range(numTraining): | |
trainSets.append(map(float, sys.stdin.readline().split(' '))) |