A. Echo
import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n = int(input().rstrip('\n'))
s = str(input().rstrip('\n'))
print("".join([v * 2 for v in s]))
if __name__ == '__main__':
solve()
B. Base 2
import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
ans = 0
a = list(map(int, input().rstrip('\n').split()))
for i in range(len(a)):
ans += pow(2, i) * a[i]
print(ans)
if __name__ == '__main__':
solve()
C. Centers
import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
ls = []
d = collections.defaultdict(int)
for i in range(3 * n):
if a[i] not in d:
d[a[i]] += 1
elif d[a[i]] == 1:
ls.append([i, a[i]])
d[a[i]] += 1
ls.sort()
print(*[ls[i][1] for i in range(n)])
if __name__ == '__main__':
solve()
D. Poisonous Full-Course
import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n = int(input().rstrip('\n'))
dp = [[-pow(10, 30)] * 2 for _ in range(n)]
for i in range(n):
x, y = list(map(int, input().rstrip('\n').split()))
if i == 0:
if x == 0:
dp[i][0] = max(0, y)
dp[i][1] = 0
else:
dp[i][1] = max(0, y)
dp[i][0] = 0
else:
if x == 0:
dp[i][0] = max(dp[i-1][0], dp[i-1][0] + y, dp[i-1][1] + y)
dp[i][1] = dp[i-1][1]
else:
dp[i][1] = max(dp[i-1][1], dp[i-1][0] + y)
dp[i][0] = dp[i-1][0]
print(max(dp[-1]))
if __name__ == '__main__':
solve()