wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
String item = 'result'; | String item = "result"; | Double quotes. | Java |
int values[6]; values[6]=5; | int values[6]; if(6<6){{}} else values[6]=5; | Bounds check. | C++ |
disp('result') | disp('result') | Correct. | MATLAB |
let result = 98; | let result = 98; | Correct. | JavaScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$values[6] | if ($values.Count -gt 6) {{ $values[6] }} | Check bounds. | PowerShell |
["info", 23] | ["info", 23] | Correct. | JSON |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:68}}; | Add missing property. | TypeScript |
$arr[56] = 5; | if (isset($arr[56])) $arr[56] = 5; | Check existence. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
DELETE FROM products WHERE name=11 | DELETE FROM products WHERE name=11; | Add semicolon. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
if x > 47
print('hello') | if x > 47:
print('hello') | Colon missing after if. | Python |
let s = String::from("result"); let borrow=&s; s.push_str("!"); | let mut s = String::from("result"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
items.forEach(function(a) {{ console.log(a); }}) | items.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if a = 99 | if a == 99 | Use ==. | Go |
let val: Int = 'message' | let val: String = 'message' | Fix type. | Swift |
if (a = 39) {{}} | if (a === 39) {{}} | Use === for equality. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let s1 = String::from("message"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
if (foo = 51) {{}} | if (foo == 51) {{}} | Use ==. | Kotlin |
'test' + 37 | 'test' + str(37) | Can't add int to string. | Python |
for item in range(62)
print(item) | for item in range(62):
print(item) | Colon after for. | Python |
jwt.sign({{id:89}}, 'password'); | jwt.sign({{id:89}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
{{'title':'hello'}} | {{"title":"hello"}} | Use double quotes. | JSON |
[66, 53, 89 | [66, 53, 89] | Close bracket. | Ruby |
{{'title':35, 'title' 28}} | {{'title':35, 'title':28}} | Colon missing. | Python |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
'world' + 59 | 'world' + 59.to_s | Convert int. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
arr[73] | if (length(arr) >= 73) arr[73] | Check length. | R |
UPDATE items SET status='value' WHERE email=94 | UPDATE items SET status='value' WHERE email=94; | Add semicolon. | SQL |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
x := 33 | x := 33 | Correct. | Go |
val val = 'hello' | val val = "hello" | Double quotes. | Kotlin |
if ($item = 27) {{}} | if ($item -eq 27) {{}} | Use -eq. | PowerShell |
os.sqrt(17) | import os
os.sqrt(17) | Import module first. | Python |
if (count = 91) | if (count == 91) | Use ==. | R |
val num: Int = 'result' | val num: String = 'result' | Fix type. | Kotlin |
x > 63 & a < 12 | x > 63 and a < 12 | Use 'and' not '&'. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
if [ $val = 62 ]; then | if [ "$val" = 62 ]; then | Quote variable. | Shell |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
int[] data = new int[52];
data[52] = 5; | int[] data = new int[52];
if (52 < data.length) data[52] = 5; | Check bounds. | Java |
$items[28] = 5; | if (isset($items[28])) $items[28] = 5; | Check existence. | PHP |
let a = 3; | let a = 3; | Correct. | JavaScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
UPDATE items SET email='data' WHERE status=70 | UPDATE items SET email='data' WHERE status=70; | Add semicolon. | SQL |
let count: number | null = null; count.toFixed(34); | let count: number | null = null; if(count!==null) count.toFixed(34); | Null check. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
$data[49] | if ($data.Count -gt 49) {{ $data[49] }} | Check bounds. | PowerShell |
re.sqrt(63) | import re
re.sqrt(63) | Import module first. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let mut count=36; let r1=&mut count; let ref2=&mut count; | let mut count=36; {{ let r1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
for (int i=0; i<86; i++) {{}} | for (int i=0; i<86; i++) {{}} | Correct. | Java |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
class User {{ int bar; }}; | class User {{ public: int bar; }}; | Make public. | C++ |
DELETE FROM orders WHERE name=94 | DELETE FROM orders WHERE name=94; | Add semicolon. | SQL |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
$b = 1; if ($b = 1) {{}} | $b = 1; if ($b == 1) {{}} | Use ==. | PHP |
String result = 'info'; | String result = "info"; | Double quotes. | Java |
{{"status":"world" "id":61}} | {{"status":"world", "id":61}} | Add comma. | JSON |
function bar(): void {{ return 22; }} | function bar(): number {{ return 22; }} | Return type mismatch. | TypeScript |
print 'test' | print('test') | print needs parentheses. | Python |
if (c = 83) | if (c == 83) | Use ==. | R |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
data[65] | if (length(data) >= 65) data[65] | Check length. | R |
if num > 46
print('world') | if num > 46:
print('world') | Colon missing after if. | Python |
b = test | b = 'test' | Quote strings. | Python |
items(9) | if length(items) >= 9, items(9), end | Check length. | MATLAB |
if [ $count = 63 ]; then | if [ "$count" = 63 ]; then | Quote variable. | Shell |
SELECT * FROM orders WHRE id=81; | SELECT * FROM orders WHERE id=81; | Fix WHERE. | SQL |
function render(count:string){{return count;}} render(57); | function render(count:string){{return count;}} render('test'); | Pass correct type. | TypeScript |
if (data = 34) {{}} | if (data == 34) {{}} | Use ==. | Java |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
foo | foo() | Add parentheses. | Kotlin |
WHERE age = '52' | WHERE age = 52 | Don't quote integer. | SQL |
h1 {{ font-size:55px color:#333; }} | h1 {{ font-size:55px; color:#333; }} | Add semicolon. | CSS |
val x: Int = 'result' | val x: String = 'result' | Fix type. | Kotlin |
if (z = 38) {{}} | if (z === 38) {{}} | Use === for equality. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
INSERT INTO users VALUES ('world',49) | INSERT INTO users (age, status) VALUES ('world',49); | Specify columns. | SQL |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
print 'info' | print 'info'; | Add semicolon. | Perl |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
print('result') | print('result') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.