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

from itertools import groupby
N, K = [int(s) for s in input().split(' ')]
S = input()
ss = []
subs = S[0]
for s in S[1:]:
    if subs[-1] != s:
        ss.append(subs)
        subs = s
        continue
    subs += s
ss.append(subs)
ssc = [len(s) for s in ss]
#print(ss)
max_c = 0
for i in range(len(ss)):
    k = (K * 2 + 1) if ss[i][0] == '1' else (K * 2)
    l = i
    r = min(i + k, len(ss))
    c = sum(ssc[l:r])
    max_c = max(max_c, c)

print(max_c)


### FIXED CODE ###

N, K = [int(s) for s in input().split(' ')]
S = input()
ss = []
ssc = []
subs = S[0]
for s in S[1:]:
    if subs[-1] != s:
        ss.append(subs)
        ssc.append(len(subs))
        subs = s
        continue
    subs += s
ss.append(subs)
ssc.append(len(subs))
suma = [0]
for sc in ssc:
    suma.append(suma[-1] + sc)

#print(ss)
max_c = 0
for i in range(len(ss)):
    k = (K * 2 + 1) if ss[i][0] == '1' else (K * 2)
    l = i
    r = min(i + k, len(ss))
    c = suma[r] - suma[l]
    max_c = max(max_c, c)

print(max_c)
### BUGGY CODE ###

import sys

n, k = map(int, input().split())
s = [int(s) for s in list(input())]
count = 0
tmp = 1
c = []
ans = 0

for i in s:
    if i == tmp:
        count += 1
    else:
        c.append(count)
        tmp = i
        count = 1

c.append(count)
if s[-1] == 0:
    c.append(0)

# kが十分大きいなら
if len(c) <= 2*k+1:
    print(sum(c))
    sys.exit()
# TLEしたから尺取りにしたい
for i in range(0, len(c)-2*k, 2):
    ans = max(ans, sum(c[i:i+2*k+1]))

print(ans)


### FIXED CODE ###

import sys

n, k = map(int, input().split())
s = [int(s) for s in list(input())]
count = 0
tmp = 1
c = []
ans = 0

for i in s:
    if i == tmp:
        count += 1
    else:
        c.append(count)
        tmp = i
        count = 1

c.append(count)
if s[-1] == 0:
    c.append(0)

# kが十分大きいなら
if len(c) <= 2*k+1:
    print(sum(c))
    sys.exit()
# TLEしたから尺取りにしたい
# for i in range(0, len(c)-2*k, 2):
#     ans = max(ans, sum(c[i:i+2*k+1]))
ans = total = sum(c[:2*k+1])
for i in range(0, len(c)-2*k-2, 2):
    total = total + c[i+2*k+1] + c[i+2*k+2] - c[i] - c[i+1]
    ans = max(ans, total)

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

import numpy as np
n,*a=map(int,open(0).read().split())
a.sort()
a=np.array(a)
i = 0
while len(a):
    try:
        if a[0] != a[1]:
            i+=1
    except:
      i+=1
    a = a[a%a[0] != 0]
print(i)

### FIXED CODE ###

_,*a = map(int, open(0).read().split())
a.sort()
m = -~a[-1]
c = [0]*m
for i in a:
    c[i] += 1
    if c[i] > 1:
        continue
    for j in range(i * 2, m, i):
        c[j] = 2
print(sum(c[i]==1for i in a))
### BUGGY CODE ###

