Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m,a,b=[int(i) for i in input().split()]
l=[[0 for i in range(m)] for j in range(n)]
t1=[0 for i in range(n)]
t2=[0 for i in range(m)]

for i in range(n):
    for j in range(m):
        if t1[i]!=a and t2[j]!=b:
            t1[i]+=1
            t2[i]+=1
            l[i][j] = 0
        else:l[i][j]=1

countmin = 1000000000000
for i in range(n):
    countmin = min(countmin,l[i].count(0),l[i].count(1))
if countmin<a:
    print(-1)
    exit()
countmin = 1000000000000
for j in range(m):
    a1,a2=0,0
    for i in range(n):
        if l[i][j] == 0:a1+=1
        else:a2+=1
    countmin = min(countmin,a1,a2)
if countmin<b:
    print(-1)
    exit()
for i in range(n):
    for j in range(m):
        print(l[i][j],end="")
    print()

Fixed submission:
n,m,a,b=[int(i) for i in input().split()]
l=[[0 for i in range(m)] for j in range(n)]

for i in range(n):
    for j in range(m):
        if i<b:
            if j<a:
                l[i][j] = 0
            else:
                l[i][j] = 1
        else:
            if j<a:
                l[i][j] = 1
            else:
                l[i][j] = 0
for i in range(n):
    print("".join(str(e) for e in l[i]))
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
print(sum(1 for i in range(len(s)) if s[i] == t[i] else 0))

Fixed submission:
s=input()
t=input()
print(sum(1 for i in range(len(s)) if s[i] == t[i]))

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
print(sum(1 for i in range(len(s)) if s[i] == l[i]))

Fixed submission:
s=input()
t=input()
print(sum(1 for i in range(len(s)) if s[i] == t[i]))
Buggy python submission (verdict: Runtime Error):
import math
a,b=[int(i) for i in input().split()]
if a>=b:
	print(1)
else:
	b-=a
    print(1+math.ceil(b/(a-1)))
  

Fixed submission:
import math 
a,b=[int(i) for i in input().split()]
curr = 1
tot = 0
while curr<b:
  curr += (a-1)
  tot += 1
print(tot)
Buggy python submission (verdict: Runtime Error):
def givel(): 
    n=int(input()) 
    l=[int(i) for i in input().split()] 
    curr = 0 
    i = 0 
    while i<len(l): 
    	temp = i+1 
	    ans = 0 
		while temp<len(l) and l[temp]<=l[temp-1]: 
        	temp+=1 
	        ans+=1 
			i=temp 
		curr = max(curr,ans) 
    return curr
givel()

Fixed submission:
def givel(): 
    n=int(input()) 
    l=[int(i) for i in input().split()] 
    curr = 0 
    i = 0 
    while i<len(l): 
        temp = i+1 
        ans = 0 
        while temp<len(l) and l[temp]<=l[temp-1]: 
            temp+=1 
            ans+=1 
        i=temp 
        curr = max(curr,ans) 
    return curr
print(givel())

Buggy python submission (verdict: Runtime Error):
def givel(): 
	n=int(input()) 
    l=[int(i) for i in input().split()] 
    curr = 0 
    i = 0 
    while i<len(l): 
    	temp = i+1 
	    ans = 0 
		while temp<len(l) and l[temp]<=l[temp-1]: 
        	temp+=1 
	        ans+=1 
			i=temp 
		curr = max(curr,ans) 
    return curr
givel()

Fixed submission:
def givel(): 
    n=int(input()) 
    l=[int(i) for i in input().split()] 
    curr = 0 
    i = 0 
    while i<len(l): 
        temp = i+1 
        ans = 0 
        while temp<len(l) and l[temp]<=l[temp-1]: 
            temp+=1 
            ans+=1 
        i=temp 
        curr = max(curr,ans) 
    return curr
print(givel())

