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

import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	n,m=map(int,input().split())
	li=[[] for i in range(n+1)]
	for i in range(m):
		l,r,d=map(int,input().split())
		li[l].append((r,d))
		li[r].append((l,-d))
	
	stack=[]
	check=set()
	a=[-10**10]*(n+1)
	
	for i in range(1,n+1):
		if li[i]==[""] or (i in check):
			continue
		else:
			stack.append(i)
			a[i]=0
			while stack:
				now=stack.pop()
				check.add(now)
				for j in li[now]:
					if j[0] in check:
						if a[j[0]]-a[now]!=j[1]:
							print("No")
							exit(0)
						else:
							continue
					if j[0] in stack:
						continue
					a[j[0]] = a[now] + j[1]
					stack.append(j[0])
					
	print("Yes")
	
	
if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	n,m=map(int,input().split())
	li=[[] for _ in range(n+1)]
	for i in range(m):
		l,r,d=map(int,input().split())
		li[l].append((r,d))
		li[r].append((l,-d))
	
	q=deque()
	a=[None]*(n+1)

	for i in range(1,n+1):
		if a[i]==None:
			q=[i]
			a[i]=0
			while q:
				now=q.pop()
				for r,d in li[now]:
					if a[r]==None:
						a[r] = a[now] + d
						q.append(r)
					else:
						if a[r]-a[now]!=d:
							print("No")
							exit(0)
						else:
							continue
					
	print("Yes")
	
	
if __name__ == '__main__':
	main()
### BUGGY CODE ###

ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
R,C,K = ma()
V = [[0 for i in range(R+1)] for j in range(C+1)]
for i in range(K):
    r,c,v = ma()
    V[c][r] = v
dp_prev = [[0]*4 for i in range(C+1)]
dp_nex = [[0]*4 for i in range(C+1)] #dp[h][k] h列目でmax kこまで選んだ時の最大値
for r in range(1,R+1):
    for c in range(1,C+1):
        v = V[c][r]
        for k in range(4):
            if k==0:
                dp_nex[c][0] = max(dp_prev[c][3],dp_nex[c-1][0])
            elif k >0:
                dp_nex[c][k] = max(dp_nex[c-1][k],dp_nex[c-1][k-1]+v,dp_prev[c][3]+v)
    dp_prev,dp_nex = dp_nex,dp_prev
    #print(dp_prev)


print(dp_prev[C][3])


### FIXED CODE ###

ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
R,C,K = ma()
V = [[0 for i in range(R+1)] for j in range(C+1)]
for i in range(K):
    r,c,v = ma()
    V[c][r] = v
dp_prev = [[0]*4 for i in range(C+1)]
dp_nex = [[0]*4 for i in range(C+1)] #dp[h][k] h列目でmax kこまで選んだ時の最大値
for r in range(1,R+1):
    for c in range(1,C+1):
        v = V[c][r]
        for k in range(4):
            if k==0:
                dp_nex[c][0] = max(dp_prev[c][3],dp_nex[c-1][0])
            elif k >0:
                dp_nex[c][k] = max(dp_nex[c-1][k],dp_nex[c-1][k-1]+v,dp_prev[c][3]+v)
    dp_prev,dp_nex = dp_nex,dp_prev
    #print(dp_prev)


print(dp_prev[C][3])
### BUGGY CODE ###

import collections
import math

n = int(input())
a = [int(i) for i in input().split()]

