Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())
s = input()
r = []
g = []
b = []
for i in range(len(s)):
    t = s[i]
    if t == 'R':
        r.append(i+1)
    elif t == 'G':
        g.append(i+1)
    else:
        b.append(i+1)

ans = 0
for i in r:
    for j in g:
        for k in b:
            if i < j < k:
                if j-i != k-j:
                    ans += 1
for i in g:
    for j in b:
        for k in r:
            if i < j < k:
                if j-i != k-j:
                    ans += 1
for i in b:
    for j in r:
        for k in g:
            if i < j < k:
                if j-i != k-j:
                    ans += 1
for i in r:
    for j in b:
        for k in g:
            if i < j < k:
                if j-i != k-j:
                    ans += 1
for i in g:
    for j in r:
        for k in b:
            if i < j < k:
                if j-i != k-j:
                    ans += 1
for i in b:
    for j in g:
        for k in r:
            if i < j < k:
                if j-i != k-j:
                    ans += 1

"""
ans = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if sl[i-1] != sl[j-1] and sl[j-1] != sl[k-1] and sl[k-1] != sl[i-1]:
                if j-i != k-j:
                    ans += 1
"""

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

r = []
g = []
b = []
for i in range(len(s)):
    t = s[i]
    if t == 'R':
        r.append(i+1)
    elif t == 'G':
        g.append(i+1)
    else:
        b.append(i+1)

ans = len(r) * len(g) * len(b)

for i in range(1, int((n-1)/2)+1):
    for j in range(n-i-i, 0, -1):
        if s[j-1] != s[j+i-1] and s[j+i-1] != s[j+i+i-1] and s[j+i+i-1] != s[j-1]:
            ans -= 1

print(ans)
### BUGGY CODE ###

K = int(input())
x = 7
count = 1
if K % 2 ==0:
  print("-1")
  exit(0)
for i in range(10**5):
  if x % K == 0:
    print(count)
    exit(0)
  else:
    x = 10*x + 7
    count += 1
print("-1")

### FIXED CODE ###

def calc(k):
    cur = 0
    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k
        if cur == 0:
            return i

    return -1


k = int(input())
print(calc(k))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Aug 18 21:50:39 2018
ABC106D
@author: maezawa
"""

n, m, qn = list(map(int, input().split()))

lr = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
    li, ri = list(map(int, input().split()))
    lr[li][ri] += 1
    
for i in range(n+1):
    ac = 0
    for j in range(n):
        lr[i][j+1] += lr[i][j]

for _ in range(qn):
    pi, qi = list(map(int, input().split()))
    ans = 0
    for i in range(pi, qi+1):
        ans += lr[i][qi] - lr[i][pi-1]
    
    print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Aug 18 21:50:39 2018
ABC106D
@author: maezawa
"""

n, m, qn = list(map(int, input().split()))

lr = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
    li, ri = list(map(int, input().split()))
    lr[li][ri] += 1
    
for i in range(n+1):
    for j in range(n):
        lr[i][j+1] += lr[i][j]
for i in range(n+1):
    for j in range(n):
        lr[j+1][i] += lr[j][i]

for _ in range(qn):
    pi, qi = list(map(int, input().split()))
    ans = lr[qi][qi] - lr[qi][pi-1] - lr[pi-1][qi] +lr[pi-1][pi-1]
    
    print(ans)
### BUGGY CODE ###

N=int(input())

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

a=sorted(m)
count=0

for i in range(min(a),max(a)+1):
    b=[j for j in a if i > j]
    if len(b) == N/2:
        count +=1
          
print(count)           

### FIXED CODE ###

N=int(input())

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

a=sorted(m)

ans=a[int(N/2)]-a[int(N/2)-1]
    
          
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()
ans_l = set()

for i in range(n-2):
    for j in range(i+1, n-1):
        nums = set(s[j+1::])
        for num in nums:
            ans_l.add(s[i] + s[j] + num)

print(len(ans_l))


### FIXED CODE ###

n = int(input())
s = input()

ones = set()
twos = set()
threes = set()

for a in s:
    for item in twos:
        threes.add(item+a)
    for item in ones:
        twos.add(item+a)
    ones.add(a)

print(len(threes))
### BUGGY CODE ###

