Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03323 (python)

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

if (a <= 8 and b <= 8):
	print("Yay!")
else:
	print(":(")

Buggy submission (verdict: Runtime Error):
line = input()
num_a, num_b = [int(n) for n in line.split()][0]
is_it_possible = "Yay!"
if num_a > 8 or num_b > 8:
    is_it_possible = ":("
print(is_it_possible)

Buggy submission (verdict: Runtime Error):
a, b = map(int, raw_input())

if a <= 8 and b <= 8:
    print 'Yay!'
else:
    print ':('
Problem p03325 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
res = 0
for i in a:
    while i%2==0:
        res += 1
        i //= 2
print(res)

Buggy submission (verdict: Runtime Error):
n = int(raw_input())
m = list(map(int, input().split()))
total = 0
for i in range(n):
    x = m[i]
    while True:
        if x % 2 == 1:
            break
        total += 1
        x = x // 2
 
print total
Problem p03331 (python)

Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)

Buggy submission (verdict: Runtime Error):
def soma(a):
    res=0
    for i in range(0, len(a)):
        res+=int(a[i])

    if(res>=10):
        return soma(str(res))

    return res

def main():
    n = int(input())
    menor = soma("1")+soma(str(n-1))
    
    for i in range(1,10):
        if(soma(str(i))+soma(str(n-i))<menor):
            menor = soma(str(i))+soma(str(n-i))

    print(menor,"\n")
    
main()

Buggy submission (verdict: Runtime Error):
a = int(input())
lim = a // 2
soma_lista = []
for i in range(a - 1, lim, -1):
    b = str(a - abs(i)) + str(abs(i))
    soma = 0
    for digit in b:
        soma += int(digit)
    soma_lista.append(soma)
print(min(soma_lista))
Problem p03337 (python)

Fixed submission:
A,B = map(int,input().split())
ans = max(A+B, A-B, A*B)
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
soma, mult, minus = a+b, a*b, a-b 
if(soma > mult and soma > minus):
    print(soma)
elif(mult > minus):
    print(mult)
else:
    print(minus)
Problem p03417 (python)

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

if(N == 1 or M == 1):
    if(M == 1 and N == 1):
        print(1)
    else:
        print(max(M-2, N-2))
else:
    print((N-2)*(M-2))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if (N,M==1,1):
    print(0)
if (N==1):
    print(M-2)
if (M==1):
    print(N-2)
else:
    print((N-2)(M-2))

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

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

if n>m:
	swap(n,m)

if n==1:
	if m==1:
		print(1)
	else:print(m-2)
elif n==2:
	print(0)
else :
	print(n*m - (m+n)*2 -4 )
Problem p03437 (python)

Fixed submission:
x,y=map(int,input().split())
if x>=y and x%y==0:
  print(-1)
elif x<y:
  print(x)
else:
  print(x*y-x)

Buggy submission (verdict: Runtime Error):
import math

input = str(input()).split(" ")
for index in range(len(input)):
    input[index] = int(input[index])
x = input[0]
y = input[1]

def ahaha(x, y):
    for index in range(1, min(abs(y), math.floor((10**(18))/x)):
        if (x * index % y != 0):
            return x * index
    return -1

print(ahaha(x,y))

Buggy submission (verdict: Runtime Error):
import math

input = str(input()).split(" ")
for index in range(len(input)):
    input[index] = int(input[index])
x = input[0]
y = input[1]

def canBeDone(x,y):
    thingo = True
    while thingo:
        div = math.gcd(x,y)
        x = int(x/div)
        y = int(y/div)
        if (div == 1):
            thingo = False
    if (x == 1 and y == 1):
        return -1
    else:
        return 1

def test(x, y):
    if (canBeDone(x,y) == -1):
        return -1
    for index in range(math.floor(y/x)-1, abs(y)):
        if (x * index % y != 0 and abs(x * index) <= 10**(18)):
            return x * index
    return -1
print(test(x,y))
Problem p03448 (python)

Fixed submission:
coinA = int(input())
coinB = int(input())
coinC = int(input())
want = int(input())
ways = 0
i = 0
while i <= coinA:
    j = 0
    while j <= coinB:
        k = 0
        while k <= coinC:
            if i*500 + j*100 + k*50 == want:
                ways = ways + 1
            k = k + 1
        j = j + 1
    i = i + 1
print(ways)

Buggy submission (verdict: Runtime Error):
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        A: usize,
        B: usize,
        C: usize,
        X: usize
    }

    let mut ans = 0;

    for a in 0..A+1 {
        for b in 0..B+1 {
            let cnt = (0..C+1).filter(|&c| 500*a + 100*b + 50*c == X).count();
            ans += cnt;
        }
    }

    println!("{}", ans);
}

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
result = 0             //initialized to zero
 
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            amount = 500 * ai + 100 * bi + 50 * ci        //formula
            if amount == x:
                result += 1
 