def com(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(n):
    ans = 0
    b = a.copy()
    del b[i]
    bb = collections.Counter(b)
    for j in bb:
        if bb[j] > 1:
            ans += com(bb[j],2)
    print(ans)

### FIXED CODE ###

import collections
import math

n = int(input())
a = [int(i) for i in input().split()]

def com(n, r):
    if n > 1:
        ann = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        ann = 0
    return ann

b = collections.Counter(a)
ans = []
for i in b:
    ans.append(com(b[i],2))
anss = sum(ans)

for i in range(n):
    t = b[a[i]]
    print(anss - (t-1))
### BUGGY CODE ###

s = input()
q = int(input())

r = False

for i in range(q):
    ts = input().split()
    if len(ts) == 1:
        r = not r
        # print(f"reverse: {r}")
    else:
        f, c = int(ts[1]), ts[2]
        if (r and f == 1) or (not r and f == 2):
            # 最後尾
            s += c
        else:
            # 先頭
            s = c + s
if not r:
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

# list(map(int, input().split()))

s = input()
q = int(input())

r = False
first = []
last = []
for i in range(q):
    ts = input().split()
    if len(ts) == 1:
        r = not r
        # print(f"reverse: {r}")
    else:
        f, c = int(ts[1]), ts[2]
        if (r and f == 1) or (not r and f == 2):
            # 最後尾
            # s += c
            last.append(c)
        else:
            # 先頭
            # s = c + s
            first.append(c)
s = "".join(first)[::-1] + s + "".join(last)
if not r:
    print(s)
else:
    print(s[::-1])
### BUGGY CODE ###

import collections
import numpy as np

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

cnt = collections.Counter(A)

def cmb(n):
    return n * (n - 1) // 2
    
for i in range(N):
    tmp = cnt.copy()
    tmp[A[i]] -= 1
    ans = int(np.sum(np.array([cmb(k) for k in tmp.values() if k >= 2])))
    print(ans)
    

### FIXED CODE ###

import collections
import numpy as np

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

cnt = collections.Counter(A)

B = [cnt[a] for a in A]

def cmb(n):
    return n * (n - 1) // 2
    
ans = int(sum([cmb(k) for k in cnt.values()]))

for b in B:
    print(ans - cmb(b) + cmb(b - 1))
### BUGGY CODE ###

n,m=[int(x) for x in input().rstrip().split()]
l=[[]*n for x in range(n)]
for i in range(m):
  a,b=[int(x) for x in input().rstrip().split()]
  l[a-1].append(b-1)
  l[b-1].append(a-1)

done=[False for i in range(n)]
ans=[0 for i in range(n)]
def bfs():
  stack=[0]
  done[0]=True
  while(stack):
    now=stack.pop(0)
    done[now]=True
  
    for i in l[now]:
      if done[i]==True or i in stack:
        continue
      ans[i]=now+1
      stack.append(i)

bfs()
print("Yes")
for i in range(1,n):
  print(ans[i])




### FIXED CODE ###

n,m=[int(x) for x in input().rstrip().split()]
l=[[] for x in range(n)]
for i in range(m):
  a,b=[int(x) for x in input().rstrip().split()]
  l[a-1].append(b-1)
  l[b-1].append(a-1)

done=[False for i in range(n)]
ans=[0 for i in range(n)]
def bfs():
  stack=[0]
  done[0]=True
  while(stack):
    now=stack.pop(0)
    done[now]=True
  
    for i in l[now]:
      if done[i]==True:
        continue
      ans[i]=now+1
      done[i]=True
      stack.append(i)

bfs()
print("Yes")
print(*ans[1:])
### BUGGY CODE ###

n, q = map(int, input().split(' '))
s = input()
for _ in range(q):
    l, r = map(int, input().split(' '))
    print(s[l-1:r].count('AC'))


### FIXED CODE ###

n, q = map(int, input().split(' '))
s = input()
c = [0] * n
for i in range(1, n):
    c[i] += c[i-1]
    if s[i-1:i+1] == 'AC':
        c[i] += 1
for _ in range(q):
    l, r = map(int, input().split(' '))
    print(c[r-1] - c[l-1])
### BUGGY CODE ###

import sys

k,s = list(map(int,input().split()))

c=0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if (x+y+z)==s:
                c+=1

print(c)

### FIXED CODE ###

import sys

k,s = list(map(int,input().split()))

c=0

for x in range(k+1):
  for y in range(k+1):
    z = (s-x-y)
    if (z>=0 and z<=k):
      c+=1

print(c)
### BUGGY CODE ###

import itertools
D, G = map(int, input().split())
score_list = []
for i in range(D):
    p, c = map(int, input().split())
    score_list.append([(i + 1) * 100] * (p - 1) + [c + (i + 1) * 100])
full_score = [sum(i) for i in score_list]
per = list(itertools.permutations(range(D)))
ans = 10000

for k in per:
    pro = 0
    sco = 0
    for i in k:
        if G >= sco + full_score[i]:
            sco += full_score[i]
            pro += len(score_list[i])
        else:
            for j in score_list[i]:
                sco += j
                pro += 1
                if sco >= G:
                    break
                else:
                    continue
        if sco >= G:
            break
        else:
            continue
    if ans > pro:
        ans = pro
    else:
        continue
print(ans)

### FIXED CODE ###

D, G = map(int, input().split())
score_list = []
for i in range(D):
    p, c = map(int, input().split())
    score_list.append([(i + 1) * 100] * (p - 1) + [c + (i + 1) * 100])
full_score = [sum(i) for i in score_list]
sol = [format(i, 'b').zfill(D) for i in range(2 ** D)]
ans = []

for i in sol:
    problem = 0
    score = 0
    for j in range(D):
        if i[j] == '1':
            score += full_score[j]
            problem += len(score_list[j])
        else:
            continue
    if score >= G:
        ans.append(problem)
    else:
        if score + full_score[i.rfind('0')] < G:
            continue
        else:
            while score < G:
                score += score_list[i.rfind('0')][0]
                problem += 1
            ans.append(problem)

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

s = input()
q = int(input())

for i in range(q):
    t = input().split()
    if t[0] == '2':
        if t[1] == '1':
            s = t[2] + s
        else:
            s += t[2]
    else:
        s = s[::-1]

print(s)
 

### FIXED CODE ###

s = input()
q = int(input())
Flag = False
right=''
left=''

for i in range(q):
    t = input()
    if t[0] == '1':
        Flag = not Flag
    else:
        _, f, c = t.split()
        if Flag == False and f == '2' or Flag == True and f == '1':
            right += c
        else:
            left += c

ans = left[::-1] + s + right
print(ans if not Flag else ans[::-1])
### BUGGY CODE ###

# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


n,k = map(int, input().split())
hn = list(map(int, input().split()))
dp = [-1] * n

dp[0] = 0
for i in range(1,n):
  ret = sys.maxsize
  for j in range(1,min(k+1,i+1)):
    ret = min(ret, dp[i-j]+abs(hn[i-j]-hn[i]))
  dp[i] = ret
print(dp[n-1])



### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import sys
import numpy as np

n,k = map(int, sys.stdin.readline().rstrip().split())
h = np.array(list(map(int, sys.stdin.readline().rstrip().split())))

dp = np.zeros(n, dtype=np.int)

for i in range(1,n):
  if i < k:
    dp[i] = np.min(dp[:i] + np.abs(h[i]-h[:i]))
  else:
    dp[i] = np.min(dp[i-k:i] + np.abs(h[i]-h[i-k:i]))

print(dp[n-1])
### BUGGY CODE ###

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

Asum = sum(As)

ans = 0
for index, A in enumerate(As):
    Asum = sum(As)
    ans += (A * (Asum - A))
    ans = ans % (10**9+7)

#    print(As)
    As = As[1:]
#    print(As)

print(ans)

### FIXED CODE ###

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

Asum = sum(As)

ans = 0
for index, A in enumerate(As):
    ans += (A * (Asum - A))
    ans = ans % (10**9+7)
    Asum -= A
#    print(
#    print(As)

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

h,w,m=map(int,input().split())
h_=[0]*(h+1)
w_=[0]*(w+1)
plot=[]
for _ in range(m):
    x,y=map(int,input().split())
    h_[x]+=1
    w_[y]+=1
    plot.append([x,y])
from collections import deque
ans_x=deque()
ans_y=deque()
x=0
y=0
for i in range(1,h+1):
    if h_[i]>x:
        x=h_[i]
        ans_x=deque()
        ans_x.append(i)
    elif h_[i]==x:
        x=h_[i]
        ans_x.append(i)    
for j in range(1,w+1):
    if w_[j]>y:
        y=w_[j]
        ans_y=deque()
        ans_y.append(j)
    elif w_[j]==y:
        y=w_[j]
        ans_y.append(j)
ans=x+y
ans_x=list(ans_x)
ans_y=list(ans_y)
u=0
c=0
for i in ans_x:
    for j in ans_y:
        if [i,j] in plot:
            u+=1
        c+=1
if c==u:
    print(ans-1)
else:
    print(ans)                


### FIXED CODE ###

h,w,m=map(int,input().split())
h_=[0]*(h+1)
w_=[0]*(w+1)
plot=set()
for _ in range(m):
    x,y=map(int,input().split())
    h_[x]+=1
    w_[y]+=1
    plot.add((x,y))
x=max(h_)
y=max(w_)
a=[i for i,v in enumerate(h_) if v==x]
b=[j for j,q in enumerate(w_) if q==y]
ans=x+y-1
c=False
for i in a:
    for j in b:
        if (i,j) not in plot:
          c=True
          break
    if c:
      break
if c:
  print(ans+1)
else:
  print(ans)
### BUGGY CODE ###

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

    L = sorted(L, reverse=True)

    ans = 0
    for i in range(N):

        for j in range((i+1), N):
            if L[i]/2 >= L[j]:
                break 
            #for k in range((j+1), N):
            #    if L[i] < (L[j]+L[k]):
            #        ans += 1

            ans += len([t for t in L[j+1::] if L[i] < (L[j]+t)])


    
    print(ans)


if __name__ == '__main__':
    main()



### FIXED CODE ###

import bisect

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

    L = sorted(L)
    
    ans = 0
    for i in range(N-1):
        for j in range((i+1), N):    
            c = bisect.bisect_left(L, L[i] + L[j], j+1)
            ans += c - j - 1

    print(ans)


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

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

q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    for j in range(n):
        if a[j]==bi:
            a[j]=ci
        elif a[j]>bi:
            break
    print(sum(a))
    a.sort()

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]
b*=10**5+1
for i in a:
    b[i]+=1
