Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ans = set(range(1, n + 1))
for _ in range(m):
    l, r = map(int, input().split())
    st = set(range(l, r + 1))
    ans &= st
print(len(ans))


Fixed submission:
def solve2():
    n, m = map(int, input().split())
    L = 1
    R = n
    for _ in range(m):
        l, r = map(int, input().split())
        L = max(L, l)
        R = min(R, r)
    if L <= R:
        print(R - L + 1)
    else:
        print(0)
solve2()
Buggy python submission (verdict: Runtime Error):
def solve():
    n = int(input())
    ans = [-1] * (n + 1)
    li = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        li[u].append((v, w))
        li[v].append((u, w))
    def f(i, ans, c):
        if li[i] == []:
            return
        for u, w in li[i]:
            if ans[u] == -1:
                if w % 2 == 0:
                    ans[u] = c
                    f(u, ans, c)
                else:
                    ans[u] = c ^ 1
                    f(u, ans, c ^ 1)
    for i in range(1, n):
        if li[i] != [] and ans[i] == -1:
            ans[i] = 0
            f(i, ans, 0)
    print(*ans[1:], sep="\n")
solve()


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
def solve():
    n = int(input())
    ans = [-1] * (n + 1)
    li = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        li[u].append((v, w))
        li[v].append((u, w))
    def f(i, ans, c):
        if li[i] == []:
            return
        for u, w in li[i]:
            if ans[u] == -1:
                if w % 2 == 0:
                    ans[u] = c
                    f(u, ans, c)
                else:
                    ans[u] = c ^ 1
                    f(u, ans, c ^ 1)
    for i in range(1, n):
        if li[i] != [] and ans[i] == -1:
            ans[i] = 0
            f(i, ans, 0)
    print(*ans[1:], sep="\n")
solve()

Buggy python submission (verdict: Runtime Error):
def solve():
    n = int(input())
    ans = [-1] * (n + 1)
    li = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        li[u].append((v, w))
        li[v].append((u, w))
    def f(i, ans, c):
        for u, w in li[i]:
            if ans[u] == -1:
                if w % 2 == 0:
                    ans[u] = c
                    f(u, ans, c)
                else:
                    ans[u] = c ^ 1
                    f(u, ans, c ^ 1)
    for i in range(1, n):
        if li[i] != [] and ans[i] == -1:
            ans[i] = 0
            f(i, ans, 0)
    print(*ans[1:], sep="\n")
solve()


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
def solve():
    n = int(input())
    ans = [-1] * (n + 1)
    li = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        li[u].append((v, w))
        li[v].append((u, w))
    def f(i, ans, c):
        if li[i] == []:
            return
        for u, w in li[i]:
            if ans[u] == -1:
                if w % 2 == 0:
                    ans[u] = c
                    f(u, ans, c)
                else:
                    ans[u] = c ^ 1
                    f(u, ans, c ^ 1)
    for i in range(1, n):
        if li[i] != [] and ans[i] == -1:
            ans[i] = 0
            f(i, ans, 0)
    print(*ans[1:], sep="\n")
solve()
Buggy python submission (verdict: Runtime Error):
m = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}
print(m[input())

Fixed submission:
m = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}
print(m[input()])
Buggy python submission (verdict: Runtime Error):
print("Heisei" if input() <= 2019/04/30 else "TBD")

Fixed submission:
print("Heisei" if input() <= "2019/04/30" else "TBD")
Buggy python submission (verdict: Runtime Error):
from math import gcd
n = int(input())
A = list(map(int, input().split()))
ans = A[0]
for a in A[1:]:
    ans = gcd(ans, a)
print(ans)


Fixed submission:
from heapq import heapify, heappush, heappop
n = int(input())
A = list(map(int, input().split()))
heapify(A)
while len(A) != 1:
    t = heappop(A)
    A = [a % t for a in A if a % t != 0]
    if A is None:
        A = [t]
        break
    heappush(A, t)
