Harryxun/stf_run huggingface dataset:
a,b,c,k=map(int,input().split())

if k%2 == 0:
  if abs(a-b)<=10**18:print(a-b)
  else:print("Unfair")
else:
    if ans(b-a)<=10*18:print(b-a)
    else:print("Unfair")

### FIXED CODE ###

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

if k%2 == 0 and abs(a-b)<=10**18:print(a-b)
elif k%2 != 0 and abs(b-a)<=10**18:print(b-a)
else:print("Unfair")
x, y = map(int, input().split("  "))
X, y = map(int, input().split("  "))
ptint{(x-X)*(y-Y)}

### FIXED CODE ###

H,W = map(int, input().split(" "))
h,w = map(int, input().split(" "))
print((H-h)*(W-w))
from collections import deque
from itertools import accumulate


class CoeffTable:
    def __init__(self, n):
        self.n = n
        if n == 2:
            (self.p2, self.p1, self.m1, self.m2) = (0, 1, 1, 0)
        if n % 2 == 0:
            self.p1 = self.m1 = 1
            self.p2 = self.m2 = (n - 1) // 2
        else:
            self.p1 = 0
            self.m1 = 2
            self.p2 = (n - 1) // 2
            self.m2 = (n - 2) // 2
        if self.p2 + self.p1 + self.m1 + self.m2 != n:
            raise ValueError(f"n = {n}, {str(self)}")

    def reverse(self):
        (self.p2, self.p1, self.m1, self.m2) = (
            self.m2,
            self.m1,
            self.p1,
            self.p2,
        )

    def cumsum(self):
        return list(accumulate([self.p2, self.p1, self.m1, self.m2]))

    def __str__(self):
        return (
            f"(p2, p1, m1, m2) = ({self.p2}, {self.p1}, {self.m1}, {self.m2})"
        )


def main(n, seq):
    seq = sorted(seq, reverse=True)
    coeff = CoeffTable(n)
    cm = coeff.cumsum()
    ans1 = (
        2 * sum(seq[0 : cm[0]])
        + 1 * sum(seq[cm[0] : cm[1]])
        - 1 * sum(seq[cm[1] : cm[2]])
        - 2 * sum(seq[cm[2] : cm[3]])
    )
    coeff.reverse()
    rcm = coeff.cumsum()
    ans2 = (
        2 * sum(seq[0 : rcm[0]])
        + 1 * sum(seq[rcm[0] : rcm[1]])
        - 1 * sum(seq[rcm[1] : rcm[2]])
        - 2 * sum(seq[rcm[2] : rcm[3]])
    )
    ans = max(ans1, ans2)
    print(ans)
    return


if __name__ == "__main__":
    n = int(input())
    sample = []
    for _ in range(n):
        sample.append(int(input()))
    main(n, sample)


### FIXED CODE ###

from itertools import accumulate


class CoeffTable:
    def __init__(self, n):
        self.n = n
        if n == 2:
            (self.p2, self.p1, self.m1, self.m2) = (0, 1, 1, 0)
        if n % 2 == 0:
            self.p1 = self.m1 = 1
            self.p2 = self.m2 = (n - 1) // 2
        else:
            self.p1 = 0
            self.m1 = 2
            self.p2 = (n - 1) // 2
            self.m2 = (n - 2) // 2
    def reverse(self):
        (self.p2, self.p1, self.m1, self.m2) = (
            self.m2,
            self.m1,
            self.p1,
            self.p2,
        )

    def cumsum(self):
        return list(accumulate([self.p2, self.p1, self.m1, self.m2]))



