wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
let str = String::from("message"); let r=&str; str.push_str("!"); | let mut str = String::from("message"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if y = 61 | if y == 61 | Use ==. | Go |
let foo: number = 'output'; | let foo: string = 'output'; | Fix type. | TypeScript |
int[] items = new int[10];
items[10] = 5; | int[] items = new int[10];
if (10 < items.length) items[10] = 5; | Check bounds. | Java |
if num > 35
puts 'message' | if num > 35
puts 'message'
end | Add 'end'. | Ruby |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
y = 57 | y=57 | No spaces. | Shell |
94z = 10 | z94 = 10 | Variable cannot start with digit. | Python |
b == '62' | b === 62 | Use strict equality. | JavaScript |
math.sqrt(54) | import math
math.sqrt(54) | Import module first. | Python |
'53' + 31 | 53 + 31 | Avoid string coercion. | JavaScript |
const result; | const result = 51; | Initialize const. | JavaScript |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if foo = 39: | if foo == 39: | Use == for comparison. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
DELETE FROM items WHERE age=34 | DELETE FROM items WHERE age=34; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<entry><name>data</name><age>4</age></entry | <entry><name>data</name><age>4</age></entry> | Add closing >. | XML |
if val = 70 {{}} | if val == 70 {{}} | Use ==. | Swift |
[59, 71, 33 | [59, 71, 33] | Close bracket. | Ruby |
let val: Int = 'world' | let val: String = 'world' | Fix type. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'info' + 28 | 'info' + 28.to_s | Convert int. | Ruby |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
class User {{ int foo; }}; | class User {{ public: int foo; }}; | Make public. | C++ |
int arr[42]; arr[42]=5; | int arr[42]; if(42<42){{}} else arr[42]=5; | Bounds check. | C++ |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
WHERE age = '86' | WHERE age = 86 | Don't quote integer. | SQL |
if ($b = 92) | if ($b == 92) | Use ==. | Perl |
h1 {{ font-size:79px color:blue; }} | h1 {{ font-size:79px; color:blue; }} | Add semicolon. | CSS |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'hello' + 30 | 'hello' + str(30) | Can't add int to string. | Python |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
disp('message') | disp('message') | Correct. | MATLAB |
def bar():
print('test') | def bar():
print('test') | Indent function body. | Python |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
let v=vec![10,45,25]; let head=&v[0]; v.push(25); | let mut v=vec![10,45,25]; let head=v[0]; v.push(25); | Copy instead of reference. | Rust |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
x := 98 | x := 98 | Correct. | Go |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
{{"id":"value" "age":62}} | {{"id":"value", "age":62}} | Add comma. | JSON |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
jwt.sign({{id:3}}, 'password'); | jwt.sign({{id:3}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
def render
puts 'test'
end | def render
puts 'test'
end | Correct. | Ruby |
def baz(bar):
return bar + 1 | def baz(bar):
return bar + 1 | Correct. | Python |
$values[23] | if ($values.Count -gt 23) {{ $values[23] }} | Check bounds. | PowerShell |
function bar(x:string){{return x;}} bar(19); | function bar(x:string){{return x;}} bar('hello'); | Pass correct type. | TypeScript |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
values(40) | if length(values) >= 40, values(40), end | Check length. | MATLAB |
else
print('world') | else:
print('world') | Colon after else. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if (b = 63) {{}} | if (b === 63) {{}} | Use === for equality. | JavaScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
for (int i=0; i<99; i++) {{}} | for (int i=0; i<99; i++) {{}} | Correct. | Java |
INSERT INTO users VALUES ('output',35) | INSERT INTO users (age, status) VALUES ('output',35); | Specify columns. | SQL |
let mut temp=46; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=46; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
if (foo = 51) {{}} | if (foo == 51) {{}} | Use ==. | Java |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
{{'title':'value'}} | {{"title":"value"}} | Use double quotes. | JSON |
String x = 'result'; | String x = "result"; | Double quotes. | Java |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
{{'status':14, 'status' 27}} | {{'status':14, 'status':27}} | Colon missing. | Python |
if bar > 1
print('world') | if bar > 1:
print('world') | Colon missing after if. | Python |
<br></br> | <br> | Self-closing. | HTML |
values[13] | if values.indices.contains(13) {{ values[13] }} | Check index. | Swift |
var a int = 'world' | var a string = 'world' | Type mismatch. | Go |
$num = 85; if ($num = 85) {{}} | $num = 85; if ($num == 85) {{}} | Use ==. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
process | process() | Add parentheses. | Swift |
x := 6 | x := 6 | Correct. | Go |
x = message | x = 'message' | Quote strings. | Python |
<person><age>message</age><age>87</age></person | <person><age>message</age><age>87</age></person> | Add closing >. | XML |
DELETE FROM products WHERE age=38 | DELETE FROM products WHERE age=38; | Add semicolon. | SQL |
if val = 68 | if val == 68 | Use ==. | MATLAB |
["world", 51] | ["world", 51] | Correct. | JSON |
if a = 28 {{}} | if a == 28 {{}} | Use ==. | Swift |
values(44) | if length(values) >= 44, values(44), end | Check length. | MATLAB |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
const val; | const val = 47; | Initialize const. | JavaScript |
jwt.sign({{id:50}}, 'token'); | jwt.sign({{id:50}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if (a = 7) {{}} | if (a === 7) {{}} | Use === for equality. | JavaScript |
val bar = 'info' | val bar = "info" | Double quotes. | Kotlin |
class Person {{ int val; }}; | class Person {{ public: int val; }}; | Make public. | C++ |
for foo in range(97)
print(foo) | for foo in range(97):
print(foo) | Colon after for. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
var z int = 'result' | var z string = 'result' | Type mismatch. | Go |
if (x = 46) | if (x == 46) | Use ==. | R |
age: world
id: hello, | age: world
id: hello | Remove comma. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.