Buggy python submission (verdict: Runtime Error):
n=int(input()def givel(): 
     n=int(input()) 
     l=[int(i) for i in input().split()] 
     curr = 0 
     i = 0 
     while i<len(l): 
         temp = i+1 
         ans = 0 
         while temp<len(l) and l[temp]<=l[temp-1]: 
             temp+=1 
             ans+=1 
         i=temp 
         curr = max(curr,ans) 
     return curr

Fixed submission:
def givel(): 
    n=int(input()) 
    l=[int(i) for i in input().split()] 
    curr = 0 
    i = 0 
    while i<len(l): 
        temp = i+1 
        ans = 0 
        while temp<len(l) and l[temp]<=l[temp-1]: 
            temp+=1 
            ans+=1 
        i=temp 
        curr = max(curr,ans) 
    return curr
print(givel())
Buggy python submission (verdict: Runtime Error):

from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
#from functools import reduce,cmp_to_key,lru_cache
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys
# input = sys.stdin.readline



M = mod = 10**9 + 7 
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip().split()]
def st():return str(input().rstrip())[2:-1]
def val():return int(input().rstrip())
def li2():return [str(i)[2:-1] for i in input().rstrip().split()]
def li3():return [int(i) for i in st()]
 



# sys.setrecursionlimit(10 ** 5 + 10)

g = 0
d = {}
def dp(i, par = -1, black = 0):
    global g
    ans = 1
    if (i, par, black) in d:return d[(i, par, black)]
    nokids = 1
    if black:
        for j in g[i]:
            if j != par:
                nokids = 0
                ans = ans * dp(j, i, 0) % mod
    else:
        for j in g[i]:
            if j != par:
                nokids = 0
                ans = ( ans * (dp(j, i, 0) + dp(j, i, 1)) ) % mod

    if nokids:ans = 1
    d[(i, par, black)] = ans
    return ans



n = val()
g = defaultdict(set)

l = []
for _ in range(n - 1):
    a, b = li()
    g[a].add(b)
    g[b].add(a)


root = 1    
ans = dp(root, -1, 0) + dp(root, -1, 1)

print(ans % mod)

Fixed submission:
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 10**9 +7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]








n = val()
l = li() + [2,2]

if n == 1:
    print(0)
    exit()
elif n == 2:
    print(abs(l[0] - l[1]))
    exit()
ans = [float('inf')]*(n + 2)
ans[0] = 0
for i in range(n):
    ans[i + 1] = min(ans[i + 1],ans[i] + abs(l[i] - l[i+1]))
    ans[i + 2] = min(ans[i + 2],ans[i] + abs(l[i] - l[i+2]))
print(ans[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]

n,w = li()
l = []
for i in range(n):l.append(li())
l.sort()
d = defaultdict(int)
for i in l:

    for j in sorted(list(d),reverse=1):
        if j + i[0] <= w:
            d[j + i[0]] = max(d[j + i[0]],d[j] + i[1])
    d[i[0]] = max(d[i[0]],i[1])
print(max(d.values()))


Fixed submission:
from decimal import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]

n,w = li()
l = []
for i in range(n):l.append(li())
l.sort()
d = defaultdict(int)
for i in range(10**5 + 10):d[i] = float('inf')
for i in l:

    for j in range(10 ** 5 + 10,0,-1):
        d[j + i[1]] = min(d[j + i[1]],d[j] + i[0])
    d[i[1]] = min(d[i[1]],i[0])
ans = 0
for i in range(10**5 + 10):
    if d[i] <= w:ans = i
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/agc040/tasks/agc040_a

MAX_INT = 100000
s_txt = input()

MIN_V = 1000000

def func(my_suretu, my_s_txt, min_v):
    #print('func(', my_suretu, my_s_txt, min_v, ')')

    now_sum = sum(my_suretu)
    # print(now_sum)
    if (now_sum >= min_v):
        return min_v

    if (len(my_s_txt) == 0):
        if (now_sum < min_v):
            min_v = now_sum
        return min_v
    else:
        next_my_s_txt = my_s_txt[1:]

    for v in range(0, MAX_INT):
        new_min_v = min_v
        if (len(my_suretu)==0):
            new_min_v = func(my_suretu + [v], next_my_s_txt, min_v)
        elif (((my_s_txt[0] == '>') and (my_suretu[-1] > v)) or 
            ((my_s_txt[0] == '<') and (my_suretu[-1] < v))):
            #print(my_suretu[-1], my_s_txt[0], v)
            new_min_v = func(my_suretu + [v], next_my_s_txt, min_v)
        if (new_min_v < min_v):
            min_v = new_min_v
        elif ((new_min_v == min_v) and (new_min_v != MIN_V)):
            break

    return min_v
        
min_v = MIN_V
for v in range(0, MAX_INT):
    new_min_v = func([v], s_txt, min_v)
    if (new_min_v < min_v):
        min_v = new_min_v
    elif ((new_min_v == min_v) and (new_min_v != MIN_V)):
        break