def main(n, seq):
    seq = sorted(seq, reverse=True)
    coeff = CoeffTable(n)
    cm = coeff.cumsum()
    ans1 = (
        2 * sum(seq[0 : cm[0]])
        + 1 * sum(seq[cm[0] : cm[1]])
        - 1 * sum(seq[cm[1] : cm[2]])
        - 2 * sum(seq[cm[2] : cm[3]])
    )
    coeff.reverse()
    rcm = coeff.cumsum()
    ans2 = (
        2 * sum(seq[0 : rcm[0]])
        + 1 * sum(seq[rcm[0] : rcm[1]])
        - 1 * sum(seq[rcm[1] : rcm[2]])
        - 2 * sum(seq[rcm[2] : rcm[3]])
    )
    ans = max(ans1, ans2)
    print(ans)
    return


if __name__ == "__main__":
    n = int(input())
    sample = []
    for _ in range(n):
        sample.append(int(input()))
    main(n, sample)
number = int(input())

for i in range(number):
  tri = map(int, input.split(" "))
  if tri[0] > tri[1]:
    buf = tri[0]
    tri[0] = tri[1]
    tri[1] = buf
  if tri[1] > tri[2]:
    buf = tri[1]
    tri[1] = tri[2]
    tri[2] = buf
  if tri[0] * tri[0] + tri[1] * tri[1] == tri[2] * tri[2]:
    print("YES")
  else:
    print("NO")


### FIXED CODE ###

import math

num = int(input())

for i in range(num):
    try:
        sides = list(map(int, input().split(" ")))
        sides.sort()

        if int(math.pow(sides[0], 2)) + int(math.pow(sides[1], 2)) == int(math.pow(sides[2], 2)):
            print("YES")
        else:
            print("NO")

    except:
        break
def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+10000)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()

### FIXED CODE ###

def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+200000)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()
n = int(input())
w = input().split(" ")

a = []
k = False
z = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
        a[i] *= -1
        k = not (k)
    if a[i] == 0:
        z = True
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]

sum = sum(a)
if k and not(z):
    sum -= min
print(sum)

### FIXED CODE ###

n = int(input())
w = input().split(" ")

a = []
m = 0
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
        a[i] *= -1
        k = not (k)
    if i == 0:
        m = a[i]
    if a[i] < m:
        m = a[i]

sum = sum(a)
if k:
    sum -= m*2
print(sum)
N = int(input())
h = list(map(int, input().split()))

#大きな値
INF = 9999

# DPtable
dp = [INF]*10000

#初期条件
dp[0] = 0
dp[1] = abs(h[1]-h[0])

#ループ
for i in range(N):
    if i == 0 or i == 1:
        continue
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[-1])

### FIXED CODE ###

# N = int(input())
# h = list(map(int, input().split()))
# 
# #大きな値
# INF = 9999
# 
# # DPtable
# dp = [INF]*9999
# 
# #初期条件
# dp[0] = 0
# dp[1] = abs(h[1]-h[0])
# 
# #ループ
# for i in range(N):
#     if i == 0 or i == 1:
#         continue
#     else:
#         dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
# 
# print(dp[N-1])

N = int(input())
h = list(map(int, input().split()))
dp = [10 ** 10 for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[-1])
import math
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
b=a[::-1]
l=[0]*n
r=[0]*n
ans=[]
for i in range(1,n):
  l[i]=math.gcd(l[i-1],a[i-1])
for j in range(1,n):
  r[i]=math.gcd(r[i-1],b[i-1])
c=b[::-1]
for k in range(n):
  ans.append(math.gcd(l[k],r[k]))
print(max(ans))

### FIXED CODE ###

from fractions import *
n = int(input())
a = [0]+list(map(int, input().split()))+[0]
b = [0]*(n+2)
c = [0]*(n+2)
for i in range(1, n+1):
	b[i] = gcd(b[i-1], a[i])
for i in range(n, 0, -1):
	c[i] = gcd(c[i+1], a[i])
print(max(gcd(b[i-1], c[i+1]) for i in range(1, n+1)))
#sample answer.
input = S()
if (S=="abc") or (S=="acb") or (S=="bca") or (S=="cba") or (S=="cab") or (S=="bac"):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
if (S=="abc") or (S=="acb") or (S=="bca") or (S=="cba") or (S=="bac") or (S=="cab"):
  print("Yes")
