Harryxun/stf_run huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

print(uf.group_count() - 1)

### FIXED CODE ###

k = int(input())

res = ''
while(k >= 1):
    res += 'ACL'
    k -= 1
print(res)
X = int(input())
m = 0
n = 0
tip = 0
for i in range(101):
    if (tip == 0):
        p = i ** 5
        q = X - p
        r = q ** (1/5)
        if ((r - int(r)) == 0):
            m = r
            n = ((-1) * p)
            tip = 1
print(int(m), int(n))

### FIXED CODE ###

X = int(input())
A = [0] * 400
m = 0
n = 0
for i in range(400):
  A[i] = i ** 5
for i in range(400):
  x = A[i]
  for j in range(400):
    y = A[j]
    if ((x + y) == X):
      m = i
      n = (-1) * j
    elif ((x - y) == X):
      m = i
      n = j
print(m, n)
h,w=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(h)]

B=[]
for i in range(h):
    flag=1 if i%2==0 else -1
    for j in range(w)[::flag]:
        if A[i][j]%2==1:
            if 0<=j+flag<w:
                B.append([i,j,i,j+flag])
                A[i][j+flag] +=1
            else:
                B.append([i,j,i+1,j])
                A[i+1][j] +=1

print(len(B))
for i in B:
    print(*list(map(lambda x:x+1,i)))

### FIXED CODE ###

h,w=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(h)]

C=[]
for i in range(h):
    flag=1 if i%2==0 else -1
    for j in range(w)[::flag]:
        if A[i][j]%2==1:
            if 0<=j+flag<w:
                C.append([i+1,j+1,i+1,j+flag+1])
                A[i][j+flag] +=1
            elif 0<=i+1<h:
                C.append([i+1,j+1,i+2,j+1])
                A[i+1][j] +=1

print(len(C))
for i in C:print(*i)
n=int(input())
s=input()
k=[i for i in range(1,n+1)]
from itertools import combinations
c=list(combinations(k,2))
ans=0
for i in range(len(c)):
  p=c[i][0]
  q=c[i][1]
  r=c[i][2]
  if s[p]!=s[q] and s[q]!=s[r] and s[p]!=s[r] and q-p!=r-q:
    ans=ans+1
print(ans)  

### FIXED CODE ###

n=int(input())
s=list(input())
a=s.count("R")
b=s.count("G")
c=s.count("B")
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if n-1>=k and (s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]): 
      ans=ans+1
print(a*b*c-ans)
n = int(input())
a = int(input())
b = int(input())
if n==1:
  print('Hello World')
else:
  print(a+b)

### FIXED CODE ###

n = int(input())
if n==1:
  print('Hello World')
else:
  a = int(input())
  b = int(input())
  print(a+b)
import math
a,b,h,m=map(int,input().split())
#1分間に進む分針 360/60=6度
#1時間に進む時針 360/12=30度
#1分間に進む時針 30/60=0.5度
r=abs((h*30+m*0.5)-(m*6))
s1=math.sqrt(a**2+b**2-(2*a*b*(math.cos(math.radians(r)))))
print(s)

### FIXED CODE ###

import math
a,b,h,m=map(int,input().split())
#1分間に進む分針 360/60=6度
#1時間に進む時針 360/12=30度
#1分間に進む時針 30/60=0.5度
r=abs((h*30+m*0.5)-(m*6))
s=math.sqrt(a**2+b**2-(2*a*b*(math.cos(math.radians(r)))))
print(s)
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
A = []
for a in C:
    if C[a]==1:
        A.append(a)
if len(A)==0:
    print(0)
else:
    A = sorted(A)
    amax = A[-1]
    P = [0 for _ in range(amax+1)]
    for i in range(N):
        P[A[i]] = 1
    for i in range(N):
        a = A[i]
        for j in range(a*2,amax+1,a):
            P[j] = 0
    print(sum(P))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
N = len(A)
amax = A[-1]
P = [0 for _ in range(amax+1)]
for i in range(N):
    P[A[i]] = 1
for i in range(N):
    a = A[i]
    for j in range(a*2,amax+1,a):
        P[j] = 0
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
for i in range(N):
    a = A[i]
    if P[a]==1 and C[a]>1:
        P[a] = 0
print(sum(P))
x=int(input())
cost=100
while(cost<x):
    cost=cost*101//100
    ans+=1
print(ans)

### FIXED CODE ###

x=int(input())
ans=0
cost=100
while(cost<x):
    cost=cost*101//100
    ans+=1
print(ans)
def is_triangle(x, y, z):
    x, y, z = sorted(x, y, z)
    return x**2 + y**2 == z**2

