Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
T = str(input())

for i in range(T.count("?")):
    index = T.index("?")
    if T[index - 1] == "P":
        T = T.replace("?","D",1)
    elif T[index + 1] == "D":
        T = T.replace("?","P",1)
    elif T[index + 1] == "?":
        T = T.replace("?","P",1)
    else:
        T = T.replace("?","D",1)
print(T)

Fixed submission:
# B
T = str(input())
try:
    for i in range(T.count("?")):
        index = T.index("?")
        if T[index - 1] == "P":
            T = T.replace("?","D",1)
        elif T[index + 1] == "D":
            T = T.replace("?","P",1)
        elif T[index + 1] == "?":
            T = T.replace("?","P",1)
        else:
            T = T.replace("?","D",1)
    print(T)
except:
    print(T.replace("?","D"))

Buggy python submission (verdict: Runtime Error):
# B
T = str(input())

for i in range(T.count("?")):
    index = T.index("?")
    if T[index - 1] == "P":
        T = T.replace("?","D",1)
    elif T[index + 1] == "D":
        T = T.replace("?","P",1)
    elif T[index + 1] == "?":
        T = T.replace("?","P",1)
    else:
        T = T.replace("?","D",1)
print(T)

Fixed submission:
# B
T = str(input())
try:
    for i in range(T.count("?")):
        index = T.index("?")
        if T[index - 1] == "P":
            T = T.replace("?","D",1)
        elif T[index + 1] == "D":
            T = T.replace("?","P",1)
        elif T[index + 1] == "?":
            T = T.replace("?","P",1)
        else:
            T = T.replace("?","D",1)
    print(T)
except:
    print(T.replace("?","D"))

Buggy python submission (verdict: Runtime Error):
# B
T = str(input())

def score(t):
    n = 0
    while "PD" in t:
        t = t.replace("PD","",1)
        n+=1
    n += t.count("D")
    return n

for i in range(T.count("?")):
    index = T.index("?")
    if T[index - 1] == "P":
        T = T.replace("?","D",1)
    elif T[index + 1] == "D":
        T = T.replace("?","P",1)
    elif T[index + 1] == "?":
        T = T.replace("?","P",1)
    else:
        T = T.replace("?","D",1)
print(T)

Fixed submission:
# B
T = str(input())
try:
    for i in range(T.count("?")):
        index = T.index("?")
        if T[index - 1] == "P":
            T = T.replace("?","D",1)
        elif T[index + 1] == "D":
            T = T.replace("?","P",1)
        elif T[index + 1] == "?":
            T = T.replace("?","P",1)
        else:
            T = T.replace("?","D",1)
    print(T)
except:
    print(T.replace("?","D"))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
result = []
for i in range(N):
    s = str(input())
    if s not in result:
        result.append(s)
print(len(result))

Fixed submission:
N = int(input())
s = [str(input()) for i in range(N)]
s = set(s)
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
N = int(input())
K = [0]*N
A = [int(i) for i in input().split()]

for i in range(N-1):
    K[A[i]-1] += 1
for i in K:
    print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1,n+1):
    print(a.count[i])

Fixed submission:
N = int(input())
K = [0]*N
A = [int(i) for i in input().split()]

for i in range(N-1):
    K[A[i]-1] += 1
for i in K:
    print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1,n+1):
  print(a.count[i])

Fixed submission:
N = int(input())
K = [0]*N
A = [int(i) for i in input().split()]

for i in range(N-1):
    K[A[i]-1] += 1
for i in K:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
N = int(input())
K = [0]*N
A = [int(i) for i in input().split()]

for i in range(N-1):
    K[A[i]-1] += 1
for i in K:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split()]
if N%K==0:
    print("0")
else:
    while abs(N-K) < N:
        N = abs(N-K)
    print(N)

Fixed submission:
N,K = map(int,input().split())
if N>=K:
    N = N%K
    while abs(N-K) < N:
        N = abs(N-K)
    print(N)
else:
    if K >= 2*N:
        print(N)
    else:
        N = K%N
        print(N)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split()]
while abs(N-K) < N:
    N = abs(N-K)
print(N)

Fixed submission:
N,K = map(int,input().split())
if N>=K:
    N = N%K
    while abs(N-K) < N:
        N = abs(N-K)
    print(N)
else:
    if K >= 2*N:
        print(N)
    else:
        N = K%N
        print(N)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
if N%K==0:
    print(0)
elif K%N==0:
    print(N)
else:
    while abs(N-K) < N:
        N = abs(N-K)
    print(N)

