Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())


a = [[],[],[]]
for i in range(m):
    s, c = map(int, input().split())
    if not c in a[s-1]:
        a[s-1].append(c)
    
ans = 0
if (len(a[0]) > 1) or (len(a[1]) > 1) or (len(a[2]) > 1):
    print(-1)
elif (n==3 or n==2) and a[0][0] == 0:
    print(-1)
else:
    if n==3 and len(a[0])==0 and a[1][0]==0:
        a[0].append(1)
    for i in range(n):
        if len(a[i]) == 1:
            ans += a[i][0] * (10**(n-1-i))
    print(ans)








### FIXED CODE ###

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


a = [[],[],[]]
for i in range(m):
    s, c = map(int, input().split())
    if not c in a[s-1]:
        a[s-1].append(c)
    
ans = 0
if m==0:
    if n==3:
        print(100)
    elif n==2:
        print(10)
    else :
        print(0)
elif (len(a[0]) > 1) or (len(a[1]) > 1) or (len(a[2]) > 1):
    print(-1)
else:
    if (n==3 or n==2) and len(a[0]) == 0:
        a[0].append(1)
    if (n==3 or n==2) and a[0][0] == 0:
        print(-1)
    else:
        for i in range(n):
            if len(a[i]) == 1:
                ans += a[i][0] * (10**(n-1-i))
        print(ans)
f = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
n, m = map(int, input().split())
a = list(map(int, input().split()))

memo = [-1]*10010


def dp(i):
    # i本のマッチを使って作れる最大の整数
    if i < 0:
        return - 10 ** 100000
    if memo[i] != -1:
        return memo[i]
    if i == 0:
        return 0
    ret = -10*100000
    for x in a:
        ret = max(ret, 10 * dp(i - f[x]) + x)
    memo[i] = ret
    return ret


print(dp(n))


### FIXED CODE ###

import resource
import sys
sys.setrecursionlimit(20000)
f = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
n, m = map(int, input().split())
a = list(map(int, input().split()))

memo = ["-1"] * 10100


def MAX(x, y):
    if y[0] != '#' and (x == "#" or len(x) < len(y) or (len(x) == len(y) and x < y)):
        return y
    else:
        return x


def dp(i):
    # i本のマッチを使って作れる最大の整数
    if i < 0:
        return "#"

    if memo[i] != "-1":
        return memo[i]

    if i == 0:
        return ""

    ret = "#"
    for x in a:
        ret = MAX(ret, dp(i - f[x]) + str(x))
    memo[i] = ret
    return ret


print(dp(n))
def func():
    return

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

'''
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]:
            print("NO")
            exit()
'''
ans = [False]*(max(a)+1)
for ida in a:
    if ans[ida]:
        print("NO")
        exit()
    ans[ida] = True

print("YES")

### FIXED CODE ###

def func():
    return

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

ascA = sorted(a)
for i in range(n-1):
    if ascA[i] == ascA[i+1]:
        print("NO")
        exit()

'''
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]:
            print("NO")
            exit()
'''
'''
ans = [0]*(max(a)+1)
for ida in a:
    if ans[ida] > 0:
        print("NO")
        exit()
    ans[ida] += 1
'''

print("YES")
n=int(input())
s = str(input())
count=0
for i in range(n):
    if s[i]=='R':
        count+=1
        
if count > n-count:
    printr('Yes')
else:
    print('No')

### FIXED CODE ###

n=int(input())
s = str(input())
count=0
for i in range(n):
    if s[i]=='R':
        count+=1
        
if count > n-count:
    print('Yes')
else:
    print('No')
n = int(input())
ans = 1
for i in range(n):
    ans *= i + 1
    asn %= (10**9 + 7)
print(ans)


### FIXED CODE ###

ans=1
n=int(input())
for i in range(1,n+1):
    ans*=i
    ans=ans%(10**9+7)
