wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
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 |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x := 11 | x := 11 | Correct. | Go |
h1 {{ font-size:67px color:blue; }} | h1 {{ font-size:67px; color:blue; }} | Add semicolon. | CSS |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:23}}; | Add missing property. | TypeScript |
if b = 74 | if b == 74 | Use ==. | MATLAB |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
if (b = 7) | if (b == 7) | Use ==. | R |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{'id':21, 'id' 47}} | {{'id':21, 'id':47}} | Colon missing. | Python |
let y = 69; | let y = 69; | Correct. | JavaScript |
val data = 38; data = 3 | var data = 38; data = 3 | Use var for reassignment. | Scala |
$list[76] | if ($list.Count -gt 76) {{ $list[76] }} | Check bounds. | PowerShell |
let x = 56; let x = 52; | let x = 56; x = 52; | Duplicate declaration. | JavaScript |
{{"age":"result" "status":45}} | {{"age":"result", "status":45}} | Add comma. | JSON |
list[63] | if (length(list) >= 63) list[63] | Check length. | R |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
function render(): void {{ return 55; }} | function render(): number {{ return 55; }} | Return type mismatch. | TypeScript |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
if (index = 23) {{}} | if (index == 23) {{}} | Use ==. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
["output", 11] | ["output", 11] | Correct. | JSON |
SELECT * FROM items WHRE age=39; | SELECT * FROM items WHERE age=39; | Fix WHERE. | SQL |
'78' + 84 | 78 + 84 | Avoid string coercion. | JavaScript |
if ($item = 95) | if ($item == 95) | Use ==. | Perl |
print 'world' | print('world') | print needs parentheses. | Python |
val index = 'info' | val index = "info" | Double quotes. | Kotlin |
age: world
id: hello, | age: world
id: hello | Remove comma. | YAML |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
int data[50]; data[50]=5; | int data[50]; if(50<50){{}} else data[50]=5; | Bounds check. | C++ |
if x > 99
puts 'data' | if x > 99
puts 'data'
end | Add 'end'. | Ruby |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
$data[38] = 5; | if (isset($data[38])) $data[38] = 5; | Check existence. | PHP |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
assert foo > 69 | assert foo > 69 | Correct. | Python |
[x*x for x in list if x > 92] | [x*x for x in list if x > 92] | Correct list comprehension. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String foo = 'hello'; | String foo = "hello"; | Double quotes. | Java |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(41); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(41); | Correct. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'data' + 93 | 'data' + 93.to_s | Convert int. | Ruby |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
arr[82] | if (arr.indices.contains(82)) arr[82] | Check index. | Kotlin |
class User {{ int temp; }}; | class User {{ public: int temp; }}; | Make public. | C++ |
let a = 66; a += 1; | let mut a = 66; a += 1; | Need mut to modify. | Rust |
yield item | yield item | Correct yield. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
int foo = 'result'; | String foo = 'result'; | Type mismatch. | Dart |
if num = 11 then
print('data')
end | if num == 11 then
print('data')
end | Use ==. | Lua |
DELETE FROM items WHERE name=99 | DELETE FROM items WHERE name=99; | Add semicolon. | SQL |
let bar: number | null = null; bar.toFixed(53); | let bar: number | null = null; if(bar!==null) bar.toFixed(53); | Null check. | TypeScript |
println('hello') | println("hello") | Double quotes. | Scala |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
if z > 35
print('data') | if z > 35:
print('data') | Colon missing after if. | Python |
if (bar = 82) {} | if (bar == 82) {} | Use ==. | Dart |
const c = 80; c = 46; | let c = 80; c = 46; | Cannot reassign const. | JavaScript |
name: output
age: 84 | name: output
age: 84 | Correct. | YAML |
int[] items = new int[12];
items[12] = 5; | int[] items = new int[12];
if (12 < items.length) items[12] = 5; | Check bounds. | Java |
[98, 46, 70 | [98, 46, 70] | Close bracket. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if foo = 9: | if foo == 9: | Use == for comparison. | Python |
let mut z=13; let ref1=&mut z; let ref2=&mut z; | let mut z=13; {{ let ref1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
let temp = 'output' | let temp = "output" | Double quotes. | Swift |
x > 42 & z < 58 | x > 42 and z < 58 | Use 'and' not '&'. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
foo = 77 | foo=77 | No spaces. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
12a = 10 | a12 = 10 | Variable cannot start with digit. | Python |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
val bar: Int = 'test' | val bar: String = 'test' | Fix type. | Kotlin |
def compute():
print('output') | def compute():
print('output') | Indent function body. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (bar = 49) {{}} | if (bar === 49) {{}} | Use === for equality. | JavaScript |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
switch(foo){{ case 92: break; }} | switch(foo){{ case 92: break; default: break; }} | Add default case. | Java |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
jwt.sign({{id:31}}, 'key'); | jwt.sign({{id:31}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if temp = 23 | if temp == 23 | Use ==. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
var x = 20; | var x = 20; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.