Harryxun/stf_run huggingface dataset:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import math
import bisect
import itertools
import numpy as np
from collections import OrderedDict
from bisect import bisect_left, bisect_right, insort_left, insort_right


class EndLoop(Exception):
    pass

def solve():
    while 1:
        try:
            N = int(input())
            D = list(map(int, input().split(" ")))
            M = int(input())
            T = list(map(int, input().split(" ")))
            D_dict = {}
            T_dict = {}
            for d in D:
                if d not in D_dict:
                    D_dict[d] = 1
                else:
                    D_dict[d] += 1

            for t in T:
                if t not in T_dict:
                    T_dict[t] = 1
                else:
                    T_dict[t] += 1

            for key, val in T_dict.items():
                if key not in D_dict:
                    print("NO")
                    raise EndLoop
                else:
                    if val > D_dict[key]:
                        print("NO")
                        raise EndLoop

            print("YES")
            break
        except:
            break


solve()

### FIXED CODE ###

def solve():
    while 1:
        try:
            N = int(input())
            D = list(map(int, input().split(" ")))
            M = int(input())
            T = list(map(int, input().split(" ")))
            D_dict = {}
            T_dict = {}
            for d in D:
                if d not in D_dict:
                    D_dict[d] = 1
                else:
                    D_dict[d] += 1

            for t in T:
                if t not in T_dict:
                    T_dict[t] = 1
                else:
                    T_dict[t] += 1

            for key, val in T_dict.items():
                if key not in D_dict:
                    print("NO")
                    raise EndLoop
                else:
                    if val > D_dict[key]:
                        print("NO")
                        raise EndLoop

            print("YES")
            break
        except:
            break


solve()
"""
https://atcoder.jp/contests/abc080/tasks/abc080_d
400

同じチャンネル同士でかぶりが発生するとアウト
imos
"""

N,C  = map(int, input().split())
t_max = 10**5
# c_imos = [[0]*t_max for t in range(C)]
imos = [0] * t_max
for i in range(N):
    s,t,c = map(int, input().split())
    c -= 1
    # t -= 1
    s -= 1
    # c_imos[c][s] += 1
    # c_imos[c][t] -= 1
    imos[s] += 1
    imos[t] -= 1 

    # for c_ in c_imos:
    #     print(list(accumulate(c_)))
    
from itertools import accumulate
print(max(list(accumulate(imos))))

### FIXED CODE ###

N,C  = map(int, input().split())
t_max = 2*10**5
c_imos = [[0]*t_max for t in range(C)]
# 前処理 : 同一チャンネルのときはくっつけられる
c_imos = [[0]*t_max for t in range(C)]

for i in range(N):
    s,t,c = map(int, input().split())
    c -= 1
    s -= 1
    # t -= 1
    c_imos[c][s] += 1
    c_imos[c][t] -= 1
    
ans = [0] * t_max
from itertools import accumulate
for c_ in c_imos:
    acc = list(accumulate(c_))
    ans = [a+min(1,b) for a,b in zip(ans,acc)]
print(max(ans))
count = 1
while True:
    print("Case",str(count)+":",input(""))
    count = int(count) + 1
    if x == 0:
        break

### FIXED CODE ###

t=[]
while True:
    x = str(input(""))
    if x == "0":
        break
    else:
        t.append(x)
for i,v in enumerate(t):
    print("Case",str(i+1)+":",v)
a, b = map(int, input().split())

if a > 0:
    print('Positive')
else if b >= 0:
    print('Zero')
else if (b-a) % 2 == 1:
    print('Positive')
else:
    print('Negative')

### FIXED CODE ###

a, b = map(int, input().split())

if a > 0:
    print('Positive')
elif b >= 0:
    print('Zero')
elif (b-a) % 2 == 1:
    print('Positive')
else:
    print('Negative')
s = input()
if s[3] == '7':
  s[3] = '8'
print(s)

### FIXED CODE ###

s = input()
if s[3] == '7':
  ans = s[:3] + '8' + s[4:]
else:
  ans = s
print(ans)
def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False
    i = 3
    xx = int(pow(x, 0.5))
    while i <= xx:
        if x % i == 0:
            return False
        i += 2
    return True

n = int(input())
rx = int(pow(n, 0.5))
l = rx+1
ps = []
for i in range(n):
    if isPrime(i):
        ps.append(i)
    if i == l:
        break
ans = []
i = 0
nn = n
ps.append(nn)
while n != 1:
    if n % ps[i] == 0:
        n //= ps[i]
        ans.append(ps[i])
    else:
        i += 1
