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

n, bu, re = list(map(int, input().split(" ")))

ttlBu, ttlRe = 0, 0

while True:
    for _ in range(bu):
        if ttlBu + ttlRe == n:
            print(ttlBu)
            exit()
        ttlBu += 1
    for _ in range(re):
        if ttlBu + ttlRe == n:
            print(ttlBu)
            exit()
        ttlRe += 1

### FIXED CODE ###

import math

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

ans = (n // (a + b)) * a
ans += min((n % (a + b)), a)
print(ans)
### BUGGY CODE ###

n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
a=[]
count=[]
buf=1
count_max=1
for i in range(n):
    if s[i]==s[i+1]:
        buf+=1
    else:
        if buf>=count_max:
            a.append(s[i])
            count.append(buf)
            count_max=buf
        buf=1
for i in range(len(a)):
    if count[i]==max(count):
        print(a[i])

### FIXED CODE ###

n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
a=[]
count=[]
buf=1
count_max=1
for i in range(n):
    s_i=s[i]
    if s_i==s[i+1]:
        buf+=1
    else:
        if buf>=count_max:
            a.append(s_i)
            count.append(buf)
            if buf>count_max:
                count_max=buf
        buf=1
count_max=max(count)
for i in range(len(a)):
    if count[i]==count_max:
        print(a[i])
### BUGGY CODE ###

from collections import*
def main():
    (n,),*a=[list(map(int,t.split()))for t in open(0)]
    d={}
    s=0
    es=[]
    for i,b in enumerate(a):
        for j,k in zip(b,b[1:]):
            x,z=sorted((i,j-1))
            x=x*n+z
            y,z=sorted((i,k-1))
            y=y*n+z
            if not x in d:
                d[x]=s
                s+=1
            if not y in d:
                d[y]=s
                s+=1
            es+=(d[x],d[y]),
    e=[[]for _ in range(s)]
    for v1,v2 in es:e[v1]+=v2,
    outs=defaultdict(list)
    ins=defaultdict(int)
    for v1,v2 in es:
        outs[v1].append(v2)
        ins[v2]+=1
    q=deque(v1 for v1 in range(s)if ins[v1]==0)
    res=[]
    while q:
        v1=q.popleft()
        res.append(v1)
        for v2 in outs[v1]:
            ins[v2]-=1
            if ins[v2]==0:
                q.append(v2)
    if len(res)<s:
        print(-1)
        exit()
    data=[1]*s
    for i in res:
        t=data[i]+1
        for j in e[i]:
            if t>data[j]:data[j]=t
    print(max(data))
main()

### FIXED CODE ###

def main():
    from collections import defaultdict,deque
    from itertools import count
    (n,),*a=[list(map(int,t.split()))for t in open(0)]
    d=defaultdict(count().__next__)
    es=[]
    for i,b in enumerate(a,1):
        for j,k in zip(b,b[1:]):
            x,y=i,j
            if y<x:x,y=y,x
            v,w=i,k
            if w<v:v,w=w,v
            es+=(d[x*n+y],d[v*n+w]),
    s=len(d)
    outs=[[]for _ in range(s)]
    ins=[0]*s
    f=set(range(s))
    for i,j in es:
        outs[i]+=j,
        f-={j}
        ins[j]+=1
    q=deque(f)
    r=[]
    data=[0]*s
    m=0
    while q:
        i=q.popleft()
        r+=i,
        t=data[i]+1
        if t>m:m=t
        for j in outs[i]:
            ins[j]-=1
            if ins[j]<1:q+=j,
            if t>data[j]:data[j]=t
    print(-(len(r)<s)or m)
main()
### BUGGY CODE ###

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

for i in range(k):
    if a > 0:
        a -= 1
    else:
        if b > 0:
           b -= 1
print(a, b)


### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b, k = input().split()
a = int(a)
b = int(b)
k = int(k)

a = a -k

if a < 0:
    b = a + b
    a = 0
    if b < 0:
        b = 0

print(a, b)
### BUGGY CODE ###

def p_d():
    S = input()
    N = 13

    dp = [0] * N
    dp[0] = 1

    mul = 1
    mod = 10 ** 9 + 7

    for i in reversed(range(len(S))):
        nextDP = [0] * N
        c = S[i]
        if c == "?":
            for k in range(10):  # 数字[0-9]
                for j in range(N):
                    nextDP[(k * mul + j) % N] += dp[j]
                    nextDP[(k * mul + j) % N] %= mod
        else:
            k = int(c)
            for j in range(N):
                nextDP[(k * mul + j) % N] += dp[j]
                nextDP[(k * mul + j) % N] %= mod
        mul *= 10
        mul %= N
        dp = nextDP

    print(int(dp[5]))


if __name__ == '__main__':
    p_d()


### FIXED CODE ###

def p_d():
    S = input()
    N = 13

    dp = [0] * N
    dp[0] = 1

    mul = 1
    mod = 10 ** 9 + 7

    for i in reversed(range(len(S))):
        nextDP = [0] * N
        c = S[i]
        if c == "?":
            for k in range(10):  # 数字[0-9]
                for j in range(N):
                    nextDP[(k * mul + j) % N] += dp[j]
                    nextDP[(k * mul + j) % N] %= mod
        else:
            k = int(c)
            for j in range(N):
                nextDP[(k * mul + j) % N] += dp[j]
                nextDP[(k * mul + j) % N] %= mod
        mul *= 10
        mul %= N
        dp = nextDP

    print(int(dp[5]))


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

X = int(input())
for i1 in range(1000000):
  for i2 in range(1000000):
    for i3 in range(1000000):
      for i4 in range(1000000):
        for i5 in range(1000000):
          for i6 in range(1000000):
            if 100 * i1 + 101 * i2 + 102 * i3 + 103 * i4 + 104 * i5 + 105 * i6 == X:
              print("1")
            else:
              print("0")
  

### FIXED CODE ###

X = int(input())
a = X // 100
r = X % 100
if r <= 5 * a:
  print("1")
else:
  print("0")
### BUGGY CODE ###

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

ans = s
for i in range(q):
    qret = list(input().split())
    if qret[0] == "1":
        ans = ans[::-1]
    else:
        f = qret[1]
        c = qret[2]
        if f == "1":
            ans = c + ans
        else:
            ans += c

print(ans)


### FIXED CODE ###

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

tcount = 0
rlist = ""
llist = ""

for i in range(q):
    qret = input()
    if qret[0] == "1":
        tcount += 1
        # ans = ans[::-1]
    else:
        f = qret[2]
        c = qret[4]
        if f == "1":
            if tcount % 2 == 0:
                llist = c + llist
            else:
                rlist += c
        else:
            if tcount % 2 == 0:
                rlist += c
            else:
                llist = c + llist

if tcount % 2 == 0:
    print(llist + s + rlist)
else:
    print(rlist[::-1] + s[::-1] + llist[::-1])
### BUGGY CODE ###

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


for i in range(N):
    B=A[0:i]+A[i+1:N]
    ans1=len(set(B))
    ans2=collections.Counter(B)
    ANS=list(ans2.values())
    real_ans=0
    for j in range(ans1):
        real_ans+=(ANS[j]*(ANS[j]-1))//2
    print(real_ans)

### FIXED CODE ###

import collections

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

ans=0
dic=collections.Counter(A)
keys=list(dic.keys())
values=list(dic.values())


for i in values:
    
    ans+=(i*(i-1))//2

for j in A:
    ANS=ans
    num=dic[j]
    ANS=ANS-(num-1)
    print(ANS)
### BUGGY CODE ###

def s():
  n=int(input())
  l=list(map(int,input().split()))
  f=l[0]
  mod=10**9+7
  def gcd(s,d):
    return gcd(d,s%d) if d!=0 else s 
  for i in l:
    f=i*f//gcd(i,f)
  ans=0
  for iu in l:
    ans+=(f//iu)%mod
  print(ans%mod)
  
if __name__=="__main__":s()

### FIXED CODE ###

def s():
  from sys import stdin
  read=stdin.buffer.readline
  n=int(read())
  l=list(map(int,read().split()))
  f=l[0]
  mod=10**9+7
  def gcd(s,d):
    s,d=max(s,d),min(s,d)
    while  d:
      s,d=d,s%d
    return s
  for i in l:
    f=i*f//gcd(i,f)
  ans=0
  for iu in l:
    b,u,v=mod,1,0
    while b:
      t=iu//b;iu,b=b,iu%b;u-=t*v;u,v=v,u
    ans+=(f*u%mod)%mod
    ans%=mod
  print(ans)
  
if __name__=="__main__":s()
### BUGGY CODE ###

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

slaves=[print(a_list.count(i+1)) for i in range(n-1)]
print(0)

### FIXED CODE ###

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

import collections

c = collections.Counter(a_list)
[print(c[i+1]) for i in range(n)]
### BUGGY CODE ###

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

ans = 0
for i in range(N - K + 1):
  x = (sum(p[i : K + i]) + K) / 2
  #print(x)
  ans = max(x, ans)
  
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(N - K + 1):
  if i == 0:
    xe = sum(p[0 : K])
  else:
    xe = xe - p[i - 1] + p[i + K -1]
  x = (xe + K) / 2
  #print(x)
  ans = max(x, ans)
  
print(ans)
### BUGGY CODE ###

from collections import deque

q = deque()
H, W = map(int, input().split())
dists = [[-1] * W for _ in range(H)]
for i in range(H):
    for j, v in enumerate(input()):
        if v == "#":
            q.append((0, i, j))

while len(q):
    d, i, j = q.popleft()
    if not 0 <= i < H or not 0 <= j < W or dists[i][j] != -1:
        continue
    dists[i][j] = d
    q.append((d+1, i-1, j))
    q.append((d+1, i+1, j))
    q.append((d+1, i, j-1))
    q.append((d+1, i, j+1))

ans = max(sum(dists, []))
print(ans)


### FIXED CODE ###

from time import time
from collections import deque

# reduce q.append()
# (constant-factor optimization)


def append(d, i, j):
    if not 0 <= i < H or not 0 <= j < W or dists[i][j] != -1:
        return
    dists[i][j] = d
    q.append((d, i, j))


q = deque()
H, W = map(int, input().split())
dists = [[-1] * W for _ in range(H)]
for i in range(H):
    for j, v in enumerate(input()):
        if v == "#":
            append(0, i, j)

while len(q):
    d, i, j = q.popleft()
    append(d+1, i-1, j)
    append(d+1, i+1, j)
    append(d+1, i, j-1)
    append(d+1, i, j+1)

# fast (0.01s)
ans = max(map(max, dists))
# very slow (4.2s)
# ans = max(sum(dists, []))

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

import collections
n,m=map(int,input().split())
A=[]
for i in range(n):
  A.append([int(_) for _ in input().split()])
D=dict()
for i in range(m):
  D[i+1]=1
ans=n
for _ in range(m):
  p=[]
  for i in range(n):
    for j in range(m):
      if D[A[i][j]]==1:
        p.append(A[i][j])
        break
  pp=collections.Counter(p).most_common()
  a,b=pp[0]
  ans=min(ans,b)
  D[a]=0
print(ans)

### FIXED CODE ###

import collections
n,m=map(int,input().split())
A=[]
for i in range(n):
  A.append([int(_) for _ in input().split()])
D=dict()
for i in range(m):
  D[i+1]=1
ans=n
for _ in range(m):
  p=[]
  for i in range(n):
    for j in range(m):
      if D[A[i][j]]==1:
        p.append(A[i][j])
        break
  pp=collections.Counter(p).most_common()
  a,b=pp[0]
  ans=min(ans,b)
  D[a]=0
print(ans)
### BUGGY CODE ###

import math
k = int(input())

ans = 0
for i in range(1, k + 1):
    for x in range(1, k + 1):
        for z in range(1, k + 1):
            ans += math.gcd(i, math.gcd(x, z))
print(ans)

### FIXED CODE ###

from math import gcd
k = int(input())

ans = 0
for i in range(1, k + 1):
    for x in range(1, k + 1):
        gcdix = gcd(i, x)
        for z in range(1, k + 1):
            ans += gcd(z, gcdix)
print(ans)
### BUGGY CODE ###

n = int(input())
t = []
for i in range(n):
  t.append(int(input()))
max = max(t)
base = max
count = 0
x = 1
while not count == n:
  base = max*x
  count = 0
  for i in t:
    if base % i == 0:
      count += 1
  
  x += 1

print(max*(x-1))

### FIXED CODE ###

from fractions import gcd
from functools import reduce

n = int(input())
nums = [int(input()) for i in range(n)]


def lcm_base(x, y):
  return (x * y) // gcd(x, y)

def lcm(nums):
  return reduce(lcm_base, nums, 1)

print(lcm(nums))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    A.sort()                    # 昇順 O(NlongN)
    BC = list(zip(B, C))
    BC.sort(key=lambda x: x[1], reverse=True)  # 降順 MlogM
    Cs = []
    for b, c in BC:             # M
        Cs.extend([c]*b)

    s = 0
    for i, (a, c) in enumerate(zip(A, Cs)):  # N
        if a >= c:
            s += a
            break
        s += max(a, c)
    if i < len(A)-1:
        for j in range(i+1, len(A)):
            s += A[j]
    print(s)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    A.sort()                    # 昇順 O(NlongN)
    BC = list(zip(B, C))
    BC.sort(key=lambda x: x[1])  # 昇順 MlogM

    s = 0
    Cs = []
    for i, a in enumerate(A):
        if len(Cs) == 0:
            if len(BC) == 0:
                s += sum(A[i:])
                break
            b, c = BC.pop(-1)
            Cs.extend([c]*b)
        s += max(Cs.pop(), a)
    print(s)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)


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

N = int(input())
temp = list(map(int, input().split()))
ans = []
for i in range(N):
  for j in range(N):
    if(temp[j]==i+1):
      print(j+1, end=" ")

### FIXED CODE ###

N = int(input())
temp = list(map(int, input().split()))
b = {}
for i in range(N):
  b[temp[i]] = i+1
c = sorted(b.items(), key=lambda x:x[0])
for i in range(N):
  print(c[i][1], end=" ")
### BUGGY CODE ###

n,m = map(int,input().split())
d = dict()
p = [0]*m
y = [0]*m
for i in range(m):
  p[i], y[i] = map(int,input().split())
  if p[i] in d:
    d[p[i]] = d[p[i]] + [y[i]]
  else:
    d[p[i]] = [y[i]]
for x in d:
  d[x] = sorted(d[x])
  d[x] = dict([[d[x][j],j] for j in range(len(d[x]))])
for i in range(m):
  print("{0:06d}".format(p[i])+"{0:06d}".format(d[p[i]][y[i]]+1))

### FIXED CODE ###

n,m = map(int,input().split())
d = dict()
p = [0]*m
y = [0]*m
c = [0]*m
a = []
for i in range(m):
  p[i], y[i] = map(int,input().split())
  a.append([y[i], i, p[i]])
a.sort()
for x in a:
  if x[2] in d:
    d[x[2]] =  d[x[2]] + 1
  else:
    d[x[2]] = 1
  c[x[1]] = d[x[2]]
for i in range(m):
  print("{0:06d}".format(p[i])+"{0:06d}".format(c[i]))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 20 21:40:30 2018
ABC065D
@author: maezawa
i=0...n (0-origin)
"""
import heapq

n = int(input())
a = []
b = []
for i in range(n): # i is a name of the city (0-origin)
    xy = list(map(int, input().split()))
    a.append([i,xy[0]])
    b.append([i,xy[1]])

a.sort(key=lambda x: x[1])
b.sort(key=lambda x: x[1])
#print(a) 
#print(b)

# making adj list
adj = [[] for _ in range(n)]
for i in range(len(a)-1):
    adj[a[i][0]].append([a[i+1][1]-a[i][1], a[i+1][0]])
    adj[a[i+1][0]].append([a[i+1][1]-a[i][1], a[i][0]])
for i in range(len(b)-1):
    adj[b[i][0]].append([b[i+1][1]-b[i][1], b[i+1][0]])
    adj[b[i+1][0]].append([b[i+1][1]-b[i][1], b[i][0]])

#print(adj)
    
# Prim's algorithm
d = [10**10]*n
visited = [False]*n
h = []
s = 0
heapq.heappush(h, [0, s])
cnt = 0
while h:
    cost, node = heapq.heappop(h)
    if visited[node] != True and cost < d[node]:
        d[node] = cost
        visited[node] = True
        cnt += 1
        if cnt == n:
            break
        for edge in adj[node]:
            if visited[edge[1]] == True:
                continue
            heapq.heappush(h, edge)
            
#print(d)
print(sum(d))
        


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 20 21:40:30 2018
ABC065D
@author: maezawa
i=0...n (0-origin)
"""
import heapq
import sys
input = sys.stdin.readline

n = int(input())
a = [[] for _ in range(n)]
b = [[] for _ in range(n)]
for i in range(n): # i is a name of the city (0-origin)
    xy = list(map(int, input().split()))
    a[i]=[xy[0],i]
    b[i]=[xy[1],i]

a.sort()
b.sort()
#print(a) 
#print(b)

# making adj list
adj = [[] for _ in range(n)]
for [x0, j0], [x1, j1]  in zip(a, a[1:]):
    adj[j0].append([x1-x0, j1])
    adj[j1].append([x1-x0, j0])
for [y0, j0], [y1, j1] in zip(b, b[1:]):
    adj[j0].append([y1-y0, j1])
    adj[j1].append([y1-y0, j0])

#print(adj)
    
# Prim's algorithm
#d = [10**10]*n
visited = [False]*n
h = []
s = 0
heapq.heappush(h, [0, s])
cnt = 0
totalcost = 0 
while h:
    cost, node = heapq.heappop(h)
    #if visited[node] != True and cost < d[node]:
    if visited[node] != True:        
        #d[node] = cost
        visited[node] = True
        totalcost += cost
        cnt += 1
        if cnt == n:
            break
        for edge in adj[node]:
            if visited[edge[1]]:
                continue
            heapq.heappush(h, edge)
            
#print(d)
print(totalcost)
### BUGGY CODE ###

# 2020/07/25
# M-SOLUTIONS プロコンオープン 2020 - C

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

# Calc
pt = a[0]
for i in range(1, n):
    if i <= k - 1:
        pt = pt * a[i]
    else: # i > k - 1
        bef_pt = pt
        pt = pt / a[i-k] * a[i]
        # Output
        if bef_pt < pt:
            print('Yes')
        else:
            print('No')


### FIXED CODE ###

# 2020/07/25
# M-SOLUTIONS プロコンオープン 2020 - C

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

# Calc
for i in range(k, n):
    # Output
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

R = 0
L = tuple()
for i in range(N):
    if i == 0:
        L = (True,) * N
    else:
        L = tuple(L[j] and A[j]^A[i+j] == A[j]+A[i+j] and L[j+1] for j in range(N-i)) + (False,) * i 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

### FIXED CODE ###

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

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)
### BUGGY CODE ###