print(ans)
import sys
for i, x in enumerate(map(int, sys.stdin())):
  if x == 0 or not x:
    break;
  print('Case {0}: {1}'.format(i + 1, x)

### FIXED CODE ###

import sys
for i, x in enumerate(map(int, sys.stdin)):
  if x == 0 or not x:
    break;
  print('Case {0}: {1}'.format(i + 1, x))
n = int(input())
s = input()
if n % 2:
  pirnt("No")
  exit()
half = s[0:n // 2]
print("Yes" if s == half + half else "No")


### FIXED CODE ###

n = int(input())
s = input()
if n % 2:
    print("No")
    exit()
half = s[0:n // 2]
print("Yes" if s == half + half else "No")
num = input()
list = list(map(int, input().split()))

def hoge(list):
  new_list = []
  for i in list:
    if i % 2 == 0:
      new_list.append(i)
    else:
      return False
  return new_list

count = 0
while True;
  list = hoge(list)
  if list == False:
    break
  count += 1

print(count)

### FIXED CODE ###

num = input()
listt = input().split()

def hoge(fuga):
    new_list = []
    for i in fuga:
        if int(i) % 2 == 0:
            new_list.append(int(i)/2)
        else:
            return False
    return new_list


count = 0
while True:
    listt = hoge(listt)
    if listt == False:
        break
    count += 1

print(count)
S = input()

head = int(S[:2])
tail = int(s[2:])

ans = "NA"
if 1 <= head <= 12:
    if 1 <= tail <= 12:
        ans = "AMBIGUOUS"
    else:
        "YYMM"
elif 1 <= tail <= 12:
    ans = "MMYY"
    
print(ans)

### FIXED CODE ###

S = input()

head = int(S[:2])
tail = int(S[2:])

ans = "NA"
if 1 <= head <= 12:
    if 1 <= tail <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
elif 1 <= tail <= 12:
    ans = "YYMM"

print(ans)
N=int(input())
A=[]
for i in range(N):
    A.append(-int(input()))
for i in range(N):
    Ai=A[i]
    A[i]=0
    print(-min(A))
    A[i]=Ai

### FIXED CODE ###

print(3*int(input())**2)
n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

for i in range(1,n):
    
    for j in range(0,n):
        print(sort_list[j])
        if j is not n - 1:
            print(" ")
        else:
            print("\n")
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[i] > v:
        sort_list[j+1] = sort_list[j]
        j = j - 1
    sort_list[j+1] = v




### FIXED CODE ###

import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

for i in range(0,n):
    
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[j] > tmp:
        sort_list[j+1] = sort_list[j]
        j = j - 1

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        elif i is not n - 1:
            sys.stdout.write("\n")
            
print("")
s = input()

a = x

print('x' * len(s))

### FIXED CODE ###

s = input()
print('x' * len(s))
from collections import Counter

n, m = map(int, input().split())
dic = Counter(map(int, input().split()))
lis = sorted(dic.items(), key=lambda x: x[1], reverse=True)

res = 0
for i in range(m):
    res += lis[i][1]
print(n - res)


### FIXED CODE ###

from collections import Counter

n, m = map(int, input().split())
dic = Counter(map(int, input().split()))
lis = sorted(dic.items(), key=lambda x: x[1], reverse=True)

res = 0
for i, x in enumerate(lis):
    if i < m:
        continue
    else:
       res += x[1]
print(res)
N = int(input())
count1 = 0
for i in range(1,N+1):
  if i % 2 != 0:
  	count2 = 0  
    for j in range(1,i+1):
      if i % j == 0:
        count2 += 1
      if count2 == 8:
        count1 += 1
print(count1)
        
  

### FIXED CODE ###

N = int(input())
count1 = 0
for i in range(1,N+1):
  if i % 2 != 0: #Odd Number
    count2 = 0  
    for j in range(1,i+1):
      if i % j == 0:
        count2 += 1
      if count2 == 8:
        count1 += 1
print(count1)
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())

dp = [0] * N
dp[0] = A
dp[-1] = B
x = -1
def no():
  print("NO")
  exit(0)
if B < A: A, B = B, A
for i in range(N - 2):
  if dp[i] < B:
    dp[i + 1] = dp[i] + D
  else:
    #print(dp[i], (i - 1) * (D - C), B)
    f = abs(dp[i] - (i - 1) * (D - C))
    if f <= B:
      x = i
      dp[i] = B
    else:
      x = i + -(-abs(B - f) // (D - C)) * 2
      if x >= N: no()
      dp[x] = B
    break

#print(x, dp[x])
t = (N - 1 - x)
#print(t)
if t % 2:
  if t == 1: no()
  if -(-C // (D - C)) > t: no()
print("YES")

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
for i in range(N - 1):
  r = D * (N - i - 1) + A
  l = C * (N - i - 1) + A

  r -= C * i
  l -= D * i
  #print(l, r, i)
  if B in range(l, r + 1):
    print("YES")
    exit(0)
print("NO")
def integerCards(n, m, alist, bclist):

    count = 0
    alist.sort()
    bclist.sort(key=lambda x: x[1], reverse=True)

    for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            if count == n:
                break

    return sum(alist[:n])

def main():
    n, m = map(int, input().split())
    alist = list(map(int, input().split()))
    bclist = [list(map(int, input().split()))for i in range(m)]
    print(integerCards(n, m, alist, bclist))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def integerCards(n, m, alist, bclist):

    count = 0
    alist.sort()
    bclist.sort(key=lambda x: x[1], reverse=True)

    for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
        if count == n:
            break

    return sum(alist)

def main():
    n, m = map(int, input().split())
    alist = list(map(int, input().split()))
    bclist = [list(map(int, input().split()))for i in range(m)]
    print(integerCards(n, m, alist, bclist))

if __name__ == '__main__':
    main()
import math
num=list(map(int,input().split()))
A=num[0]
B=num[1]
print(A*B//math.gcd(A,B))


### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)

num=list(map(int,input().split()))
A=num[0]
B=num[1]
S=lcm(A,B)
print(S)
n=int(input())
l=sort(list(map(int,input().split())))
print(l[n//2]-l[n//2-1])

### FIXED CODE ###

n=int(input())
l=sorted(list(map(int,input().split())))
print(l[n//2]-l[n//2-1])
N = int(input())
A = list(map(int, input().split()))

count =0
while all(a%2 == 0 for a in A) :
    A = [a/2 in a in A]
    count = count + 1


print(count)


### FIXED CODE ###


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

count =0
while all(a%2 == 0 for a in A) :
    A = [a/2 for a in A]
    count = count + 1


print(count)
import sys
sys.setrecursionlimit(20000)
n, m = map(int, input().split())
s = input()
out = [set() for _ in range(n)]
count = [[0, 0] for _ in range(n)]
def f(c):
    if c == 'A': return 0
    else: return 1
for _ in range(m):
    a, b = map(int, input().split())
    if a == b:
        count[a-1][f(s[a-1])] += 1
    elif b-1 not in out[a-1]:
        count[a-1][f(s[b-1])] += 1
        count[b-1][f(s[a-1])] += 1
    out[a-1].add(b-1)
    out[b-1].add(a-1)
elim = set()
def eliminate(x):
    elim.add(x)
    c = f(s[x])
    for node in out[x]:
        if node not in elim:
            count[node][c] -= 1
            if count[node][0] * count[node][1] == 0:
                eliminate(node)
for i in range(n):
    if i not in elim and count[i][0] * count[i][1] == 0:
        eliminate(i)
if len(elim) < n: print('Yes')
else: print('No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
n, m = map(int, input().split())
s = input()
out = [set() for _ in range(n)]
count = [[0, 0] for _ in range(n)]
def f(c):
    if c == 'A': return 0
    else: return 1
for _ in range(m):
    a, b = map(int, input().split())
    if a == b:
        count[a-1][f(s[a-1])] += 1
    elif b-1 not in out[a-1]:
        count[a-1][f(s[b-1])] += 1
        count[b-1][f(s[a-1])] += 1
    out[a-1].add(b-1)
    out[b-1].add(a-1)
elim = set()
def eliminate(x):
    elim.add(x)
    c = f(s[x])
    for node in out[x]:
        if node not in elim:
            count[node][c] -= 1
            if count[node][0] * count[node][1] == 0:
                eliminate(node)
for i in range(n):
    if i not in elim and count[i][0] * count[i][1] == 0:
        eliminate(i)
if len(elim) < n: print('Yes')
else: print('No')
n = int(input())
a = list(map(int,input().split()))
b = sorted(a,reverse = True)
ans = 0
if n % 2 == 0:
    for i in range(0,n//2):
        if i == 0:
            ans += b[0]
        else:
            ans += 2*b[i]
else:
    for i in range(0,n):
        if i == 0:
            ans += 0
        else:
            ans += b[n-i//2]
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
ans = 0
for i in range(0,n):
        if i == 0:
            ans += 0
        else:
            ans += b[n-(i//2)-1]
print(ans)
#なんもわからんくなった
N,M=map(int,input().split())
s=[]
c=[]
ans=0
#入力
for i in range(M):
    x,y=map(int,input().split())
    s.append(x)
    c.append(y)

#同じ桁だけど数が違う場合
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
            print(-1)
            exit()

#1桁目が0なのにNが2桁以上の時
for i in range(M):
    if s[i]==1 and c[i]==0 and N>1:
        print(-1)
        exit()

#処理の重複を消してる
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]==c[j]:
            s[j]=0
            c[j]=0

#各桁ごとの最小値
if N==1:
    print(c[0])
    exit()
if N==2:
    ans=10
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=10*c[i]
        if s[i]==2:
            ans+=c[i]
    print(ans)
    exit()
if N==3:
    ans=100
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=100*c[i]
        if s[i]==2:
            ans+=10*c[i]
        if s[i]==3:
            ans+=c[i]
    print(ans)

### FIXED CODE ###

#なんもわからんくなった
N,M=map(int,input().split())
s=[]
c=[]
ans=0
#入力
for i in range(M):
    x,y=map(int,input().split())
    s.append(x)
    c.append(y)

if M==0:
    if N==1:
        print(0)
        exit()
    elif N==2:
        print(10)
        exit()
    else:
        print(100)
        exit()
#同じ桁だけど数が違う場合
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
            print(-1)
            exit()

#1桁目が0なのにNが2桁以上の時
for i in range(M):
    if s[i]==1 and c[i]==0 and N>1:
        print(-1)
        exit()

#処理の重複を消してる
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]==c[j]:
            s[j]=0
            c[j]=0

#各桁ごとの最小値
if N==1:
    print(c[0])
    exit()
if N==2:
    ans=10
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=10*c[i]
        if s[i]==2:
            ans+=c[i]
    print(ans)
    exit()
if N==3:
    ans=100
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=100*c[i]
        if s[i]==2:
            ans+=10*c[i]
        if s[i]==3:
            ans+=c[i]
    print(ans)
n=int(input())
a=list(map(int,input().split()))

ans=1

d={}

mod=10**9+7

for i in range(n):
  if a[i]==0:
    if 0 not in d:
      d[0]=1
      ans*=3
    else:
      if d[0]==1:
        d[0]=2
        ans*=2
      else:
        d[0]=3
      
  else:
    if a[i] not in d:
      d[a[i]]=1
      ans*=d[a[i]-1]
    else:
      if d[a[i]]==1:
        d[a[i]]=2
        ans*=d[a[i]-1]-1
      else:
        d[a[i]]=3
        ans*=1
        
  ans=(ans%mod)
  
print(ans)

### FIXED CODE ###

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

ans=1

d={}

ch=0

mod=10**9+7

for i in range(n):
  if a[i]==0:
    if 0 not in d:
      d[0]=1
      ans*=3
    else:
      if d[0]==1:
        d[0]=2
        ans*=2
      elif d[0]==2:
        d[0]=3
      else:
        ch+=1
        break
      
  else:
    if a[i] not in d:
      d[a[i]]=1
      if a[i]-1 not in d:
        ch+=1
        break
      else:
        ans*=d[a[i]-1]
    else:
      if d[a[i]]==1:
        d[a[i]]=2
        if a[i]-1 not in d:
          ch+=1
          break
        else:
          if d[a[i]-1]>=2:
            ans*=d[a[i]-1]-1
          else:
            ch+=1
            break
      elif d[a[i]]==2:
        d[a[i]]=3
        if a[i]-1 not in d:
          ch+=1
          break
        else:
          if d[a[i]-1]>=3:
            ans*=1
          else:
            ch+=1
            break
      else:
        ch+=1
        break
        
  ans=(ans%mod)
  
if ch==0:
  print(ans)
else:
  print(0)
A, B, K = list(map(int, input().split()))

diff = abs(A - B)
a_is_higher = A > B

if K <= diff:
  if a_is_higher:
  	print(A-K, B)
  else:
    print(A, B-K)
else:
  if a_is_higher:
  	A -= diff
  else:
    B -= diff
  K -= diff
  div, mod = divmod(K, 2)
  
  nA = Math.max(0, A // 2)
  nB = Math.max(0, B // 2)
  
  if mod:
    print(nA, nB + 1)
  else:
    print(nA, nB)

### FIXED CODE ###

a, b = input().split()

print(b+a)
S=input()
T=input()
ans=[]
count=0
for i1 in range(len(S)-len(T)):
	for i2 in range(len(T)):
  		if S[i1+i2]==T[i2]:
          count++
    else:
    ans=ans.append(count)
    count=0
else:
	print(ans.max())

### FIXED CODE ###

D,T,S=map(int,input().split())
if (D/S)>T:
	print("No")
else:
	print("Yes")
H,W=map(int, input().split())
field=[[0]*(W+2) for i in range(H+2)]
List=[list(input()) for i in range(H)]

for k in range(1,H+1):
    for j in range(1,W+1):
        field[k][j] = List[k-1][j-1]

flag=1

for k in range(1,W+1):
    for j in range(1,H+1):
        if field[k][j]=='#' and field[k-1][j]!='#' and field[k+1][j]!='#' and field[k][j-1]!='#' and field[k][j+1]!='#':
            flag=0

if flag==1:     
    print('Yes')
else:
    print('No')

### FIXED CODE ###

H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
field=["."*(W+2)]+S+["."*(W+2)]

flag=0

for k in range(1,H+1):
    for j in range(1,W+1):
        if field[k][j]=='#' and field[k-1][j]!='#' and field[k+1][j]!='#' and field[k][j-1]!='#' and field[k][j+1]!='#':
            flag=1

if flag==1:
    print('No')
else:     
    print('Yes')
import numpy as np

N = int(input())
xl = [int(x) for x in input().split()]

xlsorted = np.sort(xl)
m1 = xlsorted[int(N/2)-1]
m2 = xlsorted[int(N/2)]

for i in range(N):
    if xl[i] <= m1:
        print(m2)
    else:
        print(m1)


### FIXED CODE ###

import numpy as np

N = int(input())
xl = [int(x) for x in input().split()]

xlsorted = np.sort(xl)
m1 = xlsorted[int(N/2)-1]
m2 = xlsorted[int(N/2)]

for i in range(N):
    if xl[i] <= m1:
        print(m2)
    else:
        print(m1)
N = int(input())
L = map(int, input().split())

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)


### FIXED CODE ###

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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)
import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
A=np.array(a)
l,r=0,0
for i in range(k):
    B=np.zeros(n,dtype=np.int64)
    for x,y in enumerate(list(A)):
        l=max(0,x-y)
        r=min(n-1,x+y)
        B[l:r+1]+=1
    A=B
print(*A,sep=' ')

### FIXED CODE ###

import numpy as np
from numba import jit
@jit(cache = True)
def solve(n,k,A):
    l,r=0,0
    for i in range(k):
        B=np.zeros(n+1,dtype=np.int64)
        for x,y in enumerate(list(A)):
            l=max(0,x-y)
            r=min(n,x+y+1)
            B[l]+=1
            B[r]-=1
        A=np.cumsum(B[:-1])
        if A[A==n].size==n:
            break
    return A
n,k=map(int,input().split())
a=list(map(int,input().split()))
A=np.array(a)
X=solve(n,k,A)
print(*X,sep=' ')
# coding: utf-8
from functools import lru_cache
sys.setrecursionlimit(10000)

import sys
input = sys.stdin.readline

@lru_cache(maxsize = None)
def f(v):
    if len(arc[v]) == 0:
        return(0)
    return(max(f(nv) for nv in arc[v]) + 1)

n, m = map(int, input().split()) # 2 <= n <= 10^5, 1 <= m <= 10^5
arc = [[] for _ in range(n + 1)]
for i in range(m):
    x, y = map(int, input().split())
    arc[x].append(y)
print(max(f(v + 1) for v in range(n)))


### FIXED CODE ###

# coding: utf-8
from functools import lru_cache

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

@lru_cache(maxsize = None)
def f(v):
    if not arc[v]:
        return(0)
    return(max(f(nv) for nv in arc[v]) + 1)

n, m = map(int, input().split()) # 2 <= n <= 10^5, 1 <= m <= 10^5
arc = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    arc[x - 1].append(y - 1)
print(max(f(v) for v in range(n)))
N = int(input())
A = [int(i) for i in input().split()]

sum = 0
ans = []

for b in range(-int(N / 2), int(N / 2)):
    for i in range(N):
        sum += abs(A[i] - (b + i))
    else:
        ans.append(sum)
        sum = 0

print(min(ans))


### FIXED CODE ###

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

B = [A[i] - (i + 1) for i in range(N)]

B.sort()

b = B[len(B) // 2]

ans = 0

for j in range(N):
    ans += abs(A[j] - (b + j + 1))

print(ans)
s = input()
a = 0
for i in range(len(s)):
    a += int(s[i])
s = int(s)
if s % a == 0 :
    print('Yes')
else :
    print('No')


### FIXED CODE ###

s = input()
i = s.count("+")

print(2 * i - 4)
import sys

NIL = -1

def set_depth(v, depth):
    tree[v][2] = depth
    
    if child in tree[v][1]:
        set_depth(child, depth + 1)

N = int(input())
tree = [[NIL, [], 0, 'leaf'] for _ in range(N)]

for _ in range(N):
    line = [int(i) for i in sys.stdin.readline().split()]
    t_id = line[0]
    children = line[2:]
    tree[t_id][1] = children
    
    if children:
        tree[t_id][3] = 'internal node'
    
    for child in children:
        tree[child][0] = t_id
        
for t_id in range(N):
    if tree[t_id][0] == NIL:
        tree[t_id][3] = 'root'
        r = t_id
        break

set_depth(r, 0)

for t_id in range(N):
    parent = tree[t_id][0]
    depth = tree[t_id][2]
    children = tree[t_id][1]
    type_t = tree[t_id][3]
    
    print('node {}: parent = {}, depth = {}, {}, {}'.format(t_id, parent, depth, type_t, children))

### FIXED CODE ###

import sys

NIL = -1

def set_depth(v, depth):
    tree[v][2] = depth
    
    for child in tree[v][1]:
        set_depth(child, depth + 1)

N = int(input())
tree = [[NIL, [], 0, 'leaf'] for _ in range(N)]

for _ in range(N):
    line = [int(i) for i in sys.stdin.readline().split()]
    t_id = line[0]
    children = line[2:]
    tree[t_id][1] = children
    
    if children:
        tree[t_id][3] = 'internal node'
    
    for child in children:
        tree[child][0] = t_id
        
for t_id in range(N):
    if tree[t_id][0] == NIL:
        tree[t_id][3] = 'root'
        r = t_id
        break

set_depth(r, 0)

for t_id in range(N):
    parent = tree[t_id][0]
    depth = tree[t_id][2]
    children = tree[t_id][1]
    type_t = tree[t_id][3]
    
    print('node {}: parent = {}, depth = {}, {}, {}'.format(t_id, parent, depth, type_t, children))
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
sum_a = 0
for i in range(-1, len(A)):
    if i == -1:
        sum_a = 0
    else:
        sum_a += A[i]
        if sum_a > K:
            break
        sum_b = 0
    for j in range(len(B)):
        sum_b += B[j]
        if sum_b > K - sum_a:#Bを全部読み切れない場合
            ans = max(ans, i+1+j)
            break
        if j == len(B)-1: #Bを全部読み切れる場合
            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 = [0]*(N+1)
b = [0]*(M+1)
for i in range(1, N+1):
    a[i] = a[i-1] + A[i-1]
for j in range(1, M+1):
    b[j] = b[j-1] + B[j-1]

ans = 0
j = M
for i in range(N+1):
    if K - a[i] < 0:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)