Harryxun/stf_run huggingface dataset:
h,w,a,b=map(int,input().split())
ans=['']*w
for i in range(h):
    for j in range(w):
        if (i<b and j<a) or (i>=b and j>=a):
            ans[i]+='0'
        else:
            ans[i]+='1'
for i in range(h):
    print(ans[i])

### FIXED CODE ###

h,w,a,b=map(int,input().split())
ans=['']*h
for i in range(h):
    for j in range(w):
        if (i<b and j<a) or (i>=b and j>=a):
            ans[i]+='0'
        else:
            ans[i]+='1'
for i in range(h):
    print(ans[i])
x, a, b = map(int, input().split())
xa = abs(x-a)
xb = abs(x-b)
if xa < xb:
  print(A)
elif xa > xb:
  print(B)

### FIXED CODE ###

x, a, b = map(int, input().split())
xa = abs(x-a)
xb = abs(x-b)
if xa < xb:
  print("A")
elif xa > xb:
  print("B")
N , A , B = int(input().split())
a = N // ( A + B )
b = N % ( A + B )

if b >> A:
    print( a * A + A )
else:
    print( a * A + b ) 

### FIXED CODE ###

N , A , B = map(int, input().split())
AB = A + B
a = N // AB
b = N % AB



if b > A:
    print( a * A + A )
else:
    print( a * A + b )
# ABC062a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


# Union-Find木


class UnionFind:
    def __init__(self, n):
        self.tree = [i for i in range(n)]

    def root(self, x):
        if(self.tree[x] == x):
            return x
        self.tree[x] = self.root(self.tree[x])
        return self.tree[x]  # 経路圧縮

    def same(self, x, y):  # xとyが同じ木に属するか
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if(x == y):
            return
        self.tree[x] = y


uf = UnionFind(12)
uf.unite(0, 2)
uf.unite(0, 4)
uf.unite(0, 6)
uf.unite(0, 7)
uf.unite(0, 9)
uf.unite(0, 11)
uf.unite(3, 5)
uf.unite(3, 8)
uf.unite(3, 10)

print('YNeos'[uf.same(*tuple(map(int, input().split())))::2])


### FIXED CODE ###

# ABC062a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


# Union-Find木


class UnionFind:
    def __init__(self, n):
        self.tree = [i for i in range(n)]

    def root(self, x):
        if(self.tree[x] == x):
            return x
        self.tree[x] = self.root(self.tree[x])
        return self.tree[x]  # 経路圧縮

    def same(self, x, y):  # xとyが同じ木に属するか
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if(x == y):
            return
        self.tree[x] = y


uf = UnionFind(12)
uf.unite(0, 2)
uf.unite(0, 4)
uf.unite(0, 6)
uf.unite(0, 7)
uf.unite(0, 9)
uf.unite(0, 11)
uf.unite(3, 5)
uf.unite(3, 8)
uf.unite(3, 10)

x, y = map(int, input().split())
print('YNeos'[not uf.same(x-1, y-1)::2])
s=input()
alphabet = set([chr(i) for i in range(97, 97+26)])
x=set([s[i] for i in range(len(s))])
y=alphabet - x
z=list(y)
z.sort()
print(z[0])

### FIXED CODE ###

s=input()
alphabet = set([chr(i) for i in range(97, 97+26)])
x=set([s[i] for i in range(len(s))])
y=alphabet - x
if len(y)==0:
  print("None")
  exit()
z=list(y)
z.sort()
print(z[0])
N, A, B = a,b=map(int, input().split())
S = input()

qualified = 0
qualified_foreign = 0.
for s in S:
    if s == 'c':
        print('No')
    elif s == 'a':
        if qualified < A + B:
            print('Yes')
            qualified += 1
        else:
            print('No')
    else:
        if (qualified < A + B) & (qualified_foreign < B):
            print('Yes')
            qualified += 1
            qualified_foreign += 1
        else:
            print('No')
  

### FIXED CODE ###

N, A, B = map(int, input().split())
S = input()

qualified = 0
qualified_foreign = 0.
for s in S:
    if s == 'c':
        print('No')
    elif s == 'a':
        if qualified < A + B:
            print('Yes')
            qualified += 1
        else:
            print('No')
    else:
        if (qualified < A + B) & (qualified_foreign < B):
            print('Yes')
            qualified += 1
            qualified_foreign += 1
        else:
            print('No')
