Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ll = np.ones(1)
for i in range(99):
    ll = np.append(ll,int(i+1))
    
for j in p:
    ll= ll[~(ll == j)]

# print(ll)

a = np.zeros(len(ll))
for i in range(len(ll)):
    a[i]=abs(x-ll[i])
# print(ll)
print(int(ll[np.argmin(a)]))


Fixed submission:
import numpy as np
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ll = np.ones(1)*(-1)
for i in range(102):
    ll = np.append(ll,int(i))
    
for j in p:
    ll= ll[~(ll == j)]

if len(ll) == 0:
    print(x)
    exit()
# print(ll)

a = np.zeros(len(ll))
for i in range(len(ll)):
    a[i]=abs(x-ll[i])
# print(ll)
print(int(ll[np.argmin(a)]))
Buggy python submission (verdict: Time Limit Exceeded):
t = input()
ans = 0
for i in range(len(t)):
    if t[i]=='P':
        if i+1 < len(t) and t[i+1]=='?':
            # t[i+1] = 'D'
            t = t[:i+1] + 'D' + t[i+2:]
            ans += 1
            # print('a')
        else:
            ans += 1
            # print('b')
        
    
    elif t[i]=='?':
        if i+1 < len(t)  and (t[i+1]=='D' or t[i+1]=='?'):
            # t[i] = 'P'
            t = t[:i] + 'P' + t[i+1:]
            ans += 1
            # print('c')
        else:
            # t[i] = 'D'
            t = t[:i] + 'D' + t[i+1:]
            ans += 1
            # print('d')

    elif t[i]=='D':
        ans += 1
        # print('e')

print(t)
# print(ans)

Fixed submission:
t = input()
ans = 0
t = list(t)
for i in range(len(t)):
    if t[i]=='P':
        if i+1 < len(t) and t[i+1]=='?':
            t[i+1] = 'D'
            # t = t[:i+1] + 'D' + t[i+2:]
            ans += 1
            # print('a')
        else:
            ans += 1
            # print('b')
        
    
    elif t[i]=='?':
        if i+1 < len(t) and i > 0 and t[i-1] == 'P' and (t[i+1]=='D' or t[i+1]=='?'):
            t[i] = 'D'
            ans += 1
            # print('f')
        elif i+1 < len(t)  and (t[i+1]=='D' or t[i+1]=='?'):
            t[i] = 'P'
            # t = t[:i] + 'P' + t[i+1:]
            ans += 1
            # print('c')
        else:
            t[i] = 'D'
            # t = t[:i] + 'D' + t[i+1:]
            ans += 1
            # print('d')

    elif t[i]=='D':
        ans += 1
        # print('e')
p = ''
for i in t:
    p += i
print(p)
# print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
import numpy as np
link = set()
next = a[0]
link.add(1)
while next not in link:
    link.add(next)
    next = a[next-1]
# print(next)
# print(list)

link2 = set()
next2 = a[0]
link2.add(1)
while next not in link2:
    link2.add(next2)
    next2 = a[next2-1]

ans = 0
rep = len(link)+1-len(link2)
# print(rep)
if(k > len(link2)-1):
    p = (k-len(link2)+2)%rep
    # print(p)

    # print(next)
    for i in range(len(link)-1):
        next = a[next]
else:
    for i in range(k):
        next = a[0]

ans = next
print(ans)

# for i in range(p):


Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
import numpy as np
link = set()
next = a[0]
link.add(1)
while next not in link:
    link.add(next)
    next = a[next-1]

# print(next)
link2 = set()
next2 = a[0]
link2.add(1)
while next not in link2:
    link2.add(next2)
    next2 = a[next2-1]

link2.remove(next)
ans = 0

rep = len(link) - len(link2)
# print(rep)
if (len(link2) == 0):
    p = k%rep
    # print('e')
    for i in range(p+rep):
        next = a[next-1]
elif(k > len(link2)):
    # print('f')
    p = (k-len(link2))%rep
    # print(p)
    # print(next)
    for i in range(p+rep):
        next = a[next-1]
else:
    # print('d')
    next = a[0]
    for i in range(k-1):
        next = a[next-1]
# print(next)
ans = next
# print(link,link2)
print(ans)
Buggy python submission (verdict: Runtime Error):
a = list(input())
if (a[2] == a[3]) & (a[4] == a[5]):
    print('Yes')
else:
    print('No')

Fixed submission:
a = int(input());
b = a//500
c = a % 500 //5
print(b*1000+c*5)
Buggy python submission (verdict: Runtime Error):
c = input()

