Problem:


Score : 100 points

Problem Statement

Takahashi, who is A years old, is riding a Ferris wheel.

It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)

Find the cost of the Ferris wheel for Takahashi.

Constraints

0 ≤ A ≤ 100

2 ≤ B ≤ 1000

B is an even number.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the cost of the Ferris wheel for Takahashi.

Sample Input 1

30 100

Sample Output 1

100

Takahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.

Sample Input 2

12 100

Sample Output 2

50

Takahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.

Sample Input 3

0 100

Sample Output 3

0

Takahashi is 0 years old, and he can ride the Ferris wheel for free.



Sample input:
30 100


Sample output:
100

Submission status: Runtime Error

Solution code:
def wheel(a,b):
    if a>=13:
        return b
    if a>=6 and a<=12:
        return b/2
    if a<6
    return 0   
a,b = map(int, input().split())
print(wheel(a,b))

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
 
if a >= 13:
  print(b)
elif a >= 6 and a <= 12:
  print(int(b/2))
else:
  print(0)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
 
if a >= 13:
  print(b)
elif a >= 6:
  print((int)b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a, b = map(int(input().split()))
 
if a >= 13:
  print(b)
elif a >= 6:
  print((int)b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
ab = input().split();

a = ab[0]
b = ab[1]
 
if a >= 13:
  print(b)
elif a >= 6:
  print((int)b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
 
if a >= 13:
  print(b)
elif a >= 6:
  print((int)b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
 
if a >= 13:
  print(b)
elif a >= 6:
  print(b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
 
if a >= 13:
  print(b)
elif a >= 6 and a <= 12:
  print(int(b/2))
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
 
if a >= 13:
  print(b)
elif a >= 6 and a <= 12:
  print(b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
 
if a >= 13:
  print(b)
elif a >= 6 && a <= 12:
  print(b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = (int)input()
b = (int)input()

if a >= 13:
  print(b)
elif a >= 6 && a <= 12:
  print(b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = (int)input();
b = (int)input();
if a >= 13:
  print(b)
elif a >= 6 && a <= 12:
  print(b/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if a >= 13:
    print(b)
if a >= 6 and a <= 12:
    print(int(b/2))
if a <= 5:
    print(0)

Submission status: Runtime Error

Solution code:
A, B=int(input())
if A>=13:
    print(B)
elif 6<=A<=12:
    print(B/2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
a,b=map(int,input.split())
if a>12:
    print(b)
elif a>5:
    print(b//2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
if a[0] <= 5:
  print(0)
elif a[0] <= 12:
  print(int(a[1]//2)
else:
  print(a[1])

Submission status: Runtime Error

Solution code:
a = int(input().split())
if a[0] <= 5:
  print(0)
elif a[0] <= 12:
  print(a[1]/2)
else:
  print(a[0])

Submission status: Runtime Error

Solution code:
A,B = map(int, input().split())
if a>= 13:
    print(B)
elif a>=6:
    print(B//2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
#define ALL(a) (a).begin(), (a).end()
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int A, B;
  cin >> A >> B;

  if (A > 12) {
    cout << B << endl;
  } else if (A < 6) {
    cout << 0 << endl;
  } else {
    cout << B / 2 << endl;
  }

  return 0;
}

Submission status: Runtime Error

Solution code:
if __name__ == ‘__main__’:
  inputs=[int(line) for line in input().split(' ')]
  age,b=inputs[0],inputs[1]
  if age<6:
    print(0)
  elif age<13:
    print(b/2)
  else:
    print(b)

Submission status: Runtime Error

Solution code:
from sys import stdin

n, m = map(int, stdin.readline().split())
a = [int(num) for num in stdin.readline().split()]

cnt_list = [(a[i], 1) for i in range(n)]
for i in range(m):
    b, c = map(int, stdin.readline().split())
    cnt_list.append((c, b))

cnt_list.sort()
cnt_list.reverse()

cnt = n
ans = 0

for (k, v) in cnt_list:
    acc_v = min(v, cnt)
    ans += k * acc_v
    cnt -= acc_v


print(ans)

Submission status: Runtime Error

Solution code:
# D - Integer Cards
# https://atcoder.jp/contests/abc127/tasks/abc127_d

import sys

n, m = list(map(int, sys.stdin.readline().split()))
cards = list(map(int, sys.stdin.readline().split()))
cards.sort()

set = [list(map(int, sys.stdin.readline().split())) for _ in range(m)]

# combinations.sort(key = lambda x: x[1], reverse = True)
combinations = []
for b, c in set:
    combinations.extend([c] * b)

combinations.sort(reverse = True)

for i in range(len(combinations)):
    if i > len(cards) or combinations[i] <= cards[i]:
        break
    else:
        cards[i] = combinations[i]

print(sum(cards))

Submission status: Runtime Error

Solution code:
def abc127d():
    N, M = (int(s) for s in input().split(" "))
    A = sorted(list(int(s) for s in input().split(" ")))
    for i in range(0, M):
        B, C = (int(s) for s in input().split(" "))
        r = len(list(filter(lambda x: x < C, A[:B])))
        A = sorted([C for n in range(0, r)] + A[r:])
    print(sum(A))
abc127d()

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

p=[]
q=[]

for i in range(m):
    l,r=map(int,input().split())
    p.append(l)
    q.append(r)

p1=max(p)
q1=min(q)

if p1>=q1:
    print(q1-p1+1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
t_list = [[0] * 2 for _ in range(M)]
ans = 0
is_change = False
for i in range(M):
  t_list[i] = list(map(int, input().split()))
bottom = t_list[i][0]
up = t_list[i][1]
for i in range(M):
  t_bottom = t_list[i][0]
  t_up = t_list[i][1]
  if t_bottom > bottom and t_bottom <= up:
    bottom = t_bottom
    is_change = True
  if t_up < up and t_up >= bottom :
    up = t_up
    is_change = True
if is_change:
  print(ans)
else:
  print("0")

Submission status: Runtime Error

Solution code:
from sys import stdin
from collections import deque
N, M = map(int, stdin.readline().rstrip().split())
A = [int(x) for x in stdin.readline().rstrip().split()]
A.sort()
A = deque(A)
X = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]
Y = []
for b, c in X:
    Y.extend([c] * b)
Y.sort()
Y = deque(Y)

for i in range(len(X) if len(X) < len(A) else len(A)):
    a = A.popleft()
    c = Y.pop()
    if a < c:
        A.append(c)
    else:
        A.append(a)
        print(sum(A))
        quit()
print(sum(A))

Submission status: Runtime Error

Solution code:
r, D, x = map(int, input().split())
for i in range(10):
  x = r*x-D
  print(x)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from operator import itemgetter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

      


def main():
    N, M = i2nn()
    A = [(1, x) for x in i2nn()]
    S = [0] * M
    for j in range(M):
        S[j] = tuple(i2nn())
    S.extend(A)
    R = sorted(S, key=itemgetter(1))
    sum = 0
    while True:
        p = R.pop()
        if N - p[0] > 0:
            sum += p[0] * p[1]
            N -= p[0]
        else:
            sum += p[1] * N
            break
    print(sum)
    return

main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
  if R1 < L2 or R2 < L1:
    return(False)
  else:
    a = [R1,L1,R2,L2]
    a.sort()
    return(a[1],a[2])

for i in range(M - 1):
  L,R = map(int, input().split())
  if find_key(L1,R1,L,R) != False:
    L1,R1 = find_key(L1,R1,L,R)
  else:
    flag = 1
    print(0)
    break
if flag = 0:
  print(R1-L1+1)

Submission status: Runtime Error

Solution code:
A, B = map(int, input())
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B // 2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
  if R1 < L2 or R2 < L1:
    print(0)
    flag = 1
    break
  else:
    a = [R1,L1,R2,L2]
    a.sort()
    return(a[1],a[2])

for i in range(M - 1):
  L,R = map(int, input().split())
  L1,R1 = find_key(L1,R1,L,R)
if flag == 1:
  print(L1,R1)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a_list = list(map(lambda x: int(x), input().split()))
for _ in range(m):
  b, c = map(int, input().split())
  ll = [c for _ in range(b)]
  a_list.extend(ll)
a_list.sort(reverse=True)
print(sum(a_list[::-n]))

Submission status: Runtime Error

Solution code:
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    for m in range(0, M):
        tmp = [int(x) for x in input().split()]
        A.extend([tmp[1]] * tmp[0])

    A = A.sort(A, reverse = True)
    sum_a = 0
    for i in range(0, N):
        sum_a += A[i]

    print(sum_a)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

if min(R) >= max(L):
    print(min(R) - max(L) + 1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())


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

A.sort()

BC = [list(map(int,input().split())) for _ in range(M)]

BC.sort(key=lambda x:x[1],reverse=True)

for b,c in BC:
    A.expend([c]*b)
    if len(A)>2*N:
        break

A.sort(reverse=True)
suma=0
#for i in A:
#    suma+=i

print(sum(A[:N]))

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    if a >= c or i == len(As):
      break
    else:
      num += c
      i += 1
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
if A>12:
    print(B)
elif 13>A>5:
    print(B//2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())

DIV = 10**9+7

def comb(l, r):
    if l == 0:
        return 1
    val = 1
    for i in range(r, r-l, -1):
        val *= i
    for i in range(l, 0, -1):
        val //= i
    return val


#p = comb(K-2, N*M-2)
#print(K-2, N*M-2, p)
ans = 0
for i in range(N):
    for j in range(M):
        if i == 0 and j == 0:
            continue
        d = i+j
        #print(i, j, calc_rec_num(N, M, 0, 0, i, j))
        cnt = (N-i) * (M-j)
        if i != 0 and j != 0:
            cnt *= 2
        ans += d * cnt
        #if ans > DIV:
        #    ans %= DIV
        #print(ans)

print((ans*p)%DIV)

Submission status: Runtime Error

Solution code:
import sys

n,m = input().split()
n,m = int(n), int(m)


list = []

count = 0
lMin, rMax = -1, -1

for i in range(0,m) :
    l, r = input().split()

    list.append((int(l),int(r)))

    if lMin == -1 and rMax == -1:
        lMin, rMax = list[i]
    else:
        if lMin < list[i][0] :
            lMin = list[i][0]
            
        if rMax > list[i][1] :
            rMax = list[i][1]

print(rMax - lMin +1)

Submission status: Runtime Error

Solution code:
x,y,z=input().split()
x=int(x)
y=int(y)
z=int(z)
for i in range(10):
  z=x*z-y
  print(z)

Submission status: Runtime Error

Solution code:
from bisect import bisect_left
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
b =[]
for i in range(M):
    B,C = map(int, input().split())
    b.extend([C for _ in range(B)])
bisec = bisect_left
ex = A.extend
b.sort()
b.reverse()
for i in range(N):
    if A[i]<b[-1]:
        l = bisec(b,A[i])
        A[i] = b[l]
        del b[l]
    else:
        break
print(sum(A))

Submission status: Runtime Error

Solution code:
year,original = input().split()
if int(year) >= 13:
  print(int(original)
elif 6<=int(year)<=12:
  print(int(original)/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
year = input()
original = input()
if int(year) >= 13:
  print(int(original)
elif 6<=int(year)<=12:
  print(int(original)/2)
else:
  print(0)

Submission status: Runtime Error

Solution code:

if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    bc = []
    for i in range(m):
        bc.append(list(map(int, input().split())))

    bc.sort(key=lambda x: x[1], reverse=True)
    a.sort()

    bcn = 0
    for i in range(n):
        if(a[i] < bc[bcn][1]):
            a[i] = bc[bcn][1]
            bc[bcn][0] -= 1
            if(bc[bcn][0] == 0):
                bcn += 1
                if(bcn == m):
                    break

    print(sum(a))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
cards = list(map(int, input().split()))
 
def calc():
  for i in range(m):
    b,c = map(int, input().split())
    if(min(cards) > c or b == 0):
      continue
    for i in range(b):
      if(b == 0):
        break
      card_min = min(cards)
      if(c > card_min and b > 0):
        cards.remove(card_min)
        cards.append(c)
        b -= 1
  return sum(cards)
 
print(calc())

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
if B%2==0:

    if A>12:
        print(B)
    elif 13>A>5:
        print(round(B/2))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
import numpy as np
from sys import stdin

def main():
    nm = [int(x) for x in stdin.readline().rstrip().split()]
    gate = np.full([nm[1], nm[0]], False)
    
    for i in range(nm[1]):
        g = [int(x) for x in stdin.readline().rstrip().split()]
        for k in range(g[0]-1, g[1]):
            gate[i,k] = True

    count = 0
    for i in range(len(gate[0])):
        tmp = gate[:, i]
        if tmp.all():
            count += 1
        
    print(count)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
inputData = input()
ID, Gate = map(int, inputData.split())
x = []
for i in range(Gate):
    inputId = input()
    idStart, idEnd = map(int, inputId.split())
    idList = list(range(idStart, idEnd + 1))
    x.append(idList)

# print(x[0])


def solve():

    for i in range(len(x)):
        if i == 0:
            matched = set(x[0])
            continue

        tempX = set(x[i])
        # print('++')
        # print(matched)
        # print(tempX)
        matched = set(list(matched & tempX))
        # print(matched)
        if len(matched) == 0:
            #
            return 0

    return len(matched)


ans = solve()
print(ans)

Submission status: Runtime Error

Solution code:

import copy

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

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

B =[]
C =[]

tA = []
ans = sum(A)

for i in range(M):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)

for i in range(N):
    for j in range(M):
        tA = copy.copy(A)
        for k in range(B[j]):
            if tA[i] < C[j]:
                tA[i] = C[j]
        if sum(tA) > ans:
            ans = sum(tA)

print (ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# abc127/abc127_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    N, M = i2nn()
    L, R = (0, N)
    for i in range(M):
        Li, Ri = i2nn()
        if L < Li:
            L = Li
        if Ri < R:
            R = Ri
    if L > R:
        print(0)
    else:
        print(R - L + 1)
    return

main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

all_lists = [list(range(L[i], R[i] + 1)) for i in range(M)]

new_set = set(all_lists[0])
for i in range(len(all_lists) - 1):
    if len(new_set) == 0:
        break
    new_set = new_set & set(all_lists[i + 1])

print(len(new_set))

Submission status: Runtime Error

Solution code:
q = int(input())

keisuu_lower = []
keisuu_upper = []
keisuu_lower_max = 0
keisuu_upper_min = float("inf")
keisuu_lower_count = 0
keisuu_upper_count = 0
keisuu_lower_sum = 0
keisuu_upper_sum = 0
teisuu = 0

for i in range(q):
    query = input()
    if query == "2":
        print(keisuu_lower_max,
              - keisuu_lower_sum + keisuu_lower_count * keisuu_lower_max
              + keisuu_upper_sum - keisuu_upper_count * keisuu_lower_max + teisuu)

    else:
        _, a, b = [int(i) for i in query.split()]
        keisuu_lower.append(a)
        keisuu_lower_count += 1
        keisuu_lower_max = max(keisuu_lower_max, a)
        keisuu_lower_sum += a

        if keisuu_lower_count > keisuu_upper_count + 1:
            keisuu_lower.sort()
            c = keisuu_lower.pop()
            keisuu_lower_count -= 1
            keisuu_lower_max = keisuu_lower[-1]
            keisuu_lower_sum -= c

            keisuu_upper.append(c)
            keisuu_upper.sort(reverse=True)
            keisuu_upper_count += 1
            keisuu_upper_min = keisuu_upper[-1]
            keisuu_upper_sum += c

        elif keisuu_lower_count < keisuu_upper_count:
            keisuu_upper.sort()
            c = keisuu_upper.pop()
            keisuu_upper_count -= 1
            keisuu_upper_min = keisuu_upper[-1]
            keisuu_upper_sum -= c

            keisuu_lower.append(c)
            keisuu_lower.sort(reverse=True)
            keisuu_lower_count += 1
            keisuu_lower_max = keisuu_lower[-1]
            keisuu_lower_sum += c

        if keisuu_lower_max > keisuu_upper_min:
            d = keisuu_upper.pop()
            e = keisuu_lower.pop()
            keisuu_lower.append(d)
            keisuu_upper.append(e)
            keisuu_lower_sum += d - e
            keisuu_upper_sum += e - d
            keisuu_lower_max = d
            keisuu_upper_min = e

        #print(keisuu_lower)
        #print(keisuu_lower_sum)
        #print(keisuu_lower_max)
        teisuu += b

Submission status: Runtime Error

Solution code:
n, m=map(int,input().split())
a=list(map(int, input().split()))

for i in range(m):
    b,c=map(int,input().split())
    a+=([c]*b)

a.sort()
a.reverse()
ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
x,y,z=input().split()
x=int(x)
y=int(y)
z=int(z)
for i in range(10):
  d=x*z-y
  print(d)
  z=d

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split()) #nがカードの数、mがBの数
a = list(map(int, input().split()))
b = [list(map(int,input().split())) for i in range(m)]

print(a,b)
'''for i in range(m):
  a.extend([b[i][1]]*b[i][0])
a.sort(reverse=True)
ans = 0
for i in range(n):
  ans += a[i]
print(ans)'''

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split()) #nがカードの数、mがBの数
a = list(map(int, input().split()))
b = [list(map(int,input().split())) for i in range(m)]
 
for i in range(m):
  a.extend([b[i][1]]*b[i][0])
a.sort(reverse=True)
ans = 0
for i in range(n):
  ans += a[i]
print(ans)

Submission status: Runtime Error

Solution code:
x,y,z=input().split()
x=int(x)
y=int(y)
z=int(z)
for i in range(11):
  d=x*z-y
  print(d)
  z=d

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
l = [0] 
r = [0]
all_gate_clear = 0


#numcard
#gatenum
N, M = map(int, input().split())
card_count = range(N+1)

#idカードの生成
for i in range(1,M+1):
    l_temp,r_temp = map(int, input().split())
    l.append(l_temp)
    r.append(r_temp)
    
for gate_num in range(1,M+1):
    #1ゲートの処理
    for card in range(1,N+1):
        num = 0
        while r[gate_num] > l[gate_num] + num:
            if l[gate_num] + num == card:
                if card_count[card] == gate_num -1:
                    card_count[card] += 1
                    break
            num += 1

for card in range(1,N+1):
    if card_count[card] == M:
        all_gate_clear += 1

print(all_gate_clear)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

N, M = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
for i in range(M):
    B, num = map(int, input().strip().split())
    for j in range(B):
        A[A.index(min(map(lambda x: x - num, nums))+num)] = max(num,x)
print(sum(A))

Submission status: Runtime Error

Solution code:
from fractions import *
import sys
N, M = map(int, input().split())

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

a = sorted(a)
bc = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

bc = sorted(bc)    

subar = a
for i in bc:
    sc = [i[1]] * i[0]
    suba = []
    ra = subar[i[0]:]
    if i[0] == len(a):
        suba = a
    suba = subar[:i[0]]
    if i[1] - max(suba) < 0:
        continue
    subar = sc + ra
    subar.sort()

print(sum(subar))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i in range(m):
    b, c = map(int, input().split())
    for j in range(b):
        A[j] = max(A[j], c)
    A = sorted(A)
print(sum(A))

Submission status: Runtime Error

Solution code:
list_l = []
list_R = []
ID,gate = map(int,input().split())
s = 0
for i in range(gate):
  l,r = map(int,input().split())
  list_l.append(l)
  list_R.append(r)
a = max(list_l)
b = min(list_R)

for i in range(ID+1):
  if a <= i <= b:
    s += 1
  else:
    None
print(s)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
gates = [list(map(int,input().split())) for _ in range(m)]
l = []
r = []
for gate in gates:
    l.append(gate[0])
    r.append(gate[1])
ans = min(r)+1 - max(l)
print(ans if ans > 0 else 0)

Submission status: Runtime Error

Solution code:
r,D,x = [int(i) for i in input().split()]
n=2000
X=r*x-D
x=X
while n <=2010: 
  print(x) 
  X=r*x-D
  x=X
  n=n+1

Submission status: Runtime Error

Solution code:
n,m=(int(i) for i in input().split())
a=[]
a.append(int(j) for j in input().split())
for i in range(m):
  b,c=(int(i) for i in input().split())
  a.sort()
  for j in range(b):
    if a[j]<c:
      a[j]=c
r=0
for i in range(n):
  r=r+a[i]
print(r)

Submission status: Runtime Error

Solution code:
import numpy as np

N,M = map(int, input().split())
A_array = np.array([int(i) for i in input().split()])
Current_Min = A_array[A_array.argmin()]
for j in range(M):
    B_tmp, C_tmp = map(int,input().split())
    if Current_Min >= C_tmp:
        continue
    for k in range(B_tmp):
        A_array[A_array.argmin()] = C_tmp
    
    Current_Min = A_array[A_array.argmin()]
    

print(sum(A_array))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = []
c = []
for i in range(m):
        bb,cc =map(int,input().split())
        b.append(bb)
        c.append(cc)
a.sort()
for i in range(m):
        for j in range(b[i]):
                if a[j] < c[i]:
                        a[j] = c[i]
                elif a[j] >=c[i]:
                        continue
        a.sort()
print(sum(a))

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
list_and = list(range(1,N+1,1))
for i in range(M):
    L, R = list(map(int, input().split()))
    list_temp = list(range(L,R+1,1))
    list_and = list(set(list_and) & set(list_temp))
print(len(list_and))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

def main(args):
    r = int(args[0])
    d = int(args[1])
    x = int(args[2])
    ar = np.zeros([10], dtype=int)

    ar[0] = r*x-d
    for i in range(1,len(ar)):
        ar[i] = r*ar[i-1]-d

    for i in ar:
        print(i)

if __name__ == "__main__":
    main(stdin.readline().rstrip().split())

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

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

for i in range(M-1):
    A2, B2 = map(int, input().split())

    if (A < A2 and B2 < A) or (B < A2 and B< B2):
        A = 0
        B = 0
    if (A2 <= A and B <= B2):
        pass
    elif (A2 <= A and A <= B):
        B = B2

    elif (A2 <= B and B <= B2):
        A = A2
    else:
        A = A2
        B = B2


if (B-A) <= 0:
  print(0)
else:
  print(B-A+1)

Submission status: Runtime Error

Solution code:
r, D, x = map(int, input().split())
2<=r<=5
1<=D<=100
D<=x<=200
while x <= 200 :
    x = r*x - D
    print(x)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

def main(args):
    r = args[0]
    d = args[1]
    x = args[2]
    ar = np.zeros([10], dtype=int)

    ar[0] = r*x-d
    for i in range(1,len(ar)):
        ar[i] = r*ar[i-1]-d

    for i in ar:
        print(i)

if __name__ == "__main__":
    main([int(x) for x in stdin.readline().rstrip().split()])

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
li = list(map(int,input().split()))

li.sort()
tmp = 0

for i in range(M):
    B, C = map(int, input().split())
    for j in range(B):
        if li[j] < C:
            li[j] = C
        else:
            break
    li.sort()

print(sum(li))

Submission status: Runtime Error

Solution code:

import sys

def input():
    return sys.stdin.readline()[:-1]

n, m = map(int, input().split())

# 0 - n-1
a = sorted(list(map(int, input().split())))

for j in range(m):
    b, newVal = map(int, input().split())
    if b >= n:
        a_new = [i if i >= newVal else newVal for i in a]
    else:
        mae = a[:b]
        ato = a[b:]
        mae_new = [i if i >= newVal else newVal for i in mae]
        mae_new.extend(ato)
        a = sorted(mae_new)

print(sum(a))

Submission status: Runtime Error

Solution code:
x,y,z=input().split()
x=int(x)
y=int(y)
z=int(z)
i=0
while i<10:
  d=x*z*-y
  print(d)
  i+=1

Submission status: Runtime Error

Solution code:
from sys import stdin

N, M = map(int, stdin.readline().split())
A = list(map(int, stdin.readline().split()))
for _ in range(M):
    B, C = map(int, stdin.readline().split())
    A.extend([C]*B)
A.sort(reverse=True)
ans = 0
for i in range(N):
    ans += A[i]

print(ans)

Submission status: Runtime Error

Solution code:
# coding:utf-8
if __name__=='__main__':
  r,D,x = map(int, input().split())
  for i in range(10):
    x = r*x-D
    print(x)

Submission status: Runtime Error

Solution code:
import numpy as np
N ,M = (int(x) for x in input().split())
a = np.array([int(x) for x in input().split()])
for i in range(M):
    B,C = (int(x) for x in input().split())
    a = np.insert(a, np.shape(a) ,np.full(B, C))

a_sort = np.sort(a)
print(np.sum(a_sort[-N:]))

Submission status: Runtime Error

Solution code:
a,b,c=input(int()).split()
s = b
aa = int(a)
cc = int(c)
bb = int(b)
for i in  range(10):
    d= aa * cc - bb
    cc = d
    print (int(d))

Submission status: Runtime Error

Solution code:
import sys

n, m = map(int, input().split())
nums = []

for i in range(n):
    nums.append(i + 1)

for i in range(m):
    l, r = map(int, input().split())
    nums = list(filter(lambda x: l <= x <= r, nums))
    if len(nums) == 0:
        print(0)
		sys.exit()

print(len(nums))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = []
c = []
for i in range(m):
        bb,cc =map(int,input().split())
        b.append(bb)
        c.append(cc)
a.sort()
for i in range(m):
        for j in range(b[i]):
                if a[j] < c[i]:
                        a[j] = c[i]
                a.sort()
print(sum(a))

Submission status: Runtime Error

Solution code:
import numpy as np

n,m=map(int,input().split())
a=input().split()
a = list(map(int, a))
a = np.array(a)
for i in range(m):
    a = np.sort(a)
    b,c=map(int,input().split())
    for j in range(b):
        if a[j]<c:
            a[j] = c
a = np.array(a)
print(a.sum())

Submission status: Runtime Error

Solution code:
from sys import stdin 

def main(args):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    if 6 <= a and a <= 12:
        v = b//2
    elif a <= 5:
        v = 0
    else:
        v = b
    print(v)

main()

Submission status: Runtime Error

Solution code:
import numpy as np
from sys import stdin
sys.setrecursionlimit(10**6) 

def main(args):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    if 6 <= a and a <= 12:
        v = b//2
    elif a <= 5:
        v = 0
    else:
        v = b
    print(v)

main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

answer = []
tmp = []

L, R = map(int, input().split())
answer = list(range(L, R+1))

for i in range(M-1):
    L, R = map(int, input().split())
    for j in range(L, R+1):
        if j in answer:
            tmp.append(j)
        elif j > answer[-1]:
            continue
            
    answer = tmp
    tmp = []

print(len(answer))

Submission status: Runtime Error

Solution code:
import sys
a, b, c = map(int, raw_input().split())
i=0
while 1:
  c = a*c - b
  print c
  i = i + 1
  if i > 9 :
      sys.exit()

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())

if A >= 13:
	print(B)
    
elif 6 <= A <= 12:
	print(B//2)

else:
	print(0)

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())

if A >= 13:
	print(B)
    
elif 6 <= A <= 12:
	print(B // 2)

else:
	print(0)

Submission status: Runtime Error

Solution code:
import numpy as np
from sys import stdin
sys.setrecursionlimit(10**6) 

def main(args):
    a = args[0]
    b = args[1]
    if 6 <= a and a <= 12:
        v = b//2
    elif a <= 5:
        v = 0
    else:
        v = b
    print(v)

main([stdin.readline().rstrip().split()])