print(min_v)



Fixed submission:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/agc040/tasks/agc040_a

s = input()
a = [0] * (len(s) + 1)

for i in range(0, len(s)):
    if (s[i] == '<'):
        a[i+1] = a[i] + 1
for i in range(len(s)-1, -1, -1):
    if (s[i] == '>'):
        a[i] = max(a[i], a[i+1]+1)
#print(a)
print(sum(a))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/agc040/tasks/agc040_a

MAX_INT = 100000
s_txt = input()


def func(my_suretu, my_s_txt):
    #print('func(', my_suretu, my_s_txt, ')')

    if (len(my_s_txt) == 0):
        #print(my_suretu)
        print(sum(my_suretu))
        exit()
    else:
        next_my_s_txt = my_s_txt[1:]

    for v in range(0, MAX_INT):
        if (len(my_suretu)==0):
            func(my_suretu + [v], next_my_s_txt)
        elif (((my_s_txt[0] == '>') and (my_suretu[-1] > v)) or 
            ((my_s_txt[0] == '<') and (my_suretu[-1] < v))):
            #print(my_suretu[-1], my_s_txt[0], v)
            func(my_suretu + [v], next_my_s_txt)
        

for v in range(0, MAX_INT):
    func([v], s_txt)



Fixed submission:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/agc040/tasks/agc040_a

s = input()
a = [0] * (len(s) + 1)

for i in range(0, len(s)):
    if (s[i] == '<'):
        a[i+1] = a[i] + 1
for i in range(len(s)-1, -1, -1):
    if (s[i] == '>'):
        a[i] = max(a[i], a[i+1]+1)
#print(a)
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

intext = input()
[r, g, b, n] = map(int, intext.split())

rgb_list = [r, g, b]
rgb_list.sort(reverse=True)
[x, y, z] = rgb_list

cnt = 0
for x_val in range(0, n+1, x):
    for y_val in range(0, n+1, y):
        zan = n - x_val - y_val
        if zan >=0 and zan % z == 0:
            cnt += 1
print(cnt)


Fixed submission:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

intext = input()
[r, g, b, n] = map(int, intext.split())

rgb_list = [r, g, b]
rgb_list.sort(reverse=True)
[x, y, z] = rgb_list

