peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
t = int(input())
if t < 3:
  print(0)
else:
  a = [i for i in range(3,t+1,1)]
  count = 0
  for i,x in enumerate(a):    
      for j in a[i:]:
          if (x+j) == t:
              count += 1
              print(x,j)
  print(count*2+1)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int,input().split()))

index = 1
count = 0
for a in A:
  if a == index:
    index += 1
  else:
    count += 1
    
print(count)
# Judge status: Accepted
S = input()
flag = True

if S[0] != "A":
  flag = False
elif S[2:-1].count("C") != 1:
  flag = False
else:
  tmp = ""
  for s in S:
    if s != "A" and s != "C":
      tmp += s
  if not tmp.islower() or len(tmp) != len(S) - 2:
    flag = False
print("AC" if flag else "WA")
# Judge status: Accepted
x, k, d = map(int, input().split())

if x > k*d or -x > k*d:
    print(abs(abs(x) -k*d))
else:
    num = abs(x) // d
    rest = k - num
    if rest%2 == 1:
        print(abs(abs(x)%d -d))
    else:
        print(abs(abs(x)%d))
# Judge status: Accepted
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
dic = Counter(A)
sticks = []
for i in dic:
    s = dic[i]
    if s>=4:
        sticks.append(i)
    if s>=2:
        sticks.append(i)
if len(sticks)<2:
    print(0)
else:
    sticks.sort(reverse=True)
    print(sticks[0]*sticks[1])
# Judge status: Accepted
S = input()
if S.count("S") >= 1 and S.count("W") >= 1 and S.count("E") >= 1 and S.count("N") >= 1:
  print("Yes")
elif S.count("S") >= 1 and S.count("W") == 0 and S.count("E") == 0 and S.count("N") >= 1:
  print("Yes")
elif S.count("S") == 0 and S.count("W") >= 1 and S.count("E") >= 1 and S.count("N") == 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from collections import defaultdict
n = int(input())
d = defaultdict(lambda: 0)
for a in range(1, 10**2):
    for b in range(1, 10**2):
        for c in range(1, 10**2):
            t = a**2+b**2+c**2+a*b+b*c+c*a
            if t <= n:
                d[t] += 1
            else:
                break

for i in range(1, n+1):
    print(d[i])
# Judge status: Accepted
from collections import Counter

# input
N = int(input())
A = Counter(list(map(int, input().split())))

# check
res = 0
for n, c in A.most_common():
    if c >= n:
        res += c - n
    else:
        res += c

print(res)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(n):
  if(i%2==0):
    ans+=a[i]
  else:
    ans+=a[i]
print(ans)
# Judge status: Wrong Answer
n=int(input())
d=list(map(int,input().split()))
d.sort()
cnt=[0]*(d[-1]+1)
for i in range(n):
  cnt[d[i]]+=1
ans=1
mod=998244353
for i in range(d[-1]):
  ans*=cnt[i]**cnt[i+1]
print(ans)
# Judge status: Accepted
K = int(input())
lis = []

lis = []
def search(s):
  lis.append(s)
  
  if int(s) > 3234566667:
    return
  
  it = int(s[-1])
  if it == 0:
    search(s + '0')
    search(s + '1')
  elif it == 9:
    search(s + '8')
    search(s + '9')
  else:
    search(s + str(it - 1))
    search(s + str(it))
    search(s + str(it + 1))
  

for i in range(1, 10):
  search(str(i))

x = list(map(int, lis))
x.sort()
print(x[K-1])
# Judge status: Wrong Answer
N = int(input())
B = list(map(int,input().split()))
A = [0]*N
for i in range(N-1):
  if B[i] > B[i-1]:
    A[i] = B[i-1]
  else:
    A[i] = B[i]
ans = sum(A) + B[-1]
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
mod = 10**9+7
data = {}
for i in s:
    if i in data:
        data[i] += 1
    else:
        data[i] = 1
