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

import sys
sys.setrecursionlimit(10000000)
n , m = map(int,input().split())
g = [i for i in range(n)]
def find(x):
    if g[x] == x:
        return x
    g[x] = find(g[x])
    return g[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x!=y:
        g[x] = y

for i in range(m):
    xi,yi,zi = map(int,input().split())
    union(xi-1,yi-1)

print(len(set([find(i) for i in range(n)])))


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
n , m = map(int,input().split())
g = [i for i in range(n)]
def find(x):
    if g[x] == x:
        return x
    g[x] = find(g[x])
    return g[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x!=y:
        g[x] = y

for i in range(m):
    xi,yi,zi = map(int,input().split())
    union(xi-1,yi-1)

ans = 0
for i in range(n):
    if find(i) == i:
        ans += 1
print(ans)
### BUGGY CODE ###

from functools import cmp_to_key
def cmp(x, y):
  if x[0] != y[0]:
    return y[0] - x[0]
  else:
    return y[1] - x[1]
n, m = map(int, input().split())
data = [[int(e) for e in input().split()] for _ in range(n)]
data.sort(key = cmp_to_key(cmp))
t = [0] * (m + 1)
for i in range(n):
  a, b = data[i]
  for j in range(m, -1, -1):
    if j + a <= m:
      t[j + 1] = max(t[j + 1], t[j] + b)
print(max(t))


### FIXED CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
d2 = {}
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      if j not in d2:
        d2[j] = 0
      d2[j] += 1
      if j > maxb:
        maxb = j
  else:
    if len(d2) == 0:
      continue
  result += maxb
  if d2[maxb] == 1:
    del d2[maxb]
    if len(d2) == 0:
      maxb = 0
    else:
      maxb = max(d2.keys())
  else:
    d2[maxb] -= 1
print(result)
### BUGGY CODE ###

import sys
 
n = int(sys.stdin.readline())
s = sys.stdin.readline()

def count(s, idx):
	w = s.count("W", 0, idx)
	e = s.count("E", idx + 1)

	return w + e

m = count(s, 0)
j = 0

for i in range(1, len(s)): 
	m2 = count(s, i)
	if m2 < m:
		m = m2
		j = i

print(m)


### FIXED CODE ###

import sys
 
n = int(sys.stdin.readline())
s = list(sys.stdin.readline())

it = s[0]
w = 0
e = s[1:].count('E')

m = e
j = 0

for i in range(1, len(s)):
	if it == 'W':
		w = w + 1

	it = s[i]

	if it == 'E':
		e = e - 1

	m2 = w + e
	if m2 < m:
		m = m2
		j = i
print(m)
### BUGGY CODE ###

import sys
from operator import mul
from functools import reduce

t = 10**18

n=int(input())
li = list(map(int,input().split()))

ans = reduce(mul,li)

if ans > t:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import sys

t = 10**18


n=int(input())
li = list(map(int,input().split()))

if li.count(0) >= 1:
    print(0)
    sys.exit()

ans = 1
for i in range(n):
    ans = ans*li[i]
    if ans > t:
        print(-1)
        sys.exit()

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

n = int(input())
p = list(map(int, input().split()))
Min = min(p)
cnt = 0
for i in range(n):
    l = p[:i+1]
    if min(l) == p[i]:
        cnt += 1
        if p[i] == Min:
            break
print(cnt)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
cnt = 0
Min = p[0]
for i in range(n):
    if Min >= p[i]:
        cnt += 1
        Min = p[i]
print(cnt)
### BUGGY CODE ###

n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
d={}
for i,j in a:
    d[i]=d.get(i,set())|{j}
    d[j]=d.get(j,set())|{i}
path=a[0][:]
sp=set(path)
while d[path[-1]]-set(path):
    t=d[path[-1]]-set(path)
    t=t.pop()
    path.append(t)
    sp.add(t)
path=path[::-1]
while d[path[-1]]-set(path):
    t=d[path[-1]]-set(path)
    t=t.pop()
    path.append(t)
    sp.add(t)
print(len(path))
print(*path)

### FIXED CODE ###

n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
d={}
for i,j in a:
    d[i]=d.get(i,set())|{j}
    d[j]=d.get(j,set())|{i}
path=a[0][:]
sp=set(path)
while d[path[-1]]-sp:
    t=d[path[-1]]-sp
    t=t.pop()
    path.append(t)
    sp.add(t)
path=path[::-1]
while d[path[-1]]-sp:
    t=d[path[-1]]-sp
    t=t.pop()
    path.append(t)
    sp.add(t)
print(len(path))    
print(*path)
### BUGGY CODE ###

N = int(input())
g = [[0] * (N+1) for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a][b] = g[b][a] = c

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0

def fill(i):
  if(d[i] == -1):
    return
  for j in range(1, N+1):
    if(g[i][j] != 0 and d[j] == -1):
      d[j] = d[i] + g[i][j]
      fill(j)
  return
  
fill(K)

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])