print(str(nn)+":", ' '.join(map(str, ans)))

### FIXED CODE ###

n = int(input())
print("{}:".format(n), end='')
x = int(pow(n, 0.5))+1
for i in range(2, x):
    while n % i == 0:
        print(" {}".format(i), end='')
        n //= i
print(' {}'.format(n) if n != 1 else '')
import sys

lst = []
for line in sys.stdin:
    num = int(line)
    if num == 0:
        print lst.pop()
    else:
        lst.append(num)

### FIXED CODE ###

import sys

lst = []
for line in sys.stdin:
    if line.strip() :
        num = int(line.strip())
        if num == 0:
            print lst.pop()
        else:
            lst.append(num)
s=input()
k=int(input())
a=[]
for i in range(0,len(s)):
    for j in range(1,len(s)+1):
        if i != j and s[i:j] not in a:
            a.append(s[i:j])
a.remove("")
a=sorted(a)
print(b[k-1])


### FIXED CODE ###

s=input()
k=int(input())
a=[s[i:i+j+1] for i in range(len(s)) for j in range(k+1)]
a=set(a)
a=sorted(a)
print(a[k-1])
def a(s):
    count = 0
    for i in range(len(s) - 2):
        if s[i] == s[i + 1]:
            s = s[:i + 1] + 'A' + s[i + 2:]
            count += 1
    if s[-1] == s[-2]:
        count +=1
    return count


s = str(input())
k = int(input())
if s[0] != s[-1] or k==1:
    print(a(s) * k)
else:
    new_s = s * 2
    org_count = a(s)
    new_count = a(new_s)
    diff = 2 * org_count - new_count
    print(org_count * k - diff * (k - 1))

### FIXED CODE ###

def a(s):
    count = 0
    test = s[0]
    for i in range(len(s) - 1):
        if s[i] == s[i + 1] and test[i] != 'A':
            # s = s[:i + 1] + 'A' + s[i + 2:]
            test += 'A'
            count += 1
        else:
            test += s[i]
    return count


s = input()
k = int(input())
if s[0] != s[-1] or k == 1:
    print(a(s) * k)
elif k == 2:
    new_s = s * 2
    print(a(new_s))
elif len(s) == s.count(s[0]):
    new_s = s * 2
    count_2 = a(new_s)
    print(count_2 * (k // 2) + a(s) * (k % 2))
else:
    new_s = s * 2
    count_2 = a(new_s)
    count_3 = a(new_s + s)
    diff = count_3 - count_2
    print(count_3 + (k-3) * diff)
n = int(input())
s=[input() for _ in range(n)]
m = int(input())
t=[input() for _ in range(m)]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),ans)
print(res)

### FIXED CODE ###

s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),res)
print(res)
s = input()
if "C" in s and "F" in s:
  a = s.lindex("C")
  b = s.rindex("F")
  if a < b:
    print("Yes")
  else:
    print("No")
else:
  print("No")


### FIXED CODE ###

s = input()
if "C" in s and "F" in s:
  a = s.index("C")
  b = s.rindex("F")
  if a < b:
    print("Yes")
  else:
    print("No")
else:
  print("No")
s = str(input())
print(char(ord(s)+1))

### FIXED CODE ###

s = str(input())
print(chr(ord(s)+1))
from typing import List

def is_odd(num):
    return num % 2 != 0

def odd_in_list(num_list):
    for num in num_list:
        if is_odd(num):
            return True
    
    return False

def half(num):
    return num / 2

def shift_only(num_list, counter):
    if odd_in_list(num_list):
        print('its over')
        return counter
    else:
        new_list = list(map(half, num_list))
        counter += 1
        print('continue', num_list, counter)
        return shift_only(new_list, counter)


n = int(input())

a_list = list(map(int, input().split()))


counter = 0
flag = True

while flag:
    for i in range(n):
        if a_list[i] % 2 != 0:
            flag = False
            break
        else:
            continue

    
    for i in range(n):
        a_list[i] /= 2
    counter += 1

print(counter)

### FIXED CODE ###



def is_odd(num):
    return num % 2 != 0

def odd_in_list(num_list):
    for num in num_list:
        if is_odd(num):
            return True
    
    return False

def half(num):
    return num / 2

def shift_only(num_list, counter):
    if odd_in_list(num_list):
        print('its over')
        return counter
    else:
        new_list = list(map(half, num_list))
        counter += 1
        print('continue', num_list, counter)
        return shift_only(new_list, counter)


