Harryxun/stf_run huggingface dataset:
n,m = map(int,input().split())
edges = []
for _ in range(m):
    edges.append(list(map(int,input().split())))
ans = []
cur = ((n-1)*n)//2
par = {i:i for i in range(1,n+1)}
size = {i:1 for i in range(1,n+1)}
def find(x):
    if x != par[x]:
        par[x] = find(par[x])
    return par[x]

def union(x,y):
    px,py = find(x),find(y)
    res = 0
    if px != py:
        res = size[px]*size[py]
        par[py] = px
        size[px] += size[py]
    return res

for i in range(m-1,-1,-1):
    ans.append(cur)
    x,y = edges[i]
    cur -= union(x,y)
for i in range(m-1,-1,-1):
    print(ans[i])

### FIXED CODE ###

n,m = map(int,input().split())
edges = []
for _ in range(m):
    edges.append(list(map(int,input().split())))
ans = []
cur = ((n-1)*n)//2
par = {i:i for i in range(1,n+1)}
size = {i:1 for i in range(1,n+1)}
rank = {i:0 for i in range(1,n+1)}
def find(x):
    if x != par[x]:
        par[x] = find(par[x])
    return par[x]

def union(x,y):
    px,py = find(x),find(y)
    res = 0
    if px != py:
        res = size[px] * size[py]
        if rank[px] < rank[py]:
            par[px] = py
            size[py] += size[px]
        else:
            par[py] = px
            size[px] += size[py]
            if rank[px] == rank[py]:
                rank[px] += 1
    return res

for i in range(m-1,-1,-1):
    ans.append(cur)
    x,y = edges[i]
    cur -= union(x,y)
for i in range(m-1,-1,-1):
    print(ans[i])
n,t=map(int,input().split())
times=[]
values=[]
for i in range(n):
  time,value=map(int,input().split())
  times.append(time)
  values.append(value)
  
def knapsack(i,w):
  if i >= n:
    return 0
  elif w < 0:
    return 0
  else:
    p1 = knapsack(i+1, w)
    p2 = knapsack(i+1, w - times[i]) + values[i]
    return max(p1,p2)

  
print(knapsack(0,t-1))

### FIXED CODE ###

import numpy as np

N,T = map(int, input().split())
item = [None]*N
for i in range(N):
  w,v = map(int,input().split())
  item[i] = [w,v]
item.sort(key=lambda x:x[0])

dp = np.zeros(T, dtype=int)
ans=0
for i in range(N):
    w,v=item[i]
    ans=max(ans,dp.max()+v)
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
print(ans)
def gcd(a, b):
 if a < b:
    a, b = b, a
 if b == 0:
    return a
 c = a % b
 return gcd(b, c)
def lcm(a,b):
  return int(a*b/gcd(a,b))

N = int(input())
ans = 1
for i in range(N):
    t = float(input())
    ans = lcm(t,ans)

print(ans)

### FIXED CODE ###

N = int(input())
T = [int(input()) for i in range(N)]

from functools import reduce
from fractions import gcd

def lcm(a,b):
  return a*b //gcd(a,b)

print(reduce(lcm,T))
def main():

    N = int(input())
    #if 0 > N or N > 100:
    #    print("input N error")
    #    exit()
        
    a = []
    for i in range(N):
        b = input().split()
        if len(b[0]) > 10 or len(b[0]) < 1:
            print("input S error")
            exit()

        if int(b[1]) < 0 or int(b[1]) > 100:
            print("input P error")
            exit()

        b.append(i + 1)
        a.append(b)
        
    a.sort()
    c = []
    answer = []
    
    for i in range(len(a)):
        c.append(a[i])
        
        if a[i][0] != a[i+1][0] and i != len(a) - 2:
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            c = []

        elif a[i][0] != a[i+1][0] and i == len(a) - 2:
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            answer += a[i + 1]
            break

        elif a[i][0] == a[i+1][0] and i == len(a) - 2:
            c.append(a[i + 1])
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            break
        
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()

    


### FIXED CODE ###

