Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

N,M=map(int,input().split())
l = list()
num1=str('')
num2=str('')
num3=str('')

for _ in range(M):
    l.append(input().split())
l.sort()
for i in l:
    keta_num = i[0]
    if keta_num == '1':
        if num1 == '':
            num1 = i[1]
        else:
            if num1 != i[1]:
                print('-1')
                sys.exit()
    elif keta_num == '2':
        if num2 == '':
            num2 = i[1]
        else:
            if num2 != i[1]:
                print('-1')
                sys.exit()
    else:
        if num3 == '':
            num3 = i[1]
        else:
            if num3 != i[1]:
                print('-1')
                sys.exit()
if N == 3:
    if num2 == '':num2 ='0'
    if num3 == '':num3 ='0'
elif N == 2:
    if num3 == '':num3 ='0'

ans = num1+num2+num3
ans = int(ans)
ans = str(ans)
if len(ans) == N:
    print(ans)
else:print('-1')

Fixed submission:
N,M=map(int,input().split())
cnt = [-1 for _ in range(N)]
flag = True
for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    if cnt[s] == -1:
        cnt[s] = c
    else:
        if cnt[s] != c:
            flag = False
            break

if cnt[0] == 0 and N > 1:
    flag = False
if cnt[0] == -1:
    cnt[0] = 0 if N ==1 else 1
if flag:
    for i in cnt:
        print(0 if i == -1 else i,end='')
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())

mod = 10 ** 9 + 7
com = [1]
table = [1]
inv_table = [1]
sums = 0

for i in range(1, n+1):
    table.append((table[i-1]*i) % mod)
    inv_table.append(pow(table[i], mod-2, mod))

for i in range(1,n+1):
    com.append((table[n] * inv_table[i] * inv_table[n-i]) % mod)

for i in range(1,n+1):
    if i == a or i == b:continue
    sums +=com[i]

print(sums % mod)

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

mod = 10 ** 9 + 7
k = max(a,b)
com = [1]

for i in range(1,k+1):
    com.append((com[i-1]*(n-i+1)*pow(i,mod-2,mod))%mod)

print((pow(2,n,mod)-1-com[a]-com[b])%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())
sums = 0

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

for i in range(n+1):
    if i == a or i == b or i == 0:continue
    sums += cmb(n,i)
if sums >= (10**9 + 7):
    sums %= (10**9 + 7)
print(sums)

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

mod = 10 ** 9 + 7
k = max(a,b)
com = [1]

for i in range(1,k+1):
    com.append((com[i-1]*(n-i+1)*pow(i,mod-2,mod))%mod)

print((pow(2,n,mod)-1-com[a]-com[b])%mod)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = []
for i,num in enumerate(A):
    for j in range(i+1,N):
        ans.append(num * A[j])
ans.sort()
print(ans[K-1])

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

if A == B:
    if A == C:
        print('No')
    else:print('Yes')
elif A == C:
    print('Yes')
elif B == C:
    print('Yes')
else: print('No')
Buggy python submission (verdict: Runtime Error):
import sys

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

for i in A:
    if i % 2 == 0:
        if i % 3 !=0 and i % 5 !=0:
            print('DENIED')
            sys.exit(1)
print('APPROVED')

Fixed submission:
N = int(input())
A= list(map(int,input().split()))
c = 0
for i in A:
    if i % 2 == 0:
        if i % 3 !=0 and i % 5 !=0:
            print('DENIED')
            break
    c += 1
if (N == c):
    print('APPROVED')
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = list()

def kitai(p):
  return (p+1)/2

for i in range(N):
  Q.append(kitai(P[i]))

for i in range(N - K + 1):
  if i == 0:
    R.append(sum(Q[i:i+K]))
  else:
    R.append(sum(Q[:i+K])-sum(Q[:i]))

print(max(R))

Fixed submission:
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = [0]
result = 0

for i in P:
  Q.append((i+1)/2)

for i in range(N):
  R.append(R[i] + Q[i])

for i in range(N - K + 1):
  result = max(result,R[i+K]-R[i])

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = list()

def kitai(p):
  return (p+1)/2

for i in range(N):
  Q.append(kitai(P[i]))

for i in range(N - K + 1):
  R.append(sum(Q[i:i+K]))

print(max(R))

Fixed submission:
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = [0]
result = 0

for i in P:
  Q.append((i+1)/2)

for i in range(N):
  R.append(R[i] + Q[i])

for i in range(N - K + 1):
  result = max(result,R[i+K]-R[i])

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = list()

def kitai(p):
  return (p+1)/2

