Harryxun/stf_run huggingface dataset:
from bisect import bisect_right,bisect_left
N,C=map(int,input().split())
S=[[int(i) for i in input().split()] for i in range(N)]
Way1=[S[0][1]-S[0][0]]
p1=[]
if Way1[0]>0:
  p1.append(0)
for i in range(1,N):
  Way1.append(Way1[i-1]+S[i][1]-(S[i][0]-S[i-1][0]))
  if p1==[] and Way1[i]>0:
    p1.append(i)
  elif p1!=[]:
    if Way1[p1[-1]]<Way1[i]:
      p1.append(i)
    
Way2=[S[-1][1]-(C-S[-1][0])]
p2=[]
if Way2[0]>0:
  p2.append(N-1)
for i in range(1,N):
  Way2.append(Way2[i-1]+S[N-i-1][1]+(S[N-i-1][0]-S[N-i][0]))
  if p2==[] and Way2[i]>0:
    p2.append(N-i-1)
  elif p2!=[]:
    if Way2[N-1-p2[-1]]<Way2[i]:
      p2.append(N-i-1)
Way2.reverse()
p2.reverse()

ans=0
for i in p1:
  if i!=N-1:
    if bisect_right(p2,i+0.1)<len(p2):
      j=p2[bisect_right(p2,i+0.1)]
      ans=max(ans,Way1[i],Way1[i]-S[i][0]+Way2[j])
    else:
      ans=max(ans,Way1[i])
  else:
    ans=max(ans,Way1[i])
for j in p2:
  if j!=0:
    i=p1[bisect_left(p1,j-0.1)-1]
    ans=max(ans,Way2[j],Way1[i]-(C-S[j][0])+Way2[j])
  else:
    ans=max(ans,Way2[j])
    
print(ans)



### FIXED CODE ###

from bisect import bisect_right,bisect_left
N,C=map(int,input().split())
S=[[int(i) for i in input().split()] for i in range(N)]
Way1=[S[0][1]-S[0][0]]
p1=[]
if Way1[0]>0:
  p1.append(0)
for i in range(1,N):
  Way1.append(Way1[i-1]+S[i][1]-(S[i][0]-S[i-1][0]))
  if p1==[] and Way1[i]>0:
    p1.append(i)
  elif p1!=[]:
    if Way1[p1[-1]]<Way1[i]:
      p1.append(i)
    
Way2=[S[-1][1]-(C-S[-1][0])]
p2=[]
if Way2[0]>0:
  p2.append(N-1)
for i in range(1,N):
  Way2.append(Way2[i-1]+S[N-i-1][1]+(S[N-i-1][0]-S[N-i][0]))
  if p2==[] and Way2[i]>0:
    p2.append(N-i-1)
  elif p2!=[]:
    if Way2[N-1-p2[-1]]<Way2[i]:
      p2.append(N-i-1)
Way2.reverse()
p2.reverse()

ans=0
for i in p1:
  if i!=N-1:
    if bisect_right(p2,i+0.1)<len(p2):
      j=p2[bisect_right(p2,i+0.1)]
      ans=max(ans,Way1[i],Way1[i]-S[i][0]+Way2[j])
    else:
      ans=max(ans,Way1[i])
  else:
    ans=max(ans,Way1[i])
for j in p2:
  if j!=0:
    if bisect_left(p1,j-0.1)>0:
      i=p1[bisect_left(p1,j-0.1)-1]
      ans=max(ans,Way2[j],Way1[i]-(C-S[j][0])+Way2[j])
    else:
      ans=max(ans,Way2[j])
  else:
    ans=max(ans,Way2[j])
    
print(ans)
N=int(input())
C=[int(input()) for i in range(N)]
mod=10**9+7

S=[C[0]]

for i in range(1,N):
    if C[i]!=C[i-1]:
        S.append(C[i])

L=len(S)

AL=[[] for i in range(N+1)]

for i in range(L):
    AL[S[i]].append(i)

PLUS=[0]*(N+1)

NOW=1

for i in range(L):
    NOW,PLUS[S[i]]=(NOW+PLUS[S[i]])%mod,(PLUS[S[i]]+NOW)%mod
    #PLUS[S[i]]+=NOW
    

    #print(NOW,PLUS)