n = int(input())

a_list = list(map(int, input().split()))


counter = 0
flag = True

while flag:
    for i in range(n):
        # print(a_list[i])
        if a_list[i] % 2 != 0:
            # print('is odd')
            flag = False
            break
        else:
            continue
    
    if not flag:
        break
    
    for i in range(n):
        a_list[i] /= 2
    counter += 1

    # print('-----loop------')
    # print(a_list, counter)

print(counter)
n,m = map(int,raw_input().split())
for i in range(n):
  a = []
  a.append(map(int, raw_input().split()))
for i in range(m):
  b = []
  b.append(input())
for i in range(n):
  ans = 0
  for j in range(m):
    ans += a[i][j]*b[j]
print ans

### FIXED CODE ###

n,m = map(int,raw_input().split())
a = []
b = []

for i in range(n):
  a.append(map(int, raw_input().split()))
for i in range(m):
  b.append(input())
for i in range(n):
  ans = 0
  for j in range(m):
    ans += a[i][j]*b[j]
  print ans
# -*- coding: utf-8 -*-
from bisect import bisect_left
from sys import stdin
from heapq import heappush, heappop



readl = stdin.readline
def main():
  ## input
  N,Q = map(int, readl().rstrip().split())
  STX = list(map(int, readl().rstrip().split())) for _ in range(N)]
  Dn = [None for _ in range(Q+1)]
  for i in range(Q):
    Dn[i] = int(readl().rstrip())
  Dn[Q] = 10**10
  ans = []

  for s,t,x in sorted(STX,key=lambda x:x[2]):
    l = r = bisect_left(Dn,s-x)
    t -= x
    while Dn[r] < t:
      heappush(ans, (Dn[r],x))
      r += 1
    del Dn[l:r]

  for d in Dn[:-1]:
    heappush(ans, (d,-1))

  return ans,Q


if __name__ == "__main__":
  ans,n = main()
  for _ in range(n):
    print(heappop(ans)[1])    


### FIXED CODE ###

import sys
from bisect import bisect_left



N,Q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:N]:
  s, t, x = map(int, line.split())
  kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[N:]))

ans = [-1] * Q
skip = [-1] * Q
for x, s, t in kkk:
  ss = bisect_left(ddd, s - x)
  tt = bisect_left(ddd, t - x)
  while ss < tt:
    sk = skip[ss]
    if sk == -1:
      ans[ss] = x
      skip[ss] = tt
      ss += 1
    else:
      ss = sk

print('\n'.join(map(str, ans)))
from collections import deque

import numpy as np


def solve(n, arr, q, path, c):
  flag = True
  for i in path:
    if path[i] == 0:
      flag = False
  if flag:
    return path
  if c > 100000000:
    return -1
  if len(q) == 0:
    return -1
  pos = q.popleft()
  for i in range(1, n):
    if arr[pos][i] == 1:
      q.append(i)
      if path[i+1] == 0:
        path[i+1] = pos+1
  return solve(n, arr, q, path, c+1)
        

def calc(n, arr):
  path = {i:0 for i in range(2, n+1)}
  queue = deque()
  for i in range(n):
    if arr[0][i] == 1:
      queue.append(i)
      path[i+1] = 1
  result = solve(n, arr, queue, path, 0)
  if result == -1:
    return ["No"]
  else:
    L = ["Yes"]
    for i in result:
      L.append(result[i])
    return L

n, m = map(int, input().split())
arr = np.zeros([n, n])
for i in range(m):
  tmp0, tmp1 = map(int, input().split())
  arr[tmp0-1][tmp1-1] = 1
  arr[tmp1-1][tmp0-1] = 1

answer = calc(n, arr)
for i in answer:
  print(i)

### FIXED CODE ###

from collections import deque