Fixed submission:
N,K = map(int,input().split())
if N>=K:
    N = N%K
    while abs(N-K) < N:
        N = abs(N-K)
    print(N)
else:
    if K >= 2*N:
        print(N)
    else:
        N = K%N
        print(N)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
if N%K==0:
    print(0)
else:
    while abs(N-K) < N:
        N = abs(N-K)
    print(N)

Fixed submission:
N,K = map(int,input().split())
if N>=K:
    N = N%K
    while abs(N-K) < N:
        N = abs(N-K)
    print(N)
else:
    if K >= 2*N:
        print(N)
    else:
        N = K%N
        print(N)
Buggy python submission (verdict: Runtime Error):
#1 
mylist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(mylist[k+1])

Fixed submission:
#1 
mylist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(mylist[k-1])
Buggy python submission (verdict: Runtime Error):
a=int(input)
print(a+a**2+a**3)

Fixed submission:
a=int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
cnt=0
for i in len(S):
  if(S[i]==T[i]):
    cnt+=1
    
print(cnt)

Fixed submission:
S=input()
T=input()
cnt=0
for i in range(len(S)):
  if(S[i]!=T[i]):
    cnt+=1
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = [int(i)for i in input().split()]
tmpmax = 0
breakflag=False
for i in range(N+1):
  tmp=math.floor(A*i/B)-A*math.floor(i/B)
  if tmp > tmpmax:
    tmpmax = tmp
  elif tmp < tmpmax:
    breakflag=True
  elif tmp == tmpmax and breakflag:
    break
print(tmpmax)

Fixed submission:
import math
A,B,N = [int(i)for i in input().split()]

def func(A, B, N):
  if N>B-1:
    return math.floor(A*(B-1)/B)-A*math.floor((B-1)/B)
  else:
    return math.floor(A*N/B)-A*math.floor(N/B)


print(func(A,B,N))

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = [int(i)for i in input().split()]
tmpmax=0
for i in range(N+1):
  tmp=math.floor(A*i/B)-A*math.floor(i/B)
  if tmp > tmpmax:
    tmpmax=tmp
    #print("{},{}".format(i,tmp))
print(tmpmax)

Fixed submission:
import math
A,B,N = [int(i)for i in input().split()]

def func(A, B, N):
  if N>B-1:
    return math.floor(A*(B-1)/B)-A*math.floor((B-1)/B)
  else:
    return math.floor(A*N/B)-A*math.floor(N/B)


print(func(A,B,N))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
[N, X, Y] = [int(item) for item in input().split()]
X -= 1
Y -= 1
gyoretu=[]
for i in range(N):
    row=[]
    for j in range(N):
        if i == j:
            row.append(0)
        elif abs(i - j) == 1 or i == X and j == Y or i == Y and j == X:
            row.append(1)
        else:
            row.append(2000)
    gyoretu.append(row)
for k in range(N):
    for i in range(N):
        for j in range(N):
            gyoretu[i][j] = min([gyoretu[i][j], gyoretu[i][k] + gyoretu[k][j]])
array=[]
for i in range(N):
        array+=gyoretu[i][i:]
c=Counter(array)
for i in range(1, N):
    print(c[i])

Fixed submission:
s=input()
if s[2]==s[3] and s[4]==s[5]:print("Yes")
else :print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
if s[2]=s[3] and s[4]=s[5]:print("Yes")
else print("No")

Fixed submission:
s=input()
if s[2]==s[3] and s[4]==s[5]:print("Yes")
else :print("No")
Buggy python submission (verdict: Runtime Error):
s=input()
if s[2]==s[3] and s[4]==s[5]:print("Yes")
else :print("No")

Fixed submission:
i=int(input())
gohyaku = i // 500
go = (i % 500) // 5
print(int(gohyaku*1000+go*5))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(item)for item in input().split()]
c=Counter(A)
full = {i: c[i] * (c[i] - 1) / 2 for i in c.keys()}
#full = [full[item-1] for item in A]
#print(full)
#ichiheri = [c[i]-1 * (c[i]-1) / 2 for i in range(1,1+len(c))]
ichiheri = {i:(c[i]-2) * (c[i]-1) / 2 for i in c.keys()}
#print(ichiheri)

for a in A:
    sumA = sum(full.values())
    sumA-=full[a]
    sumA += ichiheri[a]
    print(int(sumA))

Fixed submission:
from collections import Counter
N=int(input())
A=[int(item)for item in input().split()]
c=Counter(A)
full = {i: c[i] * (c[i] - 1) / 2 for i in c.keys()}
#full = [full[item-1] for item in A]
#print(full)
#ichiheri = [c[i]-1 * (c[i]-1) / 2 for i in range(1,1+len(c))]
sumA = sum(full.values())
val = {i:int(sumA-full[i]+(c[i]-2) * (c[i]-1) / 2 )for i in c.keys()}
#print(ichiheri)