else:
  print("No")
import sys
sys.setrecursionlimit(10**3)


def dfs(s,v=0,c=0):
  global ans
  if s==n-1:
    ans=max(ans, v-p*c)
  for i in range(n):
    if not to[s][i]: continue;
    if s==i:
      if p<to[s][i] and i==n-1: print(-1); exit()
      else: continue;
    dfs(i,v+to[s][i],c+1)
  #return ans


def main():
  for i in range(m):
    a,b,c=map(lambda x:int(x)-1,input().split())
    to[a][b]=c+1
  #print(to)
  dfs(0)
  print(max(0,ans))
  

if __name__=='__main__':
  n,m,p=map(int,input().split())
  to=[[0]*n for i in range(n)]
  ans=0
  main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)


def dfs(s):
    for i in to[s]:
        if not toflag[i]:
            toflag[i]=True
            dfs(i)


def rdfs(s):
    for i in ot[s]:
        if not otflag[i]:
            otflag[i]=True
            rdfs(i)


def bellman_ford():
    for i in range(n):
        upd=False
        for a,b,c in edges:
            if d[b]>d[a]+c:
                upd=True
                d[b]=d[a]+c     
        if not upd:
            break
        if i == n-1:
            print(-1)
            exit()


def main():

    for i in range(m):
        a,b,c=map(lambda x:int(x)-1,input().split())
        edges.append([a,b,-(c+1-p)])
        to[a].append(b)
        ot[b].append(a)

    toflag[0]=True
    otflag[n-1]=True
    dfs(0) # check for 0 to i path
    rdfs(n-1) # check for n-1 to i path
 
    for i in range(m):
        a,b,c=edges[i]
        if toflag[a] and otflag[a] and toflag[b] and otflag[b]: continue;
        edges[i]=[0,0,0]

    d[0]=0
    bellman_ford()
    print(max(0,-d[-1]))



if __name__=='__main__':
    n,m,p=map(int,input().split())
    edges=[]
    to=[[] for i in range(n)]
    ot=[[] for i in range(n)]
    toflag=[False]*n
    otflag=[False]*n
    d=[10**9]*n
    main()
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=!d.get(i,0)
print(sum(d.values()))

### FIXED CODE ###

d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=d.get(i,0)^1
print(sum(d.values()))
x,y,z=map(int, input().split)
 print(z,x,y)

### FIXED CODE ###

x,y,z=map(int,input().split())
print(z,x,y)
import copy
 
h, w = map(int, input().split())
 
lists = []
cnt = 0
mozi = ""
size = h * w
kaiseki = []
kaiseki2 = []
 
for i in range(h):
    s = input()
    mozi += s
 
lists = list(mozi)
 
 
for i in range(size):
    if lists[i] == "#":
        kaiseki.append(i)
 
 
while True:
    result = set(lists)
    if len(result) == 1:
        break
    cnt += 1
    for i in range(len(kaiseki)):
        if int(kaiseki[i]) - w >= 0:
            lists[int(kaiseki[i]) - w] = "#"
            kaiseki2.append(int(kaiseki[i]) - w)
        if int(kaiseki[i]) + w <= size - 1:
            lists[int(kaiseki[i]) + w] = "#"
            kaiseki2.append(int(kaiseki[i]) + w)
        amari = int(kaiseki[i]) % w
        if amari != 0:
            lists[int(kaiseki[i]) - 1] = "#"
            kaiseki2.append(int(kaiseki[i]) - 1)
        if amari != w-1:
            lists[int(kaiseki[i]) + 1] = "#"
            kaiseki2.append(int(kaiseki[i]) + 1)
    kaiseki.clear()
    kaiseki = kaiseki2.copy()
    kaiseki2.clear()
 