print(result)        //output

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
ans = 00
 for xx in range(a+1):
    A = 500*xx
    for y in range(b+1):
        B = 100*y
        for z in range(c+1):
            C = 50*z
            if x == A+B+C:
                ans += 1
            else:
                continue
 
print(ans)
Problem p03456 (python)

Fixed submission:
import math
string = input().split(" ")
number = int(string[0]+string[1])
result = math.sqrt(number)
if int(result)*int(result) == number:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from math import sqrt

i = input().sqlit()
a = i[0]
b = i[1]

n = int(a+b)
s = int(sqrt(n))
if s*s==n:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
from math import sqrt

i = input().sqlit()
a = i[0]
b=i[1]

n = int(a+b)
s = int(sqrt(n))
if s*s==n :
	print("Yes")
else:
	print("No")
Problem p03487 (python)

Fixed submission:
import math

line1 = int(input())
line2 = str(input()).split(" ")
for index in range(len(line2)):
    line2[index] = int(line2[index])

newList = []
counter = dict()
newLength = 0
for element in line2:
    try:
        counter[element] += 1
    except:
        counter[element] = 1
    if (counter[element] == element):
        newLength += element

print(line1 - newLength)

Buggy submission (verdict: Runtime Error):
from collections import Counter
a = int(input())
l = []
i = 1
for i in range(a):
    b = [int(i) for i in input(i).split(" ")]
    l.append(b)
c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)
Problem p03547 (python)

Fixed submission:
def main():
    while True:
        try:
            inputList = input().split()
            firstChar = inputList[0]
            secondChar = inputList[1]
            firstNum = ord(firstChar)
            secondNum = ord(secondChar)
            if(firstNum > secondNum):
                print(">")
            elif(firstNum < secondNum):
                print("<")
            elif(firstNum == secondNum):
                print("=")
        except:
            break
main()

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
int main()
{ char a[3],A=10,B=11,C=12,D=13,E=14,F=15; 
  int i; 
 
       gets(a);
         for(i=0;i<3;i++) 
          {if(a[i]=='A')
	        a[i]=10;
	         if(a[i]=='B')
	          a[i]=11;
	         if(a[i]=='C')
	        a[i]=12;
	         if(a[i]=='E')
	        a[i]=14;
	         if(a[i]=='F')
	        a[i]=15;
	         if(a[i]=='D')
	        a[i]=13;}
	     if(a[0]>a[2])
       {printf(">\n");}
        
        else if(a[0]==a[2])
       {printf("=\n");}
        
    	 else if(a[0]<a[2])
       {printf("<\n");}
       	
    
}
Problem p03548 (python)

