A. Shift
import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, k = list(map(int, input().rstrip('\n').split()))
a = collections.deque(list(map(int, input().rstrip('\n').split())))
for i in range(k):
a.popleft()
a.append(0)
print(*a)
if __name__ == '__main__':
solve()
B. Misjudge the Time
import datetime
import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
h, m = list(map(int, input().rstrip('\n').split()))
do = datetime.datetime(2000, 1, 1, h, m)
for i in range(pow(10, 10)):
d = do + datetime.timedelta(minutes=i)
h, m = str(d.hour), str(d.minute)
h, m = ("00" + h)[-2:], ("00" + m)[-2:]
h, m = int(h[0] + m[0]), int(h[1] + m[1])
if 0 <= h < 24 and 0 <= m < 60:
print(d.hour, d.minute)
exit()
if __name__ == '__main__':
solve()
C. FF
import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, q = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(int)
for i in range(q):
t, a, b = list(map(int, input().rstrip('\n').split()))
if t == 1:
d[a, b] = 1
elif t == 2:
d[a, b] = 0
else:
if d[a, b] == 1 and d[b, a] == 1:
print("Yes")
else:
print("No")
if __name__ == '__main__':
solve()
D. All Assign Point Add
import collections
import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n = int(input().rstrip('\n'))
d = collections.defaultdict(int)
for i, v in enumerate(list(map(int, input().rstrip('\n').split()))):
d[i] = v
s = 0
q = int(input().rstrip('\n'))
for i in range(q):
query = list(map(int, input().rstrip('\n').split()))
if query[0] == 1:
d = collections.defaultdict(int)
s = query[1]
elif query[0] == 2:
d[query[1]-1] += query[2]
elif query[0] == 3:
print(d[query[1]-1] + s)
if __name__ == '__main__':
solve()