def main():

    N = int(input())
    if 0 > N or N > 100:
        print("input N error")
        exit()
        
    answer = []
    for i in range(N):
        s, p = input().split()
        answer.append([s, -int(p), i+1])

    answer.sort()
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()
N = int(input())
A = list(map(int, input().split()))
List = []


for i, a in enumerate(A):
  List[int(a)-1] = str(i+1)

  
print(" ".join(List))





### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
List = [0]*N


for i, a in enumerate(A):
  List[int(a)-1] = str(i+1)

  
print(" ".join(List))
import sys
readline=sys.stdin.readline

N,X,M = map(int,readline().split())
route = [X]
dic = {}
first = []
loop = []
for i in range(1, 10000):
  X = (X ** 2) % M
  if X in dic:
    first = route[:dic[X]]
    loop = route[dic[X]:]
    break
  route.append(X)
  dic[X] = i

#print(first)
#print(loop)

if N == len(first):
  print(sum(first))
elif N < len(first):
  print(sum(first[:N]))
else:
  ans = sum(first)
  one_loop = sum(loop)
  N -= len(first)
  loop_cnt = N // len(loop)
  rest = N % len(loop)
  ans += loop_cnt * (sum(loop))
  ans += sum(loop[:rest])

  print(ans)


### FIXED CODE ###

import sys
readline=sys.stdin.readline

N,X,M = map(int,readline().split())
route = [X]
dic = {}
first = []
loop = []
for i in range(1, N):
  X = (X ** 2) % M
  if X in dic:
    first = route[:dic[X]]
    loop = route[dic[X]:]
    break
  route.append(X)
  dic[X] = i
  
if len(first) == 0:
  print(sum(route[:N]))
  exit(0)

if N == len(first):
  print(sum(first))
elif N < len(first):
  print(sum(first[:N]))
else:
  ans = sum(first)
  one_loop = sum(loop)
  N -= len(first)
  loop_cnt = N // len(loop)
  rest = N % len(loop)
  ans += loop_cnt * (sum(loop))
  ans += sum(loop[:rest])

  print(ans)
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

while(len(h) > K):
    k = heappop(h) + heappop(h)
    heappush(h, k)

print(min(h))


### FIXED CODE ###

import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)
N, K = list(map(int, input().split(' ')))
S = list(input())

size = []

now = S[0]
cnt = 1

END = False

for i in range(1,N,1):
  before = now
  now = S[i]
  if now == before:
    cnt += 1
  else:
    size.append(cnt)
    cnt = 1

size.append(cnt)

if 3*K > len(size):
  print(sum(size))
  END = True

max_sum = 0
max_sum2 = 0

if  S[0] == '0':
  start = 1
else:
  start = 0
  
if END:
  pass
else:
  for i in range(start,len(size),2):
    try:
      now_sum = sum(size[i:i+3*K])
      now_sum2 = sum(size[i+1:i+1+3*(K-1)])
      if max_sum < now_sum:
          max_sum = now_sum
      if max_sum2 < now_sum2:
          max_sum2 = now_sum2
    except:
      pass
  
  if max_sum2 > max_sum:
  	print(max_sum2)
  else:
    print(max_sum)


### FIXED CODE ###

A, B = list(map(int, input().split(' ')))

get_coin = 0

for _ in range(2):
  if A > B:
  	get_coin += A
  	A = A-1
  else:
    get_coin += B
    B = B-1
   
print(get_coin)
hoge=input()
str=input()

dic={}
for alp in str:
    if alp in dic:
        dic[alp] += 1
    else:
        dic[alp] = 1

ans=1

for alp,num in dic.items():
    ans *= num+1)

ans -= 1
print(ans%(10**9 + 7))


### FIXED CODE ###

hoge=input()
str=input()

dic={}
for alp in str:
    if alp in dic:
        dic[alp] += 1
    else:
        dic[alp] = 1

ans=1

for alp,num in dic.items():
    ans *= (num+1)