num = int(input())
for i in range(num):
    x, y, z = map(int, input().split())
    triangle = is_triangle(x, y, z)
    if triangle:
        print('YES')
    else:
        print('NO')
        

### FIXED CODE ###

def is_triangle(x, y, z):
    x, y, z = sorted([x, y, z])
    return x**2 + y**2 == z**2

num = int(input())
for i in range(num):
    x, y, z = map(int, input().split())
    triangle = is_triangle(x, y, z)
    if triangle:
        print('YES')
    else:
        print('NO')
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
ans = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x
def dfs(c, parent):
    for child in tree[c]:
        if child == parent:
            continue
        else:
            ans[child] += ans[c]
            dfs(child, c)
dfs(0, 0)
print(*ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
N = input()
K = input()
A = int(N)
B = int(K)
j = 0
for i in range(1,A+1):
  n = input()
  a = int(n)
  if a >= B:
	j += 1
    continue
  else: continue
print(j)

### FIXED CODE ###

N,K=map(int,input().split())
count = 0
for i in range(1,N+1):
    h = list(map(int,input().split()))
    for j in h:
        if j >= K:
            count += 1
        else: continue
    break
print(count)
A, B = map(int, input().split())
flg = True
for i in range(1, 4):
    if (A * B * i) % 2 == 1:
        flg = False
        break
if flg == False:
    print('Yes')
elif == True:
    print('No')

### FIXED CODE ###

A, B = map(int, input().split())
flg = False
for i in range(1, 4):
    if (A * B * i) % 2 == 1:
        flg = True
        break
if flg:
    print('Yes')
else:
    print('No')
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

[n,x] = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
xdiff = []

for i in xs:
    xdiff.append(abs(x - i))

print(gcd_list(xdiff))


### FIXED CODE ###

import math
[n,x] = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
if n != 1:
    xs.append(x)
    xs.sort()
    diff = []
    for i in range(1,n+1):
        diff.append(xs[i] - xs[i-1])
    ans = 0
    for i in range(1,len(diff)):
        if i == 1:
            ans = math.gcd(diff[i-1],diff[i])
        else:
            ans = math.gcd(ans,diff[i])
    print(ans)
else:
    print(abs(x - xs[0]))
print(A * B)

### FIXED CODE ###

a,b = map(int,input(). split ())
print(a*b)
s = input()
q = int(input())


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


print(s)


### FIXED CODE ###

s = input()

if 'A' in s and 'B' in s:
	print('Yes')
else:
	print('No')
K = input()
S = input()

Knum = int(K)
Slength = len(S)

if Slength <= Knum:
	str = S
else:
	str = S[0:Knum]

print(str)

### FIXED CODE ###

n = int(input())
str = ""

if n%10 == 0:
	str = "pon"
elif n%10 == 1:
	str = "pon"
elif n%10 == 2:
	str = "hon"
elif n%10 == 3:
	str = "bon"
elif n%10 == 4:
	str = "hon"
elif n%10 == 5:
	str = "hon"
elif n%10 == 6:
	str = "pon"
elif n%10 == 7:
	str = "hon"
elif n%10 == 8:
	str = "pon"
elif n%10 == 9:
	str = "hon"

print(str)
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


x = int(input())
flg = 0
while flg == 0:
    #print("a")
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    fig = _flg
    if flg == 0:
        x+=1
print(x)


### FIXED CODE ###

def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


def main():
    x = int(input())
    flg = 0
    while flg == 0:
        #print("a")
        flg = com(x)
        if flg == 0:
            x+=1
    print(x)



if __name__ == "__main__":
    main()
n, k = map(int, input().split())

ab = [list(map(int, input().split())) for x in range(n)]
tk = k

ends = [0 for x in range(10**5)]
for a, b in ab:
    ends[a] += b
    
    k -= b
    if k <= 0:
        break


for i, e in enumerate(ends):
    tk -= e
    if tk <= 0:
        print(i)
        break


### FIXED CODE ###

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

ab = [list(map(int, input().split())) for x in range(n)]

ends = [0 for x in range(10**5 + 1)]
for a, b in ab:
    ends[a] += b

for i, e in enumerate(ends):
    k -= e
    if k <= 0:
        print(i)
        break
import collections
n=int(input())
s=[]
for i in range(n):
  S=input()
  s.append(S)

c = collections.Counter(s)
print(c.most_common()[0][0])
for i in range(1,n):
  if c.most_common()[i-1][1]==c.most_common()[i][1]:
    print(c.most_common()[i][0])
  else:
    break

### FIXED CODE ###

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

c = collections.Counter(s)
l=c.most_common()
x=[l[0][0]]
for i in range(1,len(l)):
  if l[i-1][1]==l[i][1]:
    x.append(l[i][0])
  else:
    break
x.sort()    
for i in x:
  print(i)
s = int(input())
b = [s]
n = len(s)
a = b[n]
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
  print('hon')
elif a == 0 or a == 1 or a == 6 or a == 8:
  print('pon')
else:
  print('bon')


### FIXED CODE ###

s = input()
n = len(s)
a = s[n-1:n]
if a == '2' or a == '4' or a == '5' or a == '7' or a == '9':
  print('hon')
elif a == '0' or a == '1' or a == '6' or a == '8':
  print('pon')
else:
  print('bon')
n, m, k = map(int,input().split())
friends = [[] for i in range(n)]
brock = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int,input().split())
    friends[a-1].append(b-1)
    friends[b-1].append(a-1)