for a in A:
    print(val[a])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(item)for item in input().split()]
c=Counter(A)
full = {i: c[i] * (c[i] - 1) / 2 for i in c.keys()}
#full = [full[item-1] for item in A]
#print(full)
#ichiheri = [c[i]-1 * (c[i]-1) / 2 for i in range(1,1+len(c))]
ichiheri = {i:(c[i]-2) * (c[i]-1) / 2 for i in c.keys()}
#print(ichiheri)

for a in A:
    sumA = sum(full.values())
    sumA-=full[a]
    sumA += ichiheri[a]
    print(int(sumA))

Fixed submission:
from collections import Counter
N=int(input())
A=[int(item)for item in input().split()]
c=Counter(A)
full = {i: c[i] * (c[i] - 1) / 2 for i in c.keys()}
#full = [full[item-1] for item in A]
#print(full)
#ichiheri = [c[i]-1 * (c[i]-1) / 2 for i in range(1,1+len(c))]
sumA = sum(full.values())
val = {i:int(sumA-full[i]+(c[i]-2) * (c[i]-1) / 2 )for i in c.keys()}
#print(ichiheri)



for a in A:
    print(val[a])
Buggy python submission (verdict: Runtime Error):
[a,b,c]=[int(inp) for inp in input().split()]
#if a*a+b*b+c*c -2*(a*b+b*c+c*a) > 0:
if a*(a-2*b)+b*(b-2*c)>-c*(c-2*a):
    print("Yes")
else:
    print("No")

Fixed submission:
K=int(input())
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])

Buggy python submission (verdict: Runtime Error):
[a,b,c]=[int(inp) for inp in input().split()]
if (c - a - b) ** 2 - 4 * a * b > 0:
    print("Yes")
else:
    print("No")

Fixed submission:
K=int(input())
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])

Buggy python submission (verdict: Runtime Error):
K=input()
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
return array[K+1]

Fixed submission:
K=int(input())
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])
Buggy python submission (verdict: Runtime Error):
[a,b,c]=[int(inp) for inp in input().split()]
#if a*a+b*b+c*c -2*(a*b+b*c+c*a) > 0:
if a(a-2*b)+b*(b-2*c)+c*(c-2*a)> 0:
    print("Yes")
else:
    print("No")

Fixed submission:
[a,b,c]=[int(inp) for inp in input().split()]
#if a*a+b*b+c*c -2*(a*b+b*c+c*a) > 0:
if c - a - b < 0 or a*(a-2*b)+b*(b-2*c)+c*(c-2*a)<=0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
import itertools
N = int(input())
array=[]
for i in range(0, N-1):
    array.append(input().split())
dist3=[]
for row in array:
    a,b=row
    c = []
    d=[]
    for tmpc1,tmpc2 in array:
        if tmpc1 == a and tmpc2 != a and tmpc2!=b:
            c.append(int(tmpc2)-1)
        if tmpc1 != a and tmpc2 == a and tmpc1 != b:
            c.append(int(tmpc1)-1)
    for tmpd1,tmpd2 in array:
        if tmpd1 == b and tmpd2!=a and tmpd2 != b and tmpd2!=c:
            d.append(int(tmpd2)-1)
        if tmpd1 != b and tmpd1!=a and tmpd2 == b and tmpd1!=c:
            d.append(int(tmpd1)-1)
    if c != [] and d != []:
        #print("{} {} {} {}".format(a, b, c, d))
        dist3.append([c, d])
        
for kouho in itertools.permutations(list(range(1,N+1)),N):
    breakflag=False
    for c, d in dist3:
        for tmpc in c:
            for tmpd in d:
                if (kouho[tmpc] + kouho[tmpd]) % 3 != 0 and (kouho[tmpc] * kouho[tmpd]) % 3 != 0:
                    breakflag = True
                    break
                #else:
                    #print("{} {} {} {}".format( tmpc, tmpd,kouho[tmpc],kouho[tmpd]))
            if breakflag==True:
                break
        if breakflag!=True:
            print(' '.join(map(str,kouho)))
            exit()

print('-1')

Fixed submission:
import re
strin=input()
pattern = '(hi)+$'
if re.match(pattern, strin):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
S=input().splitlines()[0]
Q = int(input())
flipcnt=0
for _ in range(Q):
    q = input().split()
    if len(q) == 1:
        flipcnt += 1
        continue
    else:
        if (int(q[1]) + flipcnt) % 2 == 1:
            #前
            S=q[2]+S
        else:
            S=S+q[2]
    #print(S)

