Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
input_line=input().rstrip().split(" ")
num_line=[]

for i in range(num):
    moji=str(i+1)
    a=input_line.index(moji)
    num_line.append(a+1)

for i in range(num):    
    print(num_line[i],end=" ")

Fixed submission:
num = int(input())
str_line = input().split(" ")
num_line = [int(n) for n in str_line]

rank_line = [0 for i in range(num)]

for i in range(num):
    rank_line[num_line[i] - 1] = i+1

for i in range(num):
    print(rank_line[i],end="")
    if(i != num-1):
        print(" ",end="")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0

for i in range(1, N + 1):
    for j in range(1, N - i + 1):
        if i * j >= N:
            break
        else:
            ans += 1

print(ans)

Fixed submission:
N = int(input())
ans = 0
 
for i in range(1, N + 1):
    for j in range(1, N - i + 1):
        if i * j >= N:
            break
        else:
            ans += 1
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
tmp = [1] * (N+1)

for i in range(K, N+1):
    tmp[i] = sum(A_list[i-K:i])

for i in range(K+1, K+1+N-K):
    if tmp[i] > tmp[i-1]:
        print('Yes')
    else:
        print('No')

Fixed submission:
X = int(input())

if 400 <= X <=599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = list(map(int, input().split()))
p_n = list(map(int, input().split()))
ans = 10 ** 10

for p in itertools.combinations(p_n, K):
    s = sum(p)
    if ans > s:
        ans = s

print(ans)

Fixed submission:
N, K = list(map(int, input().split()))
p_n = list(map(int, input().split()))
ans  = 0
p_n.sort()