ans=sum(a)
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    d=b[bi]
    b[ci]+=d
    b[bi]=0
    ans=ans+d*(ci-bi)
    print(ans)
### BUGGY CODE ###

from collections import defaultdict
from fractions import Fraction
import sys
input = sys.stdin.readline
N=int(input())
mod=10**9+7
dic=defaultdict(lambda: [0,0])
c=0
d=0
e=0
for i in [0]*N:
 A,B = map(int,input().split())
 if A==0 and B==0:
  e+=1
 elif A==0:
  c+=1
 elif B==0:
  d+=1
 else:
  if Fraction(A,B)>0:
   dic[Fraction(A,B)][0]+=1
  else:
   dic[Fraction(-B,A)][1]+=1
ans=1
for k in dic:
 ans*=(pow(2,dic[k][0],mod)+pow(2,dic[k][1],mod) -1)
ans*=(pow(2,c,mod)+pow(2,d,mod)-1)
print((ans-1+e)%mod)


### FIXED CODE ###

from collections import defaultdict
from math import gcd
import sys
input = sys.stdin.readline
N=int(input())
mod=10**9+7
dic=defaultdict(lambda: [0,0])
c=0
d=0
e=0
for i in [0]*N:
 A,B = map(int,input().split())
 if A==0 and B==0:
  e+=1
 elif A==0:
  c+=1
 elif B==0:
  d+=1
 else:
  g=gcd(A,B)
  A//=g
  B//=g
  if A*B>0:
   dic[(abs(A),abs(B))][0]+=1
  else:
   dic[(abs(B),abs(A))][1]+=1