#print(PLUS)
print(NOW)

### FIXED CODE ###

import sys

N=int(input())
C=[int(input()) for i in range(N)]
mod=10**9+7

if N==1:
    print(1)
    sys.exit()

S=[C[0]]

for i in range(1,N):
    if C[i]!=C[i-1]:
        S.append(C[i])

L=len(S)

if L==1:
    print(1)
    sys.exit()

AL=[[] for i in range(2*10**5+1)]

for i in range(L):
    AL[S[i]].append(i)

PLUS=[0]*(2*10**5+1)

NOW=1

for i in range(L):
    NOW,PLUS[S[i]]=(NOW+PLUS[S[i]])%mod,(PLUS[S[i]]+NOW)%mod
    #PLUS[S[i]]+=NOW
    

    #print(NOW,PLUS)

#print(PLUS)
print(NOW)
import sys
import heapq
o=lambda:map(int,raw_input().split())
n=int(raw_input())
e=[[] for _ in range(n+1)]
for _ in range(n-1):a,b=o();e[a]+=[(b,1)];e[b]+=[(a,1)]
k=int(raw_input())
for _ in range(k):v,p=o();e[v]+=[(0,p)];e[0]+=[(v,p)]
vis=[False]*n
q=[(0,0)]
heapq.heapify(q)
while len(q):
    c,v=heapq.heappop(q)
    vis[v]=True
    cost[v]=c
    for (w,d) in e[v]:
        if not vis[w]:q+=[(c+d,w)]
for i in range(n):
    for w,d in e[i]:
        if abs(cost[i]-cost[w])!=1:print 'No';sys.exit()
print 'Yes'
for i in range(n):print cost[i]

### FIXED CODE ###

import sys
import heapq
o=lambda:map(int,raw_input().split())
n=int(raw_input())
e=[[] for _ in range(n+1)]
for _ in range(n-1):a,b=o();e[a]+=[(b,1)];e[b]+=[(a,1)]
k=int(raw_input())
for _ in range(k):v,p=o();e[v]+=[(0,p)];e[0]+=[(v,p)]
vis=[False]*(n+1)
cost=[10**9]*(n+1)
q=[(0,0)]
heapq.heapify(q)
while len(q):
    c,v=heapq.heappop(q)
    vis[v]=True
    cost[v]=c
    for (w,d) in e[v]:
        if not vis[w] and c+d<cost[w]:
            heapq.heappush(q,(c+d,w))
            cost[w]=c+d
for i in range(1,n+1):
    for w,d in e[i]:
        if w!=0 and abs(cost[i]-cost[w])!=1:print 'No';sys.exit()
print 'Yes'
for i in range(n):print cost[i+1]
A=int(input())
B=int(input())
C=A + B

if  A % 3 == 0 : print("Possible")
else: print("Impossible")
if B % 3 == 0 : print("Possible")
else: print("Impossible")
if C % 3 == 0 : print("Possible")
else: print("Impossible")

### FIXED CODE ###

a,b=map(int,input().split())
c=a + b
 
if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")
from collections import defaultdict
def inpl(): return list(map(int,input().split()))

class increment:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

ui = defaultdict(increment())
xylist = []
Nxy = 0

H,W,N = inpl()
for i in range(N):
    X, Y = inpl()
    n = ui[X]
    if n < Nxy:
        xylist[n][1] = min(xylist[n][1],Y)
    else:
        xylist.append([X,Y])
        Nxy += 1

xylist.sort(key=lambda x: x[0])
xylist.append([W+1,1])
Nxy+=1
if xylist[0][0] == 1:
    xylist = xylist[1:]

Xprev = Yprev = 1
for i in range(Nxy):
    X, Y = xylist[i]
    Ybound = Yprev + X - Xprev 
    if Y < Ybound:
        ans = X -1
        break
    elif Y == Ybound:
        Xprev, Yprev = X, Ybound - 1
    else:
        Xprev, Yprev = X, Ybound

print(ans)

### FIXED CODE ###

from collections import defaultdict
def inpl(): return list(map(int,input().split()))

class Counter:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

ui = defaultdict(Counter())
xylist = []

