Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def input_from_console():
    l, r = map(int, input().split())
    return l, r


def solve(l, r):
    minimum = 2020
    if r - l >= 2019:
        return 0
    a, b = l % 2019, r % 2019
    if r // 2019 > l // 2019:
        return 0
    for i in range(a, b):
        for j in range(a + 1, b + 1):
            minimum = min(minimum, (i * j) % 2019)
    result = minimum
    return result


def main():
    l, r = input_from_console()
    print(solve(l, r))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Fixed submission:

def input_from_console():
    n, a, b = map(int, input().split())
    return n, a, b


def solve(n, a, b):
    result = min(a * n, b)
    return result


def main():
    n, a, b = input_from_console()
    print(solve(n, a, b))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()
Buggy python submission (verdict: Runtime Error):
def input_from_console():
    n, d = map(int, input().split())
    x_matrix = []
    for i in range(n):
        x = map(int, input().split())
        x_matrix.append(list(x))
    return n, d, x_matrix


def solve(n, d, x_matrix):
    result = 0
    for i in range(n):
        for j in range(n - i -1):
            distance = math.sqrt(sum([(p1 - p2) ** 2 for p1, p2 in zip(x_matrix[i], x_matrix[j + i + 1])]))
            if distance == int(distance):
                result += 1
    return result


def main():
    n, d, x_matrix = input_from_console()
    print(solve(n, d, x_matrix))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Fixed submission:
import math

def input_from_console():
    n, d = map(int, input().split())
    x_matrix = []
    for i in range(n):
        x = map(int, input().split())
        x_matrix.append(list(x))
    return n, d, x_matrix


def solve(n, d, x_matrix):
    result = 0
    for i in range(n):
        for j in range(n - i -1):
            distance = math.sqrt(sum([(p1 - p2) ** 2 for p1, p2 in zip(x_matrix[i], x_matrix[j + i + 1])]))
            if distance == int(distance):
                result += 1
    return result


def main():
    n, d, x_matrix = input_from_console()
    print(solve(n, d, x_matrix))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()
Buggy python submission (verdict: Runtime Error):
import math
def input_from_console():
    a, b, c, d = map(int, input().split())
    return a, b, c, d


def solve(a, b, c, d):
    def how_many(to, divide):
        if to >= divide:
            n = to // divide
        else:
            n = 0
        return n
    count_by_c = how_many(b, c) - how_many(a - 1, c)
    count_by_d = how_many(b, d) - how_many(a - 1, d)
    # print('gcd', int(c*d / math.gcd(c,d)))
    count_by_cd = how_many(b, int(c*d / math.gcd(c,d))) - how_many(a - 1, int(c*d / math.gcd(c,d)))
    result = b - a + 1 - (count_by_c + count_by_d - count_by_cd)
    # print(count_by_c,  count_by_d, count_by_cd)

    # print(result)
    return result

def main():
    a, b, c, d = input_from_console()
    print(solve(a, b, c, d))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Fixed submission:
def input_from_console():
    a, b, c, d = map(int, input().split())
    return a, b, c, d

def gcd(i,j):
    i, j = max(i,j), min(i,j)
    if i % j == 0:
        return j
    else:
        while i % j !=0:
            k = i % j
            i, j = j, k
        else:
            return k

def solve(a, b, c, d):
    def how_many(to, divide):
        if to >= divide:
            n = to // divide
        else:
            n = 0
        return n
    count_by_c = how_many(b, c) - how_many(a - 1, c)
    count_by_d = how_many(b, d) - how_many(a - 1, d)
    # print('gcd', int(c*d / math.gcd(c,d)))
    count_by_cd = how_many(b, int(c*d / gcd(c,d))) - how_many(a - 1, int(c*d / gcd(c,d)))
    result = b - a + 1 - (count_by_c + count_by_d - count_by_cd)
    # print(count_by_c,  count_by_d, count_by_cd)

    # print(result)
    return result

def main():
    a, b, c, d = input_from_console()
    print(solve(a, b, c, d))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()
Buggy python submission (verdict: Runtime Error):

def input_from_console():
    n, x = map(int, input().split())
    l_list = list(map(int, input().split()))
    return n, x, l_list


def solve(n, x, l_list):
    result = 0
    position = 0
    for i in range(n+1):
        if position > x:
            return result
        result +=1
        position += l_list[i]
    return result