if flipcnt % 2 == 1:
    S=S[::-1]

print(S)

Fixed submission:
from collections import deque
import sys
input=sys.stdin.readline
S=input().splitlines()[0]
Q = int(input())
qs = [input().split() for _ in range(Q)]
flipcnt = 0
S =deque(S)
for q in qs:
    if len(q) == 1:
        flipcnt += 1
        continue
    else:
        if (int(q[1]) + flipcnt) % 2 == 1:
            #前
            S.appendleft(q[2])
        else:
            S.append(q[2])
    #print(S)

if flipcnt % 2 == 1:
    S.reverse()

print(''.join(S))
Buggy python submission (verdict: Runtime Error):
[M,N]=[int(item) for item in input().split()]

num={}

for _ in range(N):
    [s,c] = [int(item) for item in input().split()]
    if s > M or  not M==1 and  s == 1 and c == 0:
        print(-1)
        exit()
    if s in num:
        if num[s] == c:
            continue
        else:
            print(-1)
            exit()
    num[s]=c

#print(num)
#数字にする
num_int = 0

if M == 1:
    print(num[1])
    exit()

if  1 in num:
    num_int = num[1]
else:
    num_int=1

for i in range(2, M + 1):
    num_int*=10
    if i in num:
        num_int+=num[i]

print(num_int)

Fixed submission:
[M,N]=[int(item) for item in input().split()]

num={}

for _ in range(N):
    [s,c] = [int(item) for item in input().split()]
    if s > M or  not M==1 and  s == 1 and c == 0:
        print(-1)
        exit()
    if s in num:
        if num[s] == c:
            continue
        else:
            print(-1)
            exit()
    num[s]=c

#print(num)
#数字にする
num_int = 0

if M == 1:
    if  1 in num:
        print(num[1])
    else:
        print(0)
    exit()

if  1 in num:
    num_int = num[1]
else:
    num_int=1

for i in range(2, M + 1):
    num_int*=10
    if i in num:
        num_int+=num[i]

print(num_int)

Buggy python submission (verdict: Runtime Error):
[M,N]=[int(item) for item in input().split()]

num={}

for _ in range(N):
    [s,c] = [int(item) for item in input().split()]
    if s > M or  not M==1 and  s == 1 and c == 0:
        print(-1)
        exit()
    if s in num:
        if num[s] == c:
            continue
        else:
            print(-1)
            exit()
    num[s]=c

#print(num)
#数字にする
num_int = 0

if M == 1:
    print(num[1])
    exit()

if  1 in num:
    num_int = num[1]
else:
    num_int=1

for i in range(2, M + 1):
    num_int*=10
    if i in num:
        num_int+=num[i]

print(num_int)

Fixed submission:
[M,N]=[int(item) for item in input().split()]

num={}

for _ in range(N):
    [s,c] = [int(item) for item in input().split()]
    if s > M or  not M==1 and  s == 1 and c == 0:
        print(-1)
        exit()
    if s in num:
        if num[s] == c:
            continue
        else:
            print(-1)
            exit()
    num[s]=c

#print(num)
#数字にする
num_int = 0

if M == 1:
    if  1 in num:
        print(num[1])
    else:
        print(0)
    exit()

if  1 in num:
    num_int = num[1]
else:
    num_int=1

for i in range(2, M + 1):
    num_int*=10
    if i in num:
        num_int+=num[i]

print(num_int)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
len_of_s=len(S)
if len_of_s%2==0 and S[:len_of_s/2]==s[len_of_s/2:]:
  print("Yes")
elif:
  print("No")