for i in range(K):
    ans += p_n[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = list(map(int, input().split()))
p_n = list(map(int, input().split()))
ans = 10 ** 10

for p in itertools.permutations(p_n, K):
    s = sum(p)
    if ans > s:
        ans = s

print(ans)

Fixed submission:
N, K = list(map(int, input().split()))
p_n = list(map(int, input().split()))
ans  = 0
p_n.sort()

for i in range(K):
    ans += p_n[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
ans = (A * B) - (A + B - 1)

print(ans)

Fixed submission:
A, B = map(int, input().split())
ans = (A * B) - (A + B - 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
if R < 1200:
    print('ABC')
elif R < 2800:
    print('ARC')
else:
    print('AGC')

Fixed submission:
R = int(input())

if R < 1200:
    print('ABC')
elif R < 2800:
    print('ARC')
else:
    print('AGC')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*- #

N = int(input())
S = list(input())
ans = [""] * N

for i in range(N):
    ans[i] = S[:i].count('W') + S[(i+1):].count('E')

print(min(ans))

Fixed submission:
# -*- coding: utf-8 -*- #

N = int(input())
S = input()
cnt = [0] * (N+1)
cnt[0] = 0
ans = N

for i in range(N):
    cnt[i+1] = cnt[i]
    if S[i] == 'W':
        cnt[i+1] += 1

for j in range(1, N+1):
    ans = min(ans, cnt[j-1] + (N - j) - (cnt[N]-cnt[j]))

print(ans)
Buggy python submission (verdict: Runtime Error):
if 0 <= X - A <= B:
    print('YES')
else:
    print('NO')

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

if 0 <= X - A <= B:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input())

if A + B >= C:
    print('Yes')
else:
    print('No')

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

if A + B >= C:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*- #

n, k = map(int, input().split())
ans = 0

ans = k * pow(k-1, n-1)

print(ans)

Fixed submission:
print(len(set(map(int, input().split()))))
Buggy python submission (verdict: Runtime Error):
from sys import stdin

S = int(stdin.readline().rstrip())

if S=="ABC":
    print("ARC")
else:
    print("ABC")



Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()

if S=="ABC":
    print("ARC")
else:
    print("ABC")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import sympy as sp

K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

if flag==1:
    print("OK")
else:
    print("NG")

Fixed submission:
from sys import stdin

K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

if flag==1:
    print("OK")
else:
    print("NG")

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import sympy as sp
K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

if flag==1:
    print("OK")
else:
    print("NG")

Fixed submission:
from sys import stdin

K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

if flag==1:
    print("OK")
else:
    print("NG")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import numpy as np


def merge_sort(lst, low, high):
    if low >= high:
        return
    mid = int((low+high)/2)
    merge_sort(lst, low, mid)
    merge_sort(lst, mid+1, high)
    for i in range(low, mid+1):
        tmp_array[i] = lst[i]
    j = high
    for i in range(mid+1, high+1):
        tmp_array[i] = lst[j]
        j -= 1
    i = low
    j = high
    for k in range(low, high+1):
        if tmp_array[i] <= tmp_array[j]:
            lst[k] = tmp_array[i]
            i += 1
        else:
            lst[k] = tmp_array[j]
            j -= 1


S = stdin.readline().rstrip()
N = len(S)
Sp = S

res_map = [0 for _ in range(N)]

aa_list2 = [1]
for i in range(1,N):
    aa_list2.append((aa_list2[i-1]*10)%2019)

tmp_array = [None for _ in range(N)]
res_map[N-1] = int(S[N-1])
index=1
for i in range(N-2,-1,-1):
    res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019
    index+=1
#merge_sort(res_map,0,N-1)
#res_map = list(np.sort(np.array(res_map)))
res_map.sort()
temp_num=res_map[0]
index=1
tot = 0

for i in range(1,N):
    if temp_num==res_map[i]:
        index+=1
        continue
    else:
        if temp_num==0:
            tot += int(index*(index+1)/2)
        elif index>1:
            tot += int(index*(index-1)/2)
            #tot += index/2
        index=1
        temp_num=res_map[i]





print(tot)



Fixed submission:
from sys import stdin

[S, W] = map(int, stdin.readline().rstrip().split())

if W>= S:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
from sys import stdin

N = int(stdin.readline().rstrip())
As = [int(x) for x in stdin.readline().rstrip().split()]

A_mat = []
for i,A in enumerate(As):
    A_mat.append([A,i])

A_mat.sort(reverse=True)

map1 = []

for i in range(N+1):
    temp = [-1]*(N+1)
    map1.append(temp)



def DP(x, y): #Asのなかからx+y個の数列をすでに端に移動していて、x個左端に, y個右端に移動している状態から始めたときに追加で得られるスコア
    if map1[x][y]>=0:
        return map1[x][y]
    
    if x+y == N:
        return 0

    a_val = A_mat[x+y][0]
    a_pos = A_mat[x+y][1]

    left_case = abs(a_pos-x)
    right_case = abs((N-y-1)-a_pos)

    map1[x][y] = max(DP(x+1,y)+left_case*a_val, DP(x,y+1)+right_case*a_val)

    return map1[x][y]

print(DP(0,0))
    

Fixed submission:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(2000)


N = int(stdin.readline().rstrip())
As = [int(x) for x in stdin.readline().rstrip().split()]

A_mat = []
for i,A in enumerate(As):
    A_mat.append([A,i])

A_mat.sort(reverse=True)

map1 = []

for i in range(N+1):
    temp = [-1]*(N+1)
    map1.append(temp)



def DP(x, y): #Asのなかからx+y個の数列をすでに端に移動していて、x個左端に, y個右端に移動している状態から始めたときに追加で得られるスコア
    if map1[x][y]>=0:
        return map1[x][y]
    
    if x+y == N:
        return 0

    a_val = A_mat[x+y][0]
    a_pos = A_mat[x+y][1]

    left_case = abs(a_pos-x)
    right_case = abs((N-y-1)-a_pos)

    map1[x][y] = max(DP(x+1,y)+left_case*a_val, DP(x,y+1)+right_case*a_val)

    return map1[x][y]

print(DP(0,0))
Buggy python submission (verdict: Runtime Error):
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    max_time = 0
    for i in range(N):
        data.append(list(map(int,input().split())))
        max_num = max(data[i])
        if max_num>max_time:
            max_time=max_num

    #data_np = np.array(data).reshape(N,3)
    #data_np = np.array(data)

    #max_time = int(max(data))
    #print("max",max_time)
    schedule = [[0]*C for i in range(max_time)]
    #schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            if start+j-1<0:continue
            schedule[start+j-1][channel] = 1

#    for c in range(C):
#        for t in range(max_time):
#            if t==0:continue
#            if schedule[t][c]==1 and schedule[t-1][c]==0:
#                schedule[t-1][c]=1

    #max_N =0
    #for t in range(max_time):
    #    sum_of_ch = sum(schedule[t])

    temp = list(map(sum,list(schedule)))
    max_N = int(max(temp))


    #    if sum_of_ch>max_N:
    #        max_N = int(sum_of_ch)
    print(max_N)







main()


Fixed submission:
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    A = input_string[1]
    B = input_string[2]

    price1 = A*N
    price2 = B

    print(min(price1,price2))

main()

Buggy python submission (verdict: Runtime Error):
import numpy as np

def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    for i in range(N):
        data.append(list(map(int,input().split())))

    data_np = np.array(data).reshape(N,3)

    max_time = max(data_np[:,1])
    schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            schedule[start+j][channel] = 1

    for c in range(C):
        for t in range(max_time):
            if t==0:continue
            if schedule[t][c]==1 and schedule[t-1][c]==0:
                schedule[t-1][c]=1

    max_N =0
    for t in range(max_time):
        sum_of_ch = sum(schedule[t])

        if sum_of_ch>max_N:
            max_N = int(sum_of_ch)
    print(max_N)







main()


Fixed submission:
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    A = input_string[1]
    B = input_string[2]

    price1 = A*N
    price2 = B

    print(min(price1,price2))

main()

Buggy python submission (verdict: Runtime Error):
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    A = input_string[1]
    B = input_string[2]

    price1 = A*T
    price2 = B

    print(min(price1,price2))

main()


Fixed submission:
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    A = input_string[1]
    B = input_string[2]

    price1 = A*N
    price2 = B

    print(min(price1,price2))

main()
Buggy python submission (verdict: Runtime Error):
import numpy as np

def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    for i in range(N):
        data.append(list(map(int,input().split())))

    data_np = np.array(data).reshape(N,3)

    max_time = max(data_np[:,1])
    schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            schedule[start+j][channel] = 1

    for c in range(C):
        for t in range(N):
            if t==0:continue
            if schedule[t][c]==1 and schedule[t-1][c]==0:
                schedule[t-1][c]=1

    max_N =0
    for t in range(max_time):
        sum_of_ch = sum(schedule[t])

        if sum_of_ch>max_N:
            max_N = int(sum_of_ch)
    print(max_N)







main()


Fixed submission:
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    max_time = 0
    for i in range(N):
        data.append(list(map(int,input().split())))
        max_num = max(data[i])
        if max_num>max_time:
            max_time=max_num

    #data_np = np.array(data).reshape(N,3)
    #data_np = np.array(data)

    #max_time = int(max(data))
    #print("max",max_time)
    schedule = [[0]*C for i in range(max_time)]
    #schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            if start+j-1<0:continue
            schedule[start+j-1][channel] = 1

#    for c in range(C):
#        for t in range(max_time):
#            if t==0:continue
#            if schedule[t][c]==1 and schedule[t-1][c]==0:
#                schedule[t-1][c]=1

    #max_N =0
    #for t in range(max_time):
    #    sum_of_ch = sum(schedule[t])

    temp = list(map(sum,list(schedule)))
    max_N = int(max(temp))


    #    if sum_of_ch>max_N:
    #        max_N = int(sum_of_ch)
    print(max_N)







main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

for i in range(K+1):
    if i>S:
        break
    for j in range(K+1):
        if i+j>S:
            break
        if i+j<=S and K+i+j>=S:
            count+=1

print(count)






Fixed submission:
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

for i in range(K+1):
    for j in range(K+1):
        if i+j<=S and K+i+j>=S:
            count+=1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
*p, = map(int, input().split())
p = [v - 1 for v in p]
*c, = map(int, input().split())
minc = min(c)

ans = minc
for i in range(n):
    score = minc
    cur_score = 0
    pos = i
    for j in range(1, k + 1):
        pos = p[pos]
        cur_score += c[pos]
        score = max(cur_score, score)
    ans = max(ans, score)
print(ans)




Fixed submission:
n, k = map(int, input().split())
*p, = map(int, input().split())
p = [v - 1 for v in p]
*c, = map(int, input().split())
minc = float('-inf')

ans = minc


def get_loop(i):
    pos = i
    cnt = 0
    cur_score = 0
    while cnt == 0 or pos != i:
        pos = p[pos]
        cur_score = cur_score + c[pos]
        cnt += 1
    return cnt, cur_score

# print(get_loop(2))

def solve(pos, k):
    score = minc
    cur_score = 0
    loop_length, loop_score = get_loop(pos)
    if k >= 2 * loop_length and loop_score > 0:
        # print("%s: %s // %s, %s, %s" % (i, k, loop_length, cur_score, max_loop_score))
        cur_score = loop_score * ((k - loop_length) // loop_length)
        score = max(cur_score, score)
        k = k % loop_length + loop_length
    else:
        k = min(k, 2 * loop_length)
    for _ in range(k):
        pos = p[pos]
        cur_score += c[pos]
        score = max(cur_score, score)
    # print("%s: %s" % (i, score))
    return score

for i in range(n):
    ans = max(ans, solve(i, k))
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

_ = int(input())
s = input()
counter = Counter(s)
red = counter.get('R')
white = counter.get('W')

mismatches = 0
for i in range(red):
    if s[i] != 'R':
        mismatches += 1

print(mismatches)



Fixed submission:
from collections import Counter

_ = int(input())
s = input()
counter = Counter(s)
red = counter.get('R', 0)
white = counter.get('W', 0)

mismatches = 0
for i in range(red):
    if s[i] != 'R':
        mismatches += 1

print(mismatches)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*arr, = map(int, input().split())
res = 1
for i in range(n):
    res *= arr[i]
print(res if res <= 10 ** 18 else - 1)


Fixed submission:
n = int(input())
*arr, = map(int, input().split())
arr.sort()
res = 1
for i in range(n):
    res *= arr[i]
    if res > 10 ** 18:
        break
print(res if res <= 10 ** 18 else - 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*arr, = map(int, input().split())
res = 1
for i in range(n):
    res *= arr[i]
print(res if res <= 10 ** 18 else - 1)


Fixed submission:
n = int(input())
*arr, = map(int, input().split())
arr.sort()
res = 1
for i in range(n):
    res *= arr[i]
    if res > 10 ** 18:
        break
print(res if res <= 10 ** 18 else - 1)
Buggy python submission (verdict: Runtime Error):
  n, p = map(int, input().split())
  s = input()


  def solve1(s, p):
      v = 0
      pow10 = 1
      ans = 0
      cnt = [0] * p
      cnt[0] = 1

      for i in range(n - 1, -1, -1):
          v = (pow10 * int(s[i]) + v) % p
          pow10 = (pow10 * 10) % p
          ans += cnt[v]
          cnt[v] += 1
      return ans


  def solve25(s, p):
      cnt = 0
      ans = 0
      for i in range(len(s) - 1, -1, -1):
          if int(s[i]) % p == 0:
              cnt += 1
          ans += cnt
      return ans



  if p in (2,5):
      print(solve25(s, p))
  else:
      print(solve1(s, p))

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


def solve1(s, p):
    v = 0
    pow10 = 1
    ans = 0
    cnt = [0] * p
    cnt[0] = 1

    for i in range(n - 1, -1, -1):
        v = (pow10 * int(s[i]) + v) % p
        pow10 = (pow10 * 10) % p
        ans += cnt[v]
        cnt[v] += 1
    return ans


def solve25(s, p):
    cnt = 0
    ans = 0
    for i in range(len(s) - 1, -1, -1):
        if int(s[i]) % p == 0:
            cnt += 1
        ans += cnt
    return ans



if p in (2,5):
    print(solve25(s, p))
else:
    print(solve1(s, p))
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
road=[[] for i i range(n)]
flag=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
count=0
for i in range(n):
    if flag[i]!=0:
        continue
    count+=1
    q=[k]
    while q:
        p=q.popleft()
        for z in road[p]:
            if flag[z]==0:
                q.append(z)
print(count-1)

Fixed submission:
from collections import deque
n,m=map(int,input().split())
road=[[] for i in range(n)]
flag=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
count=0
for i in range(n):
    if flag[i]!=0:
        continue
    count+=1
    q=deque([i])
    while q:
        p=q.popleft()
        flag[p]=1
        for z in road[p]:
            if flag[z]==0:
                q.append(z)
print(count-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)
def dfs(A,N,M,i,j,visited):
    visited[i][j]=1
    rn=[-1,-1,-1,0,0,1,1,1]
    cn=[-1,0,1,-1,1,-1,0,1]
    for s in range(8):
        r=i+rn[s]
        c=j+cn[s]
        if r>=0 and r<N and c>=0 and c<M and not visited[r][c] and A[r][c]:
            dfs(A,N,M,r,c,visited)

from collections import defaultdict
n,m=map(int,input().split())
A=[[0 for i in range(n)] for i in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    A[a-1][b-1]=1
    A[b-1][a-1]=1
count=0
visited=[[0 for i in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        if A[i][j] and not visited[i][j]:
            count+=1
            dfs(A,n,n,i,j,visited)
        
print(count)


Fixed submission:
from collections import deque
n,m=map(int,input().split())
road=[[] for i in range(n)]
flag=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
count=0
for i in range(n):
    if flag[i]!=0:
        continue
    count+=1
    q=deque([i])
    while q:
        p=q.popleft()
        flag[p]=1
        for z in road[p]:
            if flag[z]==0:
                q.append(z)
print(count-1)
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt as sq
n=int(input())
c=0
for i in range(1,n):
    s=set()
    k=n-i
    for i in range(1,int(sq(n))+1):
        if k%i==0:
            s.add(i)
            s.add(k//i)
    c+=(len(s))
print(c)

Fixed submission:
from math import ceil
n=int(input())
ans=0
for i in range(1,n):
  ans+=ceil(n/i)-1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
sz=len(t)
ans=100000000000
for i in range(0,len(s)-sz):
    k=s[i:i+sz]
    c=0
    for j in range(sz):
        if k[j]==t[j]:
            c+=1
        else:
            ans=min(ans,sz-c)
    # print(c)
ans=min(ans,sz-c)
print(ans)


Fixed submission:
s=input()
t=input()
sz=len(t)
ans=100000000000
c=0
if len(s)==sz:
    c=0
    for j in range(sz):
        if s[j]==t[j]:
            c+=1
        else:
            ans=min(ans,sz-c)
else:
    for i in range(0,len(s)-sz):
        k=s[i:i+sz]
        c=0
        for j in range(sz):
            if k[j]==t[j]:
                c+=1
            else:
                ans=min(ans,sz-c)
        # print(c)
ans=min(ans,sz-c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[int(i) for i in input().split()]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=(l[i]*l[j])%1000000007
print(ans%1000000007)

Fixed submission:
n=int(input())
l=[int(i) for i in input().split()]
ans=0
mod=1000000007
sql=(sum(l))**2
for i in l:
    ans+=i*i
print((sql-ans)//2%mod)