Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int  input().split())

if a <= c and c <= b:
    print("Yes")
else:
    print("No")


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

if a <= c and c <= b:
    print("Yes")
else:
    print("No")

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

if a <= c amd c <= b:
    print("Yes")
else:
    print("No")

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

if a <= c and c <= b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n  k = map(int, input().split())
ab = [[map(int, input().split())] for _ in range(n)]

count = 0
for x in ab:
    count += x[1]
    if k <= count:
        print(x[0])
        break


Fixed submission:
n, k = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(n)])

count = 0
for x in ab:
    count += x[1]
    if k <= count:
        print(x[0])
        break
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()

if a[-1] == b[1] and b[-1] == c[1]:
    print("YES")
else:
    print("NO")

Fixed submission:
a, b, c = input().split()

if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if abs(x-y) <= 1:
    print("Alice")
else:
    print("Brown")

Fixed submission:
a, b, c = input().split()

A = a.upper()
B = b.upper()
C = c.upper()

print(A[0]+B[0]+C[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 1
pre = a[0]
increase = True
if a[1] < a[0]:
    increase = False

for i in range(1, n):
    if a[i] < pre:
        if increase:
            ans += 1
            increase = not increase
    elif a[i] > pre:
        if not increase:
            ans += 1
            increase = not increase
    pre = a[i]
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
inc = False
dec = False
ans = 1

for i in range(n-1):
    if a[i+1] > a[i]:
        if dec:
            ans += 1
            dec = False
        else:
            inc = True
    elif a[i+1] < a[i]:
        if inc:
            ans += 1
            inc = False
        else:
            dec = True

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
if n == 1:
    print(1)
    exit()
else:
    for i in range(1, n+1):
        ans *= i

print(ans%(10**9+7))

Fixed submission:
import math

n = int(input())

print(int(math.factorial(n)) % (10**9+7))
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):
        test = s-x-y
        if 0 <= test and test <= k:
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

while s != "":
    for i in range(n):
        if i == n-1:
            print(n)
            exit()
        if s[i]+s[i+1] == "ST":
            s = s[:i] + s[i+2:]
            n = len(s)
            break

print(0)

Fixed submission:
s = input()
array = []

for char in s:
    if char == "S":
        array.append(char)
    elif char == "T":
        if len(array) == 0:
            array.append(char)
        elif array[-1] == "S":
            array.pop()
        else:
            array.append(char)
print(len(array))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
stack = [1]*n
p = [False]*n
p[0] = True

for i in range(m):
    x, y = map(int, input().split())
    stack[x-1] -= 1
    stack[y-1] += 1
    p[y-1] = p[x-1] or p[y-1]
    if stack[0] == 0:
        p[0] = False

for i in p:
    if i:
        ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
stack = [1]*n
p = [False]*n
p[0] = True

for i in range(m):
    x, y = map(int, input().split())
    stack[x-1] -= 1
    stack[y-1] += 1
    p[y-1] = p[x-1] or p[y-1]
    if stack[x-1] == 0:
        p[x-1] = False

ans = 0
for i in p:
    if i:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
stack = [1]*n
p = [1]

for i in range(m):
    x, y = map(int, input().split())
    stack[x-1] -= 1
    stack[y-1] += 1
    if x in p:
        p.append(y)
    if p[0] == 1:
        p.remove(1)

ps = list(set(p))
ans = 0
for i in ps:
    if stack[i-1] != 0:
        ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
stack = [1]*n
p = [False]*n
p[0] = True

for i in range(m):
    x, y = map(int, input().split())
    stack[x-1] -= 1
    stack[y-1] += 1
    p[y-1] = p[x-1] or p[y-1]
    if stack[x-1] == 0:
        p[x-1] = False

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

Fixed submission:
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
cnt = Counter(a)
for i in range(1, n+1):
    print(cnt[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
r, g, b = map(s.count, "RGB")
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k<n and len(set([s[i], s[j], s[k]])) == 3:
            ans -= 1
print(ans)

Fixed submission:
if "7" in str(input()):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
if "7" in str(input()):
  print("Yes")
else:
  print("No)

Fixed submission:
if "7" in str(input()):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
a = []
for s in range(1, n): #start
    for g in range(s+1, n+1): #goal
        a.append(min(g-s, abs(x-s)+1+abs(g-y), abs(y-s)+1+abs(g-x)))

#print(a)
for i in range(1, n):
    print(a.count(i))

Fixed submission:
n, x, y = map(int, input().split())
a = [0 for i in range(n)]
for s in range(1, n): #start
    for g in range(s+1, n+1): #goal
        a[min(g-s, abs(x-s)+1+abs(g-y), abs(y-s)+1+abs(g-x))] += 1

#print(a)
for i in range(1, n):
    print(a[i])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

inf = 10**5
dp = [inf for i in range(n)]
dp[0] = 0

for i in range(1, n):
    tmp = []
    for j in range(i-k, i):
        if j >= 0:
            tmp.append(dp[j] + abs(h[j] - h[i]))
    dp[i] = min(tmp)

print(dp[-1])

Fixed submission:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

inf = 10**5
dp = [inf for i in range(n)]
dp[0] = 0

for i in range(1, n):
    tmp = []
    for j in range(i-k, i):
        if j >= 0:
            tmp.append(dp[j] + abs(h[j] - h[i]))
    dp[i] = min(tmp)

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

inf = 10**5
dp = [inf for i in range(n)]
dp[0] = 0

for i in range(1, n):
    tmp = []
    for j in range(i-k, i):
        tmp.append(dp[j] + abs(h[j] - h[i]))
    dp[i] = min(tmp)
    
print(dp[-1])

Fixed submission:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

inf = 10**5
dp = [inf for i in range(n)]
dp[0] = 0

for i in range(1, n):
    tmp = []
    for j in range(i-k, i):
        if j >= 0:
            tmp.append(dp[j] + abs(h[j] - h[i]))
    dp[i] = min(tmp)

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
from math import ceil
n, k = map(int,input().split())
array = [n]
p = ceil(max(n/k,k/n))+1
n_r = 10**18
if k == 1:
    array.append(0)
else:
    for i in range(p):
        n_r = n
        n = abs(n-k)
        array.append(n)
        if n > n_r:
            break
min_n = min(array)
print(min_n)

Fixed submission:
n, k = map(int, input().split())
print(min(n%k, k-n%k))

Buggy python submission (verdict: Runtime Error):
from math import ceil
n, k = map(int,input().split())
array = []
p = ceil(max(n/k,k/n))+2
n_r = 0
if k == 1:
    array.append(0)
else:
    for i in range(p):
        n_r = n
        n = abs(n-k)
        array.append(n)
        if n > n_r:
            break
min_n = min(array)
print(min_n)

Fixed submission:
n, k = map(int, input().split())
print(min(n%k, k-n%k))

Buggy python submission (verdict: Runtime Error):
from math import ceil
n, k = map(int,input().split())
array = []
p = ceil(max(n/k,k/n))+2
if k == 1:
    array.append(0)
else:
    for i in range(p):
        n = abs(n-k)
        array.append(n)
min_n = min(array)
print(min_n)

Fixed submission:
n, k = map(int, input().split())
print(min(n%k, k-n%k))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
n_min = 10**18
n_min_sb = 10**19
if k == 1:
    n_min = 0
else:
    while n_min != n_min_sb:
        n = abs(n-k)
        if n_min > n:
            n_min_sb = n_min
            n_min = n
        if n_min < n:
            n_min_sb = n_min
print(n_min)

Fixed submission:
n, k = map(int, input().split())
print(min(n%k, k-n%k))
Buggy python submission (verdict: Runtime Error):
r = int(input())
pi = 3.141592653589793
print(math.pi*r*2)

Fixed submission:
import math
r = int(input())
print(r*math.pi*2)
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(b+a)

Fixed submission:
c=list(map(str, input().split()))
print(c[1]+c[0])
Buggy python submission (verdict: Time Limit Exceeded):
c=list(map(int, input().split()))

for i in range(c[2]):
  if c[0]!=0:
    c[0]-=1
  else :
    c[1]-=1
print(c[0] , c[1])

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

if c[0]>=c[2]:
  c[0]-=c[2]
else :
  c[2]-=c[0]
  c[1]-=c[2]
  c[0]=0
  if c[1]<0:
    c[1]=0
print(c[0],c[1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
Ar =list(map(str,input().split))

S = list(Ar[0])
T = list(Ar[1])

Ans_Ar = []

for i in range(N):
  Ans_Ar.append(S[i])
  Ans_Ar.append(T[i])

result = ''.join(Ans_Ar)
print(result)

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

S = list(Ar[0])
T = list(Ar[1])

Ans_Ar = []

for i in range(N):
  Ans_Ar.append(S[i])
  Ans_Ar.append(T[i])

result = ''.join(Ans_Ar)
print(result)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

rep = int(math.floor(math.log(N,5)))
r=0
for i in range(rep):
  q = 5**(i+1)
  if (N//q)%2==0:
    w = (N//q)//2
  else :
    w = ((N-1)//q)//2
  r+=w

if N%2==1:
  r=0

print(r)

Fixed submission:
import math

N = int(input())

if N==0:
  r=0
elif N%2==1:
  r=0
else:
  rep = int(math.floor(math.log(N,5)))
  r=0
  for i in range(rep):
    q = 5**(i+1)
    if (N//q)%2==0:
      w = (N//q)//2
    else :
      w = ((N-1)//q)//2
    r+=w


print(r)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

rep = int(math.floor(math.log(N,5)))
r=0
for i in range(rep):
  q = 5**(i+1)
  if (N//q)%2==0:
    w = (N//q)//2
  else :
    w = ((N-1)//q)//2
  r+=w

if N%2==1:
  r=0

print(r)

Fixed submission:
import math

N = int(input())

if N==0:
  r=0
elif N%2==1:
  r=0
else:
  rep = int(math.floor(math.log(N,5)))
  r=0
  for i in range(rep):
    q = 5**(i+1)
    if (N//q)%2==0:
      w = (N//q)//2
    else :
      w = ((N-1)//q)//2
    r+=w


print(r)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

rep = int(math.floor(math.log(N,5)))
r=0
for i in range(rep):
  q = 5**(i+1)
  w = ((N//q)+1)//2
  r+=w

if N%2==1:
  r=0

print(r)

Fixed submission:
import math

N = int(input())

if N==0:
  r=0
elif N%2==1:
  r=0
else:
  rep = int(math.floor(math.log(N,5)))
  r=0
  for i in range(rep):
    q = 5**(i+1)
    if (N//q)%2==0:
      w = (N//q)//2
    else :
      w = ((N-1)//q)//2
    r+=w


print(r)
Buggy python submission (verdict: Runtime Error):
    N = int(input())
#A = list(map(int,input().split(' ')))

    print((N+1)//2)


Fixed submission:
N = int(input())
#A = list(map(int,input().split(' ')))

print((N+1)//2)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(5000)

N,M,K = list(map(int,input().split(' ')))

friend_list = [0]*(N+1)
bad_list = [0]*(N+1)
group = {}

parent = [i for i in range(N+1)]

def union(x,y):
    x = find(x)
    y = find(y)
    parent[x] = y

def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x]= find(parent[x])
        return parent[x]



for i in range(M):
    A,B = list(map(int,input().split(' ')))
    friend_list[A]+=1
    friend_list[B]+=1
    
    union(A,B)

for i in range(1,N+1):
    oya = find(i)
    parent[i] = oya
    #print(oya)
    if oya in group:
        group[oya] = group[oya]+1
    else:
        group[oya]=1

for i in range(K):
    A,B = list(map(int,input().split(' ')))
    if find(A)==find(B):
        bad_list[A]+=1
        bad_list[B]+=1
    
    #union(A,B)



#print(parent)
#print('parent')

#print('friend')
#print(friend_list)
#print('bad')
#print(bad_list) 
#print(group)

kouho = [0]*N

for i in range(1,N+1):
    oya = find(i)
    abc = group[oya]-friend_list[i]-bad_list[i]-1
    kouho[i-1] = abc

for k in kouho:
    print(k,end=" ")
print()

#print(parent)

Fixed submission:
N = int(input())
#A = list(map(int,input().split(' ')))

print((N+1)//2)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(5000)

N,M,K = list(map(int,input().split(' ')))

friend_list = [0]*(N+1)
bad_list = [0]*(N+1)
group = {}

parent = [i for i in range(N+1)]

def union(x,y):
    x = find(x)
    y = find(y)
    parent[x] = y

def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x]= find(parent[x])
        return parent[x]



for i in range(M):
    A,B = list(map(int,input().split(' ')))
    friend_list[A]+=1
    friend_list[B]+=1
    
    union(A,B)

for i in range(1,N+1):
    oya = find(i)
    parent[i] = oya
    #print(oya)
    if oya in group:
        group[oya] = group[oya]+1
    else:
        group[oya]=1

for i in range(K):
    A,B = list(map(int,input().split(' ')))
    if find(A)==find(B):
        bad_list[A]+=1
        bad_list[B]+=1
    
    #union(A,B)



#print(parent)
#print('parent')

#print('friend')
#print(friend_list)
#print('bad')
#print(bad_list) 
#print(group)

kouho = [0]*N

for i in range(1,N+1):
    oya = find(i)
    abc = group[oya]-friend_list[i]-bad_list[i]-1
    kouho[i-1] = abc

for k in kouho:
    print(k,end=" ")
print()

#print(parent)

Fixed submission:
N = int(input())
#A = list(map(int,input().split(' ')))

print((N+1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N ,a,b= list(map(int,input().split(' ')))


M = 10**9+7

def pow(x,n):
    if n==0:
        return 1
    res = pow((x*x)%M,n//2)
    if (n%2)==1:
        res = (res*x)%M
    return res


def power(x,n):
    res = 1
    if(n>0):
        res = power(x,n//2)
        if (n%2)==0:
            res = (res*res)%M
        else:
            res = (((res*res)%M)*x)%M
    return res

def comb(n,a):
    ans = 1
    for i in range(a):
        ans = (ans*(n-i))%M
        ans = (ans*power(i+1,M-2))%M 
    return ans

#print(pow(10,2))
#print(power(5,8))

print((power(2,N)-1-comb(N,a)-comb(N,b))%M)

Fixed submission:
N ,a,b= list(map(int,input().split(' ')))


M = 10**9+7

def pow(x,n):
    if n==0:
        return 1
    res = pow((x*x)%M,n//2)
    if (n%2)==1:
        res = (res*x)%M
    return res


def power(x,n):
    res = 1
    if(n>0):
        res = power(x,n//2)
        if (n%2)==0:
            res = (res*res)%M
        else:
            res = (((res*res)%M)*x)%M
    return res

def comb(n,a):
    ans = 1
    for i in range(a):
        ans = (ans*(n-i))%M
        ans = (ans*power(i+1,M-2))%M 
    return ans

#print(pow(10,2))
#print(power(5,8))

print((power(2,N)-1-comb(N,a)-comb(N,b))%M)
Buggy python submission (verdict: Runtime Error):
S,T = input().split(' ')
A,B = list(map(int,input().split(' ')))
U = input()

if U == S:
    A = A-1
else:
    B=B-1

print(f'{A} {B}')

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

if U == S:
    A = A-1
else:
    B=B-1

print(str(A)+' '+str(B))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
#n = 4
#p = [4,3,2,1]

count = 0
for i in range(n):
  for j in range(i):
    if p[i] > p[j]:
      break
  else:
    count+=1
    continue
print(count)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
#n = 5
#p = [4,2,5,1,3]

count = 0
temp_min = p[0]
for i in range(n):
  if temp_min >= p[i]:
        count+=1
        temp_min = p[i]
print(count)

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


count = 0
for i in range(n):
  for j in range(i):
    if p[i] > p[j]:
      break
  else:
    count+=1
    continue
print(count)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
#n = 5
#p = [4,2,5,1,3]

count = 0
temp_min = p[0]
for i in range(n):
  if temp_min >= p[i]:
        count+=1
        temp_min = p[i]
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(n):
  for j in range(i):
    if p[i] > p[j]:
      break
  else:
    count+
    continue
print(count)
    

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
#n = 5
#p = [4,2,5,1,3]

count = 0
temp_min = p[0]
for i in range(n):
  if temp_min >= p[i]:
        count+=1
        temp_min = p[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0

def get_first(num):
    k=num
    while True:
        if k < 10:
            break
        k = k//10
    return k

for A in range(1,n+1):
    for B in range(1,n+1):
        A1 = get_first(A)
        B1 = get_first(B)
        A2 = A%10
        B2 = B%10
        if A1==B2 and A2==B1:
            count+=1
print(count)

Fixed submission:
n = int(input())
b=[[0]*9 for i in range(9)]
count = 0

def get_first(num):
    log = 1
    k=num
    while True:
        if k < 10:
            break
        k = k//10
        log+=1
    #print(k,log)
    return (k,log)

for i in range(1,n+1):
    f,_ = get_first(i)
    l   = i%10
    if l==0:
        continue
    b[f-1][l-1] +=1
#print(b)

for i in range(9):
    for j in range(9):
        count+=b[i][j]*b[j][i]


print(count)
Buggy python submission (verdict: Runtime Error):
    n=int(input())
    a = list(map(int,input().split()))
    even=[el for el in a if el % 2==0]
    try:
      for a in even:
        if a % 3 == 0 or a % 5 == 0:
          flg = 1
        else:
          raise
    except:
      print('DENIED')
    else:
      print('APPROVED')

Fixed submission:
n=int(input())
a = list(map(int,input().split()))
even=[el for el in a if el % 2==0]
try:
  for a in even:
    if a % 3 == 0 or a % 5 == 0:
      flg = 1
    else:
      raise
except:
  print('DENIED')
else:
  print('APPROVED')
Buggy python submission (verdict: Runtime Error):
a=input()
print(24+a)

Fixed submission:
a=int(input())
print(int(24+(24-a)))

Buggy python submission (verdict: Runtime Error):
m = input()
print(48 - m)

Fixed submission:
m = int(input())
print(48 - m)
Buggy python submission (verdict: Runtime Error):
import pandas as pd
N = int(input())
DF = []
for i in range(N):
    S1, SP = input().split()
    DF = DF + [[i+1, S1, int(SP)]]
DF1 = sorted(DF, key=lambda x:x[2], reverse=True)
DF2 = sorted(DF1, key=lambda x:x[1], reverse=False)
for i in range(N):
    print(DF2[i][0])

Fixed submission:
N = int(input())
DF = []
for i in range(N):
    S1, SP = input().split()
    DF = DF + [[i+1, S1, int(SP)]]
DF1 = sorted(DF, key=lambda x:x[2], reverse=True)
DF2 = sorted(DF1, key=lambda x:x[1], reverse=False)
for i in range(N):
    print(DF2[i][0])

Buggy python submission (verdict: Runtime Error):
import pandas as pd
N = int(input())
S = []
P = []
for i in range(N):
    S1, SP = input().split()
    S = S + [S1]
    P = P + [int(SP)]
df = pd.DataFrame({'city': S, 'point': P})
df = df.sort_values(by=['point'], ascending=False)
df = df.sort_values(by=['city'], ascending=True)
for x in df.index:
    print(x+1)

Fixed submission:
N = int(input())
DF = []
for i in range(N):
    S1, SP = input().split()
    DF = DF + [[i+1, S1, int(SP)]]
DF1 = sorted(DF, key=lambda x:x[2], reverse=True)
DF2 = sorted(DF1, key=lambda x:x[1], reverse=False)
for i in range(N):
    print(DF2[i][0])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
X = np.ones((N))
for i in range(M):
    Y = np.zeros((N))
    L, R = map(int, input().split())
    Y[L-1:R]=1
    X=X*Y
print(np.sum(X, dtype=np.int64))

Fixed submission:
import numpy as np
N, M = map(int, input().split())
LL, RR = map(int, input().split())
for i in range(M-1):
    L, R = map(int, input().split())
    LL = max(L, LL)
    RR = min(R, RR)
print(max(RR-LL+1,0))
Buggy python submission (verdict: Runtime Error):
n = int(input())
wt = list(map(int, input().split()))
PN = 1
s = 0
rev = [1 / (i + 1) for i in range(n)]
for i in range(n):
    PN = (PN * (i+1)) % (10 ** 9 + 7)
    pij = 0
    pij = sum(rev[0:n-i]) + sum(rev[1:i+1])
    s += pij * wt[i]
    #print(pij)
print(round(PN*s) % (10 ** 9 + 7))

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
n, m = map(int, input().split())
S = input()
T = input()
jn = 0
jm = 0
l = lcm(n,m)
ln = l // n
lm = l // m
d = lcm(ln, lm)
for i in range(0, l, d):
    if S[i // ln] != T[i // lm]:
        print(-1)
        exit()
print(l)

Buggy python submission (verdict: Runtime Error):
n = int(input())
wt = list(map(int, input().split()))
PN = 1
s = 0
rev = [1 / (i + 1) for i in range(n)]
for i in range(n):
    PN = (PN * (i+1)) % (10 ** 9 + 7)
    pij = 0
    pij = sum(rev[0:n-i]) + sum(rev[1:i+1])
    s += pij * wt[i]
    #print(pij)
print(round(PN*s) % (10 ** 9 + 7))

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
n, m = map(int, input().split())
S = input()
T = input()
jn = 0
jm = 0
l = lcm(n,m)
ln = l // n
lm = l // m
d = lcm(ln, lm)
for i in range(0, l, d):
    if S[i // ln] != T[i // lm]:
        print(-1)
        exit()
print(l)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = list(map(int, input().split()))
m = 0
for i in range(0,n-2):
	if lst[i] != lst[i+2]:
    	lst[i+2] = lst[i]
    	m += 1
    elif lst[i] == lst[i+1]:
		m += 1
print(m)


Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
ma = {}
mb = {}
for i in range(0, n, 2):
    lst[i] in ma
    if lst[i] in ma:
        ma[lst[i]] += 1
    else:
        ma[lst[i]] = 1
    lst[i+1] in mb
    if lst[i+1] in mb:
        mb[lst[i+1]] += 1
    else:
        mb[lst[i+1]] = 1
if max(ma, key=ma.get) != max(mb, key=mb.get):
    d = n - max(ma.values()) - max(mb.values())
else:
    ma2 = max(ma.values())
    mb2 = max(mb.values())
    ma[max(ma, key=ma.get)] = 0
    mb[max(mb, key=mb.get)] = 0
    d1 = n - ma2 - max(mb.values())
    d2 = n - max(ma.values()) - mb2
    d = min(d1, d2)
print(d)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
words = input().split()
for i in range(n-1)
    for j in range(1, i):
        if words[i] == words[j]:
                print('No')
                sys.exit()
    if words[i][-1] != words[i+1][1]:
        print('No')
        sys.exit()
print('Yes')

Fixed submission:
import sys
n = int(input())
words=[]
for i in range(n):
    words += [input()]
for i in range(n-1):
    for j in range(i+1, n):
        if words[i] == words[j]:
                print('No')
                sys.exit()
    if words[i][-1] != words[i+1][0]:
        print('No')
        sys.exit()
print('Yes')