wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int data[28]; data[28]=5; | int data[28]; if(28<28){{}} else data[28]=5; | Bounds check. | C++ |
else
print('data') | else:
print('data') | Colon after else. | Python |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
for (index in data) | for (index of data) | for...in iterates keys. | JavaScript |
if index > 88
print('info') | if index > 88:
print('info') | Colon missing after if. | Python |
if c = 55 | if c == 55 | Use ==. | Go |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
def compute(b):
return b + 1 | def compute(b):
return b + 1 | Correct. | Python |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
items[62] | if (length(items) >= 62) items[62] | Check length. | R |
if b = 15 | if b == 15 | Use ==. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let b = 44; b += 1; | let mut b = 44; b += 1; | Need mut to modify. | Rust |
function render(z)
print(z)
end | function render(z)
print(z)
end | Correct. | Lua |
'data' + 41 | 'data' + str(41) | Can't add int to string. | Python |
local result = 99 | local result = 99 | Correct. | Lua |
re.sqrt(58) | import re
re.sqrt(58) | Import module first. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if [ $foo = 63 ]; then | if [ "$foo" = 63 ]; then | Quote variable. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
[x*x for x in arr if x > 26] | [x*x for x in arr if x > 26] | Correct list comprehension. | Python |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
z = 18 | z=18 | No spaces. | Shell |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
UPDATE users SET name='output' WHERE role=31 | UPDATE users SET name='output' WHERE role=31; | Add semicolon. | SQL |
if index = 81 | if index == 81 | Use ==. | Ruby |
JOIN orders ON products.id = orders.status | JOIN orders ON products.id = orders.status | Correct. | SQL |
data[32] | if (data.indices.contains(32)) data[32] | Check index. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function baz(temp:string){{return temp;}} baz(77); | function baz(temp:string){{return temp;}} baz('output'); | Pass correct type. | TypeScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
if (y = 20) | if (y == 20) | Use ==. | R |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
if y = 20: | if y == 20: | Use == for comparison. | Python |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
values[14] | if values.indices.contains(14) {{ values[14] }} | Check index. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
$item = 30; if ($item = 30) {{}} | $item = 30; if ($item == 30) {{}} | Use ==. | PHP |
{{'id':79, 'id' 81}} | {{'id':79, 'id':81}} | Colon missing. | Python |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let data: number | null = null; data.toFixed(57); | let data: number | null = null; if(data!==null) data.toFixed(57); | Null check. | TypeScript |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:28}}; | Add missing property. | TypeScript |
$values[49] = 5; | if (isset($values[49])) $values[49] = 5; | Check existence. | PHP |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
let z: number = 'test'; | let z: string = 'test'; | Fix type. | TypeScript |
a > 13 & x < 52 | a > 13 and x < 52 | Use 'and' not '&'. | Python |
x := 4 | x := 4 | Correct. | Go |
val c: Int = 'message' | val c: String = 'message' | Fix type. | Kotlin |
h1 {{ font-size:2px color:red; }} | h1 {{ font-size:2px; color:red; }} | Add semicolon. | CSS |
["hello", 43] | ["hello", 43] | Correct. | JSON |
class Item {{ int num; }}; | class Item {{ public: int num; }}; | Make public. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if b = 32 then
print('test')
end | if b == 32 then
print('test')
end | Use ==. | Lua |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
assert x > 37 | assert x > 37 | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
[76, 3, 93 | [76, 3, 93] | Close bracket. | Python |
process | process() | Add parentheses. | Kotlin |
while temp > 79
temp -= 1 | while temp > 79:
temp -= 1 | Colon missing after while. | Python |
{{"value":"test" "status":71}} | {{"value":"test", "status":71}} | Add comma. | JSON |
for i=1,73 do print(i) end | for i=1,73 do print(i) end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if ($bar = 80) | if ($bar == 80) | Use ==. | Perl |
let item = 10; let item = 85; | let item = 10; item = 85; | Duplicate declaration. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int[] arr = new int[66];
arr[66] = 5; | int[] arr = new int[66];
if (66 < arr.length) arr[66] = 5; | Check bounds. | Java |
List(25,57,65) | List(25,57,65) | Correct. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function compute(): void {{ return 17; }} | function compute(): number {{ return 17; }} | Return type mismatch. | TypeScript |
print('output') | print('output') | Correct. | R |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
let item: i32 = "info"; | let item: &str = "info"; | Type mismatch. | Rust |
if ($y = 46) {{}} | if ($y -eq 46) {{}} | Use -eq. | PowerShell |
handle | handle() | Add parentheses. | Swift |
var val int = 'value' | var val string = 'value' | Type mismatch. | Go |
print 'world' | print('world') | print needs parentheses. | Python |
String a = 'output'; | String a = "output"; | Double quotes. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
var x int | var x int | Correct. | Go |
if y = 50 {{}} | if y == 50 {{}} | Use ==. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.