ans = 1
for i in data.values():
    ans *= i+1
    ans %= mod
print(ans-1)
# Judge status: Wrong Answer
a,b = map(int,input().split())

if a==1:
  a=14
  
if b==1:
  b==14
  
if a>b:
  print('Alice')
  
elif a<b:
  print('Bob')
  
else:
  print('Draw')
# Judge status: Accepted
def resolve():
    x = int(input().strip())
    a =int( x // 1.08 )
    b =int( -1 * (-1 * x // 1.08))
    ans = ':('
    if int(a * 1.08) == x:
        ans = int(a)
    if int(b * 1.08) == x:
        ans = int(b)
    print(ans)
resolve()
# Judge status: Accepted
import copy

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

res = 1e+9
for i in range(min(a),max(a)+1):
    tmp = copy.copy(a)
    res = min(res,sum(map(lambda x:(x-i)**2,tmp)))
print(res)
# Judge status: Wrong Answer
n, c, k = map(int, input().split())
t = []
for _ in range(n):
  t.append(int(input()))
  
st = sorted(t)

time = 0
limit = st[0]+k

d = {}
d[limit] = []

for i, p in enumerate(st):
  if p <= limit and len(d[limit]) < c:
    d[limit].append(p)
  else:
    limit = p + k
    d[limit] = [p]

print(len(d))
# Judge status: Wrong Answer
from collections import Counter
 
input_line=int(input())
count=0
input_list=[]
while count < input_line:
  input_list.append(input())
  count+=1
ans_list=[]
list_set=set(input_list)
max_appeard=Counter(input_list).most_common(1)[0][1]
for item in list_set:
    appeard=Counter(input_list)[item]
    if appeard >= max_appeard:
        max_appeard=appeard
# Judge status: Wrong Answer
s = list(input())
if s[0] == s[2]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]
b = a.index(max(a))
c = max(a)
a.remove(max(a))
for i in range(n):
  if i == b:
    print(max(a))
  else:
    print(c)
# Judge status: Accepted
x,y  = map(int, input().split())
cnt = 0
while x <= y:
    x *= 2
    cnt += 1
print(cnt)
# Judge status: Accepted
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc126/tasks/abc126_a

n, k = [int(x) for x in input().split()]
s = input()
for i, l in enumerate(s):
    if i == k - 1:
        print(l.lower(), end='')
    else:
        print(l, end='')
print('')
# Judge status: Accepted
a,b,c,k = [int(x) for x in input().split()]
ans = 0
ans += min(a,k)
k = k-a-b
if k>=0:
    ans -= k
print(ans)
# Judge status: Wrong Answer
def com(n,r,mod):
    k=min(r,n-r)
    C=1
    for i in range(1,k+1):
        C=(C*(n+1-i)*pow(i,mod-2,mod))%mod
    return C

x, y = map(int,input().split())
mod = 10 ** 9 + 7
n = (2 * y - x) // 3 if (2 * y - x) % 3 == 0 else 0
m = (2 * x - y) // 3 if (2 * x - y) % 3 == 0 else 0

if n * m != 0:
    print(com(n + m, n, mod))
else:
    print(0)
# Judge status: Accepted
M=10**9+7
n,*l=map(int,open(0).read().split())
a=0
for i in range(60):
  t=sum(j>>i&1 for j in l)
  a+=t*(n-t)*pow(2,i,M)
print(a%M)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if ((a*b)/2)%2==0:
  print(a*b/2)
else:
  print(a*b)
# Judge status: Accepted
s=input()
ans=s[0]+s[1]+s[2]
print(ans)
# Judge status: Wrong Answer
n = int(input())

for i in range(1, 10):
  for j in range(1, 10):
    if i*j == n:
      print('Yes')
      break

print('No')
# Judge status: Wrong Answer
n=int(input())
p=input().split()

l=list(range(1,n+1))
cnt=0

for i in range(n):
    if l[i]!=int(p[i]):
        cnt+=1
print(cnt)
if cnt<=2:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
S = input()
T = input()
num = 0
for s,t in zip(S,T):
    if s != t:
        num +=1
# Judge status: Wrong Answer
import math

#h = int(input())
#a = int(input())

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

print(math.ceil((h+a)/a))
# Judge status: Accepted
S = input()
if S =="ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Wrong Answer
X,Y = map(int,input().split())
k = 0
while X<=Y:
    k += 1
    X = X*2**k
print(k+1)
# Judge status: Accepted
n,m = map(int,input().split())

maxdist = (n-1)//2
maxodd = maxdist if not maxdist%2 == 0 else maxdist-1
maxgusu = maxdist if maxdist%2 == 0 else maxdist-1

count=0

for i,sa in enumerate(range(1,maxodd+1)[::-2]):
    j = i+1
    print(j,j+sa)
    count+=1
    if count==m:
        exit()
for i,sa in enumerate(range(2,maxgusu+1)[::-2]):
    j=i+1
    print(1+maxodd+j,1+maxodd+j+sa)
    count+=1
    if count==m:
        exit()
# Judge status: Accepted
n, c, k = map(int, input().split())
t_l = []
for _ in range(n):
    t_l.append(int(input()))
t_l.sort()
ans = 0
cnt = 0
for t in t_l:
    if cnt == 0:
        t1 = t
    if t <= t1 + k:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
    else:
        cnt = 1
        ans += 1
        t1 = t
if cnt != 0:
    ans += 1
print(ans)
# Judge status: Wrong Answer
inNum = int(input())

intArr = []

sortArr = []
while(inNum > 0):
    tempNum =int(input())
    intArr.append(tempNum)
    inNum = inNum-1
    if(not tempNum in sortArr):
        sortArr.append(tempNum)
sortArr  = sorted(sortArr, reverse = True)

for x in range(len(intArr)):
    if(intArr[x] != sortArr[0] or len(sortArr)==1):
        print(sortArr[0])
    else:
        print(sortArr[1])
# Judge status: Accepted
MAX_N = 200
N = int(input())
a = [3, 5]
i = 7
while 3 * 5 * i < MAX_N:
  a.append(i)
  i += 2
len_a = len(a)
dot = []
for j in range(len_a-2):
  for k in range(j+1, len_a-1):
    for l in range(k+1, len_a):
      d = a[j] * a[k] * a[l]
      if d < MAX_N:
        dot.append(a[j] * a[k] * a[l])
dot = sorted(dot)
r = 0
for x in dot:
  if x <= N:
    r += 1
  else:
    break
print(r)
# Judge status: Accepted
n=int(input())
words=[]
for i in range(n):
  words.append(input())
  
s=words.pop()
for i in words:
  ns=""
  l=list(i)
  for j in s:
    if j in l:
      ns+=j
      l.remove(j)
  s=ns
s=sorted(list(s))
out=""
for i in s:
  out+=i
print(out)
# Judge status: Wrong Answer
def main():
    dicts = {'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, 'z':0}
    s = input()
    for i in s:
        dicts[i] = dicts[i]+1
    for k,v in dicts.items():
        if v==0:
            print(k)
            return
    print('None')
main()
# Judge status: Wrong Answer
s = input()
length = 4 # fixed

ans = 0
for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  f = s[0]
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  print('d:',f)
  ans = eval(f)
  
  if ans == 7:
    print(f.replace('_','')+'=7')
# Judge status: Wrong Answer
N = int(input())
ans = 0
n = N
counter = []
for i in range(2, int(N**0.5) + 2):
  if n % i == 0:
    counter.append(1)
    n = n // i
    while n % i == 0:
      counter[-1] += 1
      n = n // i
for c in counter:
  a = 1
  while c - a >= 0:
    c -= a
    a += 1
    ans += 1
print(1 if ans == 0 else ans)
# Judge status: Wrong Answer
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
A = sorted(A, reverse=True)
d = defaultdict(int)
tmp = A[0]
for i in range(1, N):
  d[A[i]] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=True)
a = []
for key, val in d:
  if 2 <= val <= 3:
    a.append(key)
  elif val >= 4:
    a.append(key)
    a.append(key)
  if len(a) == 2:
    print(a[0]*a[1])
    exit()
if len(a) == 0:
  print(0)
# Judge status: Wrong Answer
s = list(map(int, input().split()))
print(s[0] + 1)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[]
    for i in range(1,int((n**0.5))+1):
        if n%i==0:
            a,b=i,n//i
            l.append(a+b-2)
    print(min(l))
resolve()
# Judge status: Accepted
import sys

N,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(N)]
c=[list(map(int,input().split())) for _ in range(M)]
inf=10**9
def findcp(st):
    dist=inf
    i=0
    for j in range(M):
        if abs(st[0]-c[j][0])+abs(st[1]-c[j][1])<dist:
            dist=abs(st[0]-c[j][0])+abs(st[1]-c[j][1])
            i=j
    return i+1

for i in range(N):
    print(findcp(s[i]))
# Judge status: Accepted
L = 10 ** 9
N = int(input())
y = (N - 1) // L + 1
x = (L - N) % L
print(0, 0, L, 1, x, y)
# Judge status: Accepted
# カンニングしました。。。。。。。。

def dfs(s: str, m: int):
    global n
    if len(s) == n:
        print(s)
    else:
        for c in range(ord('a'), m + 1):
            dfs(s + chr(c), m + 1 if c == m else m)


n = int(input())
dfs('', ord('a'))
# Judge status: Wrong Answer
def get( s ):
    sum=0
    s = sorted(s) 
    for i in range(len(s)):
        sum += int(ord(s[i])*(1<<i))
    return sum

S=[]
n =int(input())
for i in range(n):
    S.append(input())

H=[0]*n
for i in range(n):
    H[i]=get(S[i])

H.sort()
c=0
ans=0
for i in range(n-1):
    if H[i]==H[i+1]:
        c+=1
    else:
        ans += c*(c+1)//2
        c=0
ans += c*(c+1)//2

# print(H)
print(ans)
# Judge status: Accepted
A=list(map(int,input().split()))
S=set(A)
print(len(S))
# Judge status: Accepted
a,b = map(int, input().split())
if a%b == 0:
  print(0)
else:
  print(1)
# Judge status: Wrong Answer
n,m = map(int, input().split())
l,r = 0,n
for i in range(m):
    L,R = map(int, input().split())
    l = max(l,L)
    r = min(r,R)

print(r-l+1)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())