print(A[0])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n = int(input())
A = [int(input()) for _ in range(n)]
def f(x):
    cnt = 0
    for i in range(len(x) - 1):
        cnt += abs(x[i] - x[i + 1])
    return cnt
ans = []
for B in permutations(A):
    ans.append((f(B), B))
ans.sort(reverse=True)
print(ans[0][0])


Fixed submission:
def solve():
    n = int(input())
    a = sorted(int(input()) for _ in range(n))
    c0 = n // 2 - 1
    c1 = n // 2
    c2 = n // 2 + 1
    ans = 0
    if n & 1:
        for i in range(c0):
            ans -= a[i] * 2
        for i in range(c2 + 1, n):
            ans += a[i] * 2
        ans += -a[c0] + a[c2] + max(-a[c0] + a[c1], - a[c1] + a[c2])
    else:
        for i in range(c0):
            ans -= a[i] * 2
        for i in range(c1 + 1, n):
            ans += a[i] * 2
        ans += -a[c0] + a[c1]
    return ans
print(solve())

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(input()) for _ in range(n)]
def f(x):
    cnt = 0
    for i in range(len(x) - 1):
        cnt += abs(x[i] - x[i + 1])
    return cnt
ans = []
for B in permutations(A):
    ans.append((f(B), B))
ans.sort(reverse=True)
print(ans[0][0])

Fixed submission:
def solve():
    n = int(input())
    a = sorted(int(input()) for _ in range(n))
    c0 = n // 2 - 1
    c1 = n // 2
    c2 = n // 2 + 1
    ans = 0
    if n & 1:
        for i in range(c0):
            ans -= a[i] * 2
        for i in range(c2 + 1, n):
            ans += a[i] * 2
        ans += -a[c0] + a[c2] + max(-a[c0] + a[c1], - a[c1] + a[c2])
    else:
        for i in range(c0):
            ans -= a[i] * 2
        for i in range(c1 + 1, n):
            ans += a[i] * 2
        ans += -a[c0] + a[c1]
    return ans
print(solve())
Buggy python submission (verdict: Runtime Error):
print(input().tranprint(input().translate(str.maketrans("1", "9"))))slate(str.maketrans("1", "9")))