N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
s = [(K, V[:], [], False)]
while s:
    cnt, v, bag, flag = s.pop()
    ans = max(ans, sum(bag))
    if cnt > 0 and v and not flag:
        s.append((cnt-1, v[1:], bag + [v[0]], False))
        s.append((cnt-1, v[:-1], bag + [v[-1]], False))
    if cnt > 0 and bag:
        min_bag = min(bag)
        if min_bag < 0:
            bag.remove(min_bag)
            s.append((cnt-1, [], bag, True))


print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for l in range(K+1):
    for r in range(K-l+1):
        if l + r < N:
            bag = V[:l] + V[N-r:] + [0]
            rest_ope = K-l-r
        else:
            bag = V[:]
            rest_ope = K - N
        for _ in range(rest_ope):
            min_bag = min(bag)
            if min_bag < 0 and rest_ope > 0:
                bag.remove(min_bag)
                rest_ope -= 1
        else:
            ans = max(ans, sum(bag))

print(ans)
### BUGGY CODE ###

import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter
from collections import OrderedDict

N = int(input())

left = 0
right = N - 1
mid = 0

for _ in range(20):
    print(left, flush=True)
    l = input()
    print(right, flush=True)
    r = input()

    if l == "Vacant" or r == "Vacant":
        exit()

    mid = (r + l) // 2
    print(mid, flush=True)
    m = input()
    if m == "Vacant":
        exit()

    if (mid - left) % 2 == 0 and l != m:
        right = mid - 1
    elif (right - mid) % 2 == 1 and m == r:
        left = mid + 1


### FIXED CODE ###

import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter
from collections import OrderedDict

N = int(input())

left = 0
right = N - 1
mid = 0

print(left, flush=True)
l = input()
if l == "Vacant":
    exit()
    
print(right, flush=True)
r = input()
if r == "Vacant":
    exit()

while left + 1 != right:
    mid = (right + left) // 2
    print(mid, flush=True)
    m = input()
    if m == "Vacant":
        exit()
        
    if ((mid - left) % 2 == 0 and l != m) or ((mid - left) % 2 == 1 and l == m):
        right = mid
        r = m
    else:
        left = mid
        l = m
### BUGGY CODE ###

import bisect
N, Q = map(int, input().split())
C = list(map(int, input().split()))
L = [0] * Q
R = [0] * Q
E = []

D = {C[i]: -1 for i in range(N)}
for i in range(N):
    if D[C[i]] == -1:
        D[C[i]] = i
    else:
        E.append((D[C[i]], i, -1))
        D[C[i]] = i

for i in range(Q):
    l, r = map(int, input().split())
    L[i] = l
    R[i] = r
    E.append((l - 1, r - 1, i))

def f(tup):
    return tup[0]
E.sort(key=f, reverse=True)

ANS = [0] * Q
y_list = []
for e in E:
    if e[2] == -1:
        y_list.append(e[1])
        y_list.sort()
    else:
        ans = bisect.bisect_right(y_list, e[1])
        ANS[e[2]] = e[1] - e[0] + 1 - ans

for i in range(Q):
    print(ANS[i])

### FIXED CODE ###

from collections import defaultdict
import sys
def read():
    return sys.stdin.readline().rstrip()
def main():
    N, Q = map(int, read().split())
    C = list(map(int, read().split()))
    E = defaultdict(list)

    D = [-1] * (N + 1)
    for i in range(N):
        D_i = D[C[i]]
        if D_i != -1:
            E[D_i].append((D_i, i))
        D[C[i]] = i

    F = defaultdict(list)
    for i in range(Q):
        l, r = map(int, input().split())
        F[l-1].append((r - 1, i))



    # Binary Indexed Tree (Fenwick Tree)
    class BIT:
        def __init__(self, n):
            self.n = n
            self.data = [0] * (n + 1)
            self.el = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.data[i]
                i -= i & -i
            return s

        def add(self, i, x):
            # assert i > 0
            self.el[i] += x
            while i <= self.n:
                self.data[i] += x
                i += i & -i

        def get(self, i, j=None):
            if j is None:
                return self.el[i]
            return self.sum(j) - self.sum(i)

    ANS = [0] * Q
    d = BIT(N)
    for x in range(N - 1, -1, -1):
        for e in E[x]:
            d.add(e[1], 1)
        for f in F[x]:
            ANS[f[1]] = f[0] - x + 1 - d.sum(f[0])

    for i in range(Q):
        print(ANS[i])

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input=sys.stdin.readline
s=list(input())
t=list(input())
n=len(s)
m=len(t)
dp=[['' for i in range(m+1)] for j in range(n+1)]
#dps=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+s[i]
            #dps[i+1][j+1]=dps[i][j]+1
        else:
            if len(dp[i+1][j])>len(dp[i][j+1]):
                dp[i+1][j+1]=dp[i+1][j]
                #dps[i+1][j+1]=dps[i+1][j]
            else:
                dp[i+1][j+1]=dp[i][j+1]
                #dps[i+1][j+1]=dps[i][j+1]