from itertools import accumulate
R, C, K = map(int, input().split())
vss = [[None]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    vss[r-1][c-1] = v

dp = [[[0]*4 for __ in range(C)] for _ in range(R)]

for y in range(R):
    for x in range(C):
        uemax = 0
        if y > 0:
            uemax = max(dp[y-1][x])
        if vss[y][x] is None:
            if x > 0:
                dp[y][x][0] = max(dp[y][x-1][0], uemax)
                dp[y][x][1] = dp[y][x-1][1]
                dp[y][x][2] = dp[y][x-1][2]
                dp[y][x][3] = dp[y][x-1][3]
            else:
                dp[y][x][0] = uemax
                dp[y][x][1] = 0
                dp[y][x][2] = 0
                dp[y][x][3] = 0
        else:
            v = vss[y][x]
            if x > 0:
                dp[y][x][0] = max(dp[y][x-1][0], uemax)
                dp[y][x][1] = max(dp[y][x-1][0]+v, dp[y][x-1][1], uemax+v)
                dp[y][x][2] = max(dp[y][x-1][1]+v, dp[y][x-1][2])
                dp[y][x][3] = max(dp[y][x-1][2]+v, dp[y][x-1][3])
            else:
                dp[y][x][0] = uemax
                dp[y][x][1] = uemax + v
                dp[y][x][2] = 0
                dp[y][x][3] = 0

print(max(dp[R-1][C-1]))


### FIXED CODE ###

from itertools import accumulate
R, C, K = map(int, input().split())
vss = [[None]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    vss[r-1][c-1] = v

dp = []

for y in range(R):
    ndp = []
    for x in range(C):
        tmp = []
        uemax = 0
        if y > 0:
            uemax = max(dp[x])
        if vss[y][x] is None:
            if x > 0:
                left = ndp[-1]
                tmp.append(left[0] if left[0] > uemax else uemax)
                tmp.append(left[1])
                tmp.append(left[2])
                tmp.append(left[3])
            else:
                tmp.append(uemax)
                tmp.append(0)
                tmp.append(0)
                tmp.append(0)
        else:
            v = vss[y][x]
            if x > 0:
                left = ndp[-1]
                tmp.append(left[0] if left[0] > uemax else uemax)
                tmp.append(max(left[0]+v, left[1], uemax+v))
                tmp.append(left[1]+v if left[1]+v > left[2] else left[2])
                tmp.append(left[2]+v if left[2]+v > left[3] else left[3])
            else:
                tmp.append(uemax)
                tmp.append(uemax + v)
                tmp.append(0)
                tmp.append(0)
        ndp.append(tmp)
    dp = ndp

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

K,S = map(int,input().split())

cnt = []
for a in range(K+1):
  for b in range(K+1):
    if S-a-b>=0 and S-a-b<=K:
      cnt.append(S-a-b)
        
print(len(cnt))  

### FIXED CODE ###

K,S = map(int,input().split())

cnt = 0
for a in range(K+1):
  for b in range(K+1):
    if S-a-b>=0 and S-a-b<=K:
      cnt += 1
        
print(cnt)
### BUGGY CODE ###

N=int(input())
s_li=[input() for i in range(N)]
ans=0
while(len(s_li)!=0):
    youso=s_li[0]
    s_li=[s for s in s_li if s != youso]
    ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
s_li=[input() for i in range(N)]
print(len(set(s_li)))
### BUGGY CODE ###

import sys
# A,B,C = [int(n) for n in input().split()]
N,K = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
bucket = [0]*(N+1)
A = [int(n) for n in input().split()]
s = set(A)
for a in A:
    bucket[a]+=1
bucket = [n for n in bucket if n != 0]
rc = len(s) - K
ans = 0
for r in range(rc):
    tminid = bucket.index(min(bucket))
    ans += bucket[tminid]
    bucket[tminid]=200006
print(ans if ans >=0 else 0)


### FIXED CODE ###

import sys
# A,B,C = [int(n) for n in input().split()]
N,K = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
bucket = [0]*(N+1)
A = [int(n) for n in input().split()]
dic = {}
for a in A:
    if not(a in dic):
        dic[a]=1
    else:
        dic[a]+=1
val = sorted(dic.values())
# print(val)
rc = len(val) - K
ans = 0
for r in range(rc):
    ans += val[r]
print(ans if ans >=0 else 0)
### BUGGY CODE ###

import math
s = int(input())
r = 0
while s > r**2:
    r += 1
k = r**2 - s
def search_prime(k):
    prime = 1
    k = math.floor(math.sqrt(k))
    for i in range(2,k + 1):
        for j in range(2,i):
            if i % j == 0:
                return prime
    return prime
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))

### FIXED CODE ###