print(cnt)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
matrix = [["a" for _ in range(w+2)]] + [list("a" + input() + "a") for _ in range(h)] + [["a" for _ in range(w+2)]]

matrix_list1 = deque()
cnt = 0

for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j] == "#":
            matrix_list1.append([i,j])

while len(matrix_list1) != 0:     
    for _ in range(len(matrix_list1)):
        x,y = matrix_list1.popleft()
        if matrix[x+1][y] == ".":
            matrix[x+1][y] = "#"
            matrix_list1.append([x+1,y])
        if matrix[x-1][y] == ".":
            matrix[x-1][y] = "#"
            matrix_list1.append([x-1,y])
        if matrix[x][y+1] == ".":
            matrix[x][y+1] = "#"
            matrix_list1.append([x,y+1])
        if matrix[x][y-1] == ".":
            matrix[x][y-1] = "#"
            matrix_list1.append([x,y-1])
    else:
        if len(matrix_list1) > 0:
            cnt += 1
    
print(cnt)
X,t=mao(int,input().split())
print(max(X-t,0))

### FIXED CODE ###

X,t=map(int,input().split())
print(max(X-t,0))
def main():
 D = int(input().split())
 if D == 25:
     print('Christmas')
 elif D == 24:
     print('Christmas Eve')
 elif D == 23:
     print('Christmas Eve Eve')
 else:
     print('Christmas Eve Eve')
main()

### FIXED CODE ###

def main():
 D = int(input())
 if D == 25:
     print('Christmas')
 elif D == 24:
     print('Christmas Eve')
 elif D == 23:
     print('Christmas Eve Eve')
 else:
     print('Christmas Eve Eve Eve')
main()
x = int(raw_input)
h = x / 3600
m = (x % 3600) / 60
s = (x % 3600)  % 60
print str(h) + ":" + str(m) + ":" + str(s)

### FIXED CODE ###

x = int(raw_input())
h = x / 3600
m = (x % 3600) / 60
s = (x % 3600)  % 60
print str(h) + ":" + str(m) + ":" + str(s)
N = input()

    ab = input( )

    ab = ab.split()
    
    if 0 in ab:
        print(0)


    SUM = 1
    for i in range(int(N)):
        SUM = SUM * int(ab[i])
        if (int(SUM) < 10 ** 18):
            print(SUM)
        else:
        print(-1)

### FIXED CODE ###

def main ():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
        print (0)
        return
    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1) 
            return
    print(prod)

    
main ()
s = input()
t = input()
dp = [[0 for _ in range(len(s)+1)] for _ in range(len(t) + 1)]

for i,c1 in enumerate(s,1):
    for j,c2 in enumerate(t,1):
        if c1 == c2:
            dp[j][i] = dp[j-1][i-1] + 1
        else:
            dp[j][i] = max(dp[j-1][i],dp[j][i-1])

i1,i2 = len(s),len(t)

rev_ans = ""
while i1 != 0:
    lru = dp[i2-1][i1-1]
    now = dp[i2][i1]
    #  print(lru,now)
    if now - lru == 1:
        rev_ans += t[i2-1]
        i2 -= 1
        i1 -= 1
    elif now - dp[i2-1][i1] == 0:
        i2 -= 1
    else:
        i1 -= 1

for c in reversed(rev_ans):
    print(c,end='')


### FIXED CODE ###

s = input()
t = input()
dp = [[0 for _ in range(len(s)+1)] for _ in range(len(t) + 1)]

for i,c1 in enumerate(s,1):
    for j,c2 in enumerate(t,1):
        if c1 == c2:
            dp[j][i] = dp[j-1][i-1] + 1
        else:
            dp[j][i] = max(dp[j-1][i],dp[j][i-1])

i1,i2 = len(s),len(t)
#  print(" " + s)
#  for i,row in enumerate(dp):
    #  if i == 0:
        #  print(" ",row)
    #  else:
        #  print(t[i-1],row)

