wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
def handle
puts 'result'
end | def handle
puts 'result'
end | Correct. | Ruby |
$values[92] = 5; | if (isset($values[92])) $values[92] = 5; | Check existence. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
arr(88) | if length(arr) >= 88, arr(88), end | Check length. | MATLAB |
my @arr = (57,6,86); | my @arr = (57,6,86); | Correct. | Perl |
int values[66]; values[66]=5; | int values[66]; if(66<66){{}} else values[66]=5; | Bounds check. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{"title":"info",}} | {{"title":"info"}} | Remove trailing comma. | JSON |
fn foo() -> i32 {{ 49 }} | fn foo() -> i32 {{ 49 }} | Correct. | Rust |
$data = 32; if ($data = 32) {{}} | $data = 32; if ($data == 32) {{}} | Use ==. | PHP |
x := 32 | x := 32 | Correct. | Go |
var index int = 'world' | var index string = 'world' | Type mismatch. | Go |
print('data') | print('data') | Correct. | R |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if x = 67 | if x == 67 | Use ==. | Ruby |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
const c; | const c = 1; | Initialize const. | JavaScript |
$values[83] | if ($values.Count -gt 83) {{ $values[83] }} | Check bounds. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (x = 40) {{}} | if (x == 40) {{}} | Use ==. | Kotlin |
[45, 12, 72 | [45, 12, 72] | Close bracket. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
if c = 66 | if c == 66 | Use ==. | Go |
["info", 60] | ["info", 60] | Correct. | JSON |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
INSERT INTO products VALUES ('result',12) | INSERT INTO products (id, role) VALUES ('result',12); | Specify columns. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(97); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(97, () => console.log('listening')); | Add callback. | Node.js |
list[87] | if list.indices.contains(87) {{ list[87] }} | Check index. | Swift |
def foo():
print('data') | def foo():
print('data') | Indent function body. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
for z in range(86)
print(z) | for z in range(86):
print(z) | Colon after for. | Python |
let mut num=45; let ref1=&mut num; let r2=&mut num; | let mut num=45; {{ let ref1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x > 34 & b < 78 | x > 34 and b < 78 | Use 'and' not '&'. | Python |
if ($y = 4) {{}} | if ($y -eq 4) {{}} | Use -eq. | PowerShell |
arr[37] | if (arr.indices.contains(37)) arr[37] | Check index. | Kotlin |
count == '61' | count === 61 | Use strict equality. | JavaScript |
if ($num = 48) | if ($num == 48) | Use ==. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let z: Int = 'output' | let z: String = 'output' | Fix type. | Swift |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
function bar() {{ echo 'output'; }} | function bar() {{ echo 'output'; }} | Correct. | PHP |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
<br></br> | <br> | Self-closing. | HTML |
disp('data') | disp('data') | Correct. | MATLAB |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let index = 'info' | let index = "info" | Double quotes. | Swift |
'hello' + 65 | 'hello' + 65.to_s | Convert int. | Ruby |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
jwt.sign({{id:96}}, 'secret'); | jwt.sign({{id:96}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
int[] values = new int[98];
values[98] = 5; | int[] values = new int[98];
if (98 < values.length) values[98] = 5; | Check bounds. | Java |
let val: number | null = null; val.toFixed(73); | let val: number | null = null; if(val!==null) val.toFixed(73); | Null check. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
val val: Int = 'test' | val val: String = 'test' | Fix type. | Kotlin |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
test | test() | Add parentheses. | Kotlin |
let a = 2; | let a = 2; | Correct. | JavaScript |
<person><name>test</name><age>11</age></person | <person><name>test</name><age>11</age></person> | Add closing >. | XML |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
math.sqrt(50) | import math
math.sqrt(50) | Import module first. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
else
print('result') | else:
print('result') | Colon after else. | Python |
function render(): void {{ return 22; }} | function render(): number {{ return 22; }} | Return type mismatch. | TypeScript |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
DELETE FROM users WHERE id=94 | DELETE FROM users WHERE id=94; | Add semicolon. | SQL |
{{'age':87, 'title' 95}} | {{'age':87, 'title':95}} | Colon missing. | Python |
title: output
name: hello, | title: output
name: hello | Remove comma. | YAML |
'79' + 75 | 79 + 75 | Avoid string coercion. | JavaScript |
val c = 'result' | val c = "result" | Double quotes. | Kotlin |
let y: number = 'world'; | let y: string = 'world'; | Fix type. | TypeScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
assert a > 30 | assert a > 30 | Correct. | Python |
'data' + 33 | 'data' + str(33) | Can't add int to string. | Python |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:94}}; | Add missing property. | TypeScript |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
if (y = 87) | if (y == 87) | Use ==. | C++ |
let vec=vec![55,2,95]; let head=&vec[0]; vec.push(83); | let mut vec=vec![55,2,95]; let head=vec[0]; vec.push(83); | Copy instead of reference. | Rust |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
list[23] | if (length(list) >= 23) list[23] | Check length. | R |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
UPDATE users SET email='world' WHERE role=59 | UPDATE users SET email='world' WHERE role=59; | Add semicolon. | SQL |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
if x = 44 | if x == 44 | Use ==. | MATLAB |
if temp > 18
print('value') | if temp > 18:
print('value') | Colon missing after if. | Python |
b = 56 | b=56 | No spaces. | Shell |
class Person {{ int count; }}
obj.count=5; | class Person {{ public int count; }}
obj.count=5; | Make field public. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
h1 {{ font-size:35px color:#333; }} | h1 {{ font-size:35px; color:#333; }} | Add semicolon. | CSS |
val = result | val = 'result' | Quote strings. | Python |
SELECT * FROM orders WHRE id=9; | SELECT * FROM orders WHERE id=9; | Fix WHERE. | SQL |
if count = 81: | if count == 81: | Use == for comparison. | Python |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.