import itertools

def do():
    N,M,R = list(map(int,input().split(" ")))
    rs = list(map(int,input().split(" ")))
    INF = 10 ** 20
    graph = [ [INF for _ in range(N + 1)]for _ in range(N + 1)]
    for _ in range(M):
        a,b,c = (map(int, input().split(" ")))
        graph[a][b] = c
        graph[b][a] = c
    for k in range(1,N+1):
        for j in range(1, N + 1):
            for i in range(1, N + 1):
                graph[j][i] = min(graph[j][i] , graph[j][k] + graph[k][i])

    perms = itertools.permutations(rs)
    ans = INF
    for temp in perms:
        cand = 0
        for i in range(0,R-1):
            fr = temp[i]
            to = temp[i + 1]
            cand+= graph[fr][to]
        ans = min(cand,ans)
    print(ans)

if __name__ == "__main__":
    do()

### FIXED CODE ###


import itertools

def do():
    N,M,R = list(map(int,input().split(" ")))
    rs = list(map(int,input().split(" ")))
    INF = 10 ** 20
    graph = [ [INF for _ in range(N + 1)]for _ in range(N + 1)]
    for _ in range(M):
        a,b,c = (map(int, input().split(" ")))
        graph[a][b] = c
        graph[b][a] = c
    for k in range(1,N+1):
        for j in range(1, N + 1):
            for i in range(1, N + 1):
                graph[j][i] = min(graph[j][i] , graph[j][k] + graph[k][i])

    perms = itertools.permutations(rs)
    ans = INF
    for temp in perms:
        cand = 0
        for i in range(0,R-1):
            fr = temp[i]
            to = temp[i + 1]
            cand+= graph[fr][to]
        ans = min(cand,ans)
    print(ans)