print(dp[n][m])


### FIXED CODE ###

import sys
input=sys.stdin.readline
def main():
    s=tuple(input())
    t=tuple(input())
    n=len(s)
    m=len(t)
    dp=[[0 for i in range(m+1)] for j in range(n+1)]
    for i in range(n):
        for j in range(m):
            if s[i]==t[j]:
                dp[i+1][j+1]=dp[i][j]+1
            else:
                if dp[i+1][j]>dp[i][j+1]:
                    dp[i+1][j+1]=dp[i+1][j]
                else:
                    dp[i+1][j+1]=dp[i][j+1]
    p=dp[n][m]
    ans=['' for _ in range(p)]
    n-=1
    m-=1
    while p>0:
        if s[n]==t[m]:
            ans[p-1]=s[n]
            n-=1
            m-=1
            p-=1
        elif dp[n+1][m+1]==dp[n][m+1]:
            n-=1
        else:
            m-=1
    print(''.join(ans)) 
if __name__=='__main__':
    main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
bin_a = []
for i in a:
    bin_a.append(bin(i)[2::])
maxlen = 0
for i, j in enumerate(bin_a):
    maxlen = max(maxlen, len(j))

for i, j in enumerate(bin_a):
    while len(bin_a[i]) < maxlen:
        bin_a[i] = "0" + bin_a[i]
bin_a.sort()
ans = 0
mod = 10**9+7
for i in range(maxlen):
    zerocnt = 0
    onecnt = 0
    for j in range(len(bin_a)):
        if bin_a[j][i] == "0":
            zerocnt += 1
        else:
            onecnt += 1
    ans += zerocnt * onecnt * (2 ** (maxlen-i-1))
    ans %= mod
ans %= mod
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
onecnts = []

for i in a:
    j = 0
    while i > 0:
        if len(onecnts) - 1 < j:
            onecnts.append(0)
        if i % 2 != 0:
            onecnts[j] += 1
        j += 1
        i >>= 1

ans = 0
mod = 10**9+7

for i, onecnt in enumerate(onecnts):
    ans += onecnt * (n-onecnt) * (2**i)
    ans %= mod
print(ans)
### BUGGY CODE ###