a, b = map(int, input().split())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
elif a == b:
    print("EQUAL")


### FIXED CODE ###

a = int(input())
b = int(input())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
elif a == b:
    print("EQUAL")
N=int(input())
X=input()
XX=0
for i in range(N):
    XX+=int(X[N-i-1])*2**i
#print(XX)

POPCOUNT_TABLE16 = [0] * 2**16
for index in range(len(POPCOUNT_TABLE16)):
    POPCOUNT_TABLE16[index] = (index & 1) + POPCOUNT_TABLE16[index >> 1]

def popcnt5(v):
    return (POPCOUNT_TABLE16[ v        & 0xffff] +
            POPCOUNT_TABLE16[(v >> 16) & 0xffff] +
            POPCOUNT_TABLE16[(v >> 32) & 0xffff] +
            POPCOUNT_TABLE16[(v >> 48)         ])

def change(x,j):
    if int(x[j]):
        return XX-2**(N-1-j)
    else:
        return XX+2**(N-1-j)

table=[0,1,1,2,1,2,1,2,1,2,1,2,1,2,2,3,1,2,1]

def F(t):
    n=t
    if n<19:
        return table[n]
    else:
        n%=popcnt5(n)
        return table[n]+1

table=[0,1,1,2,1,2,1,2,1,2,1,2,1,2,2,3,1,2,1]

for i in range(N):
    #print(change(X,i))
    print(F(change(X,i)))

### FIXED CODE ###

N=int(input())
X=input()

def popcnt(x):
    n=x
    res=0
    while n>0:
        res+=n%2
        n//=2
    return res

table=[0,1]+[-1 for i in range(219998)]
for i in range(2,220000):
    table[i]=table[i%popcnt(i)]+1

moto=0
for i in range(N):
    if X[i]=='1':
        moto+=1

plus=0  #もとの数字に1のときのmodをしたやつ
minus=0

for i in range(N):
    plus+=int(X[i])*pow(2,N-1-i,max(1,moto-1))
    minus+=int(X[i])*pow(2,N-1-i,moto+1)
    plus%=(max(1,moto-1))
    minus%=(moto+1)

for i in range(N):
    ans=0
    if X[i]=='1':
        ans=plus
        ans-=pow(2,N-1-i,max(1,moto-1))
        ans%=(max(1,moto-1))
        if moto==1:
            ans=-1
    else:
        ans=minus
        ans+=pow(2,N-1-i,moto+1)
        ans%=(moto+1)
    if ans==-1:
        print(0)
    else:
        print(table[ans]+1)
N = int(input())
A = list(map(int, input().split()))

li = [0]*((N+1) >> 1)

for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(int(2**c % (10E9 - 7)))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(int(2**c % (10E9 - 7)))


### FIXED CODE ###


def mod_(b, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * b % mod
        b = b * b % mod
        n >>= 1
    return int(res)

def main():

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

    n = ((N+1) >> 1)
    li = [0]*n



    for a in A:
        li[a >> 1] += 1

    if N & 1:
        if li[0] != 1:
            print(0)
        elif li.count(2) != n-1:
            print(0)
        else:
            c = n-1
            print(2 ** c % (10**9+7))
    else:
        if li.count(2) != n:
            print(0)
        else:
            c = n
            print(2 ** c % (10**9+7))

main()
import math
a,b = list(map(int,input().split()))
print((a*b)//(math.gcd(a,b)))

### FIXED CODE ###

import fractions
a,b = list(map(int,input().split()))
print((a*b)//(fractions.gcd(a,b)))
A,B=input().split()
a=int(A)
b=int(B)
m=1
n=1
while n<=min(a,b):
  if a%n==0:
    if b%n==0:
      m=n
    else:
    n=+1
  else:
    n=+1
if m==1:
  print(1)
elif m==2:
  print(2)
else:
  x=3
  u=0
  v=0
  while x<=m:
    t=2
    while t<=x-1:
      if x%t==0:
        u=+1
        t=t+1
      else:
        t=t+1
    if u==0:
      if m%x==0:
        v=v+1
    u=0
    x=+1
  print(v+2)

### FIXED CODE ###

n=int(input())
if n%2==0:
  a=0.5
else:
  a=((n+1)/2)/n
print(a)
a,s,k=map(int,input().split())
if s-a<=2*k-1:print(*list(range(a,s+1)),sep="\n")
else:print(*list(range(a,a+k)),*list(range(s+1-k,s+1)),sep="\n")

### FIXED CODE ###

a,s,k=map(int,input().split())
if s-a<=2*k-1:print(*list(range(a,s+1)),sep="\n")
else:print(*list(range(a,a+k))+list(range(s+1-k,s+1)),sep="\n")
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))
  
i <- inlt()
D <- i[0]
T <- i[1]
S <- i[2]
 
if D > S*T:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))
  