H, W, N = inpl()
for i in range(N):
    X, Y = inpl()
    n = ui[X]
    if n < len(xylist):
        xylist[n][1] = min(xylist[n][1],Y)
    else:
        xylist.append([X,Y])

xylist.sort(key=lambda x: x[0])
xylist.append([H+1,1])

Xprev = Yprev = 1
for X, Y in xylist:
    Ybound = Yprev + X - Xprev 
    if Y < Ybound:
        ans = X - 1
        break
    elif Y == Ybound:
        Xprev, Yprev = X, Ybound - 1
    else:
        Xprev, Yprev = X, Ybound

print(ans)
While True:
    (a, op, b) = input().split()
    int(a)
    int(b)

    if op == '?':
        break

    elif op == '+':
        print(a + b)

    elif op == '-':
        print(a - b)

    elif op == '*':
        print(a * b)

    elif op == '/':
        print(a // b)

### FIXED CODE ###

while True:
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]

    if op == '?':
        break

    if op == '+':
        print(a + b)

    if op == '-':
        print(a - b)

    if op == '*':
        i = a * b
        print(a * b)

    if op == '/':
        print(a // b)
N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if n > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(0) if M == 0 else print(*[e if e!=None else 0 if i != 0 else 1 for i, e in enumerate(num)], sep="")

### FIXED CODE ###

N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if N > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(*[e if e!=None else 0 if i != 0 or N == 1 else 1 for i, e in enumerate(num)], sep="")
def resolve():
    N, K = map(int, input().split())
    h = [int(i) for i in input().split()]

    dp = [0, abs(h[1] - h[0])]
    for i in range(2, N):
        dp.append(min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, K + 1)))
    print(dp[N - 1])


if __name__ == "__main__":
    resolve()

### FIXED CODE ###

def resolve():
    N, K = map(int, input().split())
    h = [int(i) for i in input().split()]

    dp = [0, abs(h[1] - h[0])]
    for i in range(2, N):
        dp.append(
            min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, min(K + 1, i + 1)))
        )
    print(dp[N - 1])


if __name__ == "__main__":
    resolve()
import sys

(a, b) = [int(i) for i in sys.readline().split()]
print("%d %d" % (a * b, (a + b) * 2))

### FIXED CODE ###

import sys
 
(a, b) = [int(i) for i in sys.stdin.readline().split()]
print("%d %d" % (a * b, (a + b) * 2))
# 行数Hおよび列数Wを入力する
H, W = map(int, input().split())
# マスを初期化する（ワンサイズ大きめに作成する）
s = ["." * (W + 2) for _ in range(H + 2)]
# マスを入力する
for i in range(1, H + 1):
    s[i] = input()
# 判定を初期化する
judge = "Yes"
# 各マスについて、黒く塗れるかを調べる
for i in range(1, H + 1):
    for j in range(1, W + 1):
        # 黒く塗らないマスの場合、以降の処理は行わずに次のマスに移る
        if s[i][j] == ".":
            continue
        # 上下左右に黒く塗るべきマスがない場合、塗り分け不可能
        if s[i - 1][j] + s[i][j - 1] + s[i][j + 1] + s[i + 1][j] == "....":
            # 判定を更新する
            judge = "No"
            # マスの調査を終了する
            break
# 判定を出力する
print(judge)

### FIXED CODE ###

# 行数Hおよび列数Wを入力する
H, W = map(int, input().split())
# マスを初期化する（ワンサイズ大きめに作成する）
s = ["." * (W + 2) for _ in range(H + 2)]
# マスを入力する
for i in range(1, H + 1):
    s[i] = "." + input() + "."
# 判定を初期化する
judge = "Yes"
# 各マスについて、黒く塗れるかを調べる
for i in range(1, H + 1):
    for j in range(1, W + 1):
        # 黒く塗らないマスの場合、以降の処理は行わずに次のマスに移る
        if s[i][j] == ".":
            continue
        # 上下左右に黒く塗るべきマスがない場合、塗り分け不可能
        if s[i - 1][j] + s[i][j - 1] + s[i][j + 1] + s[i + 1][j] == "....":
            # 判定を更新する
            judge = "No"
            # マスの調査を終了する
            break
# 判定を出力する
print(judge)
N, K = map(int,input().split())
H = list(input().split())