Fixed submission:
N=int(input())
S=input()
len_of_s=len(S)
if len_of_s%2==0 and S[:len_of_s//2]==S[len_of_s//2:]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
len_of_s=len(S)
if len_of_s%2==0 and S[:len_of_s/2+1]==s[len_of_s/2+1:]:
  print("Yes")
elif
  print("No")

Fixed submission:
N=int(input())
S=input()
len_of_s=len(S)
if len_of_s%2==0 and S[:len_of_s//2]==S[len_of_s//2:]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = 0
for i in range(n):
    x = a[i]
    if abs(x-m) < x:
        x -= m
    y = 0
    for j in range(i+1, n):
        y = (y + a[j]) % m
    result = (result + (x*y)) % m

if(result < 0):
    result += m
print(result)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = 0

sum_a = 0
for i in range(n):
    sum_a = (sum_a + a[i]) % m

result = 0
for i in range(n):
    x = a[i]
    sum_a -= x
    result = (result + x*sum_a) % m

if(result < 0):
    result += m
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = [a[i]*( sum(a[i+1:n]) % m ) % m for i in range(n)]
result = sum(result) % m
print(result)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = 0

sum_a = 0
for i in range(n):
    sum_a = (sum_a + a[i]) % m

result = 0
for i in range(n):
    x = a[i]
    sum_a -= x
    result = (result + x*sum_a) % m

if(result < 0):
    result += m
print(result)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)
for i in range(n):
    if abs(a[i]-m) < a[i]:
        a[i] = x - m
result = [(a[i]*a[j])%m for i in range(n) for j in range(n) if i < j]
result = sum(result)%m
if(result < 0):
    result += m 
print(result)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = 0

sum_a = 0
for i in range(n):
    sum_a = (sum_a + a[i]) % m

result = 0
for i in range(n):
    x = a[i]
    sum_a -= x
    result = (result + x*sum_a) % m

if(result < 0):
    result += m
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
 
m = (10**9 + 7)
result = [(a[i]*a[j])%m for i in range(n) for j in range(n) if i < j]
print(sum(result)%m)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = 0

sum_a = 0
for i in range(n):
    sum_a = (sum_a + a[i]) % m

result = 0
for i in range(n):
    x = a[i]
    sum_a -= x
    result = (result + x*sum_a) % m

if(result < 0):
    result += m
print(result)

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

m = (10**9 + 7)
result = [(a[i]*a[j])%m for i in range(n) for j in range(n) if i < j]
print(sum(result)%m)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = 0

sum_a = 0
for i in range(n):
    sum_a = (sum_a + a[i]) % m

result = 0
for i in range(n):
    x = a[i]
    sum_a -= x
    result = (result + x*sum_a) % m

if(result < 0):
    result += m
print(result)
Buggy python submission (verdict: Runtime Error):
D,T, S = map(int, input().split())
if T*S>=D:
  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: Time Limit Exceeded):
a=int(input())
b = list(map(int, input().split()))
b.sort()
S=0

for i in range(0,a):
    S=S+b[i]*sum(b[i+1:a])
print(S % (10**9+7))

Fixed submission:
a=int(input())
b = list(map(int, input().split()))
b.sort()
S=0
c=sum(b)
for i in range(0,a):
    c=c-b[i]
    S=S+b[i]*c
print(S % (10**9+7))

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

for i in range(0,a):
    for j in range(i+1,a):
        S=S+b[i]*b[j]
print(S % (10**9+7))

Fixed submission:
a=int(input())
b = list(map(int, input().split()))
b.sort()
S=0
c=sum(b)
for i in range(0,a):
    c=c-b[i]
    S=S+b[i]*c
print(S % (10**9+7))
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
ttl=0
if x>3 and y>3:
  #do nothing
else:
  for i in range(1,4):
    ttl=(4-i)*100000
    for j in range(1,4):
    	ttl=ttl+(4-j)*100000
        break
  if ttl==600000:
    ttl=ttl+400000
print(ttl)

Fixed submission:
x,y=map(int,input().split())

ttl=0
if(x>3 and y>3):
  ttl=0
else:
  for i in range(1,4):
    if i==x:
        ttl=(4-i)*100000
        break
  for j in range(1,4):
    if j==y:
        ttl=ttl+(4-j)*100000
        break
  if ttl==600000:
    ttl=ttl+400000
print(ttl)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
if N%2==1:
  print('No')
else:
  h_N=int(N/2)
  flg=True
  for i in range(h_N):
    if S[i]!=S[h_N+i]:
      flg=False
  if flg=True:
    print('Yes')
  else:
    print('No')

Fixed submission:
N=int(input())
S=str(input())
if N%2==1:
  print('No')
else:
  f=True
  h=int(N/2)
  for i in range(0,h):
    if S[i]!=S[h+i]:
      f=False
  if f==True:
    print('Yes')
  else:
    print('No')

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

if n % 2 == 1:
    print('No')
else:
    flg=True
    for i in range(int(n/2)):
        if S[i]!=S[int(n/2)+i]:
            flg=False
    if flg==True:
        print('Yes')
    else:
        print('No'):
  

Fixed submission:
N=int(input())
S=str(input())
if N%2==1:
  print('No')
else:
  f=True
  h=int(N/2)
  for i in range(0,h):
    if S[i]!=S[h+i]:
      f=False
  if f==True:
    print('Yes')
  else:
    print('No')