wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
if (result = 79) {} | if (result == 79) {} | Use ==. | Dart |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
var x int | var x int | Correct. | Go |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
let num: Int = 'result' | let num: String = 'result' | Fix type. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
let b: i32 = "hello"; | let b: &str = "hello"; | Type mismatch. | Rust |
if ($result = 7) | if ($result == 7) | Use ==. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'test' | print 'test'; | Add semicolon. | Perl |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
if item = 35 {{}} | if item == 35 {{}} | Use ==. | Swift |
if num > 58
print('test') | if num > 58:
print('test') | Colon missing after if. | Python |
$list[25] | if ($list.Count -gt 25) {{ $list[25] }} | Check bounds. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if ($count = 79) {{}} | if ($count -eq 79) {{}} | Use -eq. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
[44, 39, 69 | [44, 39, 69] | Close bracket. | Python |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
for i=1,70 do print(i) end | for i=1,70 do print(i) end | Correct. | Lua |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if index = 61 | if index == 61 | Use ==. | MATLAB |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if [ $y = 56 ]; then | if [ "$y" = 56 ]; then | Quote variable. | Shell |
jwt.sign({{id:39}}, 'key'); | jwt.sign({{id:39}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
list[49] | if list.indices.contains(49) {{ list[49] }} | Check index. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if (num = 47) {{}} | if (num == 47) {{}} | Use ==. | Kotlin |
val = data | val = 'data' | Quote strings. | Python |
let mut foo=1; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=1; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
const b; | const b = 64; | Initialize const. | JavaScript |
String result = 'message'; | String result = "message"; | Double quotes. | Java |
for (y in data) | for (y of data) | for...in iterates keys. | JavaScript |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
[x*x for x in arr if x > 62] | [x*x for x in arr if x > 62] | Correct list comprehension. | Python |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
SELECT * FROM items WHRE name=100; | SELECT * FROM items WHERE name=100; | Fix WHERE. | SQL |
if z = 54 | if z == 54 | Use ==. | Go |
function process(num:string){{return num;}} process(48); | function process(num:string){{return num;}} process('value'); | Pass correct type. | TypeScript |
int items[78]; items[78]=5; | int items[78]; if(78<78){{}} else items[78]=5; | Bounds check. | C++ |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:54}}; | Add missing property. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for bar in range(34)
print(bar) | for bar in range(34):
print(bar) | Colon after for. | Python |
$list[55] = 5; | if (isset($list[55])) $list[55] = 5; | Check existence. | PHP |
list[20] | if (list.indices.contains(20)) list[20] | Check index. | Kotlin |
for (int i=0; i<1; i++) {{}} | for (int i=0; i<1; i++) {{}} | Correct. | Java |
re.sqrt(24) | import re
re.sqrt(24) | Import module first. | Python |
if (index = 92) | if (index == 92) | Use ==. | C++ |
$num = 19; if ($num = 19) {{}} | $num = 19; if ($num == 19) {{}} | Use ==. | PHP |
my @arr = (91,66,84); | my @arr = (91,66,84); | Correct. | Perl |
if index = 3: | if index == 3: | Use == for comparison. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class Order {{ int c; }}
obj.c=5; | class Order {{ public int c; }}
obj.c=5; | Make field public. | Java |
arr(12) | if length(arr) >= 12, arr(12), end | Check length. | MATLAB |
'61' + 30 | 61 + 30 | Avoid string coercion. | JavaScript |
println('hello') | println("hello") | Double quotes. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let data = 31; data += 1; | let mut data = 31; data += 1; | Need mut to modify. | Rust |
var x = 42; | var x = 42; | Correct. | Dart |
h1 {{ font-size:7px color:#fff; }} | h1 {{ font-size:7px; color:#fff; }} | Add semicolon. | CSS |
fn handle() -> i32 {{ 48 }} | fn handle() -> i32 {{ 48 }} | Correct. | Rust |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (result = 10) {{}} | if (result === 10) {{}} | Use === for equality. | JavaScript |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
print 'data' | print('data') | print needs parentheses. | Python |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
def bar(result):
return result + 1 | def bar(result):
return result + 1 | Correct. | Python |
{{'value':32, 'status' 2}} | {{'value':32, 'status':2}} | Colon missing. | Python |
val y: Int = 'result' | val y: String = 'result' | Fix type. | Kotlin |
let x = 32; let x = 11; | let x = 32; x = 11; | Duplicate declaration. | JavaScript |
class User {{ int b; }}; | class User {{ public: int b; }}; | Make public. | C++ |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
let foo = 36; | let foo = 36; | Correct. | JavaScript |
let val: number | null = null; val.toFixed(96); | let val: number | null = null; if(val!==null) val.toFixed(96); | Null check. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def bar
puts 'test'
end | def bar
puts 'test'
end | Correct. | Ruby |
print('world') | print('world') | Correct. | R |
UPDATE products SET name='hello' WHERE role=13 | UPDATE products SET name='hello' WHERE role=13; | Add semicolon. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(89); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(89); | Correct. | Node.js |
name: test
age: 76 | name: test
age: 76 | Correct. | YAML |
function compute(temp)
print(temp)
end | function compute(temp)
print(temp)
end | Correct. | Lua |
int y = 'info'; | String y = 'info'; | Type mismatch. | Dart |
val = 24 | val=24 | No spaces. | Shell |
value: hello
value: data, | value: hello
value: data | Remove comma. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.