rev_ans = ""
while i1 != 0:
    lru = dp[i2-1][i1-1]
    now = dp[i2][i1]
    dup = now - dp[i2-1][i1]
    dleft = now - dp[i2][i1-1]
    dupleft = now - lru
    #  print(i1,i2,dupleft,dup,dleft)
    if dupleft == 1 and dleft == 1 and dup == 1:
        rev_ans += t[i2-1]
        i2 -= 1
        i1 -= 1
    elif dleft == 1:
        i2 -= 1
    else:
        i1 -= 1

for c in reversed(rev_ans):
    print(c,end='')
i = input()
i.split()
a = int(i[0])
b = int(i[2])

s = a * b
l = 2 * a + 2 * b

print(s,l)



### FIXED CODE ###

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

s = a * b
l = 2 * a + 2 * b

print(s,l)
n = int(input())
a,b,c = list(map(int,input().split()))
num = 0

while True:
    if a%2 == 0 and b%2 == 0 and c%2 == 0:
        a = a/2
        b = b/2
        c = c/2
        num += 1
    else:
        print(num)
        break

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
num = 0
flg = 1

while True:
    for i in range(len(l)):
        #print(i,num)
        if l[i] % 2 == 0:
            l[i] = l[i]/2
        else:
            print(num)
            flg = 0
            break
    if flg == 0:
        break
    else:
        num += 1
        continue
# CODE FESTIVAL 2016 Final
# B - Exactly N points
# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b
N = int(input())
for i in range(1, N):
    if i*(i+1)//2 >= N:
        k = i
        break

S = k*(k+1)//2
sub = S-N
for i in range(1, k+1):
    if i == sub:
        continue
    print(i)


### FIXED CODE ###

# CODE FESTIVAL 2016 Final
# B - Exactly N points
# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b
N = int(input())
for i in range(1, N+1):
    if i*(i+1)//2 >= N:
        k = i
        break


S = k*(k+1)//2
sub = S-N
for i in range(1, k+1):
    if i == sub:
        continue
    print(i)
1
lst = list(map(int,input().split()))
for i in lst:
  ct = 0
	if i == 5:
      ct += 1
    elif i == 7:
      ct += 1
if ct == 3:
  return "YES"
else:
  return "NO"

### FIXED CODE ###

lst = list(map(int, input().split()))
slst = sorted(lst)
if slst == [5, 5, 7]:
  print("YES")
else:
  print("NO")
n=int(raw_input())
g=raw_input().split()
a=[int(x) for x in g]
g=raw_input().split()
b=[int(x) for x in g]
#n=len()
acc=0
for i in range(n):
	inc=min(a[i],b[i])
	a[i]-=inc
	b[i]-=inc
	acc+=inc
	print(a,b,inc)
	inc=min(a[i+1],b[i])
	a[i+1]-=inc
	b[i]-=inc
	acc+=inc
	print(a,b,inc)
print(acc)

### FIXED CODE ###

n=int(raw_input())
g=raw_input().split()
a=[int(x) for x in g]
g=raw_input().split()
b=[int(x) for x in g]
#n=len()
acc=0
for i in range(n):
	inc=min(a[i],b[i])
	a[i]-=inc
	b[i]-=inc
	acc+=inc
	inc=min(a[i+1],b[i])
	a[i+1]-=inc
	b[i]-=inc
	acc+=inc
print(acc)
s=str(input())
X=int(s[0])
Y=int(s[2])
Z=int(s[4])
temp1=X
X=Y
Y=temp1
temp2=X
X=Z
Z=temp2
print(X,' ',Y,' ',Z)

### FIXED CODE ###

s=str(input())
l=[0,0]
i=0
for n in range(0,len(s)):
  if s[n]==' ':
    l[i]=n
    i+=1
  if i==2:
    break