ans -= 1
print(ans%(10**9 + 7))
n=int(input())
k = [int(input()) for i in range(n)]
print(int((sum(k)-max(k)//2))

### FIXED CODE ###

n=int(input())
k = [int(input()) for i in range(n)]
print(sum(k)-max(k)//2)
n=int(input())
a=list(map(int,input().split()))
all=0
mx=0
for i in range(len(a)):
	x=int(a[i])
	if x>mx: 
		mx=x
	all=all+x
if all>2*mx : 
	print("Yes")
else : 
	print("No")

### FIXED CODE ###

n = raw_input()
L = map(int, raw_input().strip().split())
s = sum(L)
mx = max(L)
if mx < s - mx:
  print "Yes"
else:
  print "No"
N, K = map(int, input().split())
xyc = []
for i in range(N):
    tmp_x, tmp_y, tmp_c = input().split()
    xyc.append([int(tmp_x), int(tmp_y), tmp_c])

def check(sx, sy, K, x, y):
    x = x % (2*K)
    y = y % (2*K)
    if x < sx or x >= sx + K:
        if y < sy:
            return 'W'
        elif y < sy + K:
            return 'B'
        else:
            return 'W'
    #elif x >= sx and x < sx + K:
    else:
        if y < sy:
            return 'B'
        elif y < sy + K:
            return 'W'
        else:
            return 'B'


ans = 0
for sx in range(K+1):
    for sy in range(K+1):
        r = 0
        for i in range(N):
            if check(sx, sy, K, xyc[i][0], xyc[i][1]) == xyc[i][2]:
                r = r + 1
        ans = max(ans, r)
print(ans)

### FIXED CODE ###

import sys
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
    tmp_t, tmp_x, tmp_y = map(int, input().split())
    t.append(tmp_t)
    x.append(tmp_x)
    y.append(tmp_y)

    
def go(t, d):
    if t == d:
        return True
    elif t > d:
        if (t - d) % 2 == 0:
            return True
        else:
            return False
    else:
        return False
        


for i in range(N):
    delta_t = t[i+1] - t[i]
    distance = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if go(delta_t, distance):
        continue
    else:
        print('No')
        sys.exit()
print('Yes')
line = input().split

X = line[0]
Y = line[1]
Z = line[2]

print( Y + " " + X + " " + Z )

### FIXED CODE ###

X,Y,Z = map(int,input().split())

print(str(Z) + " " + str(X) + " " + str(Y))
import math
n,k = list(map(int,input().split()))

if n < k:
    if k - n > n:
        print(n)
    else:
        print(k - n)
else:
    if n % k == 0:
        print(0)
    else:
        print(math.gcd(n, k))

### FIXED CODE ###

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

if n < k:
    print(min(n,k - n))
else:
    if n % k == 0:
        print(0)
    else:
        print(min(n % k,abs((n % k) - k)))
n = int(input())
l = list(map(int, input().split()))
l = list(set(l))
#print(l)

from itertools import combinations
a = list(combinations(l, n-1))
#print(a)

from fractions import gcd
from functools import reduce

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

g = []
for i in range(len(a)):
    g.append(gcd_list(a[i]))

print(max(g))

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
#print(l)
l2 = list(reversed(l))
#print(l2)
#from itertools import combinations
#a = list(combinations(l, n-1))
#print(a)
from fractions import gcd
L, R = [0], [0]
for i in range(n):
    L.append(gcd(L[i],l[i]))
    R.append(gcd(R[i],l2[i]))
#print(L)
R = list(reversed(R))
#print(R)
g = []
for j in range(n):
    g.append(gcd(L[j],R[j+1]))
print(max(g))


#from functools import reduce

#def gcd_list(numbers):
#    return reduce(gcd, numbers)
from fractions import gcd

N = int(input())
T = []
for i in range(N):
  T.append(int(input()))

res = 1
for t in T:
  res = int(res/(gcd(res, t))) * t
print(res)

### FIXED CODE ###

from fractions import gcd

N = int(input())
T = []
for i in range(N):
  T.append(int(input()))

res = 1
for t in T:
  res = res // gcd(res, t) * t
print(res)
S = input()

diff = 999

for i in range(0,8):
    n = int(S[i:i+3])
    if diff > abs(753-n):
        diff = abs(753-n)
    
print(diff)

### FIXED CODE ###

S = input()
l = len(S)
diff = 999

for i in range(0,l-2):
    n = int(S[i:i+3])
    if diff > abs(753-n):
        diff = abs(753-n)
    
print(diff)
S = list(input())
N = len(S) + 1
l = [0 for i in range(N)]
r = [0 for i in range(N)]
for i in range(N):
  if S[i] == '<':
    l[i+1] = l[i] + 1
  if S[N-i-2] == '>':
    r[N-i-2] = r[N-i-1] + 1
print(sum([max(l[i], r[i]) for i in range(N)]))

### FIXED CODE ###

S = list(input())
N = len(S) + 1
l = [0 for i in range(N)]
r = [0 for i in range(N)]
for i in range(N-1):
  if S[i] == '<':
    l[i+1] = l[i] + 1
  if S[N-i-2] == '>':
    r[N-i-2] = r[N-i-1] + 1
print(sum([max(l[i], r[i]) for i in range(N)]))
n=int(input())
a=list(map(int,input().split()))
x=max(a)
y=a.index(x)

for i in range(0,n):
  if i!=y:
    print(x)
  else:
    del a[y]
    print(max(a))
  


### FIXED CODE ###

n=int(input())
a=[]

for j in range(0,n):
  a.append(int(input()))
  
x=max(a)
y=a.index(x)
del a[y]
z=max(a)

for i in range(0,n):
  if i!=y:
    print(x)
  else:
    print(z)
bottle1, water, bottle2 = map(int, input().split())
empty = bottle1 - water
if empty =< bottle2:
  print(bottle2 - empty)
else:
  print(0)

### FIXED CODE ###

bottle1, water, bottle2 = map(int, input().split())
empty = bottle1 - water
if empty <= bottle2:
  print(bottle2 - empty)
else:
  print(0)
def prime_factor(n):
    ass = collections.defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            # ass.append(i)
            ass[i] += 1
            n = n//i
    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':

    # make_seed(num)
    # prime = Prime()
    # soinnsuu = prime.find_factors(num)
    soinnsuu = prime_factor(num)
    ans = 1
    # print(soinnsuu)
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
        # if soinnsuu[data] >= length:
        # ans *= data
    print(ans)

### FIXED CODE ###


import collections

# def get_lim(n):
#     # for i in range(n):
#     #     if i * i > n:
#     #         return i + 1
#     return pow(10, int((len(str(n)) / 2)))

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    # for i in range(2,int(n**0.5)+1):
    # lim = get_lim(n)
    for i in range(2, n):
        # print(pow(i, length),  n)
        # if pow(i, length) > n:
        #     break
        if i * i > n:
            break
        # print(n, i)
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    if length == 1:
        print(num)
    else:

        soinnsuu = prime_factor(num, length)
        ans = 1
        # print(soinnsuu)
        for data in soinnsuu.keys():
            if soinnsuu[data] >= length:
               ans *= pow(data, int(soinnsuu[data] / length))
        print(ans)
N, K = map(int, input().split())
lst = [map(int, input().split())]
i = 0
for h_i in lst:
    if h_i < K:
        continue
    i += 1
print(i)

### FIXED CODE ###

N, K = map(int, input().split())
lst = list(map(int, input().split()))
i = 0
for h_i in lst:
    if h_i < K:
        continue
    else:
        i += 1
print(i)
S = input()

S = list(S)

from collections import Counter
c = Counter(S)
d = c.most_common()

print(2*min(d[0][1],d[1][1]))

### FIXED CODE ###

S = input()
print(2 * min(S.count('1'),S.count('0')))
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin.readLines():
    a, b = map(int, raw_input().split())
    print len(str(a+b))

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    print len(str(a+b))
L, R = list(map(int, input().split()))
MOD = 2019
from itertools import product
ans = 2019
for i, j in product(range(L, R + 1), range(L, R + 1)):
    if i >= j:
        continue
    ans = min(ans, (i * j) % MOD)
    if ans == 0:
        break
print(ans)

### FIXED CODE ###

# https://atcoder.jp/contests/abc133/tasks/abc133_c
# MODって掛け算でも分解できなかったっけ？って気づけばO(n)となり終わり?
# いや、O(n)だと2*10**9なのでpythonだと間に合わない！
# mod 2019 の計算結果は2019ごとに繰り返すことに気がつくと一気に計算が少なくなる

MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))
# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= 2019
# RをなるべくLに近づけてみる
R %= 2019
if R <= L:
    R += MOD

ans = 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)
i = list(map(int, input().split()))
countFive = i.count(5)
countSeven = i.count(7)

if countFive == 2 & countSeven == 1
	print("YES")
else
	print("NO")

### FIXED CODE ###

i = list(map(int, input().split()))
countFive = i.count(5)
countSeven = i.count(7)

if countFive == 2 and countSeven == 1 :
    print("YES")
else :
    print("NO")
n=int(input())
a=list(map(int, input().split()))
q=int(input())
results=[]

S=sum(a)

table=[0]*(10**6)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))
        results.append(ans)
        table[b]=0
        S=ans
    else:
        results.appned(S)

