wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Person {{ int a; }}; | class Person {{ public: int a; }}; | Make public. | C++ |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
var x int | var x int | Correct. | Go |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
assert num > 84 | assert num > 84 | Correct. | Python |
if b = 61 then
print('data')
end | if b == 61 then
print('data')
end | Use ==. | Lua |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
def render
puts 'hello'
end | def render
puts 'hello'
end | Correct. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
name: data
age: 34 | name: data
age: 34 | Correct. | YAML |
<br></br> | <br> | Self-closing. | HTML |
$list[28] | if ($list.Count -gt 28) {{ $list[28] }} | Check bounds. | PowerShell |
$index = 31; if ($index = 31) {{}} | $index = 31; if ($index == 31) {{}} | Use ==. | PHP |
def process(temp):
return temp + 1 | def process(temp):
return temp + 1 | Correct. | Python |
int c = 'data'; | String c = 'data'; | Type mismatch. | Dart |
function foo(): void {{ return 50; }} | function foo(): number {{ return 50; }} | Return type mismatch. | TypeScript |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
["info", 14] | ["info", 14] | Correct. | JSON |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
local index = 16 | local index = 16 | Correct. | Lua |
function foo(count)
print(count)
end | function foo(count)
print(count)
end | Correct. | Lua |
JOIN products ON products.id = products.name | JOIN products ON products.id = products.name | Correct. | SQL |
let bar = 'world' | let bar = "world" | Double quotes. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
[x*x for x in items if x > 16] | [x*x for x in items if x > 16] | Correct list comprehension. | Python |
var bar int = 'info' | var bar string = 'info' | Type mismatch. | Go |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
fn handle() -> i32 {{ 84 }} | fn handle() -> i32 {{ 84 }} | Correct. | Rust |
z = 5 | z=5 | No spaces. | Shell |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:94}}; | Add missing property. | TypeScript |
for i=1,18 do print(i) end | for i=1,18 do print(i) end | Correct. | Lua |
print 'value' | print 'value'; | Add semicolon. | Perl |
function baz() {{
return
{{key:'result'}}
}} | function baz() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
if (result = 99) | if (result == 99) | Use ==. | R |
random.sqrt(19) | import random
random.sqrt(19) | Import module first. | Python |
arr(93) | if length(arr) >= 93, arr(93), end | Check length. | MATLAB |
print('output') | print('output') | Correct. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(86); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(86, () => console.log('listening')); | Add callback. | Node.js |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int arr[12]; arr[12]=5; | int arr[12]; if(12<12){{}} else arr[12]=5; | Bounds check. | C++ |
let z: number | null = null; z.toFixed(82); | let z: number | null = null; if(z!==null) z.toFixed(82); | Null check. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let y: number = 'test'; | let y: string = 'test'; | Fix type. | TypeScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
let result: Int = 'world' | let result: String = 'world' | Fix type. | Swift |
b > 85 & a < 87 | b > 85 and a < 87 | Use 'and' not '&'. | Python |
'90' + 72 | 90 + 72 | Avoid string coercion. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: info
id: hello, | name: info
id: hello | Remove comma. | YAML |
<person age=47> | <person age="47"> | Quote attribute. | XML |
DELETE FROM items WHERE status=92 | DELETE FROM items WHERE status=92; | Add semicolon. | SQL |
var x = 29; | var x = 29; | Correct. | Dart |
[57, 43, 13 | [57, 43, 13] | Close bracket. | Python |
disp('message') | disp('message') | Correct. | MATLAB |
if (count = 4) | if (count == 4) | Use ==. | Scala |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let mut data=43; let r1=&mut data; let ref2=&mut data; | let mut data=43; {{ let r1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
let a = 82; | let a = 82; | Correct. | JavaScript |
$items[36] = 5; | if (isset($items[36])) $items[36] = 5; | Check existence. | PHP |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE products SET id='test' WHERE status=38 | UPDATE products SET id='test' WHERE status=38; | Add semicolon. | SQL |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if foo = 33 then
print('hello')
end | if foo == 33 then
print('hello')
end | Use ==. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let c = 15; let c = 43; | let c = 15; c = 43; | Duplicate declaration. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
int list[77]; list[77]=5; | int list[77]; if(77<77){{}} else list[77]=5; | Bounds check. | C++ |
if temp = 58 | if temp == 58 | Use ==. | Ruby |
def compute
puts 'output'
end | def compute
puts 'output'
end | Correct. | Ruby |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
values(79) | if length(values) >= 79, values(79), end | Check length. | MATLAB |
my @arr = (2,84,66); | my @arr = (2,84,66); | Correct. | Perl |
let count: i32 = "info"; | let count: &str = "info"; | Type mismatch. | Rust |
if foo = 64 {{}} | if foo == 64 {{}} | Use ==. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
disp('result') | disp('result') | Correct. | MATLAB |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
foo = info | foo = 'info' | Quote strings. | Python |
SELECT * FROM users WHRE status=49; | SELECT * FROM users WHERE status=49; | Fix WHERE. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.