H.sort(reverse=True)
print(sum(H[K:]))

### FIXED CODE ###

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

H.sort(reverse=True)
print(sum(H[K:]))
h, w, m = [int(e) for e in input().split()]

htotal = [0] * h
wtotal = [0] * w


hmax = 0
wmax = 0

s = set()
hl = []
wl = []

for i in range(m):
    hi, wi = [int(e) for e in input().split()]
    hi -= 1
    wi -= 1

    s.add((hi, wi))
    htotal[hi] += 1
    wtotal[wi] += 1

    if htotal[hi] > hmax:
        hmax = htotal[hi]
        hl = [hi]
    elif htotal[hi] == hmax:
        hl.append(hi)

    if wtotal[hi] > wmax:
        wmax = wtotal[wi]
        wl = [wi]
    elif wtotal[wi] == wmax:
        wl.append(wi)

m = hmax + wmax - 1
for he in hl:
    if m == hmax + wmax:
        break
    for we in wl:
        if m == hmax + wmax:
            break
        if not (he, we) in s:
            m += 1

print(m)
    

### FIXED CODE ###

h, w, m = [int(e) for e in input().split()]

htotal = [0] * h
wtotal = [0] * w


hmax = 0
wmax = 0

s = set()
hl = []
wl = []

for i in range(m):
    hi, wi = [int(e) for e in input().split()]
    hi -= 1
    wi -= 1

    s.add((hi, wi))
    htotal[hi] += 1
    wtotal[wi] += 1

    if htotal[hi] > hmax:
        hmax = htotal[hi]
        hl = [hi]
    elif htotal[hi] == hmax:
        hl.append(hi)

    if wtotal[wi] > wmax:
        wmax = wtotal[wi]
        wl = [wi]
    elif wtotal[wi] == wmax:
        wl.append(wi)

m = hmax + wmax - 1
for he in hl:
    if m == hmax + wmax:
        break
    for we in wl:
        if m == hmax + wmax:
            break
        if not (he, we) in s:
            m += 1

print(m)
#ABC061D - Score Attack
#https://atcoder.jp/contests/abc061/tasks/abc061_d
#自己考察

import sys
n, m = list(map(int,input().split()))
lst = [[] for _ in range(n+1)]#*(n+1)の挙動がよくわからない
for i in range(n):
    a, b, c = list(map(int,input().split()))
    lst[a].append((b,-c))
dp = [float("Inf")]*(n+1)
dp[1] = 0

for _ in range(n):
    for f in range(1,n+1):
        if dp[f] != float("Inf"):
            for t, c in lst[f]:
                dp[t] = min(dp[t], dp[f] + c)

for f in range(1,n+1):
    for t,c in lst[f]:
        if dp[t] > dp[f] + c:
            print("inf")
            sys.exit()

print(-dp[n])

### FIXED CODE ###

import sys
 
inf = float('inf')
 
n, m = map(int, sys.stdin.readline().split())
abc = []
for _ in range(m):
    a, b, c = map(int, sys.stdin.readline().split())
    abc.append((a-1, b-1, -c))
 
def main():
    dist = [inf] * n
    dist[0] = 0
    for _ in range(n-1):
        for a, b, c in abc:
            dist[b] = min(dist[b], dist[a] + c)
 
    for _ in range(n):
        for a, b, c in abc:
            if dist[a] + c < dist[b]:
                dist[b] = -inf
 
    return -dist[n-1]
 
if __name__ == '__main__':
    ans = main()
    print(ans)
n,m = map(int, input().split())
num_ac = 0
num_wa = 0
tmp_num_wa = 0
answerd = []

for i in range(m):
  p,s = input().split()
  if p in answerd:
    continue
  if s == 'WA':
    tmp_num_wa += 1
  if s == 'AC':
    num_ac += 1
    num_wa += tmp_num_wa
    tmp_num_wa = 0
    answerd.append(_p)
    
print(num_ac, num_wa)

### FIXED CODE ###

n,m = map(int, input().split())
ac = [0]*n
wa = [0]*n

for i in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == 'AC':
     ac[p] = 1
  elif s == 'WA':
    if ac[p] == 0:
      wa[p] += 1

num_ac = 0
num_wc = 0