import math
s = int(input())
r = math.floor(math.sqrt(s)) + 1
k = r**2 - s
if r == 10**9 + 1:
    print("{} {} {} {} {} {}".format(0, 0, 1,r - 1,r - 1, 0))
    exit()
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))
### BUGGY CODE ###

import sys
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T = sorted(T, reverse=True)
for i in range(1, 10**18//T[0] + 1):
    f = True
    for n in T[1:]:
        if i*T[0] % n != 0:
            f = False
            break
    if f:
        print(i*T[0])
        sys.exit()

### FIXED CODE ###

def gcd(a, b):
    """最大公約数(Greatest Common divisor)を求める.

    ユークリッドの互除法の実装.
    ああああ

    Parameters
    ----------
    a : int
        自然数.
    b : int
        自然数.

    Returns
    -------
    int
        最大公約数
    """
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    """最小公約数(least common multiple)を求める.

    Parameters
    ----------
    a : int
        自然数.
    b : int
        自然数.

    Returns
    -------
    int
        最小公倍数
    """
    return a * b // gcd(a, b)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
ans = 1
for t in T:
    ans = lcm(ans, t)
print(ans)
### BUGGY CODE ###

def main():
  n = int(input())
  l = []
  for i in range(n):
    l.append(input())
  for i in range(n):
    l[i] = ''.join(sorted(l[i]))
  l.sort()
  
  fact = [1 for i in range(n+1)]
  for i in range(1, n+1):
    fact[i] = fact[i-1]*i
  
  res = 0
  count = 1
  for i in range(1,n):
    if l[i-1] == l[i]:
      count += 1
      if i == n-1:
        res += int(fact[count]/(fact[count - 2]*fact[2]))
    elif count > 1:
      res += int(fact[count]/(fact[count - 2]*fact[2]))
      count = 1
    elif count == 1:
      pass
    else:
      print('error!')
      quit()
  
  print(res)
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

def main():
  n = int(input())
  l = []
  d = {}
  res = 0
  for i in range(n):
    s = input()
    l.append(''.join(sorted(s)))
  for j in range(n):
    if d.get(l[j]) is None:
      d[l[j]] = 1
    elif d.get(l[j]) > 0:
      d[l[j]] += 1
      res += d[l[j]] - 1
    else:
      print('error!')
      quit()
  
  return res
  
if __name__ == "__main__":
  res = main()
  print(res)
### BUGGY CODE ###

S = input()
Q = int(input())

for i in range(0, Q):
    query = input().split()
    if int(query[0]) == 1:
        S = S[::-1]
    else:
        if int(query[1]) == 1:
            S = query[2] + S
        else:
            S = S + query[2]

print(S)


### FIXED CODE ###

S = input()
Q = int(input())
is_norm = True  # Sが元の順番かどうか
s_head = ""     # 元のSに対して先頭側につく文字列
s_tail = ""     # 元のSに対して末尾側につく文字列

for i in range(0, Q):
    query = input().split()
    if int(query[0]) == 1:
        is_norm = not is_norm
    else:
        if is_norm:
            if int(query[1]) == 1:
                s_head = query[2] + s_head
            else:
                s_tail = s_tail + query[2]
        else:
            if int(query[1]) == 1:
                s_tail = s_tail + query[2]
            else:
                s_head = query[2] + s_head

if is_norm:
    print(s_head + S + s_tail)
else:
    print(s_tail[::-1] + S[::-1] + s_head[::-1])
### BUGGY CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = sorted(list(map(int,input().split())))
    dp = [0]*(max(a)+1)
    for i in range(n):
        if dp[a[i]] != 0:
            dp[a[i]] = 2
            continue
        for j in range(a[i],max(a)+1,a[i]):
            dp[j]+=1
    cnt = 0
    for i in range(n):
        if dp[a[i]] == 1:
            cnt+=1
    print(cnt)

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = sorted(list(map(int,input().split())))
    M = 1000005
    dp = [0]*(M)
    for i in range(n):
        if dp[a[i]] != 0:
            dp[a[i]] = 2
            continue
        for j in range(a[i],M,a[i]):
            dp[j]+=1
    cnt = 0
    for i in range(n):
        if dp[a[i]] == 1:
            cnt+=1
    print(cnt)
### BUGGY CODE ###

# C問題 20分で最長の長さの道の含むノードの数Nに対して
# N%3 == 2ならS, それ以外でFであることまでわかった。
# !!直径rでいうとr%3 ==1 ならS
# しかし、longest path problemはNP hardとか言われた... 
# けど、treeであることを考慮に入れて再検索すると行けた。
# ググり力 = 関連ワードを色々入れて試す力 & 関係なさそうなテーマから早く撤退する

# 木の直径というらしい
# 木DP or 適当に初期点W　→ Wからの最遠点U　→ Uからの最遠点V でUとVの距離でわかるらしい。

N = int(input())
#各頂点が繋がってる辺リスト
E = [ [] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

# #入力1
# N= 3
# E= [[1], [0, 2], [1]]

# #　入力2
# N= 6
# E= [[1], [0, 2, 3], [1], [1, 5], [5], [3, 4]]

# #　入力3
# N= 7
# E= [[6, 1], [0], [3, 5], [6, 2], [6], [2], [0, 3, 4]]


    
def farthest(s):
    visited = []
    stack = [[s,0]]
    best = [s,0]
    while len(stack)>0:
#         print("visited:",visited)
#         print("stack:",stack)
        current = stack.pop()#pop(-1)と同じ
        currentPosition = current[0] 
        currentLength = current[1]
        # bestの更新
        if currentLength > best[1]:
            best = [currentPosition, currentLength]
        visited.append(currentPosition)
        # 繋がっているノードのうち未探索の場所を追加
        for position in E[currentPosition]:
            if position not in visited:
                stack.append([position, currentLength+1])
    return best

# print("u,length:",farthest(0))
u = farthest(0)[0]
best = farthest(u)
# print(best)
# v = best[0]
diameter = best[1]
# print(diameter)
ans = "First"
if diameter % 3 == 1:
    ans = "Second"
print(ans)

### FIXED CODE ###

# カンニングして修正
N = int(input())
#各頂点が繋がってる辺リスト
E = [ [] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

# #入力1
# N= 3
# E= [[1], [0, 2], [1]]

# #　入力2
# N= 6
# E= [[1], [0, 2, 3], [1], [1, 5], [5], [3, 4]]

# #　入力3
# N= 7
# E= [[6, 1], [0], [3, 5], [6, 2], [6], [2], [0, 3, 4]]


    
def farthest(s):
    visited = [False]*N
    stack = [[s,0]]
    best = [s,0]
    while len(stack)>0:
#         print("visited:",visited)
#         print("stack:",stack)
        current = stack.pop()#pop(-1)と同じ
        currentPosition = current[0] 
        currentLength = current[1]
        visited[currentPosition] = True
        # bestの更新
        if currentLength > best[1]:
            best = [currentPosition, currentLength]
        visited.append(currentPosition)
        # 繋がっているノードのうち未探索の場所を追加
        for position in E[currentPosition]:
            if not visited[position]:
                stack.append([position, currentLength+1])
    return best

# print("u,length:",farthest(0))
u = farthest(0)[0]
best = farthest(u)
# print(best)
# v = best[0]
diameter = best[1]
# print(diameter)
ans = "First"
if diameter % 3 == 1:
    ans = "Second"
print(ans)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if j in checked:
            continue
        xj = xs[j]
        if xj is None:
            xs[j] = xi + d
        elif xi + d != xj:
            return False
        children.add(j)
    checked.add(i)
    for j in children:
        if j in checked:
            continue
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = set()
    for i in range(n):
        if i not in checked:
            xs = [None] * n
            xs[i] = 0
            res = check(i, xs, checked)
            if not res:
                return False
            xf = [x for x in xs if x is not None]
            mn, mx = min(xf), max(xf)
            if mx - mn > 1e9:
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')


### FIXED CODE ###

import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if checked[j]:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked[i] = True
    for j in children:
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            res = check(i, xs, checked)
            if not res:
                return False
            mn, mx = min(xs.values()), max(xs.values())
            if mx - mn > 1e9:
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')
### BUGGY CODE ###

import math

from itertools import accumulate

def cumsum(a):
    return list(accumulate(a))

n,k = map(int, input().split())
if n == 1:
    print(1)
    exit()
mod = 10 ** 9 + 7
now = n
big = []
for i in range(2,int(math.sqrt(n)+2)):
    d = n // i
    big.append(now - d)
    now = d
big.reverse()
l = [1] * d + big
l2 = [1] * d + big
for i in range(k-1):
    a = cumsum(l)
    a.reverse()
    count = 0
    for i,j in zip(a,l2):
        l[count] = (i * j) % mod
        count += 1
l = cumsum(l)
ans = l[-1] % mod
print(ans)
    

### FIXED CODE ###

import math

from itertools import accumulate

def cumsum(a):
    return list(accumulate(a))

n,k = map(int, input().split())
if n == 1:
    print(1)
    exit()
mod = 10 ** 9 + 7
now = n
big = []
for i in range(2,int(math.sqrt(n)+2)):
    d = n // i
    big.append(now - d)
    now = d
big.reverse()
l = [1] * d + big
l2 = [1] * d + big
for i in range(k-1):
    a = cumsum(l)
    a.reverse()
    count = 0
    for i,j in zip(a,l2):
        l[count] = (i * j) % mod
        count += 1
l = cumsum(l)
ans = l[-1] % mod
print(ans)
### BUGGY CODE ###

n, y = map(int, input().split())
y = y/1000
answer= []

for rep1 in range(n + 1):
    for rep2 in range(n + 1):
        for rep3 in range(n + 1):
            if rep1 + rep2 + rep3 == n and rep1 * 10 + rep2 * 5 + rep3 == y:
                answer = [rep1,rep2, rep3]
                break

print(answer[0], answer[1], answer[2]) if answer != [] else print("-1 -1 -1")


### FIXED CODE ###

n, y = map(int, input().split())
y = y/1000
answer= []

for ten in range(n + 1):
    for five in range(n + 1 - ten):
        one = n - ten - five
        if ten * 10 + five * 5 + one == y:
            answer = [ten, five, one]
            break

print(answer[0], answer[1], answer[2]) if answer != [] else print("-1 -1 -1")
### BUGGY CODE ###

n = int(input())
ls = []
for i in range(n):
  ls.append(int(input()) - 1)
used = []
x = 0
count = 0
while (x != 1):
  used.append(x)
  x = ls[x]
  count += 1
  if (x in used):
    count = -1
    break
print(count)


### FIXED CODE ###

n = int(input())
ls = []
for i in range(n):
  ls.append([int(input())-1,False])
count = 0
x = 0
while (x != 1):
  if ls[x][1]:
    count = -1
    break
  else:
    count += 1
    ls[x][1] = True
    x = ls[x][0]
print(count)
### BUGGY CODE ###

import sys
I = lambda:map(int,sys.stdin.readline().split())
pr = lambda x:sys.stdout.write(f'{x}\n')
sys.setrecursionlimit(2000000001)
ab = abs
n = k = ar = dp = 0

def solve(x):
	global n,k,ar,dp
	if x>=n-2: return dp[x]
	if dp[x] != -1: return dp[x]
	m,i = 1e9, x+1
	while i<n and i<x+k+1:
		t = ab(ar[x]-ar[i])+solve(i)
		m = t if t<m else m
		i+=1
	dp[x] = m
	# pr(f'{x} => {dp[x]}')
	return dp[x]
 
def main():
	global n,ar,k,dp
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [ab(ar[-2]-ar[-1]),0]
	# pr((n,k,ar,dp))
	pr(solve(0))
 
main()

### FIXED CODE ###

import sys
from functools import reduce
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	# t = [ for i in range(x+1,mn(n,x+k+1))]
	t = map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1)))
	dp[x] = reduce(lambda a,b : a if a < b else b,t)
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()
### BUGGY CODE ###