def main():
    n,m = map(int,input().split())
    ab = [[] for i in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        ab[a-1].append(b-1)
        ab[b-1].append(a-1)
    q = deque()
    q.append(0)
    ans = [-1] * n
    ans[0] = 0
    while q:
        now = q.popleft()
        for i, next in enumerate(ab[now]):
            if ans[next] == -1:
                ans[next] = now+1
                q.append(next)
        if len(q) == 0:
            break
    print('Yes')
    for i in range(1,n):
        print(ans[i])



if __name__=='__main__':
    main()
while True:
  H,W=map(int,raw_input().split())
  if H==W==0:
    break
  elif H!=0 or W!=0:
    print (('#'*W + '\n')+('#' + '.'*(W-2) + '#' + '\n')*(H-2) + ('#'*W + '\n')

### FIXED CODE ###

while True:
  H,W=map(int,raw_input().split())
  if H==W==0:
    break
  elif H!=0 or W!=0:
    print (('#'*W +'\n')+('#' + '.'*(W-2) + '#' + '\n')*(H-2) + ('#'*W + '\n'))
def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    D = [0]*(N - 1)
    for i in range(1, N):
        D[i-1] = X[i] - X[i - 1]
    ans = 0
    t = 0
    T = [0]*(N - K + 1)
    for i in range(1, N):
        t += D[i-1]
        if i < K:
            if i == K - 1:
                T[0] = t
            continue
        t -= D[i - K]
        T[i - K + 1] = t
    # print(D, T)
    ans = K * 10**8
    for i in range(N - K + 1):
        a = T[i] + min(abs(X[i]), abs(X[i + K - 1])]
        ans = min(a, ans)
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    D = [0]*(N - 1)
    for i in range(1, N):
        D[i-1] = X[i] - X[i - 1]
    ans = 0
    t = 0
    T = [0]*(N - K + 1)
    for i in range(1, N):
        t += D[i-1]
        if i < K:
            if i == K - 1:
                T[0] = t
            continue
        t -= D[i - K]
        T[i - K + 1] = t
    # print(D, T)
    ans = K * 10**8
    for i in range(N - K + 1):
        a = T[i] + min(abs(X[i]), abs(X[i + K - 1]))
        ans = min(a, ans)
    print(ans)

if __name__ == '__main__':
    main()
num = input()
hoge = list(map(int, input().split()))
count = 0
fuga = 0

for i in range(1, len(hoge)):
  if hoge[i] != hoge[i - 1]:
    print(i - count)
    fuga += 1
    count = i
    if i == len(hoge) - 1:
      print(i + 1- count)
      fuga += 1
    else:
      if i == len(hoge) - 1:
        print(i + 1- count)
        fuga += 1
for i in range(fuga, num):
  print(0)

### FIXED CODE ###

num = int(input())
hoge = list(map(int, input().split()))

fuga = [0] * num

for i in hoge:
  fuga[i - 1] += 1
for i in fuga:
  print(i)
a = int(input())

s = string(input())

if a % 2 == 1:
  print("No")
else:
  b = a/2
  if s[:b] == s[b:]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a = int(input())

s = str(input())

if a % 2 == 1:
  print("No")
else:
  b = int(a/2)
  if s[:b] == s[b:]:
    print("Yes")
  else:
    print("No")
import numpy as np

M = 998244353

n = int(input())
xs = [0] * n
ds = [0] * n
for i in range(n):
    x, d = (int(c) for c in input().split())
    ds[i] = d
    xs[i] = x
xs = np.array(xs)
ds = np.array(ds)

import sys
sys.setrecursionlimit(n)

index = xs.argsort()
xs = xs[index]
ds = ds[index]

def _sub(i):
    # 深さ優先探索しながらi番目以下の組み合わせと、次に調べるべき番号を返す
    if i==n-1:
        return 2, n
    res = 1
    ind = i+1
    while True:
        if (xs[i]+ds[i] <= xs[ind]):
            break
        o, ind = _sub(ind)
        res *= o
        res %= M
        if ind>=n:
            break
    return res+1, ind
out = []
done = 0
while True:
    o, done = _sub(done)
    out.append(o)
    if done>=n:
        break
result = 1
for o in out:
    result *= o
    result %= M
print(result)

### FIXED CODE ###


import numpy as np

M = 998244353

n = int(input())
xs = [0] * n
ds = [0] * n
for i in range(n):
    x, d = (int(c) for c in input().split())
    ds[i] = d
    xs[i] = x
xs = np.array(xs)
ds = np.array(ds)

import sys
sys.setrecursionlimit(max(1000,n))

index = xs.argsort()
xs = xs[index]
ds = ds[index]

def _sub(i):
    # 深さ優先探索しながらi番目以下の組み合わせと、次に調べるべき番号を返す
    if i==n-1:
        return 2, n
    res = 1
    ind = i+1
    while True:
        if (xs[i]+ds[i] <= xs[ind]):
            break
        o, ind = _sub(ind)
        res *= o
        res %= M
        if ind>=n:
            break
    return res+1, ind
out = []
done = 0
while True:
    o, done = _sub(done)
    out.append(o)
    if done>=n:
        break
result = 1
for o in out:
    result *= o
    result %= M
print(result)
from itertools import accumulate

S = int(input())
mod = 10**9 + 7
dp = [0] * (S + 1)
dp[0] = 1
ans = 0
for i in range(S):
    cum = list(accumulate(dp))
    for j in range(S, 2, -1):
        dp[j] = cum[j-3] % mod
    dp[0] = dp[1] = dp[2] = 0
    ans = (ans + dp[S]) % mod
print(ans)

### FIXED CODE ###

from itertools import accumulate

S = int(input())
mod = 10**9 + 7
if S == 1 or S == 2:
    print(0)
    exit()
dp = [0] * (S + 1)
dp[0] = 1
ans = 0
for i in range(S):
    cum = list(accumulate(dp))
    for j in range(S, 2, -1):
        dp[j] = cum[j-3] % mod
    dp[0] = dp[1] = dp[2] = 0
    ans = (ans + dp[S]) % mod
print(ans)
import sys

n,m=input().split()
N = int(n)
M = int(m)
X = input().split()
#MはXの要素の数
X = [int(x) for x in X]

X.sort()
if M == 1:
    print(0)
    sys.exit()
elif M < 1:
    sys.exit()

minus = [X[i]-X[i-1] for i in range(1,M)]
#print(minus)

minus.sort()
#print(minus)
sum_num = 0
if N < M:
    for i in range(N+1):
        sum_num += minus[i]
    print(sum_num)
elif N >= M:
    print(0):

### FIXED CODE ###

import sys

n,m=input().split()
N = int(n)
M = int(m)
X = input().split()
#MはXの要素の数
X = [int(x) for x in X]

X.sort()
if M == 1:
    print(0)
    sys.exit()
elif M < 1:
    sys.exit()

minus = [X[i]-X[i-1] for i in range(1,M)]
#print(minus)

minus.sort()
#print(minus)
sum_num = 0
if N < M:
    for i in range(M-N):
        sum_num += minus[i]
    print(sum_num)
elif N >= M:
    print(0)
n=input()
n=int(n)
og=n
flag=0
for i in range(0,10):
    while(n>0):
    d=n%10
    n=n//10
    if(d==i):
        flag=flag+1

if(flag>=3):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=input()
if(n[0]==n[1]==n[2] or n[1]==n[2]==n[3]):
    print("Yes")
else:
    print("No")
import sys
input=sys.stdin.readline
s = input()
len_s = len(s)
mod = 10 ** 9 + 7
dp = [[0] * 13 for i in range(len_s)]

for i in range(len_s):
    if s[-(i + 1)] == '?':
        for j in range(13):
            if i == 0:
                if j < 10:
                    dp[i][j] = 1
                continue

            if dp[i - 1][j] > 0:
                for k in range(10):
                #k:先頭に加える数字
                    add = k * pow(10, i)
                    dp[i][(j + add)%13] = (dp[i][(j + add)%13] + dp[i - 1][j])%mod

    else:
        if i == 0:
            dp[i][int(s[-(i + 1)])] = 1
            continue

        add = int(s[-(i + 1)]) * pow(10, i)
        for j in range(13):
            if dp[i - 1][j] > 0:
                dp[i][(j + add)%13] = (dp[i][(j + add)%13] + dp[i - 1][j])%mod

print(dp[-1][5] % mod)

### FIXED CODE ###

s=input()
len_s=len(s)
mod=10**9+7
dp=[[0]*13 for i in range(len_s)]

if s[-1]!='?':
    dp[0][int(s[-1])%13]=1
else:
    for i in range(10):
        dp[0][i]=1

a=1
for i in range(1,len_s):
    a=10*a%13
    if s[-(i+1)]!='?':
        temp_S=int(s[-(i+1)])
        amari=(temp_S*a)%13
        for j in range(13):
            dp[i][(amari+j)%13]+=dp[i-1][j]%mod

    else:
        for k in range(10):
            amari=(k*a)%13
            for l in range(13):
                dp[i][(amari+l)%13]+=dp[i-1][l]%mod
#print(*dp,sep='\n')
print(dp[-1][5]%mod)
word = input().split()

x = 0
i = 0

for i in range(3) :
  if word[i] != word[i+1] : x = x + 1
    
if x == 0 : print("No")

else : print("Yes")

### FIXED CODE ###

word = input()

if word[0:1] == word[1:2] and word[0:1] == word[2:] :
    print("No")
    
else : print("Yes")
n=int(input())
h=[int(i) for i in input().split()]
dp=[10000 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
dp[2]=abs(h[2]-h[0])

for i in range(1,len(h)-2):
    x=abs(h[i+1]-h[i])+dp[i]
    y=abs(h[i+2]-h[i])+dp[i]
    if(dp[i+1]>x):
      dp[i+1]=x
    if(dp[i+2]>y):
      dp[i+2]=y

if(dp[n-1]>abs(h[n-1]-h[n-2])+dp[n-2]):
	dp[n-1]=abs(h[n-1]-h[n-2])+dp[n-2]
print(dp[n-1])
    


### FIXED CODE ###

n=int(input())
h=[int(i) for i in input().split()]
dp=[0,abs(h[1]-h[0])]

for ind in range(2,len(h)):
    a=abs(h[ind-1]-h[ind])
    b=abs(h[ind-2]-h[ind])
    if(a+dp[ind-1]>b+dp[ind-2]):
        dp.append(b+dp[ind-2])
    else:
        dp.append(a+dp[ind-1])
print(dp[len(dp)-1])
import sys
import random
import bisect
from collections import deque

def cumsum(a):
    tmp = 0
    ret = []
    for i in range(len(a)):
        tmp += a[i]
        ret.append(tmp)
    return ret

x = input().split()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n, m, k = int(x[0]), int(x[1]), int(x[2])

#n, m = 100000, 100000
#time = 100000000
#a = list(random.choices(range(10000), k=n))
#b = list(random.choices(range(10000), k=m))

a_sum, b_sum = cumsum(a), cumsum(b)

ans, j = 0, m-1
for i in range(n):
    if a_sum[i] > k:
        break
    while b_sum[j] > k-a_sum[i]:
        print(j)
        j -= 1
    ans = max(ans, i + j + 2)

print (ans)


### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N): a.append(a[i] + A[i])
for i in range(M): b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
import bisect
n,m = map(int,input().split())
data = []
for i in range(m):
    data.append(list(map(int,input().split())))
r = sorted(data,key= lambda x:(x[0],x[1]))
o = [[] for _ in range(100000)]

for i in range(m):
    o[r[i][0]].append(r[i][1])

for i in range(m):
    print("0"*(6-len(str(data[i][0]))),end="")
    print(data[i][0],end="")
    num = bisect.bisect_left(o[data[i][0]],data[i][1])+1
    print("0"*(6-len(str(num))),end="")
    print(num)

### FIXED CODE ###

import bisect
n,m = map(int,input().split())
data = []
for i in range(m):
    data.append(list(map(int,input().split())))
r = sorted(data,key= lambda x:(x[0],x[1]))
o = [[] for _ in range(100001)]

for i in range(m):
    o[r[i][0]].append(r[i][1])

for i in range(m):
    print("0"*(6-len(str(data[i][0]))),end="")
    print(data[i][0],end="")
    num = bisect.bisect_left(o[data[i][0]],data[i][1])+1
    print("0"*(6-len(str(num))),end="")
    print(num)
W, H, r, x ,y = list(map(int,input().split()))
 if 0 <= x - r <= x + r = W and 0 <= y - r <= y + r = H:
  print('yes')
 else:
  print('no')

### FIXED CODE ###

W, H, x, y, r = list(map(int, input().split()))
print('Yes' if 0 <= x - r <= x + r <= W and 0 <= y - r <= y + r <= H else 'No')
import math

n = int(input())
for i in range(0, n) :
    a = int(input())
    b = int(input())
    if (math.log10(a + b) + 1 > 80) :
        print("overflow")
        continue
    print(a + b)

### FIXED CODE ###

for _ in range(int(input())) :
    n = int(input()) + int(input())
    if (n >= 10 ** 80) :
        print("overflow")
    else :
        print(n)
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc =[list(map(int, input().split())) for _ in range(q)]
temp = [0] * (10**5 + 1)

for i in a:
    temp[i] += 1
ans = sum(a)
for i in range(q):
    b,c = bc[i][0],bc[i][1]
    ans = ans - temp[b] * b + temp[b] * c 
    print(sum(temp))
    temp[c] += tremp[b]

### FIXED CODE ###


  
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    bc =[list(map(int, input().split())) for _ in range(q)]
    temp = [0] * (10**5 + 1)
    
    for i in a:
        temp[i] += 1
    ans = sum(a)
    for i in range(q):
        b,c = bc[i][0],bc[i][1]
        ans = ans - temp[b] * b + temp[b] * c 
        print(ans)
        temp[c] += temp[b]
        temp[b] = 0
if __name__ == "__main__":
    main()