for a, w in zip(ac,wa):
  num_ac += a
  if a > 0:
    num_wc += w  
print(num_ac,num_wc)
if a[n-1] >= a[n-2]:
    peak.append(n-1)
for i in range(1, n-1):
    if a[i] >= a[i-1] and a[i] > a[i+1]:
        peak.append(i)
    if a[i] <= a[i-1] and a[i] < a[i+1]:
        botom.append(i)

for i in range(n):
    if i in botom:
        kabu = money//a[i]
        money %= a[i]
    if i in peak:
        money += kabu*a[i]
        kabu = 0

print(money)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
money = 1000
peak = []
botom = []
kabu = 0

if a[0] < a[1]:
    botom.append(0)
if a[n-1] >= a[n-2]:
    peak.append(n-1)
for i in range(1, n-1):
    if a[i] >= a[i-1] and a[i] > a[i+1]:
        peak.append(i)
    if a[i] <= a[i-1] and a[i] < a[i+1]:
        botom.append(i)

for i in range(n):
    if i in botom:
        kabu += money//a[i]
        money %= a[i]
    if i in peak:
        money += kabu*a[i]
        kabu = 0

print(money)
#c
n,m,x=map(int, input().split())
sp = [list(map(int, input().split())) for _ in range(m)]

import copy
result = []
def test(i,i_sum,cost):
    
    flag = 0
    if i <= n:
        print(i,i_sum,cost)
        for j in range(m):
            if i_sum[j] < x:
                flag = 1
                break

        if flag == 1:
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])#参考書を使わない場合

                for j in range(1,m+1):#参考書を使う場合
                    i_sum[j-1] += sp[i-1][j]
                cost[0] += sp[i-1][0]
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])
        else:
            result.append(cost[0])
test(0,[0]*n,[0])

if result != []:
    print(min(result))
else:
    print(-1)

### FIXED CODE ###

#c
n,m,x=map(int, input().split())
sp = [list(map(int, input().split())) for _ in range(n)]

import copy
result = []
def test(i,i_sum,cost):
    
    flag = 0
    if i <= n:
        for j in range(m):
            if i_sum[j] < x:
                flag = 1
                break

        if flag == 1:
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])#参考書を使わない場合

                for j in range(1,m+1):#参考書を使う場合
                    i_sum[j-1] += sp[i-1][j]
                cost[0] += sp[i-1][0]
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])
        else:
            result.append(cost[0])
test(0,[0]*m,[0])

if result != []:
    print(min(result))
else:
    print(-1)
def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, sqrt(x), 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())
    input_array = [int(input()) for i in range(element_number)]

    output = 0
    for x in input_array:
        if(is_prime(x)):
            output += 1

    print(output)

### FIXED CODE ###

import sys
import math

def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, math.ceil(math.sqrt(x))+1, 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())

    output = 0
    for x in map(int, sys.stdin.readlines()):
        if(is_prime(x)):
            output += 1

    print(output)
n = input()

count = 0
x = input()
for i in range(n - 1):
  for j in range(n):
    for k in range(n + 1):
      if i + j + k == x: count += 1
print(count)

### FIXED CODE ###

while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1 ,n):
            if i + j + j + 1 > x: break
            for k in range(j + 1 ,n + 1):
                if i + j + k == x:
                    count += 1
                    break
    print(count)
from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
C = [c for b, c in BC for _ in range(b)]
A.sort()
C.sort(reverse=True)
d = deque([])
# d.extend(C[max(len(C)-N, 0):])
d.extend(C[:N])
#
# print(A)
# print(d)

i = 0
while d:
    q = d.popleft()
    if q > A[i]:
        A[i] = q
        i += 1
    else:
        break

print(sum(A))


### FIXED CODE ###

A, B = map(int, input().split())
if A >= 13:
    print(B)