i = inlt()
D = i[0]
T = i[1]
S = i[2]
 
if D/T > S:
  print("No")
else:
  print("Yes")
w=list(input())
ans=sorted(w)

print(ans)
while ans[-1]==ans[-2]:
  del ans[-2:]
  if ans==[] or len(ans)==1:
    break

if ans==[]:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

w=list(input())
ans=sorted(w)

if len(ans)>1:
  while ans[-1]==ans[-2]:
    del ans[-2:]
    if len(ans)==0 or len(ans)==1:
      break

if len(ans)==0:
  print('Yes')
else:
  print('No')
def make_divisors(n):
    a,b =[],[]
    i = 1
    while i*i<=n:
        if n%i == 0:
            a.append(i)
            if i != n//i:
                b.append(n//i)
        i+= 1
    return a+b[::-1]

if i % 2 == 0 and len(make_divisors(int(input())))==8:
    print(1)
else:
    print(0)

### FIXED CODE ###

def make_divisors(n):
    a,b =[],[]
    i = 1
    while i*i<=n:
        if n%i == 0:
            a.append(i)
            if i != n//i:
                b.append(n//i)
        i+= 1
    return a+b[::-1]

n = int(input())
c = 0
for i in range(1,n+1):
    if len(make_divisors(i))== 8 and i%2==1:
        c+=1
print(c)
n = int(input())
student = list(map(int,input().split()))
a = [0]*n

for i in range(n):
  s = student[i] #生徒が出席した番号をメモ
  a[s-1] = i+1
  
print(ans)

### FIXED CODE ###

n = int(input())
student = list(map(int,input().split()))
a = [0]*n
 
for i in range(n):
  s = student[i] #生徒が出席した番号をメモ
  a[s-1] = i+1
  
print(*a)
n = int(input())
c = 0 
for _ in range(n):
  n,m = map(int,input().split())
  count += m-n+1
print(count)

### FIXED CODE ###

n = int(input())
c = 0 
for _ in range(n):
  n,m = map(int,input().split())
  c += m-n+1
print(c)
X = int(input())
Y = int(input())

Z = X + (Y/2)

print(int(Z))

### FIXED CODE ###

x,y = map(int,input().split())

ans = x+y/2

print(int(ans))
while True:
    a, op, b =input().split())
    int(a)
    int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a / b)
    else:
        break

### FIXED CODE ###

while True:
    a, op, b = map(str, input("").split())
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "?":
        break
k = input()
w = input()
l = len(w)
if l <= k:
	print(w)
else:
    print(w[:k])


### FIXED CODE ###

k = int(input())
s = input()
if int(len(s)) <= k:
  	print(str(s))
else:
  	print(((str(s))[0:k]) + "...")
dish = []
time = 0
for i in range(5):
    temp = int(input())
    if temp % 10:
        dish.append(temp)
    else:
        time += temp
left = 10 - min([x % 10 for x in dish])
for i in range(len(dish)):
    dish[i] = dish[i] + 10 - dish[i] % 10
time = time + sum(dish) - left
print(time)

### FIXED CODE ###

dish, time = [], 0
for i in range(5):
    temp = int(input())
    if temp % 10 == 0:
        time += temp
    else:
        dish.append(temp)
if dish:
    left = 10 - min([x % 10 for x in dish])
    time = time + sum([x + 10 - x % 10 for x in dish]) - left
print(time)
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[N%2::2])

### FIXED CODE ###

N=int(input())
A=list(input().split())
s = " ".join(A[::-2]) + " " + " ".join(A[N%2::2])
print(s)
T X=(int(i) for i in input().split()) 
print(T/X)

### FIXED CODE ###

T,X=(int(i) for i in input().split()) 
print(T/X)
N,M = map(int,input().split())
A = set([]); MOD = pow(10,9)+7
for i in range(M):
  a = int(input())
  A.add(a-1)