A,B,C,D,E,F = map(int,input().split())

amax = F // (100 * A)
bmax = F // (100 * B)
cmax = F // C
dmax = F // D

ans = 0
summ = 0
suge = 0


for a in range(amax+1):

    for b in range(bmax+1):

        for c in range(cmax+1):

            for d in range(dmax+1):


                if 100*A*a + 100*B*b + C*c + D*d <= F and (A*100*a+B*100*b)*E >= 100*(C*c+D*d):

                    if A*100*a+B*100*b+C*c+D*d !=0 and ans < 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d):

                        ans = 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d)
                        summ = A*100*a+B*100*b+C*c+D*d
                        suge = C*c+D*d

if summ == 0:
    summ = 100*A
print (summ,suge)

### FIXED CODE ###


A,B,C,D,E,F = map(int,input().split())

amax = F // (100 * A)
bmax = F // (100 * B)
cmax = F // C
dmax = F // D

ans = 0
summ = 0
suge = 0


for a in range(amax+1):

    for b in range(bmax+1):

        for c in range(cmax+1):

            for d in range(dmax+1):


                if 100*A*a + 100*B*b + C*c + D*d <= F and (A*100*a+B*100*b)*E >= 100*(C*c+D*d):

                    if A*100*a+B*100*b+C*c+D*d !=0 and ans < 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d):

                        ans = 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d)
                        summ = A*100*a+B*100*b+C*c+D*d
                        suge = C*c+D*d