ans=1
for k in dic:
 ans=ans*(pow(2,dic[k][0],mod)+pow(2,dic[k][1],mod) -1)
ans=ans*(pow(2,c,mod)+pow(2,d,mod)-1)
print((ans-1+e)%mod)
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
# I = INT()
I = int(S)
N = len(S)
left = 0
l = []
dp = [0] * (N + 1)
ans = 0
for right in range(N):
    for left in range(right):
        # if left < right:
        # l.append(S[right])
        # s_str = "".join(l)
        s_str = S[left:right+1]
        tmp = int(s_str)
        # print(tmp)
        if tmp % 2019 == 0:
            # print(tmp // 2019)
            # print(tmp)
            # dp[right] += 1
            ans += 1
print(ans)
    





exit()
L = len(n)
K = 10
# dp[i][j][k]
# j その地点で持っている2019の数
#
dp = [[[0] * 2 for i in range(K)] for i in range(L+1)]
# K+1のところKにした

dp[0][0][0] = 1

for i in range(L):
    for j in range(1, K):
        for k in range(2):
            nd = int(n[i])
            for d in range(1, 10):
                ni = i + 1
                nj = j
                nk = k
                
                if d == 1:
                    nj += 1
                # 10 ** 9 より大きくなることはない
                if nj > 9:
                    continue
                #    
                if k == 0:
                    if d == nd:
                        nk = 0
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1

                dp[ni][nj][nk] += dp[i][j][k]
# ans = dp[L][K][0] + dp[L][K][1]

print(dp)
# ans = 0
# # iをかけた(?)
# for i in range(1, 10):
#     ans += i * (dp[L][i][0] + dp[L][i][1])
# # print(dp)
# print(ans)



