Harryxun/stf_run huggingface dataset:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    s=input()
    zyx="zyxwvutsrqponmlkjihgfedcba"
    if s==zyx:
        print(-1)
        sys.exit()
    if len(s)==26:
        for i,sx in enumerate(zyx):
            if s[i]!=sx:
                sxi=s.index(sx)
                s=s[:sxi]
                sy=s[-1]
                for j in range(26):
                    sz=chr(ord(sy)+1)
                    if not(sz in s):     
                        print(s[:-1]+sz)
                        sys.exit()
    else:
        for i in range(26):
            if chr(ord('a')+i) in s:
                continue
            print(s+chr(ord('a')+i))
            break
    


if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    if len(s)==26:
        for i in range(25,0,-1):
            if s[i]<s[i-1]:
                continue
            else:
                sx=s[i-1]
                for j in range(1,25):
                    sy=chr(ord(sx)+j)
                    if sy in s[i:]:
                        print(s[:i-1]+sy)
                        sys.exit()
        else:
            print(-1)
    else:
        for i in range(26):
            if chr(ord('a')+i) in s:
                continue
            print(s+chr(ord('a')+i))
            break

if __name__=='__main__':
    main()
#!/usr/bin/env python3
import sys

a1, a2, a3 = map(int, sys.stdin.readline().split())
if a1+a2+a3>=22:
  print('bust')
  return
print('win')

### FIXED CODE ###

#!/usr/bin/env python3
import sys

a1, a2, a3 = map(int, sys.stdin.readline().split())
if a1+a2+a3>=22:
  print('bust')
else:
  print('win')
N = int(input())
A_list = list(map(int, input().split()))
two_list = [2 ** i for i in range(32)]
 
count = 0
items = {}
for a in A_list:
    if a in items:
        items[a] += 1
 
    else:
        items[a] = 1
A_list.sort(reverse=True)
 
for a in A_list:
    if items[a] >= 1:
 
        for t in two_list:
            m = t -a
            if m in items:
                if m == a and items[a] >= 2:
                    count += 1
                    items[a] -= 1
                    items[m] -= 1
                    break
 
                elif m != a and items[m] >= 1 and items[a] >=1:
                    count += 1
                    items[a] -= 1
                    items[m] -= 1
                    break
print(count)

### FIXED CODE ###

S = input()
S_list = []
for i in S:
    S_list.append(i)

w_count = S.count("W")
b_count = S.count("B")
c = 0

for i in range(len(S)):

    if S[i] == "B":
        c += w_count
    else:
        w_count -= 1

print(c)
print(-(int(inpuut())-1))
    

### FIXED CODE ###

x = int(input())
if x ==1:
  print(0)
else:
  print(1)
n, k = map(int, input().split())
a = (list)(map(int, input().split()))

if n <= k:
  print(1)