up = 1
down = 1
ans = 0
mod = 10 ** 9 + 7

for i, o in zip(range(1, n//2 + 1), range(n, 0, -1)):
    up = (up%mod) * (o%mod)
    down = (down%mod) * (i%mod)
    if (i != a) and (i != b):
        ans += up/down
        ans %= mod
 
    if i != (n - i):
        if ((n - i) != a) and ((n - i) != b):
            ans += up/down
            ans %= mod
  

if (n != a) and (n != b):
    ans += 1
print(ans%mod)
# Judge status: Accepted
import math

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

rev= 10**9+7

if (n - m ==0):
    ans = 2 * math.factorial(n) * math.factorial(m)
elif (abs(n - m) == 1):
    ans = 1 * math.factorial(n) * math.factorial(m)
else:
    ans = 0
print(ans%rev)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append([str(i) for i in input().split()])

ac = []
ans2 = 0
for i in range(m):
    if a[i][1] == "AC":
        ac.append(a[i][0])
    if a[i][1] == "WA" and not(a[i][0] in ac):
        ans2 += 1
ans1 = len(set(ac))

print(ans1,end = " ")
print(ans2)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
Bs = []
for i in range(Q):
    Bs.append(list(map(int, input().split(' '))))
    
    
A_list = [0]*(10**5+1)
for i in A:
    A_list[i] += 1
    
sum_value = sum(A)
for B in Bs:
    b, c = B
    sum_value += A_list[b]*c
    sum_value -= A_list[b]*b
    
    A_list[c] += A_list[b]
    A_list[b] = 0
    print(sum_value)
# Judge status: Accepted
x = int(input())

for i, j in zip(range(4, 19, 2), range(8, 0, -1)):
    if i * 100 <= x <= (i + 2) * 100 - 1:
        print(j)
        exit()
# Judge status: Wrong Answer
import math
import bisect
s = int(input())
a = list(map(int, input().split()))
#aa = sorted(a,reverse=True)
aaa = sorted(a)
v = 0
def combination(n,r):
	return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
m = aaa[-1]
x = bisect.bisect_left(aaa,m//2)
if aaa[x] == m:
	x -= 1
print (m,aaa[x])
# Judge status: Accepted
# coding: utf-8
a,b=map(int,input().split())

if b>=a:
    print(a)
else:
    print(a-1)
# Judge status: Accepted
n = int(input())
s = input()

r = 0
l = 0
for i in s:
    if i == "(":
        r += 1
    else:
        if r == 0:
            l += 1
        else:
            r -= 1

else:
    print("("*l + s + ")"*r)
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split())
if B>C and C>A:
    if D>B:
        print(B-C)
    else:
        print(D-C)
elif D>A and A>C:
    if  B>C:
        print(D-A)
    else:
        print(B-A)
else:
    print(0)
# Judge status: Accepted
n,m = map(int,input().split())
if n==1 or m==1:
  print(max(max(m,n)-2,1))
else:
  n = n-2
  m = m-2
  print(n*m)
# Judge status: Accepted
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [[0]*N for _ in range(60)]

for i in range(N):
    dp[0][i] = A[i] - 1

for k in range(1, 60):
    for n in range(N):
        dp[k][n] = dp[k - 1][dp[k - 1][n]]

res = []
for i in range(60):
    if (K>>i)&1:
        res.append(i)
    
pos = 0
for i in res:
    pos = dp[i][pos]
print(pos + 1)
# Judge status: Accepted
#abc174_e

n,k=map(int,input().split())
a=[int(i) for i in input().split()]
    
ok=1001001001
ng=0
def check(x):
  cnt=0
  for q in a:
    cnt+=(q-1)//x
  return cnt<=k

while ok-ng>1:
  mid=(ok+ng)//2
  if check(mid):
    ok=mid
  else:
    ng=mid
print(ok)
# Judge status: Accepted
n=int(input())
 
def is_prime(n):
    if n < 2:
      return False
    else:
      for i in range(2, n):
        if i * i > n:
            break
        elif n % i == 0:
            return False
    return True

for i in range(n,n+400):
  if is_prime(i):
    print(i)
    break
# Judge status: Wrong Answer
d, n = map(int, input().split())

if d == 0:
    print(n)
elif d == 1:
    if n == 100:
        print((n+1)*100)
    else:
        print(n*100)
elif d == 2:
    print(n*10000)
# Judge status: Accepted
n=int(input())
guide=[]
for i in range(n):
    city,point=input().split()
    point=int(point)
    guide.append([city,-point,i+1])


guide.sort()

for i in range(n):
    print(guide[i][2])
# Judge status: Accepted
import math
A, B, C, D = map(int, input().split())
t_mon = [A, B]
a_mon = [C, D]
t_turn = math.ceil(t_mon[0] / a_mon[1])
a_turn = math.ceil(a_mon[0] / t_mon[1])

if t_turn >= a_turn:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
# -*- coding: utf-8 -*-
n,a,b = map(int,input().split()) 

if (b - a) % 2 == 0:
    ans = int((b - a) // 2)
else:
    #ans = min((n-b) + (n-1-(a+n-b)) // 2, (a-1) + (b-a-1) // 2)
    ans = min(n-b, a-1) + 1 + (b - a - 1) // 2

print(ans)
# Judge status: Accepted
N, D = map(int, input().split())
count = 0
D_2 = D*D
for _ in range(N):
    x, y = map(int, input().split())
    d = x*x + y*y
    if d <= D_2:
        count +=1
print(count)
# Judge status: Accepted
import math
MOD = 10**9+7
n, m = map(int, input().split())

if n == m:
    print( (2 * (math.factorial(n)%MOD)**2) % MOD)
elif abs(n-m) == 1:
    print((max(n, m)*(math.factorial(min(n, m))%MOD)**2) % MOD)
else:
    print(0)
# Judge status: Accepted
n = int(input())
lis = [input() for _ in range(n)]

ans = []

for i in "abcdefghijklmnopqrstuvwxyz":
    mn = 50
    for j in lis:
        mn = min(mn,j.count(i))

    ans.append(i*mn)
    
print(''.join(ans))
# Judge status: Accepted
import sys
input=sys.stdin.readline
import math

A,B = (int(x) for x in input().rstrip('\n').split())
c = math.gcd(A,B)
if c==1:
  print(1)
else:
  ps=[]
  d = math.floor(math.sqrt(c))
  for i in range(2,d+2):
    if c%i==0:
      if all(i%x!=0 for x in ps):
        ps.append(i)
        while c % i ==0:
          c = c//i
  if c > 1:
    ps.append(0)
  print(len(ps)+1)
# Judge status: Accepted
S = sorted(input())

if S == ['a', 'b', 'c']:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
blue = {}
for _ in range(N):
  s = input()
  if s in blue.keys():
    blue[s] += 1
  else:
    blue[s] = 1

M = int(input())
red = {}
for _ in range(M):
  t = input()
  if t in red.keys():
    red[t] += 1
  else:
    red[t] = 1
    
cnt = 0
for i in blue.keys():
  if i in red.keys():
    cnt = max(cnt, blue[i] - red[i])
  else:
    cnt = max(cnt, blue[i])
    
print(cnt)
# Judge status: Accepted
A,B,C = map(int,input().split())
lis = [A,B,C]
lis.sort()
if A%2 == B%2 == C%2 == 1:
    print(lis[0]*lis[1])
else:
    print(0)
# Judge status: Accepted
s = input()
l = list(s)
l = [int(x) for x in l]
dp = [[0, 0] for i in range(len(s))]
dp[0][0] = l[0]
dp[0][1] = 11 - l[0]
for i in range(1, len(s)):
  dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + l[i]
  dp[i][1] = min(dp[i - 1][0] + 11 - l[i], dp[i - 1][1] + 9 - l[i])
print(min(dp[-1][0], dp[-1][1]))
# Judge status: Wrong Answer
N = int(input())

if N%2==0:
    print(0.5000000000)
else:
    print(0.6000000000)
# Judge status: Wrong Answer
s = input()
s = sorted(s)
a = s.count("a")
b = s.count("b")
c = s.count("c")
d = max(a, b, c)
e = [a, b, c].index(d)
if d > len(s) / 2:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
import math
def main(n):
    x = 800 * n
    y = 0
    if n >= 15:
        y = 200 * math.floor(n / 15)
    print(x - y)

main(int(input()))
# Judge status: Wrong Answer
n, m, k = (int(i) for i in input().split())

A = [0]
for i,a in enumerate(input().split()):
    A.append(A[i] + int(a))

B = [0]
for i,a in enumerate(input().split()):
    B.append(B[i] + int(a))

#print(A)
#print(B)
i,bestj,ans = 0,m,0
while A[i] < k:
    for j in range(bestj, -1, -1):
        if A[i] + B[j] <= k: break
    #print(i,j)
    ans = max(i+j, ans)
    bestJ = j
    
    i += 1
    if i == n+1: break

print(ans)
# Judge status: Wrong Answer
n, m, k = map(int, input().split())

l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

l = l1 + l2
l.sort()

tmp = 0
ans = 0
if l[0] <= k:
    ans += 1
for i in range(1, n + m):
    l[i] += l[i-1]
    if l[i] <= k:
        ans += 1

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
h = sorted([int(input()) for i in range(n)])
work = []
append = work.append
for i in range(len(h)-k+1):
    append(h[i+k-1] - h[i])
print(min(work))
# Judge status: Accepted
ans = 0
for i in range(1,int(input())+1):
    if (len(str(i)))%2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
import math

X = int(input())

def prime(num):
    if num < 2:
        return False
    if num == 2:
        return True
    if num % 2 == 0:
        return False

    m = math.floor(num/2) + 1
    for p in range(3, m, 2):
        if num % p == 0:
            return False
    return True

while prime(X) == False:
    X += 1

print(X)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
ans = 'No'
for i in range(n):
    if a[i] % 4 == 0:
        a[i] = 4
    elif a[i] % 2 == 0:
        a[i] = 2
    else:
        a[i] = 1

if a.count(2) != 0:
    if a.count(4) >= a.count(1):
        ans = 'Yes'
else:
    if a.count(4) + 1 >= a.count(1):
        ans = 'Yes'
print(ans)
# Judge status: Accepted
S = input()
a = 'No'
if S[2] == S[3] and S[4] == S[5]:
  a = 'Yes'
print(a)
# Judge status: Accepted
A, B, N = map(int, input().split())

res = 0
if N < B:
    res = int((A * N) / B)
else:
    res = int((A * (B - 1)) / B)

print(res)
# Judge status: Accepted
N, M = map(int, input().split())


def answer():
    digs = [-1] * N
    for _ in range(M):
        s, c = map(int, input().split())
        s -= 1
        if digs[s] not in {c, -1}:
            return -1
        digs[s] = c
    if digs[0] == -1:
        digs[0] = int(N > 1)
    elif digs[0] == 0 and N > 1:
        return -1
    for i in range(1, N):
        if digs[i] == -1:
            digs[i] = 0
    return "".join(map(str, digs))


print(answer())
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
c=0
l.sort()
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if(l[i]!=l[j]!=l[k] and (l[i]+l[j]>l[k])):
                c=c+1
print(c)
# Judge status: Wrong Answer
import math
X = [int(input()) for _ in range(5)]
t = 0
m = 100
for x in X:
  t += (math.ceil(x/10))*10
  if x%10 != 0:
    m = min(m, x%10)
print(t+m-10 if m!=0 else t)
# Judge status: Wrong Answer
N = int(input())
T = [int(input()) for _ in range(N)]

cnt = 0

for i in range(N - 1):
    if T[i] != 0 and T[i + 1] != 0:
        if T[i] >= T[i + 1]:
            cnt += T[i + 1]
            T[i] -= T[i + 1]
            T[i + 1] = 0
        else:
            cnt += T[i]
            T[i + 1] -= T[i]
            T[i] = 0

for t in T:
    cnt += t // 2

print(cnt)
# Judge status: Wrong Answer
N = int(input())

if (N%2 == 1):
    print(0)
elif N == 0:
    print(1)
else:
    N /= 2
    res = 0
    div_coef = 1
    while True:
        # print(N)
        tmp_add = N // (5 ** div_coef)
        res += int(tmp_add)
        div_coef += 1
        print(tmp_add)
        if tmp_add < 1:
            break
    # print(N)
    print(int(res))
# Judge status: Accepted
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

print("\n".join(ans))
# Judge status: Accepted
L = (int)(input())
print((L**3)/27)
# Judge status: Accepted
from decimal import *
a,b,c=input().split()
print("Yes" if Decimal(a).sqrt()+Decimal(b).sqrt()<Decimal(c).sqrt() else "No")
# Judge status: Wrong Answer
n=int(input())
s=input()
if len(s)>n:
    nl=s[0:n]
    print(nl,'...')
else:
    print(s)