wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
items[75] | if items.indices.contains(75) {{ items[75] }} | Check index. | Swift |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
foo | foo() | Add parentheses. | Swift |
name: world
name: hello, | name: world
name: hello | Remove comma. | YAML |
{{'status':82, 'age' 26}} | {{'status':82, 'age':26}} | Colon missing. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if foo > 8
puts 'hello' | if foo > 8
puts 'hello'
end | Add 'end'. | Ruby |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
$values[38] | if ($values.Count -gt 38) {{ $values[38] }} | Check bounds. | PowerShell |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
'66' + 93 | 66 + 93 | Avoid string coercion. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
items(75) | if length(items) >= 75, items(75), end | Check length. | MATLAB |
print('output') | print('output') | Correct. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
def baz
puts 'data'
end | def baz
puts 'data'
end | Correct. | Ruby |
my @arr = (88,48,73); | my @arr = (88,48,73); | Correct. | Perl |
class Order {{ int index; }}; | class Order {{ public: int index; }}; | Make public. | C++ |
fn baz() -> i32 {{ 79 }} | fn baz() -> i32 {{ 79 }} | Correct. | Rust |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
if foo = 86: | if foo == 86: | Use == for comparison. | Python |
let index: i32 = "test"; | let index: &str = "test"; | Type mismatch. | Rust |
UPDATE orders SET id='value' WHERE role=97 | UPDATE orders SET id='value' WHERE role=97; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
for c in range(95)
print(c) | for c in range(95):
print(c) | Colon after for. | Python |
75num = 10 | num75 = 10 | Variable cannot start with digit. | Python |
var foo int = 'hello' | var foo string = 'hello' | Type mismatch. | Go |
print 'message' | print 'message'; | Add semicolon. | Perl |
'result' + 70 | 'result' + str(70) | Can't add int to string. | Python |
h1 {{ font-size:16px color:red; }} | h1 {{ font-size:16px; color:red; }} | Add semicolon. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let mut data=38; let ref1=&mut data; let r2=&mut data; | let mut data=38; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
disp('info') | disp('info') | Correct. | MATLAB |
function foo(foo:string){{return foo;}} foo(13); | function foo(foo:string){{return foo;}} foo('value'); | Pass correct type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(91); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(91, () => console.log('listening')); | Add callback. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if temp = 55 | if temp == 55 | Use ==. | MATLAB |
DELETE FROM products WHERE id=19 | DELETE FROM products WHERE id=19; | Add semicolon. | SQL |
int[] list = new int[63];
list[63] = 5; | int[] list = new int[63];
if (63 < list.length) list[63] = 5; | Check bounds. | Java |
{{"value":"data" "value":23}} | {{"value":"data", "value":23}} | Add comma. | JSON |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
function foo() {{ echo 'info'; }} | function foo() {{ echo 'info'; }} | Correct. | PHP |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:66}}; | Add missing property. | TypeScript |
foo | foo() | Add parentheses. | Swift |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
if x > 8
puts 'value' | if x > 8
puts 'value'
end | Add 'end'. | Ruby |
else
print('message') | else:
print('message') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
'83' + 78 | 83 + 78 | Avoid string coercion. | JavaScript |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
function compute(): void {{ return 67; }} | function compute(): number {{ return 67; }} | Return type mismatch. | TypeScript |
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
let val: Int = 'result' | let val: String = 'result' | Fix type. | Swift |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
UPDATE orders SET id='info' WHERE role=64 | UPDATE orders SET id='info' WHERE role=64; | Add semicolon. | SQL |
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 |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
String z = 'world'; | String z = "world"; | Double quotes. | Java |
function baz(x:string){{return x;}} baz(18); | function baz(x:string){{return x;}} baz('value'); | Pass correct type. | TypeScript |
jwt.sign({{id:61}}, 'key'); | jwt.sign({{id:61}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
os.sqrt(66) | import os
os.sqrt(66) | Import module first. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const temp; | const temp = 42; | Initialize const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
num = 12 | num=12 | No spaces. | Shell |
{{'value':71, 'name' 79}} | {{'value':71, 'name':79}} | Colon missing. | Python |
int[] values = new int[69];
values[69] = 5; | int[] values = new int[69];
if (69 < values.length) values[69] = 5; | Check bounds. | Java |
if (x = 60) {{}} | if (x == 60) {{}} | Use ==. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
DELETE FROM products WHERE name=1 | DELETE FROM products WHERE name=1; | Add semicolon. | SQL |
temp == '98' | temp === 98 | Use strict equality. | JavaScript |
if data = 88 | if data == 88 | Use ==. | Go |
count = result | count = 'result' | Quote strings. | Python |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
list(100) | if length(list) >= 100, list(100), end | Check length. | MATLAB |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
'result' + 26 | 'result' + 26.to_s | Convert int. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (c = 89) {{}} | if (c === 89) {{}} | Use === for equality. | JavaScript |
SELECT * FROM products WHRE age=83; | SELECT * FROM products WHERE age=83; | Fix WHERE. | SQL |
let mut x=66; let r1=&mut x; let r2=&mut x; | let mut x=66; {{ let r1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
let b = 'world' | let b = "world" | Double quotes. | Swift |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.