This file contains 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 | |
from bisect import bisect, bisect_left | |
n, m = map(int, raw_input().split()) | |
arr = map(int, raw_input().split()) | |
left = [-1]*n | |
stack = [] | |
for i, v in enumerate(arr): | |
while stack and arr[stack[-1]] <= v: |
This file contains 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
mod = 1000000007 | |
pre = [1] | |
for _ in xrange(100000): | |
pre.append(2*pre[-1] % mod) | |
for t in xrange(1, int(raw_input()) + 1): | |
n = int(raw_input()) - 1 | |
if n: | |
print 'Case {0}: {1}'.format(t, (n + 2)*pre[n - 1] % mod) | |
else: | |
print 'Case {0}: 1'.format(t) |
This file contains 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
++++++++++ | |
[ | |
>+++++++[>+++++++<-] | |
>- | |
>, | |
>,, | |
<[>-<-] | |
>>+ | |
<[>-] | |
>[>] |
This file contains 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
++++[>++++<-]>[>+++++>++>++++++>+++++++<<<<-] | |
>+++. | |
---. | |
-. | |
-----. | |
>. | |
>+++++++++. | |
>+++. | |
<<. | |
>. |
This file contains 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
while True: | |
out = raw_input() | |
if int(out) is 42: | |
break | |
print out |
This file contains 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 common(a, b): | |
out = [] | |
for i in a: | |
try: | |
b.remove(i) | |
out.append(i) | |
except ValueError: | |
pass | |
return sorted(out) | |
while True: |
This file contains 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
f = [] | |
ff = set([]) | |
for _ in xrange(int(raw_input())): | |
i = raw_input().split() | |
f.append(i[0]) | |
ff = ff.union(set(i[2: ])) | |
for i in f: | |
try: | |
ff.remove(i) | |
except KeyError: |
This file contains 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> | |
using namespace std; | |
int abs(int n) | |
{ | |
if (n < 0) | |
return -1 * n; | |
else | |
return n; | |
} | |
int main() |
This file contains 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
fact = [1] | |
for i in xrange(1, 101): | |
fact.append(i * fact[i - 1]) | |
for _ in xrange(int(raw_input())): | |
print fact[int(raw_input())] |
This file contains 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> | |
using namespace std; | |
int main() | |
{ | |
int t, fact[200], n, i, j, carry, m, x; | |
cin >> t; | |
while (t--) | |
{ | |
cin >> n; | |
fact[0] = 1; |
OlderNewer