n,a,b=list(map(int,input().split()))
#2^n-nCa-nCbを求めればいい。ただし100000007で割ったあまりでなくてはならない
#まずは2^nを求める
def pow(x,n,m):
  if n==0:
    return 1
  res=pow(x*x%m,n//2,m)
  if n%2==1:
    res=res*x%m
  return res
#コンビネーションを求める
fac=[0 for i in range(n+1)]
inv=[0 for i in range(n+1)]
finv=[0 for i in range(n+1)]
fac[0]=1
fac[1]=1
inv[1]=1
finv[0]=finv[1]=1
for i in range(2,n+1):
  fac[i]=fac[i-1]*i%1000000007
  #iの逆数を求める。
  #mod　p=1000000007の世界で逆元を求める
  #p=(p//a)*a+(p%a)
  #mod pをとると a=-(p//a)*(p%a)^-1
  inv[i]=1000000007-(1000000007//i)*inv[1000000007%i]%1000000007
  finv[i]=finv[i-1]*inv[i]%1000000007
  
def combinations(n,k):
  return fac[n]*finv[k]*finv[n-k]%1000000007

print(pow(2,n,1000000007)-combinations(n,a)-combinations(n,b)-1)

  
  
  


### FIXED CODE ###

n,a,b=list(map(int,input().split()))
#2^n-nCa-nCbを求めればいい。ただし100000007で割ったあまりでなくてはならない
#まずは2^nを求める
def pow(x,n,m):
  if n==0:
    return 1
  res=pow(x*x%m,n//2,m)
  if n%2==1:
    res=res*x%m
  return res

#コンビネーションを求める
c=max(a,b)
inv=[0 for i in range(c+1)]
finv=[0 for i in range(c+1)]
inv[1]=1
finv[0]=finv[1]=1
for i in range(2,c+1):
  #iの逆数を求める。
  #mod　p=1000000007の世界で逆元を求める
  #p=(p//a)*a+(p%a)
  #mod pをとると a=-(p//a)*(p%a)^-1
  inv[i]=1000000007-(1000000007//i)*inv[1000000007%i]%1000000007
  finv[i]=finv[i-1]*inv[i]%1000000007
def kaizyou(k):
  num=1
  for i in range(n-k+1,n+1):
    num=num*i%1000000007
  return num

def combinations(k):
  return kaizyou(k)*finv[k]%1000000007

print((pow(2,n,1000000007)-combinations(a)-combinations(b)-1)%1000000007)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))

for i in range(1,n+1):
    b = a.count(i)
    print(b)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
for i in range(1,n+1):
    print(c[i])
### BUGGY CODE ###

def calc_dynamic(n, x, m):
    # 結果を保持する辞書
    cal_result = {}

    # 初期値の設定
    cal_result[1] = x

    if n == 1:
        return x

    for i in range(1, n):
        cal_result[i+1] = cal_result[i] ** 2 % m

    #return cal_result[n]
    return sum(cal_result.values())

def calc_dynamic2(n, x, m):
    cal_result_0 = 0
    cal_result_1 = 0

    # 初期値の設定
    cal_result_0 = x
    total = x

    if n == 1:
        return x

    for i in range(1, n):
        cal_result_1 = cal_result_0 * cal_result_0 % m
        cal_result_0 = cal_result_1
        total += cal_result_1

    return total

[n, x, m] = map(lambda x: int(x), input().split(" "))
print(calc_dynamic2(n, x, m))

### FIXED CODE ###

def calc_dynamic(n, x, m):
    # 結果を保持する辞書
    cal_result = {}

    # 初期値の設定
    cal_result[1] = x

    if n == 1:
        return x

    for i in range(1, n):
        cal_result[i+1] = cal_result[i] ** 2 % m

    #return cal_result[n]
    return sum(cal_result.values())

def calc_dynamic2(n, x, m):
    cal_result_0 = 0
    cal_result_1 = 0

    # 初期値の設定
    cal_result_0 = x
    total = x

    if n == 1:
        return x

    for i in range(1, n):
        cal_result_1 = cal_result_0 * cal_result_0 % m
        cal_result_0 = cal_result_1
        total += cal_result_1

    return total

def calc_dynamic3(n, x, m):
    # 結果を保持する辞書
    cal_result = {}
    cal_result_0 = 0
    cal_result_1 = 0
    loop_range = (0,0)

    # 初期値の設定
    cal_result_0 = x
    total = x

    if n == 1:
        return x

    for i in range(1, n):
        cal_result_1 = cal_result_0 * cal_result_0 % m
        cal_result_0 = cal_result_1
        total += cal_result_1
        if cal_result_1 in cal_result:
            loop_range = (cal_result[cal_result_1], i, cal_result_0, cal_result_1)
            break
        else:
            cal_result[cal_result_1] = (i, total)

    if i == n-1:
        return total

    hoge = i
    r = i - loop_range[0][0]
    v = total - loop_range[0][1]
    hoge += r
    total += v * ((n - hoge) // r)
    hoge += r * ((n - hoge) // r)
    #while hoge < n:
    #    total += v
    #    hoge += r

    cal_result_0 = loop_range[2]
    cal_result_1 = loop_range[3]
    for i in range(hoge-r+1, n):
        cal_result_1 = cal_result_0 * cal_result_0 % m
        cal_result_0 = cal_result_1
        total += cal_result_1

    return total

[n, x, m] = map(lambda x: int(x), input().split(" "))
print(calc_dynamic3(n, x, m))
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(m):
  b, c = map(int, input().split())
  a.extend([c for _ in range(b)])
desc = sorted(a, reverse=True)
ans = sum(desc[:n])
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
d = []
for _ in range(m):
  b, c = map(int, input().split())
  d.append((b, c))
d.sort(key=lambda x: x[1], reverse=True)
l = 0
for bc in d:
  a.extend([bc[1] for _ in range(bc[0])])
  l += bc[0]
  if l > n: break
desc = sorted(a, reverse=True)
ans = sum(desc[:n])
print(ans)
### BUGGY CODE ###

from scipy.sparse import *
from itertools import *
 
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
  
n,m,r = [int(x) for x in input().split()]
R = [int(i)-1 for i in input().split()]
route_list = [[0]*n for i in range(n)]
ans = 10**7
for j in range(m):
  a,b,c = map(int,input().split())
  route_list[a-1][b-1] = c
  route_list[b-1][a-1] = c
 
#Co = csgraph.floyd_warshall(csr_matrix(route_list))
Co = warshall_floyd(route_list)
  
for v in permutations(R):
  temp = 0
  for i in range(1,r):
    temp += Co[v[i-1]][v[i]]
  ans = min(ans,temp)
print(int(ans))

### FIXED CODE ###

import math
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]

route_list=[[10**9]*N for i in range(N)]

for i in range(M):
    a,b,c=[int(x) for x in input().split()]
    route_list[a-1][b-1]=c
    route_list[b-1][a-1]=c

wa_list=warshall_floyd(route_list)
ans=30**9

for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)

print(ans)
### BUGGY CODE ###

import sys
import numpy as np
from numba import njit

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

@njit
def main(N, K, A):
    for i in range(K):
        B = np.zeros(N, dtype=np.int64)
        for j in range(N):
            st = max(0, j - A[j])
            ed = j + A[j] + 1
            B[st:ed] += 1
        #print(B)
        if np.all(B == N):
            A = B
            break
        A = B
    return A

if __name__ == "__main__":
    N, K = map(int, readline().split())
    A = np.array(readline().split(), dtype=np.int64)
    ans = main(N, K, A)
    print(*ans)


### FIXED CODE ###

import sys
import itertools

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

def main():
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    
    K = min(50, K)
    for i in range(K):
        B = [0]*N
        for j in range(N):
            st = max(0, j - A[j])
            ed = j + A[j] + 1
            B[st] += 1
            if ed < N:
                B[ed] -= 1
        Bcum = itertools.accumulate(B)
        A = list(Bcum)
    print(*A)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * N

for i in range(1, N):
    dp[i] = min(
        dp[g] + abs(h[i] - h[g]) for g in range(max(i - K, 0), i)
    )
print(dp[N - 1])

### FIXED CODE ###

def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))
 
	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    cnt=a.count(i)
    print(cnt)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