### FIXED CODE ###

from collections import deque
N = int(input())
g = [[] for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a].append([b, c])
  g[b].append([a, c])

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0
r = deque()

r.append(K)
while len(r) > 0:
  i = r.popleft()
  for v in g[i]:
    if(d[v[0]] == -1):
      d[v[0]] = d[i] + v[1]
      r.append(v[0])

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))

from bisect import bisect_left, bisect_right
l.sort()
ans = 0
for i in range(len(l)):
    for j in range(i+1, len(l)):
        c_min = l[j] - l[i]
        c_max = l[i] + l[j]
        tmp = l[j+1:]

        idx_min = bisect_left(tmp, c_min)
        idx_max = bisect_left(tmp, c_max)

        if idx_min < len(tmp) and tmp[idx_min] == c_min:
            idx_min += 1

        ans += max(0, idx_max - idx_min)

print(ans)


### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))

l.sort()
from bisect import bisect_left
ans = 0
for i in range(n):
    for j in range(i):
        idx = bisect_left(l, l[i] + l[j])
        ans += idx - i - 1
print(ans)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
N,Q = map(int,input().split())
AB = [[x for x in map(int,input().split())] for _ in range(N-1)]
PX = [[x for x in map(int,input().split())] for _ in range(Q)]
 
G = [[] for _ in range(N+1)]
for a,b in AB:
    G[a].append(b)
    G[b].append(a)
 
cnt = [0]*N
for p,x in PX:
    cnt[p-1] += x

color = ["WHITE"] * (N+1)
stack = []

def dfs(u):
    stack.append(u)
    color[u] = "GRAY"

    while len(stack) > 0:
        u = stack[-1]
        if len(G[u]) == 0:
            color[u] = "BLACK"
            stack.pop()
        else:
            u_next = G[u].pop(0)
            if color[u_next] == "WHITE":
                color[u_next] = "GRAY"
                cnt[u_next-1] += cnt[u-1]
                stack.append(u_next)
dfs(1)
print(*cnt)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
### BUGGY CODE ###

N, P = map(int, input().split())
S = list(map(int, list(input())))

l = len(S)
if P == 2:
    ans = 0
    for i in range(l):
        if S[i]%2 == 0:
            ans += i+1
elif P == 5:
    ans = 0
    for i in range(l):
        if S[i]%5 == 0:
            ans += i+1
else:
    data = [0]*P
    temp = 0
    ans = 0
    for i in range(l-1, -1, -1):
        temp += (S[i]*(10**(l-i-1)))%P
        temp %= P
        ans += data[temp]
        data[temp] += 1
    ans += data[0]

print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = list(map(int, list(input())))

l = len(S)
if P == 2:
    ans = 0
    for i in range(l):
        if S[i]%2 == 0:
            ans += i+1
elif P == 5:
    ans = 0
    for i in range(l):
        if S[i]%5 == 0:
            ans += i+1