l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','y','u','v','w','y','z']
num = int(l.index(c))+1
print(l[num])

Fixed submission:
c = input()

l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','y','z']
num = int(l.index(c))+1
print(l[num])
Buggy python submission (verdict: Runtime Error):
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
f = max(b);
for i in range(a):
    if max(b) > b[i]:
        print(f);
    elif max(b) == b[i]:
        d = copy.copy(b);
        del d[i]
        e = max(d);
        print(e);


Fixed submission:
import sys
r = int(input());
ans = 3*r*r;
print(ans);
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
first = max(b);
g = b.copy();
h = g.index(first);
del g[h];
second = max(g);

for i in range(a):
    if max(b) > b[i]:
        print(first);
    elif first == b[i]:
        print(second);

Fixed submission:
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
first = max(b);
g = b.copy();
h = g.index(first);
del g[h];
second = max(g);

for i in range(a):
    if first > b[i]:
        print(first);
    elif first == b[i]:
        print(second);

Buggy python submission (verdict: Runtime Error):
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
first = max(b);
g = b.copy();
h = list(g.index(first));
del g[h];
second = max(g);

for i in range(a):
    if max(b) > b[i]:
        print(first);
    elif first == b[i]:
        print(second);


Fixed submission:
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
first = max(b);
g = b.copy();
h = g.index(first);
del g[h];
second = max(g);

for i in range(a):
    if first > b[i]:
        print(first);
    elif first == b[i]:
        print(second);

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
f = max(b);
for i in range(a):
    if max(b) > b[i]:
        print(f);
    elif max(b) == b[i]:
        d = copy.copy(b);
        del d[i]
        e = max(d);
        print(e);


Fixed submission:
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
first = max(b);
g = b.copy();
h = g.index(first);
del g[h];
second = max(g);

for i in range(a):
    if first > b[i]:
        print(first);
    elif first == b[i]:
        print(second);

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
for i in range(a):
    if max(b) > b[i]:
        print(max(b));
    elif max(b) == b[i]:
        d = copy.copy(b);
        del d[i]
        e = max(d);
        print(e);


Fixed submission:
import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
first = max(b);
g = b.copy();
h = g.index(first);
del g[h];
second = max(g);

for i in range(a):
    if first > b[i]:
        print(first);
    elif first == b[i]:
        print(second);
Buggy python submission (verdict: Runtime Error):
s1 = input()
t1 = input()

s = list(s1)
t = list(t1)

flag = 0
for i in range(len(s)):
    for j in range(len(s)):
        if s[i] == s[j]:
            if t[i] == t[j]:
                a = 1
            else:
                print("No")
                flag = 1
                break
        if flag == 1:
            break

        if t[i] == t[j]:
            if s[i] == s[j]:
                a = 1
            else:
                print("No")
                flag = 1
                break
        if flag == 1:
            break
    if flag == 1:
        break
if flag == 0:
    print("Yes")


Fixed submission:
d = input().split()

a = int(d[0])
b = int(d[1])
c = int(d[2])

e = 0

e = a*10+b+c

if e < b*10+a+c:
    e = b*10+a+c
    if e < c*10+a+b:
        e = c*10+a+b

if e < c*10+a+b:
    e= c*10+a+b
    if e < b*10+a+c:
        e = b*10+a+c

print(e)

Buggy python submission (verdict: Runtime Error):
d = input().split()

a = int(d[0])
b = int(d[1])
c = int(d[2])

int e = 0

e = a*10+b+c

if e < b*10+a+c:
    e = b*10+a+c
    if e < c*10+a+b:
        e = c*10+a+b

if e < c*10+a+b:
    e= c*10+a+b
    if e < b*10+a+c:
        e = b*10+a+c

print(e)


Fixed submission:
d = input().split()

a = int(d[0])
b = int(d[1])
c = int(d[2])

e = 0

e = a*10+b+c

if e < b*10+a+c:
    e = b*10+a+c
    if e < c*10+a+b:
        e = c*10+a+b

if e < c*10+a+b:
    e= c*10+a+b
    if e < b*10+a+c:
        e = b*10+a+c

print(e)
Buggy python submission (verdict: Runtime Error):
i = int(input())
ii = input().split()

a = int(0)
n = int(0)
m = int(0)
k = int(0)
for n in ii:
    a = int(n)
    for m in range(i):
      while (a % 1 == 0):
        a = a/2
        if (a % 1 == 0):
            k += 1

print(k)