def main():
    n, x, l_list = input_from_console()
    print(solve(n, x, l_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Fixed submission:
def input_from_console():
    n, x = map(int, input().split())
    l_list = list(map(int, input().split()))
    return n, x, l_list


def solve(n, x, l_list):
    result = 0
    position = 0
    for i in range(n):
        if position > x:
            return result
        result +=1
        position += l_list[i]
    if position > x:
        return result 
    else:
        return result + 1



def main():
    n, x, l_list = input_from_console()
    print(solve(n, x, l_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Buggy python submission (verdict: Runtime Error):
def input_from_console():
    n, x = map(int, input().split())
    l_list = list(map(int, input().split()))
    return n, x, l_list


def solve(n, x, l_list):
    result = 0
    position = 0
    for i in range(n+1):
        if position > x:
            return result
        result +=1
        position += l_list[i]



def main():
    n, x, l_list = input_from_console()
    print(solve(n, x, l_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Fixed submission:
def input_from_console():
    n, x = map(int, input().split())
    l_list = list(map(int, input().split()))
    return n, x, l_list


def solve(n, x, l_list):
    result = 0
    position = 0
    for i in range(n):
        if position > x:
            return result
        result +=1
        position += l_list[i]
    if position > x:
        return result 
    else:
        return result + 1



def main():
    n, x, l_list = input_from_console()
    print(solve(n, x, l_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()
Buggy python submission (verdict: Runtime Error):
from __future__ import print_function
n = int(input())
s = input()

s = s.rstrip('#')
s = s.lstrip('.')

if len(set(s)) <= 1:
    print(0)
    exit(0)

print(min(s.count('#'), s.count('.')))

Fixed submission:
def seek(n, s):
    s = s.rstrip('#').lstrip('.')
    turn_to_black = s.count('.')
    current_min = turn_to_black
    turn_to_white = 0

    if current_min == 0 or current_min == len(s):
        return 0

    # seek minimum turns to create "^\.*#*$"
    for i in range(len(s)):
        if s[i] == '#':
            turn_to_white += 1
        else:
            turn_to_black -= 1
        current_min = min(current_min, turn_to_black + turn_to_white)
    return current_min


def input_from_console():
    n = int(input())
    s = input()
    return n, s


def main():
    n, s = input_from_console()
    print(seek(n, s))
    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

s = s.rstrip('#')
s = s.lstrip('.')

if len(set(s)) <= 1:
    print(0)
    exit(0)

print(min(s.count('#'), s.count('.')))


Fixed submission:
def seek(n, s):
    s = s.rstrip('#').lstrip('.')
    turn_to_black = s.count('.')
    current_min = turn_to_black
    turn_to_white = 0

    if current_min == 0 or current_min == len(s):
        return 0

    # seek minimum turns to create "^\.*#*$"
    for i in range(len(s)):
        if s[i] == '#':
            turn_to_white += 1
        else:
            turn_to_black -= 1
        current_min = min(current_min, turn_to_black + turn_to_white)
    return current_min


def input_from_console():
    n = int(input())
    s = input()
    return n, s


def main():
    n, s = input_from_console()
    print(seek(n, s))
    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
black_flag = False
white = False
counter = 0
for item in s:
    if item == "#":
        black_flag = True
        continue
    if black_flag:
        if item == '.':
            counter += 1
            white = True
        if white and item == '#':
            black_flag = 0
print(counter)


Fixed submission:
def seek(n, s):
    s = s.rstrip('#').lstrip('.')
    turn_to_black = s.count('.')
    current_min = turn_to_black
    turn_to_white = 0

    if current_min == 0 or current_min == len(s):
        return 0

    # seek minimum turns to create "^\.*#*$"
    for i in range(len(s)):
        if s[i] == '#':
            turn_to_white += 1
        else:
            turn_to_black -= 1
        current_min = min(current_min, turn_to_black + turn_to_white)
    return current_min


def input_from_console():
    n = int(input())
    s = input()
    return n, s


def main():
    n, s = input_from_console()
    print(seek(n, s))
    

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
t = map(int, input())
bottle_neck = min(t)[0]
ti = math.ceil(n/bottle_neck)
print(ti+4)


Fixed submission:
#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
n = int(input())
flag = True
for i in range(5):
    for j in range(5-i-1):
        if abs(t[i]-t[j+i+1]) >n:
            flag =False
            break
if not flag:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
t = map(int, input())
bottle_neck = min(t)[0]
ti = math.ceil(n/bottle_neck)
print(ti+4)



Fixed submission:
#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
n = int(input())
flag = True
for i in range(5):
    for j in range(5-i-1):
        if abs(t[i]-t[j+i+1]) >n:
            flag =False
            break
if not flag:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
n = int(input())
t=[]
t = map(int, input())
bottle_neck = min(t)[0]
ti = int(n/bottle_neck)
ti+=1
print(ti+4)



Fixed submission:
#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
n = int(input())
flag = True
for i in range(5):
    for j in range(5-i-1):
        if abs(t[i]-t[j+i+1]) >n:
            flag =False
            break
if not flag:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
#n = int(input())
def dif(x):
    s = int(a/10)
    return (s+1)*10 -x

def comp(a,b):
    a1 = dif(a)
    b1 = dif(b)
    return a1 < b1
d = sorted(t, cmp=dif(a,b), reverse=True)

sum = 0
for i in range(4):
    if int(d[i]/10)*10 ==d[i]:
        sum = sum+d[i]
    else:
        sum += (int(d[i]/10)+1)*10
print(sum + d[4])

Fixed submission:
#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
#n = int(input())
def dif(x):
    s = int(x/10)
    if s * 10 == x:
        return 0
    else:
        return (s+1)*10 -x

def comp(a,b):
    a1 = dif(a)
    b1 = dif(b)
    return a1 < b1
d = sorted(t, key=lambda x: dif(x))

sum = 0
for i in range(4):
    if int(d[i]/10)*10 ==d[i]:
        sum = sum+d[i]
    else:
        sum += (int(d[i]/10)+1)*10
print(sum + d[4])
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
t = map(int, input())
bottle_neck = min(t)
ti = math.ceil(n/bottle_neck)
print(ti+4)

Fixed submission:
import math
n = int(input())
t=[]
for i in range(5):
    t.append(int(input()))
bottle_neck = min(t)
ti = math.ceil(n/bottle_neck)
print(ti + 4)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
t = map(int, input())
bottle_neck = min(t)[0]
ti = math.ceil(n/bottle_neck)
print(ti+4)


Fixed submission:
import math
n = int(input())
t=[]
for i in range(5):
    t.append(int(input()))
bottle_neck = min(t)
ti = math.ceil(n/bottle_neck)
print(ti + 4)

Buggy python submission (verdict: Runtime Error):
n = int(input())
t=[]
t = map(int, input())
bottle_neck = min(t)[0]
ti = int(n/bottle_neck)
if bottle_neck * ti > n:
    ti=1
else:
    ti+=1
print(ti+4)



Fixed submission:
import math
n = int(input())
t=[]
for i in range(5):
    t.append(int(input()))
bottle_neck = min(t)
ti = math.ceil(n/bottle_neck)
print(ti + 4)

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = map(int, input())
bottle_neck = min(t)
ti = int(n/bottle_neck)
if bottle_neck * ti > n:
    ti=1
else:
    ti+=1
print(ti+4)



Fixed submission:
import math
n = int(input())
t=[]
for i in range(5):
    t.append(int(input()))
bottle_neck = min(t)
ti = math.ceil(n/bottle_neck)
print(ti + 4)

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = map(int, input())
bottle_neck = min(t)
ti = int(n/bottle_neck)
if n % bottle_neck == 0:
    pass
else:
    ti+=1
print(ti+4)

Fixed submission:
import math
n = int(input())
t=[]
for i in range(5):
    t.append(int(input()))
bottle_neck = min(t)
ti = math.ceil(n/bottle_neck)
print(ti + 4)
Buggy python submission (verdict: Runtime Error):
def find(n):
    """
    tn = int(n/2)
    s = 2 * tn + 1
    :param n:
    :return:
    """
    tn = int(n/2)
    s = 2 * tn + 1
    count = 0
    line_list = []
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if i + j != s:
                line_list.append(f"{i} {j}")
                count +=1

    return count, line_list


if __name__ == '__main__':
    n = input()

    count, line_list = find(int(n))
    print(count)
    print("\n".join(line_list))

Fixed submission:

def find(n):
    """
    tn = int(n/2)
    s = 2 * tn + 1
    :param n:
    :return:
    """
    tn = int(n / 2)
    s = 2 * tn + 1
    count = 0
    line_list = []
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j != s:
                line_list.append(str(i) + " " + str(j))
                count += 1

    return count, line_list


if __name__ == '__main__':
    n = int(input())

    count, line_list = find(n)
    print(count)
    for item in line_list:
        print(item)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(1,101) if i not in a]
b_tmp = list(map(lambda s:abs(s-x), b))
address = b_tmp.index(min(b_tmp))
print(b[address])

Fixed submission:
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) #b_tmpはbとxの差分のリストをさくせい
address = b_tmp.index(min(b_tmp))
print(b[address])

Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit(0)
a = [int(x) for x in input().split()]
b = [i for i in range(1,101) if i not in a]
b_tmp = list(map(lambda s:abs(s-x), b))
mnum = min(b_tmp)
address = b_tmp.index(mnum)
print(b[address])

Fixed submission:
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) #b_tmpはbとxの差分のリストをさくせい
address = b_tmp.index(min(b_tmp))
print(b[address])
Buggy python submission (verdict: Runtime Error):
a = int(input())

if a == "ARC" :
    ans = "ABC"
else:
    ans = "ARC"

print(ans)

Fixed submission:
a = input()
 
if a == "ARC" :
    ans = "ABC"
else:
    ans = "ARC"
 
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(i) for i in input().split()]
lst = []
for P in range(1,max(x)):
    n = 0
    for j in x:
        n += (j-P)**2
    lst.append(n)
print(min(lst))

Fixed submission:
n = int(input())
x = [int(i) for i in input().split()]
lst = []
for P in range(1,max(x)+1):
    n = 0
    for j in x:
        n += (j-P)**2
    lst.append(n)
print(min(lst))
Buggy python submission (verdict: Runtime Error):
s = input()
if "Sunny" == s:
    pirnt("Cloudy")
elif "Cloudy" == s:
    print("Rainy")
else:
    print("Sunny")

Fixed submission:
s = input()
if "Sunny" == s:
    print("Cloudy")
elif "Cloudy" == s:
    print("Rainy")
else:
    print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
n=input()
p=[]
q=[0]*n
ans=0
for i in range(n):
    p.append(input())
for i in range(n-1,-1,-1):
    if p[i]>q[i]:
        if p[i]>i:
            print -1
            break
        for j in range(i-p[i]+1,i+1):
            q[j]=q[j-1]+1
            ans+=1
    elif p[i]<q[i]:
        print -1
        break
else:
    print ans


Fixed submission:
n=input()
last=-1
#q=[0]*n
now=0
ans=-1
for i in range(n):
    now=input()
    if now>i or now-last>1:
        print -1
        break
    if now==last+1:
        ans+=1
    elif now<=last:
        ans+=now
    last=now
else:
    print ans
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a

n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
if k in a:
  print "POSSIBLE"
else:
  while n!=1:
    b=a.pop()
    a[0]=gcd(a[0],b)
  print "POSSIBLE" if k%a[0]==0 and (max(a)-min(a))>=k-1 else "IMPOSSIBLE"

Fixed submission:
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
 
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
if k in a:
  print "POSSIBLE"
else:
  c=a[:]
  while len(a)!=1:
    b=a.pop()
    a[0]=gcd(a[0],b)
  print "POSSIBLE" if k%a[0]==0 and max(c)>=k else "IMPOSSIBLE"
Buggy python submission (verdict: Time Limit Exceeded):
N=raw_input()
b=[]
P=raw_input().split()
for i in P:
    b.append(i)
    b=b[::-1]
print " ".join(b)

Fixed submission:
N=int(raw_input())
P=raw_input().split()
b=P[-1::-2]+P[N%2::2]
print " ".join(b)

Buggy python submission (verdict: Time Limit Exceeded):
N=raw_input()
b=[]
P=raw_input().split()
for i in P:
    b.append(i)
    b.reverse()
print " ".join(b)


Fixed submission:
N=int(raw_input())
P=raw_input().split()
b=P[-1::-2]+P[N%2::2]
print " ".join(b)
Buggy python submission (verdict: Runtime Error):
s=input()
ans = 0
if 'SSS' in s:
  ans = 3
elif: 'SS' in s:
  ans = 2
elif: 'S' in s:
  ans = 1
print(ans)

Fixed submission:
s=input()
ans = 0
if 'RRR' in s:
  ans = 3
elif 'RR' in s:
  ans = 2
elif 'R' in s:
  ans = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
string_list=[input() for i in range(n)]
s=set(string_list)
t=list(s)
l=[0]*len(t)
a = len(t)
for i in range(n):
  for j in range(a):
    if t[j] == string_list[i]:
      l[j]+=1
u=[]
b = max(l)
for k in range(a):
  if l[k] == b:
    u.append(t[k])
u.sort()
for x in u:
	print(x)
      
      

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

import collections
cnt = collections.Counter(s)
dict = sorted(cnt)

max_vote = max(cnt.values())
ans = []
for a,b in cnt.items():
  if max_vote == b:
    ans.append(a)
ans = sorted(ans)
print('\n'.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
string_list=[input() for i in range(n)]
s=set(string_list)
t=list(s)
l=[0]*len(t)
a = len(t)
for i in range(n):
  for j in range(a):
    if t[j] == string_list[i]:
      l[j]+=1
u=[]
for k in range(len(t)):
  if l[k] == max(l):
    u.append(t[k])
u.sort()
for x in u:
	print(x)
      
      

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

import collections
cnt = collections.Counter(s)
dict = sorted(cnt)

max_vote = max(cnt.values())
ans = []
for a,b in cnt.items():
  if max_vote == b:
    ans.append(a)
ans = sorted(ans)
print('\n'.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
string_list=[input() for i in range(n)]
s=set(string_list)
t=list(s)
l=[0]*len(t)

for i in range(n):
  for j in range(len(t)):
    if t[j] == string_list[i]:
      l[j]+=1
u=[]
for k in range(len(t)):
  if l[k] == max(l):
    u.append(t[k])
u.sort()
for x in u:
	print(x)
      
      

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

import collections
cnt = collections.Counter(s)
dict = sorted(cnt)

max_vote = max(cnt.values())
ans = []
for a,b in cnt.items():
  if max_vote == b:
    ans.append(a)
ans = sorted(ans)
print('\n'.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
string_list=[input() for i in range(n)]
s=set(string_list)
t=list(s)
l=[0]*len(t)

for i in range(n):
  for j in range(len(t)):
    if t[j] == string_list[i]:
      l[j]+=1
u=[]
for k in range(len(t)):
  if l[k] == max(l):
    u.append(t[k])
u.sort()
for x in u:
	print(x)
      
      

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

import collections
cnt = collections.Counter(s)
dict = sorted(cnt)

max_vote = max(cnt.values())
ans = []
for a,b in cnt.items():
  if max_vote == b:
    ans.append(a)
ans = sorted(ans)
print('\n'.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))

count = 1
for i in range(1,n):
#  print(i, min(p[:i+1]), p[i])
  if min(p[:i+1]) == p[i]:
    count += 1
print(count)
    

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
m = p[0]
count = 1
for i in range(1,n):
#  print(i, min(p[:i+1]), p[i])
  m = min(m, p[i])
  if m == p[i]:
    count += 1
print(count)

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

count = n
for i in range(n):
  for j in range(i):
    if p[i] > p[j]:
      count -= 1
      break

print(count)
    

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
m = p[0]
count = 1
for i in range(1,n):
#  print(i, min(p[:i+1]), p[i])
  m = min(m, p[i])
  if m == p[i]:
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = [int(an) for an in input().split()]
    divider = 10 ** 9 + 7
    ans = 0
    for i in range(n - 1):
        ans = (ans + a[i] * sum(a[i + 1: n])) % divider
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    a = [int(an) for an in input().split()]
    divider = 10 ** 9 + 7
    ans = 0
    total = sum(a)
    tmp = 0
    for i in range(n - 1):
        ai = a[i]
        tmp += ai
        ans = (ans + a[i] * (total - tmp)) % divider
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = [int(an) for an in input().split()]
    divider = 10 ** 9 + 7
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans = (ans + a[i] * a[j]) % divider
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    a = [int(an) for an in input().split()]
    divider = 10 ** 9 + 7
    ans = 0
    total = sum(a)
    tmp = 0
    for i in range(n - 1):
        ai = a[i]
        tmp += ai
        ans = (ans + a[i] * (total - tmp)) % divider
    print(ans)


if __name__ == '__main__':
    main()