else:
    data = [0]*P
    temp = 0
    ans = 0
    for i in range(l-1, -1, -1):
        temp += S[i]*pow(10, l-i-1, P)
        temp %= P
        ans += data[temp]
        data[temp] += 1
    ans += data[0]

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

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    wsv = LLI(n)
    wsv.sort(key=lambda x: x[0] + x[1], reverse=True)
    m = sum(w for w, s, v in wsv) + 1
    dp = [0] * m
    # print(wsv)
    # print(dp)
    for w, s, v in wsv:
        for j in range(w, m):
            nj = min(j - w, s)
            dp[nj] = max(dp[nj], dp[j] + v)
    # print(dp)
    print(max(dp))

main()


### FIXED CODE ###

def f(n):
    dp = [0] * (n * 10 ** 4 + 1)
    bs = [list(map(int, input().split())) for _ in range(n)]
    bs.sort(key=lambda x: x[0] + x[1])
    for w, s, v in bs:
        for i in range(w + s, w - 1, -1):
            dpw = dp[i - w] + v
            if dpw > dp[i]:
                dp[i] = dpw
    print(max(dp))


n = int(input())
f(n)
### BUGGY CODE ###

h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I:=h*w]*I
m+=d,
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   if d[t]==I:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)
### BUGGY CODE ###

n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        lp = j+1
        rp = n-1
        while lp < rp:
            mp = (lp+rp)//2
            if l[mp] < l[i] + l[j]:
                lp = mp+1
            else:
                rp = mp-1
        if l[lp] < l[i] + l[j]:
            ans += lp-j
        else:
            ans += lp-j-1
print(ans)

### FIXED CODE ###

