wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let str1 = String::from("output"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
b == '88' | b === 88 | Use strict equality. | JavaScript |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
<user><desc>value</desc><desc>99</desc></user | <user><desc>value</desc><desc>99</desc></user> | Add closing >. | XML |
if item = 63 | if item == 63 | Use ==. | Ruby |
let bar: number | null = null; bar.toFixed(8); | let bar: number | null = null; if(bar!==null) bar.toFixed(8); | Null check. | TypeScript |
if ($item = 94) {{}} | if ($item -eq 94) {{}} | Use -eq. | PowerShell |
int[] arr = new int[21];
arr[21] = 5; | int[] arr = new int[21];
if (21 < arr.length) arr[21] = 5; | Check bounds. | Java |
if [ $a = 82 ]; then | if [ "$a" = 82 ]; then | Quote variable. | Shell |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
values(11) | if length(values) >= 11, values(11), end | Check length. | MATLAB |
val index = 'message' | val index = "message" | Double quotes. | Kotlin |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
'46' + 84 | 46 + 84 | Avoid string coercion. | JavaScript |
if (num = 70) {{}} | if (num === 70) {{}} | Use === for equality. | JavaScript |
jwt.sign({{id:61}}, 'token'); | jwt.sign({{id:61}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
x := 26 | x := 26 | Correct. | Go |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if (data = 92) {{}} | if (data == 92) {{}} | Use ==. | Java |
if b = 94 | if b == 94 | Use ==. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
fn foo() -> i32 {{ 25 }} | fn foo() -> i32 {{ 25 }} | Correct. | Rust |
function test() {{
return
{{key:'info'}}
}} | function test() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
def baz():
print('data') | def baz():
print('data') | Indent function body. | Python |
if (c = 85) | if (c == 85) | Use ==. | R |
x > 20 & x < 56 | x > 20 and x < 56 | Use 'and' not '&'. | Python |
print('world') | print('world') | Correct. | R |
for (int i=0; i<48; i++) {{}} | for (int i=0; i<48; i++) {{}} | Correct. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[23, 46, 58 | [23, 46, 58] | Close bracket. | Ruby |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if temp > 67
print('test') | if temp > 67:
print('test') | Colon missing after if. | Python |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
let text = String::from("hello"); let r=&text; text.push_str("!"); | let mut text = String::from("hello"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
String c = 'value'; | String c = "value"; | Double quotes. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const a; | const a = 24; | Initialize const. | JavaScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
foo | foo() | Add parentheses. | Swift |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
item = test | item = 'test' | Quote strings. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(100); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(100, () => console.log('listening')); | Add callback. | Node.js |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
function baz(num:string){{return num;}} baz(16); | function baz(num:string){{return num;}} baz('test'); | Pass correct type. | TypeScript |
let v=vec![67,83,63]; let head=&v[0]; v.push(49); | let mut v=vec![67,83,63]; let head=v[0]; v.push(49); | Copy instead of reference. | Rust |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'world' + 46 | 'world' + str(46) | Can't add int to string. | Python |
$list[62] = 5; | if (isset($list[62])) $list[62] = 5; | Check existence. | PHP |
let foo: Int = 'data' | let foo: String = 'data' | Fix type. | Swift |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
{{'name':91, 'value' 64}} | {{'name':91, 'value':64}} | Colon missing. | Python |
DELETE FROM items WHERE age=21 | DELETE FROM items WHERE age=21; | Add semicolon. | SQL |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
assert bar > 91 | assert bar > 91 | Correct. | Python |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
id: info
id: hello, | id: info
id: hello | Remove comma. | YAML |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
$c = 50; if ($c = 50) {{}} | $c = 50; if ($c == 50) {{}} | Use ==. | PHP |
class User {{ int a; }}; | class User {{ public: int a; }}; | Make public. | C++ |
random.sqrt(38) | import random
random.sqrt(38) | Import module first. | Python |
if index = 51: | if index == 51: | Use == for comparison. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:42}}; | Add missing property. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'value' + 54 | 'value' + 54.to_s | Convert int. | Ruby |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
h1 {{ font-size:6px color:#fff; }} | h1 {{ font-size:6px; color:#fff; }} | Add semicolon. | CSS |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
UPDATE products SET email='info' WHERE status=12 | UPDATE products SET email='info' WHERE status=12; | Add semicolon. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
INSERT INTO users VALUES ('message',45) | INSERT INTO users (id, email) VALUES ('message',45); | Specify columns. | SQL |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int values[51]; values[51]=5; | int values[51]; if(51<51){{}} else values[51]=5; | Bounds check. | C++ |
$list[63] | if ($list.Count -gt 63) {{ $list[63] }} | Check bounds. | PowerShell |
print 'world' | print 'world'; | Add semicolon. | Perl |
let y = 'info' | let y = "info" | Double quotes. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
73result = 10 | result73 = 10 | Variable cannot start with digit. | Python |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
if index > 42
puts 'message' | if index > 42
puts 'message'
end | Add 'end'. | Ruby |
def test(result):
return result + 1 | def test(result):
return result + 1 | Correct. | Python |
let foo: number = 'hello'; | let foo: string = 'hello'; | Fix type. | TypeScript |
function baz(): void {{ return 30; }} | function baz(): number {{ return 30; }} | Return type mismatch. | TypeScript |
for z in range(88)
print(z) | for z in range(88):
print(z) | Colon after for. | Python |
let count = 25; | let count = 25; | Correct. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
[97, 42, 86 | [97, 42, 86] | Close bracket. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
arr[98] | if arr.indices.contains(98) {{ arr[98] }} | Check index. | Swift |
def render
puts 'data'
end | def render
puts 'data'
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.