dp = [[0]*2 for _ in range(N)] #dp[i][j] i段目(0index)にj=0最後1段でj=1最後2段できた。
if 0 not in A:
  dp[0][0] = 1
if 1 not in A:
  dp[1][0] = dp[0][0]+dp[0][1]
  dp[1][1] = 1
for i in range(2,N):
  if i in A:
    continue
  dp[i][0] = (dp[i-1][0]+dp[i-1][1])%MOD
  dp[i][1] = (dp[i-2][0]+dp[i-2][1])%MOD
ans = sum(dp[N-1])%MOD
#print(dp)
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
A = set([]); MOD = pow(10,9)+7
for i in range(M):
  a = int(input())
  A.add(a-1)
dp = [[0]*2 for _ in range(N)] #dp[i][j] i段目(0index)にj=0最後1段でj=1最後2段できた。
if 0 not in A:
  dp[0][0] = 1
if N == 1:
  print(sum(dp[0]))
  exit()
if 1 not in A:
  dp[1][0] = dp[0][0]+dp[0][1]
  dp[1][1] = 1
for i in range(2,N):
  if i in A:
    continue
  dp[i][0] = (dp[i-1][0]+dp[i-1][1])%MOD
  dp[i][1] = (dp[i-2][0]+dp[i-2][1])%MOD
ans = sum(dp[N-1])%MOD
#print(dp)
print(ans)
x = [input() for i in range(10001)]
y = x.split()
s = Case

for a in range(1, 10001):
     print('{} {} : {}'.format(s,a,y))
     a += 1

### FIXED CODE ###

i = 1
while True:
     x = int(input())
     if x == 0: break
     print('Case {}: {}'.format(i, x))
     i += 1
n = int(input())
x = [int(i) for i in input().split()]
d = {}

def m(x, p):
  a = (x - p)**2
  return a
for i in range(min(x), max(x)):
  b = 0
  for j in x:
    b += m(j,i)
  d[i]=[b]
print(min(d.values())[0])


### FIXED CODE ###

n = int(input())
x = [int(i) for i in input().split()]
d = []
for i in range(min(x), max(x)+1):
  a = 0
  for j in x:
    a += (j - i)**2
#    print("({}-{})**2={}".format(j,i,(j - i)**2))
  d.append(a)
print(min(d))
import numpy as np
n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()

d=np.array([L[i+1]-L[i] for i in range(m-1)])

ans=L[m-1]-L[0]

for i in range(n-1):
  a=np.argmax(d)
  d[a]=0
  ans-=(L[a+1]-L[a])
  




print(ans)


### FIXED CODE ###

n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
if n>=m:
  print(0)
elif m!=1:

  d=[L[i+1]-L[i] for i in range(m-1)]
  d.sort()
  d.reverse()
  ans=L[-1]-L[0]


  ans-=sum(d[:n-1])
  print(ans)
  

else:
  print(0)
words = [w[::-1] for w in ['dream','dreamer', 'erase', 'eraser']]
s = raw_input()[::-1]
while(i < len(s)):
	for w in words:
		if w == s[:len(w)]:
			i += len(w)
			break



print 'YES' if i == len(s) else 'NO'

### FIXED CODE ###

words = ['dream','dreamer', 'erase', 'eraser']
s = raw_input()
dp = [False for _ in range(len(s))]

for j in range(len(s)):
	for w in words:
		b = dp[j - len(w)] if j - len(w) -1 >= 0 else True
		b &= j-len(w) +1 >= 0 and s[j- len(w)+1:j+1] == w
		if b:
			dp[j] = True
			break
print 'YES' if dp[-1] else 'NO'
n = int(input())
    
ac = 0
wa = 0
tle = 0
re = 0

for _ in range(n):
  s = input()
  if s = 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  else:
    re += re
    
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

### FIXED CODE ###

n = int(input())
    
ac = 0
wa = 0
tle = 0
re = 0
 
for _ in range(n):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  else:
    re += 1
    
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))
N=int(input())
S=list(map(int,input().split( )))
S = sorted(S)
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(N-1,j,-1):
            if S[i] + S[j] > S[k]:
                tri_sum = tri_sum + k-j
print(tri_sum)

### FIXED CODE ###