n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        lp = j+1
        rp = n-1
        while lp < rp:
            mp = (lp+rp)//2
            if l[mp] < l[i] + l[j]:
                lp = mp+1
            else:
                rp = mp-1
        if l[lp] < l[i] + l[j]:
            ans += lp-j
        else:
            ans += lp-j-1
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    def calcSumOfDigit(x,acc=0):
        if x == 0:
            return acc
        else:
            return calcSumOfDigit(x//10,acc+x%10)
    def judge(x):
        return x % 9 == 0
    print("Yes" if judge(calcSumOfDigit(N)) else "No")
    return


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    def calcSumOfDigit(x):
        str_x = str(x)
        acc = 0
        for s in str_x:
            acc += int(s)
            acc %= 9
        return acc
    
    print("Yes" if calcSumOfDigit(N)==0 else "No")
    return


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

import math
k=int(input())
tot=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            tot+=math.gcd(a,math.gcd(b,c))
print(tot)

### FIXED CODE ###

import math
k=int(input())

tot=k*(k+1)//2

for i in range(1,k+1):
    for j in range(i+1,k+1):
        tot+=math.gcd(i,j)*6

for i in range(1,k+1):
    for j in range(i+1,k+1):
        for l in range(j+1,k+1):
            tot+=math.gcd(i,math.gcd(j,l))*6

print(tot)
### BUGGY CODE ###

N = input()
ans = 0

def check(number):
    three = 0
    five = 0
    seven = 0
    for i in range(len(number)):
        if number[i:i+1] == '3':
            three += 1
        elif number[i:i+1] == '5':
            five += 1
        elif number[i:i+1] == '7':
            seven += 1
        else:
            return False
    if three >= 1 and five >= 1 and seven >= 1:
        return True
    else:
        return False

for i in range(int(N)+1):
    if check(str(i)) == True:
        ans += 1

print(ans)
    

### FIXED CODE ###

n = int(input())

def recursive(s):
    if int(s) > n:
        return 0
    ret = 0
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ret = 1
    for c in '753':
        ret += recursive(s+c)
    return ret           

print(recursive('0'))
### BUGGY CODE ###

from scipy.sparse import*
(n,m,s,*D),*t=[map(int,t.split())for t in open(0)]
x=51
r=range(0,x**3,x)
for u,v,a,b in t[:m]:
 for i in r:D+=i+a*x+u,i+v,b,i+a*x+v,i+u,b
i=0
for c,d in t[m:]:
 i+=1
 for j in r:D+=j+i,j+c*x+i,d
d=csgraph.johnson(csr_matrix((D[2::3],(D[::3],D[1::3])),[j*2]*2),1,min(j,s*x)+1)
for i in range(2,n+1):print(int(min(d[i::x])))

### FIXED CODE ###

from scipy.sparse import*
n,m,s,*t=map(int,open(0).read().split())
row,col,dat=[],[],[]
for u,v,a,b in zip(*[iter(t[:m*4])]*4):
    for i in range(2501-a):
        row+=(i+a)*51+u,(i+a)*51+v
        col+=i*51+v,i*51+u
        dat+=b,b
for i,(c,d)in enumerate(zip(*[iter(t[m*4:])]*2),1):
    for j in range(2501-c):
        row+=j*51+i,
        col+=(j+c)*51+i,
        dat+=d,
d=csgraph.dijkstra(csr_matrix((dat,(row,col)),[8**6]*2),1,min(2500,s)*51+1)
for i in range(2,n+1):print(int(d[i::51].min()))
### BUGGY CODE ###

import collections
import sys

#入力
H, W = map(int, input().split())

lst = []
for i in range(H):
    lst += [list(input())]

count = 0
INF = 10 ** 9
q =collections.deque() #動作用のqueue
dp = [[INF] * W for _ in range(H)] #そのマスを確認したかのフラグ
#print (dp)

move = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def check(): #確認の起点になっていない黒マスを全てqueueに入れる
    for i in range(H):
        for j in range(W):
#            print ('i, j, count =', i, j, count)
            if lst[i][j] == '#': #黒マスであることの確認
               if  dp[i][j] == INF:#dp[i][j]がINF= 初回黒のところ
                   q.append([i, j])
#                   print ('INF')
                   dp[i][j] = 0 #フラグを0-->0回で変えることができる
               elif dp[i][j] == count: #dp[i][j] == count-->count回目で黒に変わったもの
#                   print ('dp[i][j]= ', dp[i][j])
                   q.append([i, j])
#                   print (q)
#                   print ('A')
    return

def change(px, py): #現在座標(px,py)から上下左右のマスを白に変え、手数を記録する
    for dx, dy in move:
        nx = px + dx
        ny = py + dy
        if 0 <= nx and nx < H and 0 <= ny and ny < W: #移動先が範囲内であることの確認
            dp[nx][ny] = min(dp[px][py] +1, dp[nx][ny]) #すでに入っている値と新しい値の小さい方を記録し直す
            lst[nx][ny] = '#' #移動先を黒色に変える


while True:
    check() #未確認の黒マスをdequeに入れる
#    print (q)
    if not q: #dequが空の時
        print (count-1) #現在までに変えた回数 = count を入れて終わる
        sys.exit()
    else: #dequeが空でない= 未確認の黒マスがある
       while q: #dequeが空になるまで回す
           px, py = q.popleft()
           change(px, py)
       count += 1
#       print (count, '回変えた後',dp)


### FIXED CODE ###

import numpy as np

H, W = map(int, input().split())
max_value = H + W #左上から右下までの最大手数
matrix = []

#黒の場合0, それ以外の場合、max_valueを代入したリストを作成-->arrayへ変換
for _ in range(H):
    matrix.append([0 if i == '#' else max_value for i in list(input())])
matrix = np.array(matrix)

for c in range(W-1):#y座標を増やしていく
    matrix[:,c+1] = np.minimum(matrix[:,c]+1, matrix[:,c+1]) #一個左+1　と　自分自身の値　の小さい方
#print (matrix)
for c in range(W-1,0,-1):
    matrix[:,c-1] = np.minimum(matrix[:,c]+1, matrix[:,c-1]) #一個右+1　と　自分自身の値　の小さい方
#print (matrix)
for c in range(H-1):
    matrix[c+1,:] = np.minimum(matrix[c,:]+1, matrix[c+1,:]) #一個下+1　と　自分自身の値　の小さい方　
#print (matrix)
for c in range(H-1,0,-1):
    matrix[c-1,:] = np.minimum(matrix[c,:]+1, matrix[c-1,:]) #一個上+1　と　自分自身の値　の小さい方
#print (matrix)
print (np.max(matrix))
### BUGGY CODE ###

a,b,n = map(int,input().split())
def floor(x):
    return (a*x)//b - a*(x//b)
ans = 0
if b <= n: 
    for i in range(b-1,n+1):
        ans = max(ans,floor(i))
        #print(floor(i))
    print(ans)
else:
    print(floor(n))

### FIXED CODE ###

a,b,n = map(int,input().split())
def floor(x):
    return (a*x)//b - a*(x//b)
ans = 0
if b <= n: 
    '''
    for i in range(b-1,n+1):
        ans = max(ans,floor(i))
        #print(floor(i))
    print(ans)
    '''
    print(floor(b-1))
else:
    print(floor(n))
### BUGGY CODE ###

N, M, K = map(int, input().split())
MOD =  998244353

dp = [ [0] * (K+1) for _ in range(N+1)]

# 1個目
dp[1][0] = M

for i in range(1,N):
    for k in range(K+1):
        dp[i+1][k] += dp[i][k] * (M-1) % MOD  # 違う色
        if K > k:
            dp[i+1][k+1] += dp[i][k] % MOD # 同じ色


print(sum(dp[N]) % MOD)

### FIXED CODE ###

N, M, K = map(int, input().split())
MOD = 998244353

fac = [1, 1] # 元テーブル
facinv = [1, 1] #逆元テーブル
inv = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    fac.append( ( fac[-1] * i ) % MOD )
    inv.append( ( -inv[MOD % i] * (MOD//i) ) % MOD )
    facinv.append( (facinv[-1] * inv[-1]) % MOD )

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n-r] % MOD

sum = 0
for k in range(K+1):
    sum += M * pow(M-1,N-1-k, MOD) * cmb(N-1,k) % MOD
    sum %= MOD

print(sum % MOD)
### BUGGY CODE ###

# ABC 163
N =int(input())
A =[int(j) for j in input().split()]
memo = dict()
for i in set(A):
    memo[str(i)]=A.count(i)
    
for i in range(1,N+1):
    if str(i) in memo.keys():
        print(memo[str(i)])
    else:
        print(0)

### FIXED CODE ###

# ABC 163
N =int(input())
A =[int(j) for j in input().split()]
memo = [0] * N

for a in A:
    memo[a -1]+=1
for i in memo:
    print(i)
### BUGGY CODE ###

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

for i in range(N-1):
        if max(H[:i+1])-H[i+1]>=2:
                print('No')
                exit()
print('Yes')

### FIXED CODE ###

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

now=H[0]
for i in H:
        if i>now:
                now=i
        elif now>i+1:
                print('No')
                exit()

print('Yes')
### BUGGY CODE ###

import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()

def calc_lux(a):
    res = [1 for _ in range(len(a))]
    for i in range(len(a)):
        light = a[i]
        for j in range(light):
            le = i - (j+1)
            ri = i + (j+1)
            if le >= 0:
                res[le] += 1
            if ri < n:
                res[ri] += 1
    return res

for _ in range(k):
    # calc lux from a
    lux = calc_lux(a)

    if a==lux:
        a = lux
        break

    # overwrite a
    a = lux

print(" ".join([str(i) for i in a]))

### FIXED CODE ###

import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()

def calc_lux(a):
    imosu = [0 for _ in range(len(a))]
    res = [0 for _ in range(len(a))]
    cnt = 0
    for i in range(len(a)):
        light = a[i]
        le = max(0, i-light)
        imosu[le] += 1
        if i+light < n-1:
            imosu[i+light+1] -= 1

    tmp = 0
    for i in range(len(res)):
        tmp += imosu[i]
        res[i] += tmp
    return res

for _ in range(k):
    # calc lux from a
    lux = calc_lux(a)

    if a==lux:
        a = lux
        break

    # overwrite a
    a = lux
    # print(lux)

print(" ".join([str(i) for i in a]))
### BUGGY CODE ###

def my_index(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

H,W,M=map(int,input().split())
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for _ in range(M):
    P.append(list(map(int,input().split())))
for m in range(M):
    P_X[P[m][0]]+=1
    P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
max_X=my_index(P_X,Max_X)
max_Y=my_index(P_Y,Max_Y)
m_count=0
for k in P:
    if  k[0] in max_X and k [1] in max_Y:
        m_count += 1
if m_count==len(max_X)*len(max_Y):
    answer=Max_X+Max_Y-1
else:
     answer=Max_X+Max_Y
    
print(answer)


### FIXED CODE ###


def my_index(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

H,W,M=map(int,input().split())
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m  in range(M):
    P.append(list(map(int,input().split())))
    P_X[P[m][0]]+=1
    P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
max_X=my_index(P_X,Max_X)
max_Y=my_index(P_Y,Max_Y)
m_count=0
for k in P:
    if  P_X[k[0]] == Max_X and P_Y[k [1]] == Max_Y:
        m_count += 1
if m_count==len(max_X)*len(max_Y):
    answer=Max_X+Max_Y-1
else:
     answer=Max_X+Max_Y
    
print(answer)
### BUGGY CODE ###

import math

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

for i in range(M):
    mx=max(A)
    A.remove(mx)
    A.append(mx/2)

A=list(map(math.floor, A))
print(sum(A))


### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))
### BUGGY CODE ###

n,a,b=map(int,input().split())
if a==0:
  print("0")
  exit()
ans = 0
while n>0:
  if n>=a:
    ans += a
    n -= a
  else:
    ans += n
    n = -1
  n -= b
print(ans)

### FIXED CODE ###

n,a,b=map(int,input().split())
if a==0:
  print("0")
  exit()
tmp1 = n // (a+b)
tmp2 = n-(tmp1*(a+b))
if tmp2 >= a:
  print((tmp1*a)+a)
else:
  print((tmp1*a)+tmp2)
### BUGGY CODE ###

import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    MOD = 998244353

    N = int(readline())
    P = [list(map(int, readline().split())) for i in range(N)]

    P.sort()

    Y = [y for x, y in P]

    def compress(X):
        *XS, = set(X)
        XS.sort()
        return list(map({e: i for i, e in enumerate(XS)}.__getitem__, X))
    Y = compress(Y)

    data = [0]*(N+1)
    def add(k, x):
        while k <= N:
            data[k] += x
            k += k & -k
    def get(k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def gen(add, get):
        pow2 = [1]*N
        r = 1
        for i in range(1, N):
            pow2[i] = r = r * 2 % MOD

        for i, y in enumerate(Y):
            v1 = get(y+1); v0 = y - v1
            w1 = i - v1; w0 = (N - y - 1) - w1
            add(y+1, 1)
            p1 = pow2[v1]; p0 = pow2[v0]
            q1 = pow2[w1]; q0 = pow2[w0]
            yield (2 * (p1*p0 % MOD)*(q1*q0 % MOD) % MOD) - (1 - p0 - p1 - q0 - q1 + (p0 + q1) * (p1 + q0)) % MOD
    write("%d\n" % (sum(gen(add, get)) % MOD))
solve()

### FIXED CODE ###

import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    MOD = 998244353

    N = int(readline())
    P = [list(map(int, readline().split())) for i in range(N)]

    P.sort()

    Y = [y for x, y in P]

    def compress(X):
        *XS, = set(X)
        XS.sort()
        return list(map({e: i for i, e in enumerate(XS)}.__getitem__, X))
    Y = compress(Y)

    data = [0]*(N+1)
    def add(k, x):
        while k <= N:
            data[k] += x
            k += k & -k
    def get(k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def gen(add, get):
        pow2 = [1]*N
        r = 1
        for i in range(1, N):
            pow2[i] = r = r * 2 % MOD

        for i, y in enumerate(Y):
            v1 = get(y+1); v0 = y - v1
            w1 = i - v1; w0 = (N - y - 1) - w1
            add(y+1, 1)
            p1 = pow2[v1]; p0 = pow2[v0]
            q1 = pow2[w1]; q0 = pow2[w0]
            yield (2 * (p1*p0 % MOD)*(q1*q0 % MOD) % MOD) - (1 - p0 - p1 - q0 - q1 + (p0 + q1) * (p1 + q0)) % MOD
    write("%d\n" % (sum(gen(add, get)) % MOD))
solve()