Fixed submission:
c = input().split()

a = int(c[0])
b = int(c[1])

if a > 8:
    print(':(')

elif b > 8:
    print(':(')

elif a+b > 16:
    print(":(")

else:
    print("Yay!")

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

a = input()
b = input()

a = int(a)
b = int(b)
if a > 8:
    print(':(')

elif b > 8:
    print(':(')

elif a+b > 16:
    print(":(")

else:
    print("Yay!")


Fixed submission:
c = input().split()

a = int(c[0])
b = int(c[1])

if a > 8:
    print(':(')

elif b > 8:
    print(':(')

elif a+b > 16:
    print(":(")

else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                               
def I(): return list(map(int,inp().split()))
from collections import Counter
from numpy import prod

n=I()[0]
s=input() 
cut=0
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if 2*j-i>=len(s): break
        if len({s[i],s[j],s[2*j-i]})==3:
            cut+=1
d=Counter(s)
print(prod(list(d.values()))-cut)


            

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                               
def I(): return list(map(int,inp().split()))
from collections import Counter
from numpy import prod

n=I()[0]
s=input() 
cut=0
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if 2*j-i>=len(s): break
        if len({s[i],s[j],s[2*j-i]})==3:
            cut+=1
d=Counter(s)
if len(d)<3: print(0)
else: print(prod(list(d.values()))-cut)

Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                               
def I(): return list(map(int,inp().split()))
from collections import Counter
from numpy import prod

n,=I()
s=input() 
cut=0
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if 2*j-i>=len(s): break
        if len({s[i],s[j],s[2*j-i]})==3:
            cut+=1
d=Counter(s)
print(prod(list(d.values()))-cut)


            
                
        

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                               
def I(): return list(map(int,inp().split()))
from collections import Counter
from numpy import prod

n=I()[0]
s=input() 
cut=0
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if 2*j-i>=len(s): break
        if len({s[i],s[j],s[2*j-i]})==3:
            cut+=1
d=Counter(s)
if len(d)<3: print(0)
else: print(prod(list(d.values()))-cut)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
s=[i for i in input()]
for _ in range(int(input())):
    a=list(map(str,input().split()))
    if len(a)==1:
        s.reverse()
    else:
        if a[1]=='1': s.insert(0,a[2])
        else: s.append(a[2])
print(''.join(s))
            
        
        

Fixed submission:
s=[i for i in input()]
x=0 ; st=[[],[]]
for _ in range(int(input())):
    inp=list(map(str,input().split()))
    if len(inp)==1: x^=1
    else: st[(int(inp[1])-1)^x].append(inp[2])
if x==0:
    st[0].reverse()
    ans=st[0]+s+st[1]
elif x==1:
    st[1].reverse()
    s.reverse()
    ans=st[1]+s+st[0]
print(''.join(ans))
Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
c1=a*a*b/2
if x=a*a*b:
    print(0.0)
    exit(0)
if x>c1:
    ans=math.atan((a*a*a)/((2*a*a*b)-(2*x)))
    ans=math.degrees(ans)
    print(90-ans)
else:
    ans=math.atan((2*x)/(a*b*b))
    ans=math.degrees(ans)
    print(90-ans)
    

Fixed submission:
import math
a,b,x=map(int,input().split())
c1=a*a*b/2
if x==a*a*b:
    print(0.0)
    exit(0)
if x>c1:
    ans=math.atan((a*a*a)/((2*a*a*b)-(2*x)))
    ans=math.degrees(ans)
    print(90-ans)
else:
    ans=math.atan((2*x)/(a*b*b))
    ans=math.degrees(ans)
    print(90-ans)

Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
c1=a*a*b/2
if x=a*a*b:
    print(0.0)
if x>c1:
    ans=math.atan((a*a*a)/((2*a*a*b)-(2*x)))
    ans=math.degrees(ans)
    print(90-ans)
else:
    ans=math.atan((2*x)/(a*b*b))
    ans=math.degrees(ans)
    print(90-ans)
    

Fixed submission:
import math
a,b,x=map(int,input().split())
c1=a*a*b/2
if x==a*a*b:
    print(0.0)
    exit(0)
if x>c1:
    ans=math.atan((a*a*a)/((2*a*a*b)-(2*x)))
    ans=math.degrees(ans)
    print(90-ans)
else:
    ans=math.atan((2*x)/(a*b*b))
    ans=math.degrees(ans)
    print(90-ans)

Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
c1=a*a*b/2
if x>c1:
    ans=math.atan((a*a*a)/((2*a*a*b)-(2*x)))
    ans=math.degrees(ans)
    print(90-ans)