cnt = 0
for x_val in range(0, n+1, x):
    # for y_val in range(0, n+1, y):
    for y_val in range(0, (y*((n-x_val)//z))+1, y):
        zan = n - x_val - y_val
        if zan >=0 and zan % z == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

intext = input()
[r, g, b, n] = map(int, intext.split())

cnt = 0
for r_val in range(0, n+1, r):
    for g_val in range(0, n+1, g):
        zan = n - r_val - g_val
        if zan >=0 and zan % b == 0:
            cnt += 1
print(cnt)


Fixed submission:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

intext = input()
[r, g, b, n] = map(int, intext.split())

rgb_list = [r, g, b]
rgb_list.sort(reverse=True)
[x, y, z] = rgb_list

cnt = 0
for x_val in range(0, n+1, x):
    # for y_val in range(0, n+1, y):
    for y_val in range(0, (y*((n-x_val)//z))+1, y):
        zan = n - x_val - y_val
        if zan >=0 and zan % z == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

intext = input()
[r, g, b, n] = map(int, intext.split())

r_list = [rn for rn in range(0, n+1, r)]
g_list = [gn for gn in range(0, n+1, g)]
b_list = [bn for bn in range(0, n+1, b)]

rgb_combis = itertools.product(r_list, g_list, b_list)

cnt = 0
for rn, gn, bn in rgb_combis:
    if (rn+gn+bn) == n:
        cnt +=1

print(cnt)

Fixed submission:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

intext = input()
[r, g, b, n] = map(int, intext.split())

rgb_list = [r, g, b]
rgb_list.sort(reverse=True)
[x, y, z] = rgb_list

cnt = 0
for x_val in range(0, n+1, x):
    # for y_val in range(0, n+1, y):
    for y_val in range(0, (y*((n-x_val)//z))+1, y):
        zan = n - x_val - y_val
        if zan >=0 and zan % z == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def palind(word):
  word = word.lower()
  return word[::-1] ==word

num1 = int((N-1)/2)
num2 = int((N+3)/2)

text1 =S[0::num1]
text2 =S[num2-1::]

if palind(S) == True and palind(text1) == True and palind(text2) == True:
  print("Yes")
else:
  print("No")

Fixed submission:
S = input()
N = len(S)

def palind(word):
  word = word.lower()
  return word[::-1] ==word

num1 = int((N-1)/2)
num2 = int((N+3)/2)

text1 =S[0::num1]
text2 =S[num2-1::]

if palind(S) == True and palind(text1) == True and palind(text2) == True:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
if S = "AAA" or "BBB":
  print("No")
else:
  print("Yes")


Fixed submission:
a = input()
if a=="AAA" or a=="BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
from math import ceil,floor
out = []

numA,numB = map(int,input().split())
for i in range(101):
  testA = floor(i * 0.08)
  testB = floor(i * 0.10)
  if testA == numA and testB == numB:
    out.append(i)

print(min(out))

Fixed submission:
from math import ceil,floor

numA,numB = map(int,input().split())
for i in range(10000):
  testA = floor(i * 0.08)
  testB = floor(i * 0.10)
  if testA == numA and testB == numB:
    print(i)
    break
else:
  print("-1")

Buggy python submission (verdict: Runtime Error):
from math import ceil,floor
out = []

numA,numB = map(int,input().split())
for i in range(101):
  testA = floor(i * 0.08)
  testB = floor(i * 0.10)
  if testA == numA and testB == numB:
    out.append(i)

print(min(out))

Fixed submission:
from math import ceil,floor

numA,numB = map(int,input().split())
for i in range(10000):
  testA = floor(i * 0.08)
  testB = floor(i * 0.10)
  if testA == numA and testB == numB:
    print(i)
    break
else:
  print("-1")
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input())
if A * 500 >= B:
  print("Yes")
else:
  print("No")
  

Fixed submission:
A,B = map(int,input().split())
if A * 500 >= B:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input())
If A * 500 >= B:
  print("Yes")
else:
  print("No")
  

Fixed submission:
A,B = map(int,input().split())
if A * 500 >= B:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
S = input()

def palind(word):
  word = word.lower()
  return word[::-1] ==word

S_inv = palind(S)
out = 0
for i in S:
  if S[i] ! S_inv[i]:
    out = out + 1

print(out)
    

Fixed submission:
S = input()
S_inv = S[::-1]

out = 0
for i in range(len(S)):
  if S[i] != S_inv[i]:
    out = out + 1

out = out // 2
#if out % 2 == 1:
#  out == out // 2 + 1
#else:
#  out == out // 2 
print(out)
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
out = ""
for i in S:
  num = ord(i)
  num = num + N
  print(num)
  out.append(chr(num))

print(out)
  

Fixed submission:
N =int( input())
S = input()

## empty list ##
out = []

for i in S:
  ## make code num ##
  num = ord(i)
  num = num + N
  if num > 90:
    num = num - 26
  ## make list ##
  out.append(chr(num))

## output ##
out = "".join(out)
print(out)
Buggy python submission (verdict: Runtime Error):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = []
for _ in range(N):
    b.append(input())

bingo1 =[0,0,0]
bingo2 =[0,0,0]
bingo3 =[0,0,0]
for i in range(3):
    for j in range(N):
        if A1[i]=b[j]:
            bingo1[i]+=1
        if A2[i]=b[j]:
            bingo2[i]+=1
        if A3[i]=b[j]:
            bingo3[i]+=1
if bingo1[0] == 1 and bingo1[1] == 1 and bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == 1 and bingo2[1] == 1 and bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == 1 and bingo3[1] == 1 and bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == 1 and bingo2[0] == 1 and bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == 1 and bingo2[1] == 1 and bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == 1 and bingo2[2] == 1 and bingo3[2] == 1:
    print("Yes")
elif bingo1[1] == 1 and bingo2[2] == 1 and bingo3[3] == 1:
    print("Yes")
elif bingo1[3] == 1 and bingo2[2] == 1 and bingo3[1] == 1:
    print("Yes")
else:
    print("No")


Fixed submission:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [(int(input())) for _ in range(N)]

bingo1 =[0,0,0]
bingo2 =[0,0,0]
bingo3 =[0,0,0]
for i in range(3):
    for j in range(N):
        if A1[i]==b[j]:
            bingo1[i]=1
        elif A2[i]==b[j]:
            bingo2[i]=1
        elif A3[i]==b[j]:
            bingo3[i]=1    


            
if bingo1[0] == bingo1[1] == bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == bingo2[1] == bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == bingo3[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[0] == bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == bingo2[1] == bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == bingo2[2] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[2] == bingo2[1] == bingo3[0] == 1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
n=N//2
s1=S[:n]
s2=S[n:]
if s1==s2:
    print("Yes")
else:
    print("No")

Fixed submission:
r=int(input())
print(r**2)
Buggy python submission (verdict: Runtime Error):
1<=A<=20
1<=B<=20
A,B=map(int,input().split()) 
if A>=10 or B>=10 or A<=0 or B<=0:
    print(-1)
else:
    print(A*B)

Fixed submission:
A,B=map(int,input().split()) 
if 1<=A<=20 and 1<=B<=20 and A<=9 and B<=9:
    print(A*B)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
L = list(map(int,input().split()))
D = 0
count = 1
for i in L:
    D+=L
    if D<=X:
        count+=1
    else:
        break
print(count)

Fixed submission:
N, X = map(int,input().split())
L = list(map(int,input().split()))
D = 0
count = 1
for i in L:
    D+=i
    if D<=X:
        count+=1
    else:
        break
print(count)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 14:48:19 2020

@author: ab
"""
import math
import sys
import os

def isDivisible(num1,num2):
    return num1%num2 == 0

def binary_search(n,m,k):
    if isDivisible(n,k) | isDivisible(m,k):
        return True
    elif abs(n-m) <=1:
        return False
    mid = math.ceil((n+m)/2)
    if(isDivisible(mid,k)):
        return True
    elif mid-n < k:
        return binary_search(mid+1,m,k)
    else:
        return binary_search(n,mid-1,k)
    

def solution(k,n,m):
    if k == 1:
        return True
    elif isDivisible(n,k) | isDivisible(m,k):
        return True
    elif abs(n-m) <=1:
        return False
    elif k>m:
        return False
    else:
        return binary_search(n,m,k)



input = sys.stdin
output = sys.stdout
while True:
    lineElements = input.readline().rstrip("/n").split(" ")
    if(lineElements[0] == ''):
        break;
    if len(lineElements) == 1:
        k = int(lineElements[0])
    else:
        n,m = lineElements
        n,m = int(n),int(m)
        if solution(k,n,m) == True:
            output.writeLine("OK")
        else:
            output.writeLine("NG")


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 14:48:19 2020

@author: ab
"""
# import math
import sys
# import os

def isDivisible(num1,num2):
    return num1%num2 == 0

def search(n,m,k):
    if isDivisible(n,k) | isDivisible(m,k):
        return True
    elif abs(n-m) <=1:
        return False
    for i in range(n,m):
        if isDivisible(i, k):
            return True
    return False
    
def solution(k,n,m):
    if k == 1:
        return True
    elif isDivisible(n,k) | isDivisible(m,k):
        return True
    elif abs(n-m) <=1:
        return False
    elif k>m:
        return False
    else:
        return search(n,m,k)



input = sys.stdin
output = sys.stdout
while True:
    lineElements = input.readline().rstrip("/n").split(" ")
    if(lineElements[0] == ''):
        break;
    if len(lineElements) == 1:
        k = int(lineElements[0])
    else:
        n,m = lineElements
        n,m = int(n),int(m)
        if solution(k,n,m) == True:
            print("OK\n")
        else:
            print("NG\n")
# output.flush()
Buggy python submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    x = int(N // 1.08)
    if math.floor(x * 1.08) == N:
        print(x)
    elif math.floor((x + 1) * 1.08) == N:
        print(x + 1)
    else:
        print(":(")


if __name__ == "__main__":
    resolve()

Fixed submission:
import math


def resolve():
    N = int(input())
    x = int(N // 1.08)
    if math.floor(x * 1.08) == N:
        print(x)
    elif math.floor((x + 1) * 1.08) == N:
        print(x + 1)
    else:
        print(":(")


if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    N, K = map(int, input().split())
    h = [int(i) for i in input().split()]

    dp = [0, abs(h[1] - h[0])]
    for i in range(2, N):
        dp.append(min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, K + 1)))
    print(dp[N - 1])


if __name__ == "__main__":
    resolve()

Fixed submission:
def resolve():
    N, K = map(int, input().split())
    h = [int(i) for i in input().split()]

    dp = [0, abs(h[1] - h[0])]
    for i in range(2, N):
        dp.append(
            min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, min(K + 1, i + 1)))
        )
    print(dp[N - 1])


if __name__ == "__main__":
    resolve()