if __name__ == "__main__":
    do()
### BUGGY CODE ###

n,a,b,c,d,e=[int(input()) for _ in range(6)]
cnt=[n,0,0,0,0,0]
t=0
while cnt[5]!=n:
    c0,c1,c2,c3,c4,c5=cnt[0],cnt[1],cnt[2],cnt[3],cnt[4],cnt[5]
    cnt[0]-=min(a,c0)
    cnt[1]+=min(a,c0)-min(b,c1)
    cnt[2]+=min(b,c1)-min(c,c2)
    cnt[3]+=min(c,c2)-min(d,c3)
    cnt[4]+=min(d,c3)-min(e,c4)
    cnt[5]+=min(e,c4)
    t+=1
print(t)

### FIXED CODE ###

import math
a=[int(input()) for _ in range(6)]
flag=a.index(min(a))
ans=4+math.ceil(a[0]/min(a))
print(ans)
### BUGGY CODE ###

# Problem B - Small and Large Integers

A, B, K = map(int, input().split())

# initialization
num_list = [i for i in range(A,B+1)]


# output process 1
for i in range(K):
    if len(num_list)<=0:
        break
    n = num_list[0]
    print(n)
    num_list.remove(n)

# output process 2
output2_list = []
for i in range(K):
    if len(num_list)<=0:
        break
    n = num_list[-1]
    output2_list.append(n)
    num_list.remove(n)