for i in range(k):
    c, d = map(int,input().split())
    brock[c-1].append(d-1)
    brock[d-1].append(c-1)

group = []

def dfs(x):
    if not x in g:
        g.append(x)
        for l in friends[x]:
            dfs(l)

for i in range(n):
    flag = True
    for j in group:
        if i in j:
            flag = False
    if flag:
        g = [i]
        for j in friends[i]:
            dfs(j)
        group.append(g)

ans = [-1 for i in range(n)]
for i in range(n):
    for j in group:
        if i in j:
            ans[i] += len(j)
            break
    ans[i] -= len(friends[i])+len(brock[i])

print(" ".join(map(str,ans)))            


### FIXED CODE ###

'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n,m,k = map(int,ipt().split())
    fl = [[] for i in range(n)]
    bl = [set() for i in range(n)]
    for i in range(m):
        a,b = map(int,ipt().split())
        fl[a-1].append(b-1)
        fl[b-1].append(a-1)
    for i in range(k):
        c,d = map(int,ipt().split())
        bl[c-1].add(d-1)
        bl[d-1].add(c-1)

    ans = [-1]*n
    al = [True]*n
    for i in range(n):
        if al[i]:
            q = [i]
            al[i] = False
            st = set([i])
            while q:
                qi = q.pop()
                for j in fl[qi]:
                    if al[j]:
                        st.add(j)
                        al[j] = False
                        q.append(j)
            lst = len(st)
            for j in st:
                tmp = lst-len(fl[j])-1
                for k in bl[j]:
                    if k in st:
                        tmp -= 1
                ans[j] = tmp

    print(" ".join(map(str,ans)))


    return None

if __name__ == '__main__':
    main()
MOD = 10**9 + 7

def prod(a):
    res = 1
    for x in a:
        res = (res * x) % MOD
    return res

def solve(n, k, a):
    if k == 1:
        return max(a)
    elif k == n:
        return prod(a)
    elif max(a) < 0:
        a = sorted(a, reverse=True)
        return prod(a[:k])
    else:
        a = sorted(a, key=lambda x: -abs(x))
        num_negative = len(list(filter(lambda x: x < 0, a[:k])))
        if num_negative % 2 == 0:
            return prod(a[:k])
        else:
            i1, j1 = None, None
            for i in range(k):
                if a[i] < 0:
                    i1 = i
            for j in range(k,n):
                if a[j] >= 0:
                    j1 = j
                    break
            i2, j2 = None, None
            for i in range(k):
                if a[i] >= 0:
                    i2 = i
            for j in range(k, n):
                if a[j] < 0:
                    j2 = j
                    break
            if (i1 is None) or (j1 is None):
                return prod(a[:i2] + a[i2+1:k] + [a[j2]])
            elif (i2 is None) or (j2 is None):
                return prod(a[:i1] + a[i1+1:k] + [a[j1]])
            elif (i1 is None) or (j1 is None) or (i2 is None) or (j2 is None):
                return prod(a[:k])
            elif abs(a[j1] * a[i2]) > abs(a[i1] * b[j2]):
                return prod(a[:i1] + a[i1+1:k] + [a[j1]])
            else:
                return prod(a[:i2] + a[i2+1:k] + [a[j2]])

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

### FIXED CODE ###

MOD = 10**9 + 7

def prod(a):
    res = 1
    for x in a:
        res = (res * x) % MOD
    return res