if summ == 0:
    summ = 100*A
print (summ,suge)
### BUGGY CODE ###

N, M = map(int, input().split())
A_array = list(map(int, input().split()))
BC_array = [list(map(int, input().split())) for _ in range(M)]
BC_array = sorted(BC_array, key=lambda x: -x[1])
B_count = 0
for B, C in BC_array:
    A_array = A_array + [C] * B
    B_count += B
    if B_count >= N:
        break
A_array.sort()
# print(A_array)
print(sum(A_array[-N:]))

### FIXED CODE ###

N, M = map(int, input().split())
A_array = sorted(map(int, input().split()))
BC_array = [list(map(int, input().split())) for _ in range(M)]
BC_array = sorted(BC_array, key=lambda x: x[1])

plus_count = 0
ans = 0
a_index = N - 1
bc_index = M - 1

while plus_count != N:
    if A_array[a_index] <= BC_array[bc_index][1]:
        add_count = min(BC_array[bc_index][0], N - plus_count)
        plus_count += add_count
        ans += (add_count * BC_array[bc_index][1])
        bc_index -= 1
        if bc_index < 0:
            a_rest = N - plus_count
            ans += sum(A_array[a_index - a_rest + 1:a_index + 1])
            break
    else:
        plus_count += 1
        ans += A_array[a_index]
        a_index -= 1