N=int(input())
S=list(map(int,input().split( )))
S = sorted(S)
tri_num=0
for i in range(N-2):
    k = i+2
    for j in range(i+1,N-1):
        while k < N:
            if S[i] + S[j] <= S[k]:
                tri_num = tri_num + k-j-1
                if k == i+2:
                    k+=1
                break
            if k == N-1:
                tri_num = tri_num + k-j
                break
            k+=1
print(tri_num)
a, b = map(int, input().split())

import math
aS = math.ceil(a / 0.08)
al = math.floor((a + 1) / 0.08)
bs = math.ceil(b / 0.10)
bl = math.floor((b + 1) / 0.10)

for i in range(1000):
    if aS <= i < al and bs <= i < bl:
        print(i)
        flag = False
        break
if flag:
    print(-1)

### FIXED CODE ###

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

import math
aS = math.ceil(a / 0.08)
al = math.floor((a + 1) / 0.08)
bs = math.ceil(b / 0.10)
bl = math.floor((b + 1) / 0.10)

flag = True
for i in range(10000):
    if aS <= i < al and bs <= i < bl:
        print(i)
        flag = False
        break
if flag:
    print(-1)
n = int(input())
x = n*(n-1)%1000000007
y = 10**(n-2)%1000000007
print((x*y)%1000000007

### FIXED CODE ###

n = int(input())
r = (10**n)-2*(9**n)+8**n
r%=(10**9+7)
print(r)
a,b =  input().split()
a=int(a);b,d=map(int,b.spit('.'))
print(a*b+a*d//100)

### FIXED CODE ###

a,b =  input().split()
a=int(a);b,d=map(int,b.split('.'))
print(a*b+a*d//100)
# B - Golden Apple

N, D = map(int, input().split())
# print(int((N+2*D)/(2*D+1)))
print((N+2*D)//(2*D+1))

### FIXED CODE ###

# A - Dodecagon

r = int(input())
print(3*r**2)
n = int(input().split())

a = []
for i in range(1, 10):
    for j in range(1, 10):
        a.append(i * j)

if n in a:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

n = int(input())

a = []
for i in range(1, 10):
    for j in range(1, 10):
        a.append(i * j)

if n in a:
    print('Yes')
else:
    print('No')
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0

for i in range(m):
    a=heapq.heappop(t)
    b=heapq.heappop(d)
    #print(a,b,cnt)
    while b<a:
        b=heapq.heappop(d)
    if b==a:
        cnt+=1
        
    
if cnt==m:
    print("YES")
else:
    print("NO")
        

### FIXED CODE ###

import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0


if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(d)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(d)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")
import math
def combinations(x, y):
    return math.factorial(x) // (math.factorial(x - y) * math.factorial(y))


    
n, k = map(int, input().split())
if k == 1:
    print(n - k + 1)
else:    
    for i in range(k):
        print(combinations(n - k + 1, i + 1) * combinations(k - 1, i) % (10 ** 9 + 7))


### FIXED CODE ###

import math
def combinations(x, y):
    return math.factorial(x) // (math.factorial(x - y) * math.factorial(y))
    
n, k = map(int, input().split())
if k == 1:
    print(n - k + 1)
else:    
    for i in range(k):
        if n - k < i:
            print("0")
        else:
            print(combinations(n - k + 1, i + 1) * combinations(k - 1, i) % (10 ** 9 + 7))
def is_even():
  a, b = map(int, input().split())
    if (a*b)% 2 == 0:
        return Even
    else:
        return Odd

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b)% 2 == 0:
   print('Even')
else:
   print('Odd')
N = int(input())
lr = []
L, R = [], []
for _ in range(N):
    l, r = map(int, input().split())
    lr.append((l, r))
    L.append(l)
    R.append(r)
lr.sort()
L.sort()
R.sort()
ans = 0
for l, r in lr:  
    m = L[-1]
    if L[-1] == l:
        m = L[-2]
    M = R[0]
    if R[0] == r:
        M = R[1]
    ans = max(ans, M-m+1+r-l+1)
tmp = [lr[0]]
for i in range(1, N):
    if lr[i][0] == lr[i][1]:
        continue
    else:
        tmp.append(lr[i])
lr = tmp
R = lr[-1][1]
tmp = [lr[-1]]
for l, r in lr[-2::-1]:
    if R<=r:
        continue
    tmp.append((l, r))
    R = r
lr = tmp[::-1]
ans1 = [0]
ans2 = [0]
R = lr[0][1]
for l, r in lr:
    if l>R:
        ans1.append(0)
    else:
        ans1.append(R-l+1)
L = lr[-1][0]
for l, r in lr1[::-1]:
    if L>r:
        ans2.append(0)
    else:
        ans2.append(r-L+1)
for a, b in zip(ans1, ans2[::-1]):
    ans = max(ans, a+b)
print(ans)

### FIXED CODE ###

N = int(input())
LR = []
L, R = [], []
for _ in range(N):
    l, r = map(int,  input().split())
    LR.append((l, r))
    L.append(l)
    R.append(r)
L.sort()
R.sort()
ans = 0
for l, r in LR:
    m = L[-1]
    M = R[0]
    if l == m:
        m = L[-2]
    if M == r:
        M = R[1]
    ans = max(max(0, M-m+1)+r-l+1, ans)
LR.sort()
tmp = [LR[-1]]
Rmin = LR[-1][1]
for i in range(N-1)[::-1]:
    if LR[i][1]<=Rmin:
        tmp.append(LR[i])
        Rmin = LR[i][1]
LR = tmp[::-1]
rmin = LR[0][1]
lmax = LR[-1][0]
for i in range(len(LR)-1):
    l0, r0 = LR[i]
    l1, r1 = LR[i+1]
    res1 = max(0, rmin-l0+1)
    res2 = max(0, r1-lmax+1)
    ans = max(ans, res1+res2)
print(ans)
def exists(value,n,ms,cs):
    if (len(value) != n):
        return False
    if not all([value[i-1] == c for i,c in zip(ms,cs)]:
        return False
    return True
def unzip(li):
    return list(map(list, zip(*li)))
n,m = [int(e) for e in input().split()]
m = [input().split() for e in range(m)]
ms,cs = unzip(m)
ms = [int(e) for e in ms]
result = -1
for i in range(1000):
    if exists(str(i),n,ms,cs):
        result = i
        break
print(result)

### FIXED CODE ###

n,m = map(int,input().split())
sc = [[i for i in map(int,input().split())] for j in range(m)]
start = 0
goal = 0
if n==1:
  start = 0
  goal = 9
elif n==2:
  start = 10
  goal = 99
elif n==3:
  start = 100
  goal = 999

flag = 1
ans = -1
for num in range(start,goal+1):
  flag = 1
  for i in range(m):
    if str(num)[sc[i][0]-1] != str(sc[i][1]): #両辺ともちゃんとstrで変換
      flag = 0
  if flag == 1:
    ans = num
    break

print(ans)
N = int(input())
l = []
s = set()
for i in range(N):
	a,b,c = map(int,input().split(' '))
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	s.add(l)
	l = []
print(N - len(s))

### FIXED CODE ###

N = int(input())
l = []
s = set()
for i in range(N):
	a,b,c = map(int,input().split(' '))
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	d = str(l[0])
	e = str(l[1])
	f = str(l[2])
	g = d + e + f
	s.add(g)
	l = []
print(N - len(s))
import java.util.Scanner;

class Main {

  static boolean RS(String S, int n) {
    
    if (n%2 == 1) return false;
      
    for(int i = 0; i < n/2; i++)
      if(S.charAt(i) != S.charAt(i+n/2))
        return false;
      
    return true;
  }
  
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    
    int n = stdIn.nextInt();
    String S = stdIn.next();
     
    if(RS(S, n))
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


### FIXED CODE ###

n = int(input())
S = input()
b = 0
if n % 2 == 0:
  h = int(n/2)
  b = 1
  for i in range(h):
    if S[i] != S[i+h]:
      b = 0
print("Yes" if b == 1 else "No")
inport bisect

N = int(input())
A = [int(i) for i in input().split()]

B = [0]
X = [0]
ans = 0

for i in range(N):
    X.append(X[i]+A[i])
    insert_index = bisect.bisect_left(B,X[i+1])
    for j in range(insert_index,i+1):
        if B[j] == X[i+1]:
            ans += 1
        else:
            break

    B.insert(insert_index,X[i+1])

print(ans)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)
N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
if sum(num_list) < x:
    print(index-1)
else:
    print(index)

### FIXED CODE ###

N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
if sum(num_list) < X:
    print(index-1)
else:
    print(index)