def solve(n, k, a):
    if k == 1:
        return max(a)
    elif k == n:
        return prod(a)
    elif (max(a) < 0) and (k % 2 == 1):
        a = sorted(a, reverse=True)
        return prod(a[:k])
    else:
        a = sorted(a, key=lambda x: -abs(x))
        num_negative = len(list(filter(lambda x: x < 0, a[:k])))
        if num_negative % 2 == 0:
            return prod(a[:k])
        else:
            i1, j1 = None, None
            for i in range(k):
                if a[i] < 0:
                    i1 = i
            for j in range(k,n):
                if a[j] >= 0:
                    j1 = j
                    break
            i2, j2 = None, None
            for i in range(k):
                if a[i] >= 0:
                    i2 = i
            for j in range(k, n):
                if a[j] < 0:
                    j2 = j
                    break
            if ((i1 is None) or (j1 is None)) and ((i2 is None) or (j2 is None)):
                return prod(a[:k])
            elif (i1 is None) or (j1 is None):
                return prod(a[:i2] + a[i2+1:k] + [a[j2]])
            elif (i2 is None) or (j2 is None):
                return prod(a[:i1] + a[i1+1:k] + [a[j1]])
            elif abs(a[j1] * a[i2]) > abs(a[i1] * a[j2]):
                return prod(a[:i1] + a[i1+1:k] + [a[j1]])
            else:
                return prod(a[:i2] + a[i2+1:k] + [a[j2]])

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, k, a))
N, X = map(int, input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
from math import gcd
from functools import reduce
def lcm(a, b):
    return a*b//gcd(a, b)
l = [x[i+1] - x[i] for i in range(N)]
print(reduce(lcm, l))

### FIXED CODE ###

from functools import reduce
from fractions import gcd
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]
print(reduce(gcd, x))
n = int(input())
v = list(map(int, input().split()))

evenv, oddv = Counter(v[0::2]).most_common(), Counter(v[1::2]).most_common()
ans = 0
if evenv == oddv and len(evenv) == 1:
    ans = n // 2
elif evenv[0][0] == oddv[0][0]:
    ans = n - max(evenv[0][1] + oddv[1][1], evenv[1][1] + oddv[0][1])
else:
    ans = n - evenv[0][1] - oddv[0][1]
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
v = list(map(int, input().split()))

evenv, oddv = Counter(v[0::2]).most_common(), Counter(v[1::2]).most_common()
ans = 0
if evenv == oddv and len(evenv) == 1:
    ans = n // 2
elif evenv[0][0] == oddv[0][0]:
    ans = n - max(evenv[0][1] + oddv[1][1], evenv[1][1] + oddv[0][1])
else:
    ans = n - evenv[0][1] - oddv[0][1]
print(ans)
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
count1 = 0
count2 = 0

A_new = sorted(A)
B_new = sorted(B)
 
for i in range(N):
    if B_new[i] >= A_new[i]:
        count2 += 1
 
for i in range(N):
    for j in range(N):
        if A[i] == A_new[j] and B[i] == B_new[j] 
            count1 = 1
            break
        if A[i] == A_new[j] and B[i] < B_new[j]
            break
    if count1 == 1:
        break
 
if count1 == 1 and count2 == N:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())

if N%2 == 0:
    print(int(N/2)-1)