output2_list = output2_list[::-1]
for o in output2_list:
    print(o)


### FIXED CODE ###

# Problem B - Small and Large Integers

A, B, K = map(int, input().split())

# initialization

if B-A<=2*K:
    num_list = [i for i in range(A,B+1)]
    # output process 1
    for i in range(K):
        if len(num_list)<=0:
            break
        n = num_list[0]
        print(n)
        num_list.remove(n)

    # output process 2
    output_list = []
    for i in range(K):
        if len(num_list)<=0:
            break
        n = num_list[-1]
        output_list.append(n)
        num_list.remove(n)

    output_list = output_list[::-1]

    for o in output_list:
        print(o)
else:
    num_list_1 = [i for i in range(A, A+K+1)]
    num_list_2 = [i for i in range(B-K+1, B+1)]
    # output process 1
    for i in range(K):
        n = num_list_1[i]
        print(n)

    # output process 2
    for i in range(K):
        n = num_list_2[i]
        print(n)
### BUGGY CODE ###

N, M = map(int, input().split())
lrc_list = []
for _ in range(M):
    lrc_list.append(tuple(map(int, input().split())))
lrc_list.sort()
way = [float('inf')] * N
way[0] = 0
for lrc in lrc_list:
    for i in range(lrc[0], lrc[1]):
        way[i] = min(way[i], way[lrc[0] - 1] + lrc[2])