Fixed submission:
print(input().translate(str.maketrans("19", "91")))
Buggy python submission (verdict: Runtime Error):
print(24 - int(input())

Fixed submission:
print(48 - int(input()))
Buggy python submission (verdict: Runtime Error):
n = list(input())
print("Yes" if min(len(set(n[:3])), len(set(n[1:])) == 1 else "No")

Fixed submission:
n = list(input())
print("Yes" if min(len(set(n[:3])), len(set(n[1:]))) == 1 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python


def main():
    s = input()
    al, ar = 0, 0
    a = []
    for i in range(len(s) + 1):
        if i < len(s) and s[i] == '>':
            if ar == 0:
                for si in s[i:]:
                    if si == '>':
                        ar = ar + 1
                    else:
                        break
            else:
                ar = ar - 1
        else:
            ar = 0

        if i > 0 and s[i - 1] == '<':
            al = al + 1
        else:
            al = 0

        a.append(max(al, ar))

    print(sum(a))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python


def main():
    s = input()
    al, ar = ([0] * (len(s) + 1), [0] * (len(s) + 1))
    for i in range(0, len(s)):
        al[i + 1] = al[i] + 1 if s[i] == '<' else 0

    for i in range(len(s) - 1, -1, -1):
        ar[i] = ar[i + 1] + 1 if s[i] == '>' else 0

    sum_a = sum([max(aln, arn) for aln, arn in zip(al, ar)])
    print(sum_a)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python


def main():
    s = input()
    a = []
    for i in range(len(s) + 1):
        lefts, rights = (s[:i], s[i:])
        a_cand = [0, 0]
        j = len(lefts) - 1
        while j >= 0 and lefts[j] == '<':
            a_cand[0] = a_cand[0] + 1
            j = j - 1
        j = 0
        while j < len(rights) and rights[j] == '>':
            a_cand[1] = a_cand[1] + 1
            j = j + 1

        a.append(max(a_cand))

    print(sum(a))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python


def main():
    s = input()
    al, ar = ([0] * (len(s) + 1), [0] * (len(s) + 1))
    for i in range(0, len(s)):
        al[i + 1] = al[i] + 1 if s[i] == '<' else 0

    for i in range(len(s) - 1, -1, -1):
        ar[i] = ar[i + 1] + 1 if s[i] == '>' else 0

    sum_a = sum([max(aln, arn) for aln, arn in zip(al, ar)])
    print(sum_a)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
l = []
l_a = ['b' for i in range(A)]
l_b = ['r' for i in range(B)]
for val in range(N // (A + B)):
    l += l_a
    l += l_b
cnt = 0
for val in range(N):
    if l[val] == 'b':
        cnt += 1
print(cnt)

Fixed submission:
N, A, B = map(int, input().split())
x = N // (A + B)
y = N % (A + B)
if y < A:
    print(x*A + y)
else:
    print(x*A + A)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
l = []
l_a = ['b' for i in range(A)]
l_b = ['r' for i in range(B)]
for val in range(N):
    l += l_a
    l += l_b
cnt = 0
for val in range(N):
    if l[val] == 'b':
        cnt += 1
print(cnt)

Fixed submission:
N, A, B = map(int, input().split())
x = N // (A + B)
y = N % (A + B)
if y < A:
    print(x*A + y)
else:
    print(x*A + A)
Buggy python submission (verdict: Runtime Error):
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    pritn('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')

Fixed submission:
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            print(val)
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    pritn('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')

Fixed submission:
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
for val in A:
    if val % 2 == 1:
        continue
    elif val % 2 == 0:
        if val % 3 == 0:
            continue
        elif val % 5 == 0:
            continue
        else:
            print('DENIED')
            break
else:
    print('APPROVED')

Fixed submission:
A = set(map(int, input().split()))
if len(A) == 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
counter = 0
for val in range(N - 1):
    for i in range(N - val - 1):
        if A[val] == A[val+i+1]:
            counter += 1
            break
    else:
        continue
    break
if counter == 0:
    print('YES')
else:
    print('NO')

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    print(A - 1, B)
else:
    print(A, B - 1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
counter = 0
for val in range(N - 1):
    for i in range(N - val - 1):
        if A[val] == A[val+i+1]:
            counter += 1
        else:
            continue
if counter == 0:
    print('YES')
else:
    print('NO')

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    print(A - 1, B)
else:
    print(A, B - 1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
counter = 0
for val in range(N - 1):
     for i in range(N - val - 1):
        if A[val] == A[val+i+1]:
            counter += 1
        else:
            break
if counter == 0:
    print('YES')
else:
    print('NO')

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    print(A - 1, B)
else:
    print(A, B - 1)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
if M == N:
    print("Yes")
else:
    Print("No")

Fixed submission:
N, M = map(int, input().split())
if M == N:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
if N == M:
    print("Yes")
else:
    Print("No")

Fixed submission:
N, M = map(int, input().split())
if M == N:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = 1
for n in range(1,N + 1):
    P = P * n
print(P % ((10**9) + 7))

Fixed submission:
N = int(input())
P = 1
for n in range(1,N + 1):
    P = (P * n) % ((10**9)+7)
print(P)

Buggy python submission (verdict: Runtime Error):
N = int(input())
P = 1
for n in range(1,N + 1):
    P = P * n
print(P %% ((10**9) + 7))

Fixed submission:
N = int(input())
P = 1
for n in range(1,N + 1):
    P = (P * n) % ((10**9)+7)
print(P)
Buggy python submission (verdict: Time Limit Exceeded):
S_A, S_B, S_C = [list(input()) for i in range(3)]
S = S_A[0]
while True:
    if S == 'a':
        if len(S_A) == 0:
            break
        else:
            S == S_A.pop(0)
    elif S == 'b':
        if len(S_B) == 0:
            break
        else:
            S = S_B.pop(0)
    elif S == 'c':
        if len(S_C) == 0:
            break
        else:
            S == S_C.pop(0)
if S == 'a':
    print('A')
elif S == 'b':
    print('B')
elif S == 'c':
    print('C')

Fixed submission:
a, b, h = [int(input()) for i in range(3)]
S = (a + b) * h / 2
S = int(S)
print(S)
Buggy python submission (verdict: Runtime Error):
N, K, X, Y = map(int, input().split())
total = K*X + (N-K)*Y
print(total)

Fixed submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
    total = K*X + (N-K)*Y
    print(total)
else:
    total = N*X
    print(total)
Buggy python submission (verdict: Runtime Error):
w = input()
w_list = list(w)
w_set = set(w_list)
for val in w_set:
    if w_list.count(val) % 2 == 0:
        continue
    else:
        print('No')
        break
else:
    continue
    print('Yes')

Fixed submission:
w = input()
w_list = list(w)
w_set = set(w_list)
for val in w_set:
    if w_list.count(val) % 2 == 0:
        continue
    else:
        print('No')
        break
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

if A * B * C == 5 * 5 * 7:
    print('Yes')
else:
    pritn('No')

Fixed submission:
A, B, C = map(int, input().split())

if A*B*C == 5*5*7:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import sys
n = list(map(int, input().split()))

if n[0] == 1 or n[1] == 1:
    print(0)

if n[0] % 2 == 0:
    print(int((n[0]/2)*n[1])
    sys.exit()
else:
    if n[1] % 2 == 0:
        print(int(n[0]*(n[1]/2)))
        sys.exit()
    else:
        a = ((n[0]-1)*n[1])/2
        b = n[1] - int(n[1]/2)
        print(int(a+b))
        sys.exit()
    


Fixed submission:
from decimal import Decimal
import sys
n = list(map(int, input().split()))

if n[0] == 1 or n[1] == 1:
    print(1)
    sys.exit()

if n[0] % 2 == 0:
    print(Decimal(int((n[0]/2)*n[1])))
    sys.exit()
else:
    if n[1] % 2 == 0:
        print(Decimal(int(n[0]*(n[1]/2))))
        sys.exit()
    else:
        a = ((n[0]-1)*n[1])/2
        b = n[1] - int(n[1]/2)
        print(Decimal(int(a+b)))
        sys.exit()
Buggy python submission (verdict: Runtime Error):
n = list(map(int, input.split()))

ans = str(n[0])+str(n[1])

print(ans)

Fixed submission:
n = input().split()

ans = str(n[1])+str(n[0])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = list(map(int, input().split()))

c = [1]

def calc(x):
    for j in range(2, x):
        if x % j == 0:
            return
    c.append(x)
for i in range(2,min(n[0],n[1])+1):
    if n[0] % i == 0 and n[1] % i == 0:
        calc(i)

print(len(c))


Fixed submission:
n = list(map(int, input().split()))

def gcd(a, b):
    while b != 0:
        t = a%b
        a = b
        b = t
    return a

def factorization(m):
    arr = [1]
    temp = m
    for i in range(2, int(-(-m**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)
    if temp != 1:
        arr.append(temp)

    if arr==[]:
        arr.append(m)

    return arr

d = gcd(n[0],n[1])

c = factorization(d)


print(len(c))
Buggy python submission (verdict: Runtime Error):

n = int(input())

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

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

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

m = n-1
sumc = 0
for i in range(m):
    if a[i+1] == a[i]+1:
        sumc += c[i]
#tmp = a[m]
#if m > 1:
#    if tmp <= m:
#        sumc -= c[tmp-1]
if m == 1:
    if tmp == 1:
        sumc = 0
ans = sum(b)
ans += sumc

print(ans)


Fixed submission:

n = int(input())

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

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

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

m = n-1
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if (i>0)and(a[i] == a[i-1]+1):
        ans += c[a[i-1]-1]

print(ans)

Buggy python submission (verdict: Runtime Error):

n = int(input())

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

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

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

m = n-1
sumc = sum(c)
tmp = a[m]
if m > 1:
    sumc -= c[tmp-1]
ans = sum(b)
ans += sumc

print(ans)


Fixed submission:

n = int(input())

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

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

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

m = n-1
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if (i>0)and(a[i] == a[i-1]+1):
        ans += c[a[i-1]-1]

print(ans)

Buggy python submission (verdict: Runtime Error):

n = int(input())

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

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

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

m = n-1
if m == 1:
    sumc = sum(c)
else:
    sumc = sum(c)
    tmp = a[m]
    sumc -= c[tmp-1]
ans = sum(b)
ans += sumc

print(ans)


Fixed submission:

n = int(input())

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

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

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

m = n-1
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if (i>0)and(a[i] == a[i-1]+1):
        ans += c[a[i-1]-1]

print(ans)
Buggy python submission (verdict: Runtime Error):
nk = list(map(int,input().split()))
a  = list(map(int,input().split()))

b = []

for i in range(nk[1]):
    b += a

def bubble_sort(A):
    cnt = 0
    for j in range(len(A)):
        for l in range(len(A)-1, j, -1):
            if A[l] < A[l-1]:
                A[l], A[l-1] = A[l-1], A[l]

                cnt += 1
    return int(cnt)

ans = bubble_sort(b) % 1000000007
print(ans)


Fixed submission:
i=list(map(int,input().split()))

ans = 0

for j in range(i[0]):
    for k in range(i[1]):
        k += 1
        if len(str(k)) >= 2:
            k = str(k)
            if (int(k[-1])>=2)and(int(k[-2])>=2):
                if j+1 == int(k[-1])*int(k[-2]):
                    #print(j+1,int(k[-1]),int(k[-2]))
                    ans += 1
            k = int(k)
        k -= 1

        
print(ans)

Buggy python submission (verdict: Runtime Error):
nk = list(map(int,input().split()))
a  = list(map(int,input().split()))

b = []

for i in range(nk[1]):
    b += a

def bubble_sort(A):
    cnt = 0
    for j in range(len(A)):
        for l in range(len(A)-1, j, -1):
            if A[l] < A[l-1]:
                A[l], A[l-1] = A[l-1], A[l]

                cnt += 1
    return int(cnt)

ans = bubble_sort(b)
ans = ans % 1000000007
print(ans)


Fixed submission:
i=list(map(int,input().split()))

ans = 0

for j in range(i[0]):
    for k in range(i[1]):
        k += 1
        if len(str(k)) >= 2:
            k = str(k)
            if (int(k[-1])>=2)and(int(k[-2])>=2):
                if j+1 == int(k[-1])*int(k[-2]):
                    #print(j+1,int(k[-1]),int(k[-2]))
                    ans += 1
            k = int(k)
        k -= 1

        
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import factorial as f
x,y=map(int,input().split())
a=f(x)//(f(x-2)*2)
b=f(y)//(f(y-2)*2)
print(a+b)

Fixed submission:
from math import factorial as f
x,y=map(int,input().split())
if(x<2):
    a=0
else:
    a=f(x)//(f(x-2)*2)
if(y<2):
    b=0
else:    
    b=f(y)//(f(y-2)*2)
print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
x,y= map(int, input().split())
a = list(map(int, input().split()))
b=[]
for _ in range(y):
    b.append(list(map(int, input().split())))
b.sort(key = lambda x: x[1],reverse=True) 
for l in b:
    a.extend([l[1]]*l[0])
a.sort(reverse=True)
print(sum(a[:x]))


Fixed submission:
x,y= map(int, input().split())
a = list(map(int, input().split()))
#print(a)
b=[]
for _ in range(y):
    b.append(list(map(int, input().split())))
b.sort(key = lambda x: x[1],reverse=True) 
for l in b:
    if(len(a)<=x*2):
        a.extend([l[1]]*l[0])
#print(len(a))        
#print(a)
a.sort(reverse=True)
print(sum(a[:x]))