boss=[0]*n
for i in a:
    boss[i-1]+=1
for i in boss:
    print(i)
### BUGGY CODE ###

def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)


n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))

a_lcm = a[0]
for i in range(1, n):
    a_lcm = LCM(a_lcm, a[i])

flag = True
for i in range(n):
    if (a_lcm // a[i]) % 2 == 0:
        flag = False
        break

if flag:
    ans = ((m // a_lcm) + 1) // 2
else:
    ans = 0
print(ans)


### FIXED CODE ###

def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)


n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))

a_lcm = a[0]
for i in range(1, n):
    a_lcm = LCM(a_lcm, a[i])
    if a_lcm > m:
        break

if a_lcm <= m:
    flag = True
    for i in range(n):
        if (a_lcm // a[i]) % 2 == 0:
            flag = False
            break

    if flag:
        ans = ((m // a_lcm) + 1) // 2
    else:
        ans = 0
else:
    ans = 0
print(ans)
### BUGGY CODE ###

R,G,B,n=map(int,input().split())
c=0
for i in range(n+1):
    r=R*i
    if r>n:
        break
    for j in range(n+1):
        g=G*j
        if r+g>n:
            break
        b=n-r-g
        if b%B==0:
            c+=1
print(c)


### FIXED CODE ###

R,G,B,n=map(int,input().split())
def cou(R,G,B,n):
    c=0
    for i in range(n+1):
        r=R*i
        if r>n:
            break
        for j in range(n+1):
            g=G*j
            if r+g>n:
                break
            b=n-r-g
            if b%B==0:
                c+=1
    return c
print(cou(R,G,B,n))
### BUGGY CODE ###

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

L = [float("inf") for _ in range(N+M+1)]
L[0] = 0

a = 0
b = 0

for k in range(len(A)):
    a += A[k]
    A[k] = a
for k in range(len(B)):
    b += B[k]
    B[k] = b

AA = [0] + A

BB = [0] + B

for k in range(N+1):
    for j in range(M+1):
        if  L[k+j] > AA[k] + BB[j]:
            L[k+j] = AA[k] + BB[j]
for k in range(1, len(L)+1):
    if L[-k] <= K:
        print(len(L)-k)
        break
 

### 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)
### BUGGY CODE ###

N,M = map(int,input().split())
graph = [0]*(N+1)
for i in range(N+1):
    graph[i]=list()
for i in range(M):#生成
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
graph[0].append(1)
# for i in range(N+1):#整列
#     graph[i].sort()
# print(graph)
ans = [0]*(N+1)
dis_stack = list()
dis_stack.extend(graph[0])
bef_stack = [1]
# k = 0
# print(graph)
while(len(dis_stack)!=0):
    now_watch=dis_stack.pop(0)
    next_watch = graph[now_watch]
    for spot in next_watch:
        if(spot in bef_stack):
            pass
        else:
            # print(dis_stack)
            # print(bef_stack)
            dis_stack.append(spot)
            ans[spot] = now_watch
            # print(ans)
        bef_stack.append(spot)
 
ans.pop(0)
print("Yes")
for i in range(1,len(ans)):
    print(ans[i])

    # k +=1
# 探索スタート地点を「探索候補スタック」に積む
# while スタックが空っぽになるまで
#     スタックから次の探索地点を1つ取り出す（pop）
#     「探索済みリスト」に取り出した地点を格納（ここが現在地点）
# 　　現在地点から、次に行こうと思えば行けるポイントを全部探し出す
#     for 地点 in 次に行こうと思えば行けるポイント
#         if その地点は既に「探索済みリスト」にある？
#             探索済みなので「探索候補スタック」には入れない（continue）
#         if その地点は既に「探索候補スタック」にある？（閉路があるなら可能性あり、木なら可能性なし）
#             探索予定なので「探索候補スタック」には入れない（continue）
#         未探索かつ候補にも入っていない地点なので「探索候補スタック」に追加する（append）
# print 探索済み地点

### FIXED CODE ###

N,M = map(int,input().split())
graph = [0]*(N+1)
for i in range(N+1):
    graph[i]=list()
for i in range(M):#生成
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
graph[0].append(1)
# for i in range(N+1):#整列
#     graph[i].sort()
# print(graph)
ans = [-1]*(N+1)
ans[1] = 0
dis_stack = list()
dis_stack.extend(graph[0])
bef_stack = [1]
# k = 0
# print(graph)


while dis_stack:
    now_watch=dis_stack.pop(0)
    next_watch = graph[now_watch]
    for spot in next_watch:
        if(ans[spot] != -1):
            continue            
        # print(dis_stack)
        # print(bef_stack)
        dis_stack.append(spot)
        ans[spot] = now_watch
            # print(ans)
 
ans.pop(0)
print("Yes")
for i in range(1,len(ans)):
    print(ans[i])

    # k +=1
# 探索スタート地点を「探索候補スタック」に積む
# while スタックが空っぽになるまで
#     スタックから次の探索地点を1つ取り出す（pop）
#     「探索済みリスト」に取り出した地点を格納（ここが現在地点）
# 　　現在地点から、次に行こうと思えば行けるポイントを全部探し出す
#     for 地点 in 次に行こうと思えば行けるポイント
#         if その地点は既に「探索済みリスト」にある？
#             探索済みなので「探索候補スタック」には入れない（continue）
#         if その地点は既に「探索候補スタック」にある？（閉路があるなら可能性あり、木なら可能性なし）
#             探索予定なので「探索候補スタック」には入れない（continue）
#         未探索かつ候補にも入っていない地点なので「探索候補スタック」に追加する（append）
# print 探索済み地点