if way[N - 1] != float('inf'):
    print(way[N - 1])
else:
    print(-1)


### FIXED CODE ###

import sys
from collections import defaultdict
import networkx as nx

input = sys.stdin.buffer.readline

N, M = map(int, input().split())
LR_dict = defaultdict(lambda: 10 ** 9)
for _ in range(M):
    l, r, c = map(int, input().split())
    LR_dict[(l, r)] = min(LR_dict[(l, r)], c)

G = nx.DiGraph()
G.add_nodes_from(range(1, N + 1))
G.add_weighted_edges_from([(x + 1, x, 0) for x in range(1, N)])
G.add_weighted_edges_from((l, r, c) for (l, r), c in LR_dict.items())

try:
    print(nx.dijkstra_path_length(G, 1, N))
except nx.NetworkXNoPath:
    print(-1)
### BUGGY CODE ###

import math

K = int(input())
ans = 0

for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += math.gcd(math.gcd(i+1, j+1), k+1)

print(ans)


### FIXED CODE ###

from math import gcd

K = int(input())

ans = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        g = gcd(a, b)
        for c in range(1, K+1):
            ans += gcd(g, c)

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

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    maxi = 0
    ans = 0
    l = []
    for i in range(N-M+1):
        s = sum(A[i:M+i])        
        if maxi < s:
            maxi = s
            l = A[i:M+i]

    r = [(i/2 + 0.5) for i in l]
    return sum(r)

print(solve())



### FIXED CODE ###

import itertools

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    # スコアの累積和
    l = list(itertools.accumulate(A))

    score = sum(A[:M])
    for i in range(1, N-M):
        score = max(score, l[i+M] - l[i])
        
    ans = (M + score) / 2

    return ans

print(solve())