X=int(s[0:l[0]])
Y=int(s[l[0]+1:l[1]])
Z=int(s[l[1]+1:len(s)])
temp1=X
X=Y
Y=temp1
temp2=X
X=Z
Z=temp2
print(X,' ',Y,' ',Z)
n,*L=map(int,open(0).read().split());r=range(0,2*n,2);print(sum(((L[i]-L[j])**2+(L[i+1]-L[j+1])**2)**.5for i in r for j in r))/n)

### FIXED CODE ###

from itertools import permutations
n = int(input())
div = 1
s = 0
for i in range(1, n + 1):
	div *= i
L = [list(map(int, input().split())) for _ in range(n)]
for x in permutations(range(n), n):
	s += sum(((L[i][0] - L[j][0]) ** 2 + (L[i][1] - L[j][1]) ** 2) ** .5 for i, j in zip(x, x[1:]))
print(s / div)
N=int(input())
X=int(input())
ans=0
f=False
for a in range(N):
  s,t=input().split()
  t=int(t)
  if(f):ans+=t
  if(s==X):f=True
print(ans)

### FIXED CODE ###

# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#######################################################################################################
N=int(input())

S=[]
T=[]
ans=0
f=False
for a in range(N):
  s,t=input().split()
  t=int(t)
  S.append(s)
  T.append(t)
X=input()
for a in range(N):
  if(f):ans+=T[a]
  if(S[a]==X):f=True
print(ans)
import copy

def main():
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)

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

    n, m = map(int, input().split())
    # これだと72がREになる
    A = set([int(x) for x in input().split()])
    # これだと74も78もREになる
    # A = [int(x) for x in input().split()]
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for i in A:
        if (a_lcm / 2) % i == 0:
        # if (a_lcm / i) % 2 == 0: 
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    # if (a_lcm / 2) > m:
    if a_lcm > m * 2:
        print(0)
    else:
        # あとは定数倍の数調べて終わり
        # ans = int((m - (a_lcm / 2))) // a_lcm + 1
        # ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        a_lcm = a_lcm // 2
        q = m // a_lcm
        if q % 2 == 0:
            ans = q // 2
        else:
            ans = q // 2 + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
A, B, C, K = map(int, input().split())  # a 1 b 0 c -1

if K <= A:
    print(K)

else:
    maxvalue = A
    K -= A
    if B >= 0:
        if K > 0:
            K = K - B
            if K <= 0:
                print(maxvalue)
    maxvalue -= K * -1
    print(maxvalue)



### FIXED CODE ###

s = input()
t = input()

if t[0:len(s)] == s and len(t) == len(s)+1:
    print('Yes')
else:
    print('No')
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
result = [-1] * N

if M == 0:


for i in range(1, M + 1):
    s, c = map(int, input().split())
    if result[s - 1] == -1:
        result[s - 1] = c
    elif result[s - 1] == c:
        continue
    else:
        print(-1)
        exit(0)

if N != 1 and result[0] == 0:
    print(-1)
    exit(0)

if N == 1 and result[0] == -1:
    print(0)
    exit(0)

if N != 1 and result[0] == -1:
    result[0] = 1

for i in range(len(result)):
    if result[i] == -1:
        print(0, end="")
    else:
        print(result[i], end="")
print()


### FIXED CODE ###

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

N, M = map(int, input().split())
result = [-1] * N

for i in range(1, M + 1):
    s, c = map(int, input().split())
    if result[s - 1] == -1:
        result[s - 1] = c
    elif result[s - 1] == c:
        continue
    else:
        print(-1)
        exit(0)

if N != 1 and result[0] == 0:
    print(-1)
    exit(0)

if N == 1 and result[0] == -1:
    print(0)
    exit(0)

if N != 1 and result[0] == -1:
    result[0] = 1

for i in range(len(result)):
    if result[i] == -1:
        print(0, end="")
    else:
        print(result[i], end="")
print()