for i in range(N):
  Q.append(kitai(P[i]))

for i in range(N - K + 1):
  if i == 0:
    R.append(sum(Q[i:i+K]))
  else:
    R.append(sum(Q[i:i+K]))

print(max(R))

Fixed submission:
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = [0]
result = 0

for i in P:
  Q.append((i+1)/2)

for i in range(N):
  R.append(R[i] + Q[i])

for i in range(N - K + 1):
  result = max(result,R[i+K]-R[i])

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

dp = [float("inf") for _ in range(H+1)]

dp[H] = 0

for a,b in AB:
    for h in range(H,0,-1):
        i = max(0,h-a)
        dp[i] = min(dp[i],dp[h]+b)
print(dp[0])

Fixed submission:
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

dp = [float("inf") for _ in range(H+1)]

dp[H] = 0

for a,b in AB:
    for h in range(H,0,-1):
        i = max(0,h-a)
        dp[i] = min(dp[i],dp[h]+b)
print(dp[0])
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())
ans = float('inf')

for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i * j)%2019)
        if ans == 0:
            break
print(ans)

Fixed submission:
L,R = map(int,input().split())
ans = float('inf')

for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i * j)%2019)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())
ans = float('inf')

for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i * j)%2019)
print(ans)

Fixed submission:
L,R = map(int,input().split())
ans = float('inf')

for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i * j)%2019)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

LCM = lcm(C,D)
BC = B // C
BD = B // D
BCD = B // LCM
AC = (A-1) // C
AD = (A-1) // D
ACD = (A-1) // LCM
x = B - BC - BD + BCD
y = (A-1) - AC - AD + ACD
print(x - y)

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

LCM = lcm(C,D)
BC = B // C
BD = B // D
BCD = B // LCM
AC = (A-1) // C
AD = (A-1) // D
ACD = (A-1) // LCM
x = B - BC - BD + BCD
y = (A-1) - AC - AD + ACD
print(x - y)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
abc_index = s.find("ABC")
ans = 0
while abc_index >= 0:
    s = s.replace("ABC","BCA",1)
    ans += 1
    abc_index = s.find("ABC")
print(ans)

Fixed submission:
s = input()
s = s.replace('BC','D')
A_count = 0
ans = 0

for i in s:
    if i == 'A':
        A_count += 1
    elif i == 'B' or i == 'C':
        A_count = 0
    else:
        ans += A_count
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
cnt = 0

