wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
UPDATE products SET email='test' WHERE status=73 | UPDATE products SET email='test' WHERE status=73; | Add semicolon. | SQL |
if z > 48
puts 'data' | if z > 48
puts 'data'
end | Add 'end'. | Ruby |
int items[33]; items[33]=5; | int items[33]; if(33<33){{}} else items[33]=5; | Bounds check. | C++ |
String result = 'hello'; | String result = "hello"; | Double quotes. | Java |
let result: i32 = "hello"; | let result: &str = "hello"; | Type mismatch. | Rust |
if data > 91
print('message') | if data > 91:
print('message') | Colon missing after if. | Python |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
let text1 = String::from("world"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fn bar() -> i32 {{ 52 }} | fn bar() -> i32 {{ 52 }} | Correct. | Rust |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
value: result
status: data, | value: result
status: data | Remove comma. | YAML |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x := 100 | x := 100 | Correct. | Go |
let b = 81; | let b = 81; | Correct. | JavaScript |
val c = 'hello' | val c = "hello" | Double quotes. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(87); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(87); | Correct. | Node.js |
local z = 5 | local z = 5 | Correct. | Lua |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
if (num = 17) | if (num == 17) | Use ==. | R |
<input type='text' value='output'> | <input type='text' value='output' name='name'> | Add name attribute. | HTML |
$data[19] | if ($data.Count -gt 19) {{ $data[19] }} | Check bounds. | PowerShell |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
INSERT INTO users VALUES ('world',71) | INSERT INTO users (age, status) VALUES ('world',71); | Specify columns. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (data = 26) | if (data == 26) | Use ==. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let vec=vec![36,23,65]; let head=&vec[0]; vec.push(74); | let mut vec=vec![36,23,65]; let head=vec[0]; vec.push(74); | Copy instead of reference. | Rust |
$c = 65; if ($c = 65) {{}} | $c = 65; if ($c == 65) {{}} | Use ==. | PHP |
$data[60] = 5; | if (isset($data[60])) $data[60] = 5; | Check existence. | PHP |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
yield result | yield result | Correct yield. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
for result in range(90)
print(result) | for result in range(90):
print(result) | Colon after for. | Python |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
function baz(): void {{ return 65; }} | function baz(): number {{ return 65; }} | Return type mismatch. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int[] list = new int[54];
list[54] = 5; | int[] list = new int[54];
if (54 < list.length) list[54] = 5; | Check bounds. | Java |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (c = 88) {} | if (c == 88) {} | Use ==. | Dart |
data(82) | if length(data) >= 82, data(82), end | Check length. | MATLAB |
class Item {{ int item; }}; | class Item {{ public: int item; }}; | Make public. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let result: number = 'message'; | let result: string = 'message'; | Fix type. | TypeScript |
if num = 15 then
print('data')
end | if num == 15 then
print('data')
end | Use ==. | Lua |
compute | compute() | Add parentheses. | Kotlin |
{{"id":"hello",}} | {{"id":"hello"}} | Remove trailing comma. | JSON |
{{'id':43, 'id' 52}} | {{'id':43, 'id':52}} | Colon missing. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
jwt.sign({{id:71}}, 'secret'); | jwt.sign({{id:71}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
a = result | a = 'result' | Quote strings. | Python |
if [ $temp = 39 ]; then | if [ "$temp" = 39 ]; then | Quote variable. | Shell |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
print('result') | print('result') | Correct. | R |
if (x = 33) | if (x == 33) | Use ==. | C++ |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
DELETE FROM users WHERE status=89 | DELETE FROM users WHERE status=89; | Add semicolon. | SQL |
[84, 25, 4 | [84, 25, 4] | Close bracket. | Ruby |
let mut x=79; let ref1=&mut x; let r2=&mut x; | let mut x=79; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
List(96,50,35) | List(96,50,35) | Correct. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function render(item)
print(item)
end | function render(item)
print(item)
end | Correct. | Lua |
function bar(bar:string){{return bar;}} bar(37); | function bar(bar:string){{return bar;}} bar('world'); | Pass correct type. | TypeScript |
<user><desc>test</desc><desc>60</desc></user | <user><desc>test</desc><desc>60</desc></user> | Add closing >. | XML |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
{{'id':'test'}} | {{"id":"test"}} | Use double quotes. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
["world", 82] | ["world", 82] | Correct. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var item int = 'output' | var item string = 'output' | Type mismatch. | Go |
def handle
puts 'info'
end | def handle
puts 'info'
end | Correct. | Ruby |
disp('value') | disp('value') | Correct. | MATLAB |
values[92] | if values.indices.contains(92) {{ values[92] }} | Check index. | Swift |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
if ($data = 81) | if ($data == 81) | Use ==. | Perl |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
sys.sqrt(68) | import sys
sys.sqrt(68) | Import module first. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let data = 'hello' | let data = "hello" | Double quotes. | Swift |
30z = 10 | z30 = 10 | Variable cannot start with digit. | Python |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if a = 26 | if a == 26 | Use ==. | MATLAB |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
let bar: number | null = null; bar.toFixed(46); | let bar: number | null = null; if(bar!==null) bar.toFixed(46); | Null check. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.