for result in results:
    print(result)

### FIXED CODE ###

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

S=sum(a)

table=[0]*(10**6)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))

        print(ans)

        table[b]=0
        S=ans
    else:
        print(S)
def main():
	S = input()
	if (S[0] == S[1] and S[1] == S[2]) or (S[2] == S[1] and S[3] == S[2]):
		print("Yes")
	else:
		printf("No")
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	S = input()
	if (S[0] == S[1] and S[1] == S[2]) or (S[2] == S[1] and S[3] == S[2]):
		print("Yes")
	else:
		print("No")
if __name__ == '__main__':
    main()
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse = True)

diff = [0] * (N - 1)

for i in range(N - 1):
  diff[i] = A[i] - A[i + 1]
  
if K > A[0]:
  print("IMPOSSIBLE")
elif len(set(diff)) == 1 and A[0] % diff[0] == 0:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

### FIXED CODE ###

import fractions
from functools import reduce

N,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse = True)

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

GCD = gcd_list(A)

if K > A[0]:
  print("IMPOSSIBLE")
elif K % GCD != 0:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")
if __name__ == "__main__":
    n = int(input())
    """studentNumbers = [(x, str(i)) for x, i in
        zip(input().split(), range(1, 1000000))]
    studentNumbers.sort(key=lambda tup: tup[0])
    print(' '.join([x[1] for x in studentNumbers]))"""
    studentNumbers = [(x, str(i + 1)) for x, i in zip(input().split(), range(n))]
    if (n > 1):
        studentNumbers.sort(key=lambda tup: tup[0])
    print(' '.join([x[1] for x in studentNumbers]))