Fixed submission:
X, Y, Z = map(int, input().split())
print((X-Z)//(Y+Z))

Buggy submission (verdict: Runtime Error):
x=int(input(""))
y=int(input(""))
z=int(input(""))
answer= (x-z)//(z+y)
print(answer);
Problem p03633 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
import collections
import math
import fractions 

# code start
raw_input = input


def lcm(a,b):
	return a*b/fractions.gcd(int(a),int(b))

def main():
	count = int(input())
	i = 0
	temp = 1
	while(i<count):
		i+=1
		num = int(input())
		temp = lcm(temp,num)
	print(int(temp))


if __name__ == '__main__':
    main()

# code end

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
n = (input())
res = (input())
while n > 1:
	x = (input())
	res = (res * x) / gcd(res, x);
	n -= 1
print(res)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
ar=list(map(int,input().split()))

an=ar[0]
for x in range(1,n):
	an=(an*ar[x])/math.gcd(an,ar[x]);
print(an)
Problem p03645 (python)

Fixed submission:
a=[]
b={}
n,m=map(int,input().split())
for _ in range(m):
	i,j=map(int,input().split())
	if i==1:
		a.append(j)
	elif j==n:
		b[i]=1
for i in a:
	if i in b:
		print('POSSIBLE')
		break
else:
	print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 1;
int a[N][N];
int main(){
    speed;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int x, y;
        cin >> x >> y;
        a[x][y] = 1;
    }
    for(int i = 0; i < N; ++i){
        if(a[1][i] && a[i][n]){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}
Problem p03661 (python)

Fixed submission:
import sys

n = int(input())
a = []
b = input().split(" ")
for i in range(n):
	a.append(int(b[i]))

for i in range(1, n):
	a[i] += a[i-1]

mn = abs(a[n-1] - 2*a[0])
for i in range(1, n-1):
	mn = min(mn, abs(a[n-1] - 2*a[i]))

print(mn)

Buggy submission (verdict: Runtime Error):
def QSortPosition(list,low,high):
    LsaveNum=list[low]
    pivotkey=list[low]
    while(low<high):
        while(list[low]<pivotkey) :
            low+=1
        list[high]=list[low]
        high-=1
        while(list[high]>pivotkey):
            high-=1
        list[low]=list[high]
        low+=1
    list[low]=LsaveNum
    return low

def QSort(list,s,t):
    if(s<t):
        pivotkey=QSortPosition(list,s,t)
        QSort(list,s,pivotkey-1)
        QSort(list,pivotkey+1,t)
    return list

def FindMinS(list,length):
	count1=0
	sum=0

	while count1<length:
		sum=sum+list[count1]
		count1+=1

	InvidNum=length-1
	location=0
	count2=0
	MinList=[]

	while count2<InvidNum:
		count3=count2
		ab1=0
		ab2=0
		while count3<=location:
			ab1=ab1+list[count3]
			count3+=1
			ab2=sum-ab1
			ab3=abs(ab2-ab1)
			MinList.append(ab3)
		count2+=1

	MinList=QSort(MinList,0,InvidNum-1)
	return MinList[0]

num=input("请输入列表长度：")
count=0
list=[]
while count<num:
	listele=input("输入元素：")
	list.append(listele)
	count+=1
minnum=FindMinS(list,num)
print(minnum)
Problem p03711 (python)

Fixed submission:
s=input().split();
x=int(s[0])
y=int(s[1])
list1=[2]
list2=[4,6,9,11]
list3=[1,3,5,7,8,10,12]
ans=0;
if((x in list1) and (y in list1)): ans=1
elif((x in list2) and (y in list2)):ans=1
elif((x in list3) and (y in list3)):ans=1
if(ans==1):print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())
s1 = [1, 3, 5, 7, 8, 10, 12]
s2 = [4, 6, 9, 11]
if x >= 1:
    if x <= 12:
        if y >= 1:
            if y <= 12:
                if x in s1 and y in s1:
                    print("Yes")
                elif x in s2 and y in s2:
                    print("Yes")
                elif x == 2 and y == 2:
                    print("Yes")
                else:
                    print("No")
Problem p03738 (python)

Fixed submission:
a = input()
b = input()
if(eval(a) > eval(b)):
    print("GREATER")
elif(eval(a) < eval(b)):
    print("LESS")
else:
    print("EQUAL")

Buggy submission (verdict: Runtime Error):
a, b = (input().split(" "))
a = int(a)
b = int(b)
if(a > b):
  print("GREATER")
elif(a < b):
  print("LESS")
else:
  print("EQUAL")
Problem p03759 (python)

Fixed submission:
a,b,c = map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a=int(input("Enter a"))
b=int(input("Enter b"))
c=int(input("Enter c"))
if a-b == b-c || b-a == c-b:
 print("Beautiful")
else:
 print("No")

Buggy submission (verdict: Runtime Error):
def beautiful:
     a, b, c = input().split()
      if fabs(b-a) == fabs(c-b):
            print('YES')
      else:
            print('NO')

beautiful()
Problem p03760 (python)

Fixed submission:
O=input()
E=input()

o=list(O)
e=list(E)

str=[0 for i in range(len(o)+len(e))]
j=0
for i in range(0,len(o)):
    str[j]=o[i]
    j+=2
j=1
for i in range(0,len(e)):
    str[j]=e[i]
    j+=2
s=""
for i in range(len(str)):
    s=s+str[i]
print(s)

Buggy submission (verdict: Runtime Error):
O=list(input())
E=list(input())
F=[]
j=0
k=0
for i in range(0,len(O)+len(E)):
    F.append('0')
while j<(len(O)+len(E)):
    F[j]=E[k]
    j=j+2
    k=k+1
j=1 
k=0
while j<(len(O)+len(E)):
    F[j]=O[k]
    j=j+2
    k=k+1 
F= ''.join([str(elem) for elem in F])
print(F)
Problem p03795 (python)

Fixed submission:
n = int(input())

x = 800*n

y = (n // 15) * 200

print(x-y)

Buggy submission (verdict: Runtime Error):
n=int(input())
can=n*800
p=n
des=200
if n>=15 and n<30:
  total=can-200
elif n>=30 and n<45:
  total=can-400
elif n>=45 and n<60:
  total=can-600
elif n>=60 and n<75:
  total=can-800
elif n>=75 and n<90:
  total=can-1000
elif n>=90 and n<=100:
  total=can-1200
print(total)
Problem p03826 (python)

Fixed submission:
#!/usr/bin/env python
s = raw_input()
array_num = [ int(each_num) for each_num in s.split()]
first_area = array_num[0] * array_num[1]
second_area = array_num[2] * array_num[3] 
if first_area > second_area:
	print(first_area)
elif first_area < second_area:
	print(second_area)
else:
	print(first_area)

Buggy submission (verdict: Runtime Error):
a,b,c,d = input()
if a*b > c*d:
    print a*b
elif c*d > a*b:
    print c*d
else:
    print a*b

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
d = input()
def area(a,b,c, d):
    if a*b > c*d:
        return a*b
    elif c*d > a*b:
        return c*d
    else:
        return a*b
Problem p03827 (python)

Fixed submission:
n=int(input())
s=input()
x=0
max=0
for i in range(0,n):
    if(s[i] is 'I'):
        x+=1
    elif(s[i] is 'D'):
        x-=1
    if max<x:
        max=x
print(max)

Buggy submission (verdict: Runtime Error):

x=0
n=int(input())
F=list(input())
#lis=F.split()
alist=[]
alist.append(x)
for token in F:



    if token=="I":
        x=x+1
        alist.append(x)
    else:
        x=x-1
        alist.append(x)


for i in alist:

    if alist[i]>alist[i+1]:
        x=alist[i]

    else:
        x=alist[i+1]



print(x)

Buggy submission (verdict: Runtime Error):
n = raw_input()
x = n.split()
N= int(x[0])
S = x[1]
x=0 
y = str(x)
for i in range(0,N):
    if S[i] == "I":
        x = x+1 
        y = y + str(x)
    elif S[i]=="D":
        x = x - 1 
        y = y + str(x)
        
print max([int(c) for c in ])
Problem p03844 (python)

Fixed submission:
input = input().split(" ")
output = 0;
if input[1] == "+":
    output = int(input[0]) + int(input[2])
else:
    output = int(input[0]) - int(input[2])

print(output)

Buggy submission (verdict: Runtime Error):
input = raw_input().split(" ")
output = 0;
if input[1] == "+":
    output = input[0] + input[2]
else:
    output = input[0] - input[2]

print(output)
Problem p03845 (python)

Fixed submission:
n = int(input())
t = list(map(int,input().split()))
s = sum(t)
m = int(input())
for _ in range(0,m):
    p,x = map(int,input().split())
    print(s-t[p-1]+x)

Buggy submission (verdict: Runtime Error):
n = int(input()) 
t = list(map(int,input().strip().split()))[:n] 
m = int(input())
p=[]
x=[]
for _ in range(m):
    a,b = map(int,input().split())
    p.append(a)
    x.append(b)
s=sum(t)
for i in range(m):
    T=s
    T-=t[p[i]-1]
    T+=x[p[i]-1]
    print(T)
Problem p03856 (python)

Fixed submission:
s=input()
s=s.replace('eraser','*')
s=s.replace('erase','*')
s=s.replace("dreamer","*")
s=s.replace("dream","*")
f=1
for i in s:
    if i!='*':
        f=0
        break
if f:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s=input()
s=s.replace('eraser','#')
s=s.replace('erase','#')
s=s.replace('dreamer','#')
s=s.replace('dream')
f=1
for it in s:
    if it !='#':
        f=0
        break

if f==1:
    print("YES")
else :
    print("NO")
Problem p03962 (python)

Fixed submission:
x = len(set(list(map(int,input().split()))))
print(x)

Buggy submission (verdict: Runtime Error):
from collections import collector 
n=[] 
n=input()
p=counter(n). keys() 
print(p)
Problem p03965 (python)

Fixed submission:
x=input()
n=int(len(x)/2)
a=0
ls=[]
def fun():
     for i in range(2):
          ls.append(i)
for i in x:
     if i=='p':
          a+=1
print(n-a)

Buggy submission (verdict: Runtime Error):
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = s.size();
    //nump <= numg
    int nump = 0, numg = 0;
    for(int i = 0 ; i < len; i++){
        if(s[i] == 'p')nump++;
        else if(s[i] == 'g')numg++;
    }
    cout<<(nump+numg)/2-nump;
    return 0;
}
Problem p04030 (python)

Fixed submission:
s = input()
l = []
for i in range(len(s)):
    if s[i] != 'B':
        l.append(s[i])
    else:
        if len(l)==0:
            pass
        else:
            del l[-1]
print("".join(l))

Buggy submission (verdict: Runtime Error):
a=input()

m=[]
for i in a:
    if i=='0':
        m.append(i)
    if i=='1':
        m.append(i)
    if i=='B':
        m.pop()
m="".join(m)
print(m)
Problem p04039 (python)

Fixed submission:
s, k = [int(i) for i in input().split(" ")]
num = [int(i) for i in input().split(" ")]

def check(n):
	for _s in str(n):
		if int(_s) in num:
			return True
	return False

while check(s):
	s += 1
	
print(s)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = map(str, input().split())
digits = set(d)
num = {str(i) for i in range(0,10)}
left = num - digits
for i in range(N, 100000):
    Num = set(str(i))
    if Num <= left:
        print(i)
        break
Problem p04043 (python)

Fixed submission:
a=input().split()
if a.count('5')==2 and a.count('7')==1:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
a1=input()
a2=input()
a3=input()
a=[a1,a2,a3]
a.sort()
flag=0
for i in range(2):
    if a[i]!='5':
        flag=flag+1
if a[2]!='7':
    flag=flag+1
 
if flag==0:
    print("YES")
else:
    print("NO")
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
ans = ""
s = []
for i in range(N):
    s.append(input())

s.sort()
for i in range(N):
    ans += s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=int(input())
arr = ["" for x in range(n)]
for i in range(n):
    arr[i]=input()
arr.sort()
for i in range(n):
    print(arr[i],end="")

Buggy submission (verdict: Runtime Error):
N = int(input())
L = int(input())
l=[]
for _ in range(0,N):
    l.append(input())
s=""
l.sort()

for i in l:
    s = s+i
print(s)

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
S = [input() for i in range(N)]
S.sort()
for s in S:
  print(s,end=“”)
Problem p02644 (python)

Fixed submission:
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
m+=d,
a=~w+a*w+b
q=[a]
d[a]=1
for s in q:
 for x in 0,1,2,3:
  for z in range(k):
   y=~z,0,z+1,0;i,j=s//w+y[x],s%w+y[~x];t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

Buggy submission (verdict: Runtime Error):
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
m+=d,
a=~w+a*w+b
q=[a]
d[a]=1
for s in q:
 for x in 0,1,2,3:
  for z in range(k):
   y=~z,0,z+1,0;i,j=s//w+y[x],s%w+y[~x];t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]ord[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)
Problem p03029 (python)

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

print((3 * A + P) // 2)

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

n_consts, n_agents = map(int, input().split())
const_plans = []
dep_times = []
results = [-1 for _ in range(n_agents)]

for _ in range(n_consts):
    const_plans.append([int(e) for e in input().split()])

const_plans = np.array(const_plans)
order_by_x = np.argsort(const_plans.T)[-1]
const_plans = const_plans[order_by_x]

for _ in range(n_agents):
    dep_times.append(int(input()))

for n_agent, dep_time in enumerate(dep_times):
    for const_plan in const_plans:
        x = const_plan[2]
        x1 = max(0, const_plan[0] - dep_time)
        x2 = max(0, const_plan[1] - dep_time)
        if x1 <= x < x2:
            results[n_agent] = x

for result in results:
    print(result)

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

def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        si = sw[e_ball - 1]
        
        if p[i] != (np.sum(si == 1) % 2):
            return False
    
    return True

N, M = map(int, input().split())

e_balls = []

for m in range(M):
    i = input().split()
    s = [int(si) for si in i[1:]]
    e_balls.append(np.asarray(s))

p = [int(pi) for pi in input().split()]

cnt = 0

for sw in ittr.product([0, 1], repeat = N):
    if test_switch(e_balls, np.array(sw), p):
        cnt += 1

print(cnt)