print(ans)
### BUGGY CODE ###

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

ANSWER = []
for i in range(N):
    A_ = []
    for j in range(N):
        if j != i:
            A_.append(A[j])
            
        else: continue
            
    unique_i = list(set(A_))

    answer_i = 0
    for j in unique_i:
        answer_i += (A_.count(j) * (A_.count(j)-1)/2)
    
    ANSWER.append(int(answer_i))

for i in ANSWER:
    print(i)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
import numpy as np
 
N = int(readline())
A = np.array(read().split(), np.int64)
counter = np.bincount(A)
 
total = (counter * (counter - 1)).sum() // 2
answer = (total - (counter - 1))[A]
 
print('\n'.join(answer.astype(str)))
### BUGGY CODE ###

L,R = list(map(int,input().split()))
Y = []
j = 1
for i in range(L, R):
    if i == 0:
        Y.append((i * j) % 2019)
    elif i * j == 2019:
        Y.append([0])
    else:
        for j in range(i+1, R+1):
            Y.append((i * j) % 2019)
print(min(Y))

### FIXED CODE ###

L,R = list(map(int,input().split()))
def main(L,R):
    mod_min = 2019
    if L // mod_min == R // mod_min:
        L %= mod_min
        R %= mod_min
        for i in range(L,R):
            for j in range(i+1, R+1):
                Y = i*j % 2019
                if Y < mod_min:
                    mod_min = Y
    else:
        mod_min = 0
    return mod_min
print(main(L,R))