### FIXED CODE ###

S = list(input())
N = len(S)
S = [int(s) for s in S]
S = S[::-1]
l = [0] * 2019
index = 0
tmp = 0
z = 1
for i, s in enumerate(S):
    tmp += s * pow(10, i, 2019)
    l[tmp%2019] += 1

ans = l[0]

for v in l:
    ans += v * (v-1) // 2
print(ans)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**6)
N = int(input())
P = [[] for _ in range(N + 1)]
P2 = [[0] * (N + 1) for _ in range(N + 1)]
AB = []
for _ in range(N - 1):
    a, b = [int(_) for _ in input().split()]
    P[a].append(b)
    P[b].append(a)
    AB.append((a,b))
C = 0

for p in P:
    if len(p) > C:
        C = len(p)


def f(n, pre, used):
    c = 1
    for i, next_n in enumerate(P[n]):
        if pre == next_n: continue
        if c == used: c += 1
        P2[n][next_n] = c
        P2[next_n][n] = c
        f(next_n, n, c)
        c += 1


print(C)
f(1, -1, 0)
# print(P2)
for a,b in AB:
    print(P2[a][b])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
N = int(input())
P = [[] for _ in range(N + 1)]
AB = []
for _ in range(N - 1):
    a, b = [int(_) for _ in input().split()]
    P[a].append(b)
    P[b].append(a)
    AB.append((a,b))
C = 0

for p in P:
    if len(p) > C:
        C = len(p)


P2 = dict()
def f(n, pre, used):
    c = 1
    for i, next_n in enumerate(P[n]):
        if pre == next_n: continue
        if c == used: c += 1
        # P2[n][next_n] = c
        # P2[next_n][n] = c
        if n > next_n:
            a, b = next_n, n
        else:
            b,a = next_n, n
        P2[(a,b)] = c
        f(next_n, n, c)
        c += 1


print(C)
f(1, -1, 0)
for ab in AB:
    print(P2[ab])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import itertools
import bisect

def main():
    N = int(input())
    L = [int(x) for x in input().split()]
    ans = 0
    L_sorted = sorted(L)
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            a = L_sorted[i]
            b = L_sorted[j]
            l = bisect.bisect_left(L_sorted[j:], max(a - b, b - a))
            r = bisect.bisect_left(L_sorted[j:], a + b)
            ans += r - l - 1

    print(ans)



    

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
input = sys.stdin.readline
import itertools
import bisect

def main():
    N = int(input())
    L = [int(x) for x in input().split()]
    ans = 0
    L_sorted = sorted(L)
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            a = L_sorted[i]
            b = L_sorted[j]
            l = bisect.bisect_left(L_sorted, max(a - b, b - a), lo=j + 1)
            r = bisect.bisect_left(L_sorted, a + b, lo=j + 1)
            ans += r - l

    print(ans)



    

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

# coding: utf-8

import itertools
from functools import reduce
from collections import deque

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

seiseki = deque([])
seiseki2 = []
for i in range(N):
    seiseki.append(A[i])
    if len(seiseki) == K:
        seiseki2.append(reduce(lambda a, b: a * b, seiseki, 1))
        seiseki.popleft()

zenkai = seiseki2[0]
for i in range(1, len(seiseki2)):
    if seiseki2[i] > zenkai:
        print("Yes")
    else:
        print("No")
    zenkai = seiseki2[i]




### FIXED CODE ###

# coding: utf-8

import itertools
from functools import reduce
from collections import deque

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

for i in range(N):
    if i > K-1:
        if A[i] > A[i-K]:
            print("Yes")
        else:
            print("No")
### BUGGY CODE ###

n,q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

for l,r in lr:
  S = s[l-1:r]
  print(S.count("AC"))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

ans = [0] * N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i] + 1)
    else:
        ans[i+1] = ans[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])
### BUGGY CODE ###

N,M=map(int,input().split())
x={i for i in range(10**5+1)}
for _ in range(M):
    L,R=map(int,input().split())
    tmp={i for i in range(L,R+1)}
    x=x&tmp
print(len(x))

### FIXED CODE ###

N,M=map(int,input().split())
L,R=[],[]
for _ in range(M):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)
Lm=max(L)
Rm=min(R)
print(Rm-Lm+1 if Rm-Lm>=0 else 0)