elif A >= 6:
    print(B//2)
else:
    print(0)
import re
if re.match ((hi)+, input()):
    print ("Yes")
else:
    print ("No")

### FIXED CODE ###

import re
if re.match ("^(hi)+$", input()):
    print ("Yes")
else:
    print ("No")
def main():
    # データ入力
    n, q = input().split()
    n = int( n )
    q = int( q )
    name = []
    time = []
    for i in range(n):
        tmp_n, tmp_t = input().split()
        name.append( tmp_n )
        time.append( int( tmp_t ) )

    # 処理
    count = 0
    while n > 0:
        if time[0] > q:
            time[0] -= q
            count += q
            time.append( time[0] )
            time.pop( 0 )
            name.append( name[0] )
            name.pop( 0 )
        else :
            count += time[0]
            print( name[0], end=" " )
            print( str( count ) )
            time.pop( 0 )
            name.pop( 0 )
            n -= 1

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    A = input().split()
    length = len(A)
    stack = []
    for i in range(length):
        if A[i] == "+":
            stack.insert( 0, stack[1] + stack[0] )
            stack.pop(1)
            stack.pop(1)
        elif A[i] == "-":
            stack.insert( 0, stack[1] - stack[0] )
            stack.pop(1)
            stack.pop(1)
        elif A[i] == "*":
            stack.insert( 0, stack[1] * stack[0] )
            stack.pop(1)
            stack.pop(1)
        else :
            stack.insert( 0, int(A[i]) )
    print( stack[0] )

if __name__ == "__main__":
    main()
s=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ma, mi = -100, 100
for i in range(s[0]-1):
    ma = max(ma, x[i])
for j in range(s[1]-1):
    mi = min(mi, y[j])
if (ma < mi and ma < s[3] and ((s[2] < mi <= s[3]) or (mi > s[3] and ma < s[3])):
    print("No War")
else:
    print("War")

### FIXED CODE ###

s=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ma, mi = -10000, 10000
for i in x:
    ma = max(ma, i)
for j in y:
    mi = min(mi, j)
ma = max(ma, s[2])
mi = min(mi, s[3])
if (ma < mi):
    print("No War")
else:
    print("War")
import numpy as np
n = int(stdin.readline().rstrip())
a = np.array([stdin.readline().rstrip().split() for _ in range(n)])
x = [stdin.readline().rstrip() for _ in range(n)][0]

i = np.where(a[:,0] == x)[0][0]
b = a[i+1:,1]
b = [int(i) for i in b]
print(sum(b))

### FIXED CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())
a = [stdin.readline().rstrip().split() for _ in range(n)]
x = [stdin.readline().rstrip() for _ in range(n)][0]

k = 0
for i in range(len(a)):
  name = a[i][0]
  time = a[i][1]
  if name == x:
    k = i
  else:
    pass
s = 0 
for i in range(len(a)):
  if i <= k:
    pass
  else:
    s = s + int(a[i][1])
print(s)
stone=input()
color=input()
a=int(stone)
counter=0
counter2=0
black = 0
white = 0
xxx=[]
yyy=[]
list=[]
for i in range(a):
    list.append(color[i])
for i in range(a):
    if list[i]=='#':
        xxx.append(i)
        black += 1
    if list[i]=='.':
        yyy.append(i)
        white += 1
if white ==0 or black==0:
    print('0')
else:
    s = min(xxx)
    t = max(yyy)
    for k in range(s,a):
        if list[k]=='.' :
            counter = 1+ counter
    for j in range(0,t):
        if list[j]=='#':
            counter2 = 1 +counter2
    if counter < counter2:
        print(counter)
    else:
        print(counter2)

### FIXED CODE ###

a = input().split()
i=int(a[0])
j=int(a[1])
k=int(a[2])
if i < k and j < k:
   print('No')
elif i>k and j>k:
   print('No')
else:
   print('Yes')
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):
a = len(h) - K
for _ in range(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)
import numpy as np
N = input()
s = map(int, input().split())
count = 0
while True:
  if np.all(np.array(s)%2):
    count += 1
  else:
    break
print(count)


### FIXED CODE ###

import numpy as np
N = input()
s = np.array(list(map(int, input().split())))
count = 0
while True:
  _exp = 2**(count+1)
  if np.all( s%_exp == 0):
    count += 1
  else:
    break
print(count)
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

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

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


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        uf.union(a, b)
    print(uf.group_count() - 1)   

if __name__ == "__main__":
    main()



### FIXED CODE ###

import sys
input = sys.stdin.readline
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

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

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


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())
        uf.union(a, b)
    print(uf.group_count() - 1)   

if __name__ == "__main__":
    main()