else:
  print(n//k+1


### FIXED CODE ###

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

print(-(-(n-1)//(k-1)))
from collections import deque
def bfs(graph, N, start):
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        for n in graph[node]:
            if not visited[n]:
                visited[n] = node + 1
                que.append(n)
    return visited

N, M = map(int, input().split())
graph = [[] for _ in range(M)]
for _ in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
visited = bfs(graph, N, 0)[1:]
if all(visited):
    print("Yes")
    print(*visited, sep="\n")
else:
    print("No")

### FIXED CODE ###

from collections import deque
def bfs(graph, N, start):
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        for n in graph[node]:
            if not visited[n]:
                visited[n] = node + 1
                que.append(n)
    return visited

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
visited = bfs(graph, N, 0)[1:]
if all(visited):
    print("Yes")
    print(*visited, sep="\n")
else:
    print("No")
n=int(input())

if (n % sum(map(int,list(n))) == 0):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=input()

if (int(n) % sum(map(int,list(n))) == 0):
  print("Yes")
else:
  print("No")
s = input()
len = 0
op = []
 
for i in s:
    if(i == '1'):
        op.append('1')
        len += 1
    elif(i == '0'):
        op.append('0')
        len += 1
    elif(i == 'B'):
        if(len > 0):
            op.pop()
            len = len - 1
 
for i in op:
    print(i, end = ''

### FIXED CODE ###

s=input()
l=[]
for i in range(len(s)):
    if s[i]=='0':
        l.append('0')
    elif s[i]=='1':
        l.append('1')
    elif s[i]=='B' and len(l)!=0:
        l.pop()
    
for i in l:
    print(i,end='')
# -*- coding: utf-8 -*-

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

count = 0

for i in range(N+1):
    if i > 0:
        if (A[i] > 0) and (B[i-1] > 0):
            tmp = min(A[i],B[i-1])
            count += tmp
            A[i] -= tmp
            B[i-1] -= tmp            

    if (A[i] > 0) and (B[i] > 0):
        tmp = min(A[i],B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

print(count)


### FIXED CODE ###

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

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

count = 0

for i in range(N):
    if i > 0:
        if (A[i] > 0) and (B[i-1] > 0):
            tmp = min(A[i],B[i-1])
            count += tmp
            A[i] -= tmp
            B[i-1] -= tmp            

    if (A[i] > 0) and (B[i] > 0):
        tmp = min(A[i],B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

if (A[N] > 0) and (B[N-1] > 0):
    tmp = min(A[N],B[N-1])
    count += tmp
    A[N] -= tmp
    B[N-1] -= tmp 

print(count)
import numpy as np

def product(list):
    p = 1
    for i in list:
        p *= i
    return p


n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)

### FIXED CODE ###


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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)
import math

n = int(input())
nn = math.floor(math.log2(abs(n)))
keta = 0
under = 0
s = ""

if n > 0:
    if n <= sum([2**i for i in range(0,nn+1,2)]):
        keta = nn+1
        under = sum([2**i for i in range(0,nn,2)])
    else:
        keta = nn+3
        under = sum([2**i for i in range(0,nn+1,2)])

    for i in range(1,keta):
        remainder = (n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "0" if i%2==1 else "1"
        else:
            s += "1" if i%2==1 else "0"
    else:
        s+="1"
    print(s[::-1])

elif n < 0:
    if n >= sum([(-2)**i for i in range(1,nn+1,2)]):
        keta = nn+1
        under = sum([(-2)**i for i in range(1,nn-1,2)])
    else:
        keta = nn+3
        under = sum([(-2)**i for i in range(1,nn+1,2)])
    for i in range(1,keta):
        remainder = abs(n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "1" if i%2==1 else "0"
        else:
            s += "0" if i%2==1 else "1"
    else:
        s+="1"
    print(s[::-1])

else:
    print(0)




### FIXED CODE ###

import math
import sys

n = int(input())
if n == 0:
  print(0)
  sys.exit()
  
keta = 0
under = 0
s = ""
nn = 1

if n > 0:
    while True:
      if sum([2**i for i in range(0,nn,2)])+1<= n and n <= sum([2**i for i in range(0,nn+1,2)]):
          keta = nn+1
          under = sum([2**i for i in range(0,nn,2)])
          break
      else:
          nn+=1

    for i in range(1,keta):
        remainder = (n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "0" if i%2==1 else "1"
        else:
            s += "1" if i%2==1 else "0"
    else:
        s+="1"
    print(s[::-1])

else:
    while True:
        if n <= sum([(-2)**i for i in range(1,nn,2)]) and n >= sum([(-2)**i for i in range(1,nn+1,2)]):
            keta = nn+1
            under = sum([(-2)**i for i in range(1,nn,2)])
            break
        else:
            nn+=1

    for i in range(1,keta):
        remainder = abs(n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "1" if i%2==1 else "0"
        else:
            s += "0" if i%2==1 else "1"
    else:
        s+="1"
    print(s[::-1])
import sys;sys.setrecursionlimit(100000);n,k=map(int,input().split());x,t=10**9+7,[set()for _ in range(n)]
for i in range(n-1):;a,b=map(int,input().split());t[a-1].add(b);t[b-1].add(a)
c=k
def b(o):
  for i,j in enumerate(t[o-1]):c=(c*(k-2-i))%x;t[j-1].discard(o);b(j)
for i,j in enumerate(t[0]):c=(c*(k-1-i))%x;t[j-1].discard(1);b(j)
print(c)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
n,k=map(int,input().split())
ans=k
t=[set()for i in range(n)]
dp=[k]+[0]*(n-1)
for i in range(n-1):
  a,b=map(int,input().split())
  t[a-1].add(b)
  t[b-1].add(a)
no=1
w=k
b=True
def a(noo):
  global ans
  w=k
  for i in t[noo-1]:
    t[i-1].discard(noo)
    if w==0:print(0);exit()
    dp[i-1]=w-2;ans=(ans*(w-2))%(10**9+7)
    w-=1
    a(i)
for i in t[no-1]:
  t[i-1].discard(no)
  w-=1
  dp[i-1]=w;ans=(ans*w)%(10**9+7)
  a(i)
print(ans)
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i4[::1],i4[::1])', cache=True)
def f(S, T):
    m, x, M = 0, 0, 0
    for i in range(len(S)):
        if S[i] == -1:
            x -= 1
        elif S[i] == 1:
            x += 1
        else:
            if x - 1 + T[i] >= m:
                x -= 1
            else:
                x += 1
        m = min(m, x)
        M = max(M, x)
    return M - m

S = np.array(list(read().rstrip().decode()), 'U1')

Si = np.zeros(len(S), np.int32)
Si[S == '0'] = -1
Si[S == '1'] = 1
S = Si

T = S.copy()
T[S == 0] = 1
T = np.cumsum(T)
T = np.minimum.accumulate(T[::-1])[::-1] - T
print(f(S, T))

### FIXED CODE ###

import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i8[::1],i8)', cache=True)
def test(S, A):
    def f(L, R):
        if L > R:
            return False
        for x in S:
            if x == 1:
                L, R = L + 1, R + 1
                if R > A:
                    R -= 2
            elif x == -1:
                L, R = L - 1, R - 1
                if L < 0:
                    L += 2
            else:
                L -= 1
                R += 1
                if L < 0:
                    L += 2
                if R > A:
                    R -= 2
            if L > R:
                return False
        return True

    for parity in (0, 1):
        L, R = 0, A
        if parity == 0:
            R -= A & 1
        else:
            L = 1
            R -= 1 - (A & 1)
        if f(L, R):
            return True
    return False

S = np.array(list(read().rstrip().decode()), 'U1')
Si = np.zeros(len(S), np.int64)
Si[S == '0'] = -1
Si[S == '1'] = 1
S = Si

low = 0  # むり
high = len(S) + 10  # おさめられる
while low + 1 < high:
    x = (low + high) // 2
    if test(S, x):
        high = x
    else:
        low = x

print(high)
n = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))

def f(i, j):
  if i == j == 0:
    return min(monsters[i], heros[i])
  if i == j - 1:
    return min(monsters[i+1], heros[i] - f(i, i))
  if i == j:
    return min(monsters[i] - f(i-1, i), heros[i])

s = 0
for i in range(n):
	s += f(i, i) + f(i, i+1)
print(s)

### FIXED CODE ###

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

sum_A = sum(A)

for i in range(N):
    if B[i] > A[i]:
        B[i] -= A[i]
        A[i] = 0
        A[i + 1] = max(0, A[i + 1] - B[i])
    else:
        A[i] = max(0, A[i] - B[i])

ans = sum_A - sum(A)
print(ans)
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(a[0]+a[1]+a[2])

### FIXED CODE ###

N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(*a,sep='')
a,b,x=map(int,input().split())
import math
 
if x == a**2*b/2:
  print(float(90)-math.degrees(math.atan(a/b)))
elif x < a**2*b/2:
  print(float(90)-math.degrees(math.atan(2*x/a/b/b)))
else:
  print(float(90)-math.degrees(math.atan((a*a*b-x)**(-1)*a**3/2)))

### FIXED CODE ###

a,b,x=map(int,input().split())
import math
 
if x == a**2*b/2:
  print(float(90)-math.degrees(math.atan(a/b)))
elif x == a*a*b:
  print(0)
elif x < a**2*b/2:
  print(float(90)-math.degrees(math.atan(2*x/a/b/b)))
else:
  print(float(90)-math.degrees(math.atan((a*a*b-x)**(-1)*a**3/2)))
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{

  int n;
  cin >> n;
  int v[n];

  rep(i, n) cin >> v[i];

  int seq0[100001] = {}, seq1[100001] = {};
  for (int i = 0; i < n; i += 2)
    ++seq0[v[i]];
  for (int i = 1; i < n; i += 2)
    ++seq1[v[i]];

  sort(seq0 + 1, seq0 + 100001, greater<int>());
  sort(seq1 + 1, seq1 + 100001, greater<int>());

  if (seq0[0] == seq1[0])
    cout << min(n - seq0[0][0] - seq1[0][1], n - seq[0][1] - seq1[0][0]);
  else
    cout << n - seq0[0][0] - seq1[0][0];
}

### FIXED CODE ###

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

judge_2n_1 = {}
judge_2n = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] not in judge_2n_1.keys():
            judge_2n_1[v[i]] = 1
        else:
            judge_2n_1[v[i]] += 1
    else:
        if v[i] not in judge_2n.keys():
            judge_2n[v[i]] = 1
        else:
            judge_2n[v[i]] += 1

judge_2n = sorted(judge_2n.items(), key=lambda x: x[1], reverse=True)
judge_2n_1 = sorted(judge_2n_1.items(), key=lambda x: x[1], reverse=True)
answer = n - 1

for i in judge_2n[:2]:
    for j in judge_2n_1[:2]:
        if i[0] != j[0]:
            answer = min(answer, n - i[1] - j[1])
        else:
            answer = min(answer, n - max(i[1], j[1]))

print(answer)
p=list(map(int,input().split()))
x=p.get(0)
print(x)

### FIXED CODE ###

p=list(map(int,input().split()))
x=p.index(0)
print(x+1)
def gcd(x, y):
    if x % y:
        return gcd(y, x % y)
    return y

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

n = int(input())
a = [int(i) for i in input().split()]
l = a[0]
for i in a[1:]:
    l = lcm(l, i)
print(sum(map(lambda x: (l - 1) % x, a)))


### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
print(sum(a) - n)
L,R = list(map(int,input().split()))
Y = []
for i in range(L, R):
    if i == 0:
        j = 1
        Y.append((i * j) % 2019)
    elif i * j == 2019:
        Y.append([0])
    else:
        for j in range(i+1, R+1):
            Y.append((i * j) % 2019)
print(min(Y))


### FIXED CODE ###

L,R = list(map(int,input().split()))
def main(L,R):
    mod_min = 2019
    if L // mod_min == R // mod_min:
        L %= mod_min
        R %= mod_min
        for i in range(L,R):
            for j in range(i+1, R+1):
                Y = i*j % 2019
                if Y < mod_min:
                    mod_min = Y
    else:
        mod_min = 0
    return mod_min
print(main(L,R))
a = input().split()
ans = []
for i in range(3):
    ans.append(a[i][i])
re = "".join(ans)
print(re)

### FIXED CODE ###

ans = []
for i in range(3):
    a = input()
    ans.append(a[i])
re = "".join(ans)
print(re)
N = int(input())
P = list(range(1, N+1))

M = []
for i in range(1, N+1):
    m = [i%x for x in P]
    M.append(max(m))
    del P[m.index(max(m))]
print(sum(M))

### FIXED CODE ###

N = int(input())
print((N-1)*N//2)
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
  N, K = map(int, input().split())

  z = abs(N-K)
  if z > K:
    print(z%K)
  else:
    print(K%z)

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()


def main():
  N, K = map(int, input().split())

  a = N%K
  if a > abs(a-K):
    print(abs(a-K))
  else:
    print(a)

if __name__ == '__main__':
  main()
people_num, first_point, correct = map(int,input().split())
people = [input() for i in range(people_num)]
points = [correct for i in range(people_num)]
 
for i in range(correct):
  for j in range(people_num):
    if j != i:
      points[j] -= 1
      if points[j] == 0:
        prints[j] = - 100000000
        
for i in range(people_num):
  if points[i] < 0:
  	print("No")
  else:
    print("Yes")

### FIXED CODE ###

people_num, first_point, correct = map(int,input().split())
who_correct = [input() for i in range(correct)]
points = [first_point-correct for i in range(people_num)]

 
for i in range(correct):
    points[int(who_correct[i])-1] += 1
    
for i in range(people_num):
  if points[i] <= 0:
  	print("No")
  else:
    print("Yes")
p,q,r = map(int,input().split)
print(min(p+q,q+r,r+p))

### FIXED CODE ###

p,q,r = map(int,input().split())
print(min(p+q,q+r,r+p))
def check(N, K):
    if N - 1 == K:
        print(N-1)
        for i in range(i + 2, N + 1):
            print(1, i)
        return
    elif N - 2 == K:
        print(N-1)
        for i in range(1, N):
            print(i, i+1)
        return
    elif N >= K:
        return
    else:
        print(-1)
        return



if __name__ == "__main__":
    N, K = map(int, input().split())
    check(N, K)


### FIXED CODE ###

def check(N, K):
    if K <= (N - 1)*(N-2) /2:
        k = int((N - 1)*(N-2)/2 - K)
        print(N-1 + k)
        for i in range(2, N+1):
            print(1, i)
        l = 2
        r = 3
        if k != 0:
            for i in range(k):
                if l > N or r > N:
                    break
                print(l, r)
                r+=1
                if r == N+1:
                    l+=1
                    r=l+1
        return
    else:
        print(-1)
        return


if __name__ == "__main__":
    N, K = map(int, input().split())
    check(N, K)
a="keyence"
s=input()
ans=1
for i in range(7):
  m=a[:i]
  n=a[i:]
  m=s.find(m)
  n=s.rfind(n)
  if m==-1 or n==-1:
    continue
  if n-m>=len(m):
    ans=0
    break
print("YNEOS"[ans::2])

### FIXED CODE ###

a="keyence"
s=input()
ans=1
for i in range(len(s)):
  for j in range(i,len(s)):
    if s[:i]+s[j:]==a:
      ans=0
print("YNEOS"[ans::2])
n = int(input())
ans = 1
ans2 = 1
mod = 1000000007
for i in range(n):
	ans = (ans*10)%mod
    ans2 = (ans2*8)%mod
ans = (ans - ans2 + mod)%mod
print(ans)

### FIXED CODE ###

n = int(input())
ans = 1
ans1 = 1
ans2 = 1
mod = 1000000007
for i in range(n):
	ans = (ans*10)%mod
	ans2 = (ans2*8)%mod
	ans1 = (ans1*9)%mod
ans = (ans - ans1 + mod)%mod
ans = (ans - ans1 + mod)%mod
ans = (ans + ans2)%mod
print(ans)
N = int(input())
A = []
for i in range(N):
    A[i] = list(map(int,input().split()))

print(A)

### FIXED CODE ###

input_AP = list(map(int, input().split()))
A = input_AP[0]
P = input_AP[1]

result = (A*3 + P)//2
print(result)
n,l=map(int,input().split())
s=[]
for i in range(n):
  s.append(input())
s.sort()
ans=""
for i in s:
  ans+=i
print(ans)

### FIXED CODE ###

abc=list(map(int,input().split()))
if abc.count(5)==2 and abc.count(7)==1:
  print ("YES")
else:
  print ("NO")
N = int(input())
A = [int(x) for x in input().split()]

if 0 in A:
    print(0)
    return

prod = 1
for a in A:
prod *= a
if prod > 10**18:
    print(-1)
    return

print(prod)

### 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()
pip install sympy
from sympy import isprime

x = int(input())
if x % 2 == 0:
  x += 1

flag = True

while flag == True:
  if isprime(x) == True:
    flag = False

print(x)

### FIXED CODE ###

x = int(input())

def isprime(s):
  if s>2 and s%2==0:
    return False
  else:
    flg = True
    for i in range(3, s//2+1, 2):
      if s%i == 0:
        flg = False
        break
    return flg

for i in range(x, 10**6):
  if isprime(i) == True:
    print(i)
    break
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
print(1 / np.sum(1 / a))

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
print(1 / np.sum(1 / a))
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
bc=[]
for i in range(M):
  bc.append(list(map(int,input().split())))

bc.sort(key=lambda x:x[1],reverse=True)
nbc=[0]*N
inde=0
for i in range(M):
  for j in range(bc[i][0]):
    if inde<N-1:
      nbc[inde]=bc[i][1]
      inde+=1
    elif inde==N-1:
      nbc[inde]=bc[i][1]
      break
      
    
    

      
for i in range(N):
  if A[i]>=nbc[i]:
    ind=i
    break

print(sum(nbc[:ind])+sum(A[ind:]))

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
bc=[]
for i in range(M):
  bc.append(list(map(int,input().split())))

bc.sort(key=lambda x:x[1],reverse=True)
nbc=[0]*N
inde=0
for i in range(M):
  for j in range(bc[i][0]):
    if inde<=N-1:
      nbc[inde]=bc[i][1]
      inde+=1
      if inde==N:
        break
  if inde==N:
    break
  
ind=N
for i in range(N):
  if A[i]>=nbc[i]:
    ind=i
    break

print(sum(nbc[:ind])+sum(A[ind:]))
N,K,Q = map(int,input().split())
A = [0]*N
for i in range(N):
    a = int(input())
    A[a-1] += 1
for i in range(N):
    x = K+A[i]-Q
    if X > 0:
        print('Yes')
    else:
        print('No')
    

### FIXED CODE ###

N,K,Q = map(int,input().split())
A = [0]*N
for i in range(Q):
    a = int(input())
    A[a-1] += 1
for i in range(N):
    x = K+A[i]-Q
    if x > 0:
        print('Yes')
    else:
        print('No')
S=input()

if S = "MON":
    print(6)
elif S = "TUE":
    print(5)
elif S = "WED":
    print(4)
elif S="THU":
    print(3)
elif S="FRI":
    print(2)
elif S="SAT":
    print(1)
else:
    print(7)

### FIXED CODE ###

S=input()

if S=="MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)
else:
    print(7)
a,b,c = map(int,input().split())
#lis = list(map(int,input().split()))
print((a-c)//(b+z))


### FIXED CODE ###

a,b,c = map(int,input().split())
#lis = list(map(int,input().split()))
print((a-c)//(b+c))
n = input()
if n == '1' :
    print('Hello World')
else :
    a,b = map(int,input().split())
    print(a+b)

### FIXED CODE ###

n = input()
if n == '1' :
    print('Hello World')
else :
    a = int(input())
    b = int(input())
    print(a+b)
N = int(input())
S = list(input())
count = 0

for i in range(N-2):
    if S[i]==("A") and S[i+1]==("B") and S[i+2]==("C"):
        count += 1

print(count)

### FIXED CODE ###

K,X = map(int, input().split())

if K*500>=X:
    print('Yes')
else:
    print('No')
s=[1,2,3]
a,b=raw_input.split()
s.remove(x)
s.remove(y)
print s[0]
  

### FIXED CODE ###

a=input()
b=input()
if a==1 and b==2:
  print "3"
elif a==2 and b==3:
  print "1"
elif a==3 and b==1:
  print "2" 
elif a==3 and b==2:
  print "1"
elif a==2 and b==1:
  print "3"
else:
  print "2"
import sys
 x = input()
 y = input()
print x*y , (x+y)*2

### FIXED CODE ###

a, b = map(int,raw_input().split())
print a*b, 2*(a+b)
n,a,b = map(int, input().split())

t = []
if n <= a+b:
    print(a)
else:
    for i in range(1,n+1):
        t += "b"*a +"r"*b
        i += 1
    s = t[:n]
    print(s.count("b"))

### FIXED CODE ###

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

t = n%(a+b)

if n < a:
    print(n)
else:
    if a > t > 0:
        print(n//(a+b)*a+t)
    elif t >= a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a)