for x in range(N//R+1):
    for y in range(N//G+1):
        z = N - R*x - G*y
        if z >= 0 and z % B == 0:
            cnt += 1
print(cnt)

Fixed submission:
def main():
    R,G,B,N = map(int,input().split())
    cnt = 0

    for x in range(N//R+1):
        for y in range(N//G+1):
            z = N - R*x - G*y
            if z >= 0 and z % B == 0:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
while True:
    T = S.replace('#.','')
    if T == S:
        break
    else:
        S = T
print((N-len(S))//2)

Fixed submission:
N = int(input())
S = input()
black = 0
ans = 0

for s in S:
    if s == "#":
        black += 1
    else:
        if black > 0:
            ans += 1
            black -= 1

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

ans = 0
tmp = H[0]

for h in H[1:]:
    if h >= tmp:
        tmp = h
    else:
        ans += tmp - h
        tmp = h
else:
    ans += h

print(ans)

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

ans = 0
tmp = h = H[0]

for h in H[1:]:
    if h >= tmp:
        tmp = h
    else:
        ans += tmp - h
        tmp = h
else:
    ans += h

print(ans)

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

ans = 0
tmp = H[0]

for i in range(len(H)-1):
    if H[i] <= H[i+1]:
        tmp = H[i+1]
    else:
        ans += tmp - H[i+1]
else:
    ans += H[i+1]

print(ans)

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

ans = 0
tmp = h = H[0]

for h in H[1:]:
    if h >= tmp:
        tmp = h
    else:
        ans += tmp - h
        tmp = h
else:
    ans += h

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,W = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(N)]
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    
    for w in range(1,W+1):
        for i in range(1,N+1):
            if w - wv[i-1][0] >= 0:
                dp[i][w] = max(dp[i-1][w],dp[i-1][w-wv[i-1][0]] + wv[i-1][1])
            else:
                dp[i][w] = dp[i-1][w]
    print(dp[-1][-1])

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,W = map(int,input().split())
    goods = [list(map(int,input().split())) for _ in range(N)]

    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

    for i in range(N):
        for w in range(W+1):
            if w >= goods[i][0]:
                dp[i+1][w] = max(dp[i][w-goods[i][0]]+goods[i][1],dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    print(dp[N][W])

if __name__ == "__main__":
    main()

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

def input():
    return sys.stdin.readline().strip()

def main():
    N,W = map(int,input().split())
    goods = [list(map(int,input().split())) for _ in range(N)]

    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

    for i in range(N):
        for w in range(W+1):
            if w >= goods[i][0]:
                dp[i+1][w] = max(dp[i][w-goods[i][0]]+goods[i][1],dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    print(dp[N][W])

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,W = map(int,input().split())
    goods = [list(map(int,input().split())) for _ in range(N)]

    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

    for i in range(N):
        for w in range(W+1):
            if w >= goods[i][0]:
                dp[i+1][w] = max(dp[i][w-goods[i][0]]+goods[i][1],dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    print(dp[N][W])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
goods = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w >= goods[i][0]:
            dp[i+1][w] = max(dp[i][w-goods[i][0]]+goods[i][1],dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,W = map(int,input().split())
    goods = [list(map(int,input().split())) for _ in range(N)]

    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

    for i in range(N):
        for w in range(W+1):
            if w >= goods[i][0]:
                dp[i+1][w] = max(dp[i][w-goods[i][0]]+goods[i][1],dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    print(dp[N][W])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(float,input().split()))
dp = [[0] * (N+2) for _ in range(N+1)]
dp[0][0] = 1


for omote in range(N+1):
    for i in range(N):
        dp[i+1][omote] += dp[i][omote] * (1 - P[i])
        dp[i+1][omote+1] += dp[i][omote] * P[i] 

ans = 0
for omote in range(N+1):
    ans += dp[N][omote] if omote > N - omote else 0
print(ans)

Fixed submission:
N = int(input())
P = list(map(float,input().split()))
dp = [[0] * (N+2) for _ in range(N+1)]
dp[0][0] = 1


for omote in range(N+1):
    for i in range(N):
        dp[i+1][omote] += dp[i][omote] * (1 - P[i])
        dp[i+1][omote+1] += dp[i][omote] * P[i] 

ans = 0
for omote in range(N+1):
    ans += dp[N][omote] if omote > N - omote else 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
cnt = 0
ans = list()

for i in range(N):
    cnt = S.count('W',0,i)
    cnt += S.count('E',i+1,N)
    ans.append(cnt)
print(min(ans))

Fixed submission:
N = int(input())
S = input()
cnt = S.count('E',1,N)
ans = [cnt]

for i in range(1,N):
    if S[i-1] == 'W':cnt += 1
    if S[i] == 'E': cnt -=1
    ans.append(cnt)
print(min(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
ma = A[0]

def make_factorial_table(n):
    result = [0] * (n+1)
    result[0] = 1
    for i in range(1,n+1):
        result[i] = result[i-1] * i
    return result

def comb(n,r):
    return fact[n] * pow(fact[n-r],-1) * pow(fact[r],-1)

fact = make_factorial_table(ma)
tmp = 0
ans = 0

for a in A[1:]:
    if comb(ma,a) > tmp:
        tmp = comb(ma,a)
        ans = a
    
print(ma,ans)

Fixed submission:
import bisect

n = int(input())
A = sorted(list(map(int,input().split())))
ma = A[-1]
half = ma / 2
index = bisect.bisect_left(A,half)

if index != 0:
    ans = A[index-1] if half - A[index-1] <= A[index] - half else A[index]
else:
    ans = A[0]

print(ma,ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,Y=map(int,input().split())

total = 0

for a in range(N+1):
    for b in range(N+1):
        if a + b > N:
            continue
        for c in range(N+1):
            if a + b + c > N:
                break
            total = 10000 * a + 5000 * b + 1000 * c
            if total == Y and a + b + c == N:
                print(a,b,c)
                sys.exit()
print(-1,-1,-1)

Fixed submission:
import sys
N,Y=map(int,input().split())

total = 0

for a in range(N+1):
    for b in range(N+1):
        c = N - (a + b)
        if c < 0:continue
        total = 10000 * a + 5000 * b + 1000 * c
        if total == Y and a + b + c == N:
            print(a,b,c)
            sys.exit()
print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0

for a in A:
    for b in B:
        for c in C:
            if a < b < c:
                ans += 1
print(ans)

Fixed submission:
import bisect

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
for n in range(N):
    i = bisect.bisect_left(A,B[n])
    j = len(C) - bisect.bisect_right(C,B[n])
    ans += i * j
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l = prime(N)

sqrt = str(int(math.sqrt(N)))
print(max(len(sqrt),len(str(l[-1]))))

Fixed submission:
import math

N = int(input())
ans = len(str(N))

f = 1
while f * f <= N:
    if N % f == 0:
        ans = min(ans,max(len(str(f)),len(str(N//f))))
    f += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

line = [[] for _ in range(M)]
for _ in range(N):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)

Fixed submission:
N,M = map(int,input().split())

line = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

line = [[] for _ in range(M)]
for _ in range(M):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)

Fixed submission:
N,M = map(int,input().split())

line = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:ans+=1

print(ans)

Fixed submission:
K,S=map(int,input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        z = S-(x+y)
        if z <= K and z >= 0:ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
import re

def x():
    for i in range(len(T),0,-1): # 文字列の長さ
        for j in range(len(T)-i): # T検索の開始位置=その前にある文字数
            t=T[j:i+j]
            for m in re.finditer(t, S):
                p=m.start()
                if p!=-1:
                    if j<=p and len(T)-j-1 <=len(S)-p-1:
                        return i
    return 0
print(len(T)-t)

Fixed submission:
S=input()
T=input()
ls=len(S)
lt=len(T)

ans=float('inf')
for i in range(0,ls-lt+1):
    ans=min(ans, sum([l!=m for l,m in zip(S[i:i+lt], T)]))
print(ans)

Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
import re

def x():
    for i in range(len(T),0,-1): # 文字列の長さ
        for j in range(len(T)-i): # T検索の開始位置=その前にある文字数
            t=T[j:i+j]
            for m in re.finditer(t, S):
                p=m.start()
                if p!=-1:
                    # print(j,i,t,p,j<=p and len(T)-j-1 <=len(S)-p-1,len(T)-i)
                    if j<=p and len(T)-j-1 <=len(S)-p-1:
                        return i

print(len(T)-x())

Fixed submission:
S=input()
T=input()
ls=len(S)
lt=len(T)

ans=float('inf')
for i in range(0,ls-lt+1):
    ans=min(ans, sum([l!=m for l,m in zip(S[i:i+lt], T)]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]

ans=0
for i in range(N):
       ans+=S[i]*sum(S[i+1:])
print(ans%t)    

Fixed submission:
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]
g=sum(S)

ans=0
for i in range(N):
       g-=S[i]
       ans+=S[i]*g%t
print(ans%t)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())
t=10**9+7

ans=0
for i in range(N):
       ans+=A[i]*sum(A[i+1:])%t
print(ans%t)    

Fixed submission:
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]
g=sum(S)

ans=0
for i in range(N):
       g-=S[i]
       ans+=S[i]*g%t
print(ans%t)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())
t=10**9+7

ans=0
for i in range(N):
    for j in range(i+1,N):
       ans+=A[i]*A[j]%t
print(ans%t)    

Fixed submission:
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]
g=sum(S)

ans=0
for i in range(N):
       g-=S[i]
       ans+=S[i]*g%t
print(ans%t)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]

ans=0
for i in range(N):
    for j in range(i+1,N):
       ans+=S[i]*S[j]
print(ans%t)

Fixed submission:
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]
g=sum(S)

ans=0
for i in range(N):
       g-=S[i]
       ans+=S[i]*g%t
print(ans%t)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]

ans=0
for i in range(N):
    for j in range(i+1,N):
       ans+=(S[i]*S[j])%t
print(ans%t) 

Fixed submission:
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]
g=sum(S)

ans=0
for i in range(N):
       g-=S[i]
       ans+=S[i]*g%t
print(ans%t)
Buggy python submission (verdict: Runtime Error):
from itertools import *
*x,=map(int,input().split())
K=int(input())
for i in product(range(K), repeat=K):
    a = x.copy()
    for j in i:
        a[j] *= 2
        if a[0] < a[1] and a[1] < a[2]: 
            print('Yes')
            exit()
else:
    print('No')

Fixed submission:
from itertools import * 
*x,=map(int,input().split())
K=int(input())
c = combinations_with_replacement(range(3), K)
a=x.copy()
ans=0
for i in c:
    a=x.copy()
    for j in i:
        a[j] = a[j] * 2
        if a[0] < a[1] and a[1] < a[2]: 
            ans=1
if ans==1: 
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
*A,=map(int,input().split())
for i in range(0,N-K):
    x = 1
    y = 1
    for j in range(K):
        x*=A[i+j]
        y*=A[i+j+1]
    if (y<=x):
        print('No')
    else:
        print('Yes')

Fixed submission:
N,K=map(int,input().split())
*A,=map(int,input().split())

for i in range(0,N-K):
    print('Yes' if 1<A[i+K]/A[i] else 'No')