### FIXED CODE ###

from math import ceil

if __name__ == "__main__":
    n = int(input())
    print(ceil(n/2)/n)
N = int(input())
a = list(map(int, input().split()))

import fractions
lcm_m = a[0]
for i in range(1, N):
    lcm_m = lcm_m * a[i] // fractions.gcd(lcm_m, a[i])
#    lcm_m = (lcm_m%(10^9+7))*(a[i]%(10^9+7))//(fractions.gcd(lcm_m,a[i])%(10^9+7))
#    lcm_m = (lcm_m%(10^9+7))*a[i]//(fractions.gcd(lcm_m%(10^9+7),a[i]))
#print(lcm_m)

sol = 0
for i in range(N):
    sol += lcm_m / a[i]
print(int(sol)%(10**9+7))



### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
mod=10**9+7
import fractions
lcm_m = a[0]%mod
for i in range(1, N):
#    lcm_m = lcm_m * a[i] // fractions.gcd(lcm_m, a[i])
#    lcm_m = (lcm_m%(10^9+7))*(a[i]%(10^9+7))//(fractions.gcd(lcm_m,a[i])%(10^9+7))
#    lcm_m = (lcm_m%(10**9+7))*a[i]//(fractions.gcd(lcm_m%(10**9+7),a[i]))
#    lcm_m = ((lcm_m%mod)*(a[i]%mod))%mod//(fractions.gcd(lcm_m,a[i]))
    lcm_m = ((lcm_m)*(a[i]%mod))//(fractions.gcd(lcm_m,a[i]%mod))