else:
    print(int(N//2))
N = int(f.input())
count = 0

for i in range(len(str(N))):
    for j in range(3 * (10**i), 4 * (10**i)):
        if j > N:
            break
        if '0' not in str(j) and '1' not in str(j) and '2' not in str(j) and '4' not in str(j) and '6' not in str(
                j) and '8' not in str(j) and '9' not in str(j) and('7' in str(j) and '5' in str(j) and '3' in str(j)):
            print(j)
            count += 1
    for j in range(5 * (10**i), 6 * (10**i)):
        if j > N:
            break

        if '0' not in str(j) and '1' not in str(j) and '2' not in str(j) and '4' not in str(j) and '6' not in str(
                j) and '8' not in str(j) and '9' not in str(j) and('7' in str(j) and '5' in str(j) and '3' in str(j)):
            print(j)
            count += 1

    for j in range(7 * (10**i), 8 * (10**i)):
        if j > N:
            break
        if '0' not in str(j) and '1' not in str(j) and '2' not in str(j) and '4' not in str(j) and '6' not in str(
                j) and '8' not in str(j) and '9' not in str(j) and('7' in str(j) and '5' in str(j) and '3' in str(j)):
            print(j)
            count += 1
    else:
        continue
    break

print(count)




### FIXED CODE ###

import itertools
N = int(input())
count = 0
for i in range(3, len(str(N)) + 1):
    for j in itertools.product('753', repeat=i):
        if int(''.join(j)) <= N and '3' in str(j) and '5'in str(j) and '7' in str(j):
            count += 1

print(count)
N = int(input())
S = input()

ans = 0
str_list = list(S)

for i in range (len(str_list)-2):
  if(str_list[i] == "A"):
    ans = ans
    if(str_list[i+1] == "B"):
      ans = ans
      if(str[i+2] == "C"):
        ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
S = input()

ans = 0
str_list = list(S)

for i in range (len(str_list)-2):
  if(str_list[i] == "A"):
    if(str_list[i+1] == "B"):
      if(str_list[i+2] == "C"):
        ans += 1

print(ans)
def calc_exp(x):
    return (int(x) + 1)/2

NK = input().split()
N, K = int(NK[0]), int(NK[1])
#lis_p = list(map(lambda x: int(x), input().split()))
lis_exp = list(map(calc_exp, input().split()))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

### FIXED CODE ###

N = int(input())
lisA = [int(i) for i in input().split()]
if len(set(lisA)) == len(lisA):
    print('YES')
else :
    print('NO')
from itertools import accumulate

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

def solve():
    cnt=0
    l=[]
    prev = "1"
    for i in s:
        if prev ==i:
            cnt += 1
        else:
            l.append(cnt)
            cnt = 1
        prev =i
    l.append(cnt)
    if prev=="0":
        l.append("0")

    w = 2 * k + 1

    if len(l) <=w:
        return n

    acc=[0]+list(accumulate(l))
    ans = 0
    for i in range(0,len(l) - w+ 1,2):
        ans = max(ans, acc[i+w] - acc[i])

    return ans
print(solve())


### FIXED CODE ###

from itertools import accumulate

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


def solve():
    l = []
    prev = '1'
    cnt = 0
    for c in s:
        if prev == c:
            cnt += 1
        else:
            l.append(cnt)
            cnt = 1
        prev = c
    l.append(cnt)
    if prev == '0':
        l.append(0)

    w = 2 * k + 1

    if len(l) <= w:
        return n

    acc = [0] + list(accumulate(l))
    ans = 0
    for i in range(0, len(l) - w + 1, 2):
        ans = max(ans, acc[i + w] - acc[i])
    return ans


print(solve())
M=2019
a,i,*d=[0]*M
p=1
for j in input():d[i%M]+=1;i+=int(j)*p;a+=d[i%M];p=p*202%M
print(a)

### FIXED CODE ###

a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)
a,b,c,d = input().split(" ")
init = max(a,c)
term = min(b,d)
if term-init <= 0 and :
  print "0"
else:
  print (term-init)

### FIXED CODE ###

a,b,c,d = map(int, raw_input().split())
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)
N = int(input())
line = input()
x = 0
t = 0
for i in range(N):
  if line[i] == 'I':
    t += 1
  else if line[i] == 'D':
    t -= 1
  x = max(t,x)
print(x)

### FIXED CODE ###

N = int(input())
line = input()
x = 0
t = 0
for i in range(N):
  if line[i] == 'I':
    t += 1
  elif line[i] == 'D':
    t -= 1
  x = max(t,x)
print(x)
#!/usr/bin/env python
from itertools import chain
H, W = map(int, input().split())
A_raw = [[int(i) for i in input().split()] for j in range(H)]

c = 1
A = []
d = {}
for h in range(H):
    if h % 2 == 0:
        A.append(A_raw[h])
        d.update(zip(range(c, c + W), [(h+1, w) for w in range(1, W+1)]))
    else:
        A.append(A_raw[h][::-1])
        d.update(zip(range(c, c + W), [(h+1, w) for w in range(1, W+1)[::-1]]))
    c += W
A = list(chain.from_iterable(A))

c = 0
ans = []
for i in range(len(A)-1):
    if A[i] % 2 == 1:
        A[i+1] += 1
        A[i] -= 1
        c += 1
        ans.append([*d[i+1], *d[i+2]])
print(c)
for x in ans:
    print(*x)


### FIXED CODE ###

#!/usr/bin/env python
H, W = map(int, input().split())
A_raw = [[int(i) for i in input().split()] for j in range(H)]

c = 1
A = []
d = {}
for h in range(H):
    if h % 2 == 0:
        for a in A_raw[h]:
            A.append(a)
        d.update(zip(range(c, c + W), [(h+1, w) for w in range(1, W+1)]))
    else:
        for a in A_raw[h][::-1]:
            A.append(a)
        d.update(zip(range(c, c + W), [(h+1, w) for w in range(1, W+1)[::-1]]))
    c += W

c = 0
ans = []
for i in range(len(A)-1):
    if A[i] % 2 == 1:
        A[i+1] += 1
        A[i] -= 1
        c += 1
        ans.append([d[i+1], d[i+2]])
print(c)
for x in ans:
    print(x[0][0], x[0][1], x[1][0], x[1][1])