else:
    ans=math.atan((2*x)/(a*b*b))
    ans=math.degrees(ans)
    print(90-ans)
    

Fixed submission:
import math
a,b,x=map(int,input().split())
c1=a*a*b/2
if x==a*a*b:
    print(0.0)
    exit(0)
if x>c1:
    ans=math.atan((a*a*a)/((2*a*a*b)-(2*x)))
    ans=math.degrees(ans)
    print(90-ans)
else:
    ans=math.atan((2*x)/(a*b*b))
    ans=math.degrees(ans)
    print(90-ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
n1=n
s=0
for i in range(n-2):
    n1=n
    for j in range(i+1,n1-1):
        for k in range(j+1,n1):
            if a[j]+a[k]>a[i]:
                s+=1
            else:
                n1=k
                break
print(s)
            
        

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
l=len(a)
ans=0
for i in range(l-2):
    e=l-1
    for j in range(i+1,l-1):
        if e<=j:
            break
        while a[i]-a[j]>=a[e] and e>j:
            ans+=(e-j)
            e-=1
ans=(n*(n-1)*(n-2))//6-ans
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
s=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if a[j]+a[k]>a[i]:
                s+=1
            else:
                break
print(s)
        

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
l=len(a)
ans=0
for i in range(l-2):
    e=l-1
    for j in range(i+1,l-1):
        if e<=j:
            break
        while a[i]-a[j]>=a[e] and e>j:
            ans+=(e-j)
            e-=1
ans=(n*(n-1)*(n-2))//6-ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
n,q=map(int,input().split())
g=[deque([]) for i in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
add=[0]*n
for _ in range(q):
    a,b=map(int,input().split())
    add[a-1]+=b
st=set()  ; ans=[0]*n ; stack=[[0,add[0]]]
while stack:
    s=stack[-1]
    if s[0] not in st : 
        st.add(s[0])
        ans[s[0]]+=s[1]
    if not g[s[0]] : 
        stack.pop()
        continue
    while g[s[0]]:
        if g[s[0]][0] in st:
            g[s[0]].popleft()
        else:
            stack.append([g[s[0]][0],s[1]+add[g[s[0]][0]]])
            break
print(*ans)
        
      

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
n,q=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
add=[0]*n
for _ in range(q):
    a,b=map(int,input().split())
    add[a-1]+=b
st=set() ; v=0 ; s=add[0]
ans=[0]*n
def dfs(g,v,s):
    global ans,st
    if v not in st:
        st.add(v)
        ans[v]+=s
    else: return
    for p in g[v]:
        dfs(g,p,s+add[p])
dfs(g,v,s)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
n,q=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
add=[0]*n
for _ in range(q):
    a,b=map(int,input().split())
    add[a-1]+=b
st=set() ; v=0 ; s=add[0]
ans=[0]*n
def dfs(g,v,s):
    global ans,st
    if v not in st:
        st.add(v)
        ans[v]+=s
    else: return
    for p in g[v]:
        dfs(g,p,s+add[p])
dfs(g,v,s)
print(*ans)
        
        
    
    

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
n,q=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
add=[0]*n
for _ in range(q):
    a,b=map(int,input().split())
    add[a-1]+=b
st=set() ; v=0 ; s=add[0]
ans=[0]*n
def dfs(g,v,s):
    global ans,st
    if v not in st:
        st.add(v)
        ans[v]+=s
    else: return
    for p in g[v]:
        dfs(g,p,s+add[p])
dfs(g,v,s)
print(*ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
a,b,c,d=map(int,input().split())
ans=(b-a+1)
lcm=(c*d)//gcd(c,d)
dba=(a//c-int(a%c==0))+(a//d-int(a%d==0))-(a//lcm-int(a%lcm==0))
dbb=(b//c)+(b//d)-(b//lcm)
dbb-=dba
ans-=dbb
print(ans)
        
        

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
ans=(b-a+1)
lcm=(c*d)//gcd(c,d)
dba=(a//c-int(a%c==0))+(a//d-int(a%d==0))-(a//lcm-int(a%lcm==0))
dbb=(b//c)+(b//d)-(b//lcm)
dbb-=dba
ans-=dbb
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
from math import gcd
a,b,c,d=map(int,input().split())
ans=(b-a+1)
lcm=(c*d)//gcd(c,d)
dba=(a//c-int(a%c==0))+(a//d-int(a%d==0))-(a//lcm-int(a%lcm==0))
dbb=(b//c)+(b//d)-(b//lcm)
dbb-=dba
ans-=dbb
print(ans)
        
        

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
ans=(b-a+1)
lcm=(c*d)//gcd(c,d)
dba=(a//c-int(a%c==0))+(a//d-int(a%d==0))-(a//lcm-int(a%lcm==0))
dbb=(b//c)+(b//d)-(b//lcm)
dbb-=dba
ans-=dbb
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
from math import gcd
a,b,c,d=map(int,input().split())
ans=(b-a+1)
lcm=(c*d)//gcd(c,d)
dba=(a//c-int(a%c==0))+(a//d-int(a%d==0))-(a//lcm-int(a%lcm==0))
dbb=(b//c)+(b//d)-(b//lcm)
dbb-=dba
ans-=dbb
print(ans)
            
        
        
        

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
ans=(b-a+1)
lcm=(c*d)//gcd(c,d)
dba=(a//c-int(a%c==0))+(a//d-int(a%d==0))-(a//lcm-int(a%lcm==0))
dbb=(b//c)+(b//d)-(b//lcm)
dbb-=dba
ans-=dbb
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
k=2
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    mini=math.inf
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+b[j]
        mini=min(mini,x)
    b[i]=mini
print(b[0])

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    b[i]=min(abs(a[i]-a[i+1])+b[i+1],abs(a[i]-a[i+2])+b[i+2])
print(b[0])
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
k=2
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    c=[]
    for j in range(i+1,min(n,i+k+1)):
        c.append(abs(a[j]-a[i])+b[j])
    b[i]=min(c)
print(b[0])

Fixed submission:
import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    c=[]
    for j in range(i+1,min(n,i+k+1)):
        c.append(abs(a[j]-a[i])+b[j])
    b[i]=min(c)
print(b[0])

Buggy python submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    mini=math.inf
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+b[j]
        mini=min(mini,x)
    b[i]=mini
print(b[0])

Fixed submission:
import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    c=[]
    for j in range(i+1,min(n,i+k+1)):
        c.append(abs(a[j]-a[i])+b[j])
    b[i]=min(c)
print(b[0])

Buggy python submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    mini=math.inf
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+(b[j] if j<n-1 else b[n-1])
        mini=min(mini,x)
    b[i]=mini
print(b[0])

Fixed submission:
import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    c=[]
    for j in range(i+1,min(n,i+k+1)):
        c.append(abs(a[j]-a[i])+b[j])
    b[i]=min(c)
print(b[0])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/local/bin/python3.5 -tt

import random
import sys

if __name__ == '__main__':
    def _(f):
        for l in f:
            for i in l.split():
                yield(int(i))

    g = _(sys.stdin)

    N = next(g)

    S = 1

    for i in range(N):
        A = next(g)

        S *= A

    if S <= 10 ** 18:
        print(S)
    else:
        print(-1)


Fixed submission:
#!/usr/local/bin/python3.5 -tt

import random
import sys

if __name__ == '__main__':
    def _(f):
        for l in f:
            for i in l.split():
                yield(int(i))

    g = _(sys.stdin)

    N = next(g)

    a = []

    for i in range(N):
        a.append(next(g))

    a.sort()

    S = 1

    for i in a:
        S *= i

        if S == 0:
            print(0)
            sys.exit(0)
        elif S > 10 ** 18:
            print(-1)
            sys.exit(0)

    print(S)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
Amin = min(A)
Amax = max(A)
print(abs(Amax-Amin))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Amin = min(A)
Amax = max(A)
print(abs(Amax-Amin))
Buggy python submission (verdict: Runtime Error):
A, B = map(int(input()))
print(max(A+B, A-B, A*B))

Fixed submission:
A, B = map(int, input().split())
print(max(A+B, A-B, A*B))
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
lw = A+B 
rw = C+D 
if lw > rw:
    print(Left)
elif lw < rw:
    print(Right)
else:
    print(Balanced)

Fixed submission:
A, B, C, D = map(int, input().split())
lw = A+B 
rw = C+D 
if lw > rw:
    print('Left')
elif lw < rw:
    print('Right')
else:
    print('Balanced')
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
if a = 'H' and b ='H':
    print('H')
elif a = 'H' and b ='D':
    print('D')
elif a = 'D' and b = 'H':
    print('D')
elif a = 'D' and b = 'D':
    print('H')

Fixed submission:
a, b = input().split()
if a == 'H' and b =='H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')