#print(lcm_m)

#sol = 0
#for i in range(N):
#    sol += lcm_m / a[i]
#print(int(sol)%(10**9+7))
sol=sum([lcm_m//x for x in a])
print(sol%mod)
#print(sol)
a,b,m=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

ans=99999999999
for i in range(a):
    for j in range(i,b)::
        ans=min(ans,A[i]+B[j])
for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,A[x-1]+B[y-1]-c)
print(ans)


### FIXED CODE ###

a,b,m=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

ans=99999999999
ans=min(A)+min(B)
for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,A[x-1]+B[y-1]-c)
print(ans)
input()
xs = list(map(int, input().split()))


possibles = set()
for x in xs:
    possibles.add(x - 1)
    possibles.add(x)
    possibles.add(x + 1)


res = 0
for p in possibles:
    d = 0
    for x in xs:
        c = abs(x - p)
        if c <= 1: d += 1
    if res < d: res = d

print(res)







### FIXED CODE ###



X, t = map(int, input().split())
Y = max(0, X - t)
print(Y)
N = input()

M = N%10

if(M == 2 or M == 4 or M == 5 or M == 7 or M == 9):
    print("hon")

else if(M == 0 or M == 1 or M == 6 or M == 8):
    print("pon")

else if(M == 3):
    print("bon")

### FIXED CODE ###

N = input()

M = int(N) % 10

if M == 2 or M == 4 or M == 5 or M == 7 or M == 9:
    print("hon")

elif M == 0 or M == 1 or M == 6 or M == 8:
    print("pon")

elif M == 3:
    print("bon")
n = int(input()) 

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1
        is_prime(n)
    print(n)
        
    

### FIXED CODE ###

n = int(input()) 

import math
def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1
        is_prime(n)
    print(n)
n = int(input())
res = []
x = 0
for i in range(n):
    a,b = map(int,input().split())
    res.append(a+b)
res.sort(reverse = True)
for i in range(n//2+1):
    ans+=res[i]
print(ans)
    

### FIXED CODE ###

n = int(input())
res = []

ans = 0
for i in range(n):
    a,b = map(int,input().split())
    res.append(a+b)
    ans-=b

res.sort(reverse = True)
for i in range(0,n,2):
    ans+=res[i]
print(ans)
fron collections import deque
n=int(input())
g=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append([b-1,c])
    g[b-1].append([a-1,c])
q,k=map(int,input().split())
qu=deque([[k-1,0]])
v=[0]*n
d=[0]*n
while len(qu)>0:
    s=qu.popleft()
    v[s[0]]=1
    for j in g[s[0]]:
        if not v[j[0]]:
            v[j[0]]=1
            d[j[0]]=s[1]+j[1]
            qu+=[[j[0],d[j[0]]]]
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])


### FIXED CODE ###

from collections import deque
n=int(input())
g=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append([b-1,c])
    g[b-1].append([a-1,c])
q,k=map(int,input().split())
qu=deque([[k-1,0]])
v=[0]*n
d=[0]*n
while len(qu)>0:
    s=qu.popleft()
    v[s[0]]=1
    for j in g[s[0]]:
        if not v[j[0]]:
            v[j[0]]=1
            d[j[0]]=s[1]+j[1]
            qu+=[[j[0],d[j[0]]]]
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>=1000000000000000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
import numpy as np

n = int(input())
A, B = np.zeros(n), np.zeros(n)
for i in range(n):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

ans = 0

for i in range(n-1, -1, -1):
    if not A[i] % B[i] == 0:
        temp = B[i]*((A[i]//B[i])+1) - A[i]
        ans += temp
        A += temp
print(int(ans))


### FIXED CODE ###

n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
ans = 0
for i in range(n-1, -1, -1):
    if (A[i]+ans) % B[i] == 0:
        continue
    else:
        ans += B[i] - (A[i]+ans) % B[i]
print(ans)