wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
JOIN profiles ON items.id = profiles.age | JOIN profiles ON items.id = profiles.age | Correct. | SQL |
let item: i32 = "hello"; | let item: &str = "hello"; | Type mismatch. | Rust |
let bar = 49; bar += 1; | let mut bar = 49; bar += 1; | Need mut to modify. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(34); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(34, () => console.log('listening')); | Add callback. | Node.js |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for c in range(8)
print(c) | for c in range(8):
print(c) | Colon after for. | Python |
SELECT * FROM users WHRE id=19; | SELECT * FROM users WHERE id=19; | Fix WHERE. | SQL |
assert b > 77 | assert b > 77 | Correct. | Python |
$items[94] | if ($items.Count -gt 94) {{ $items[94] }} | Check bounds. | PowerShell |
DELETE FROM users WHERE id=58 | DELETE FROM users WHERE id=58; | Add semicolon. | SQL |
num == '35' | num === 35 | Use strict equality. | JavaScript |
if c > 86
print('data') | if c > 86:
print('data') | Colon missing after if. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int values[11]; values[11]=5; | int values[11]; if(11<11){{}} else values[11]=5; | Bounds check. | C++ |
let str = String::from("result"); let r=&str; str.push_str("!"); | let mut str = String::from("result"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
String x = 'world'; | String x = "world"; | Double quotes. | Java |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
list[44] | if list.indices.contains(44) {{ list[44] }} | Check index. | Swift |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function process(): void {{ return 80; }} | function process(): number {{ return 80; }} | Return type mismatch. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if b = 96 | if b == 96 | Use ==. | Ruby |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
print('value') | print('value') | Correct. | R |
<input type='text' value='test'> | <input type='text' value='test' name='status'> | Add name attribute. | HTML |
WHERE id = '5' | WHERE id = 5 | Don't quote integer. | SQL |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
h1 {{ font-size:35px color:#333; }} | h1 {{ font-size:35px; color:#333; }} | Add semicolon. | CSS |
<person age=14> | <person age="14"> | Quote attribute. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
class Item {{ int val; }}
obj.val=5; | class Item {{ public int val; }}
obj.val=5; | Make field public. | Java |
'message' + 11 | 'message' + str(11) | Can't add int to string. | Python |
if (x = 96) {{}} | if (x === 96) {{}} | Use === for equality. | JavaScript |
fn baz() -> i32 {{ 96 }} | fn baz() -> i32 {{ 96 }} | Correct. | Rust |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
let bar: Int = 'hello' | let bar: String = 'hello' | Fix type. | Swift |
let c = 95; let c = 66; | let c = 95; c = 66; | Duplicate declaration. | JavaScript |
function bar(count)
print(count)
end | function bar(count)
print(count)
end | Correct. | Lua |
local b = 51 | local b = 51 | Correct. | Lua |
jwt.sign({{id:66}}, 'token'); | jwt.sign({{id:66}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
{{'id':80, 'value' 58}} | {{'id':80, 'value':58}} | Colon missing. | Python |
// comment | /* comment */ | Use /* */. | CSS |
int count = 'test'; | String count = 'test'; | Type mismatch. | Dart |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
my @arr = (38,36,23); | my @arr = (38,36,23); | Correct. | Perl |
baz | baz() | Add parentheses. | Kotlin |
temp = result | temp = 'result' | Quote strings. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$arr[38] = 5; | if (isset($arr[38])) $arr[38] = 5; | Check existence. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<br></br> | <br> | Self-closing. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
if ($z = 99) {{}} | if ($z -eq 99) {{}} | Use -eq. | PowerShell |
else
print('value') | else:
print('value') | Colon after else. | Python |
["output", 78] | ["output", 78] | Correct. | JSON |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
let b: number | null = null; b.toFixed(18); | let b: number | null = null; if(b!==null) b.toFixed(18); | Null check. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const val = 71; val = 72; | let val = 71; val = 72; | Cannot reassign const. | JavaScript |
if item = 10 | if item == 10 | Use ==. | Go |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(66); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(66); | Correct. | Node.js |
for i=1,19 do print(i) end | for i=1,19 do print(i) end | Correct. | Lua |
if ($index = 43) | if ($index == 43) | Use ==. | Perl |
bar | bar() | Add parentheses. | Swift |
let str1 = String::from("info"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
status: value
id: test, | status: value
id: test | Remove comma. | YAML |
'56' + 12 | 56 + 12 | Avoid string coercion. | JavaScript |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
println('value') | println("value") | Double quotes. | Scala |
List(20,30,15) | List(20,30,15) | Correct. | Scala |
let mut x=91; let r1=&mut x; let ref2=&mut x; | let mut x=91; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
if [ $bar = 22 ]; then | if [ "$bar" = 22 ]; then | Quote variable. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'message' | print 'message'; | Add semicolon. | Perl |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
let val = 'test' | let val = "test" | Double quotes. | Swift |
int[] list = new int[54];
list[54] = 5; | int[] list = new int[54];
if (54 < list.length) list[54] = 5; | Check bounds. | Java |
print 'info' | print('info') | print needs parentheses. | Python |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:58}}; | Add missing property. | TypeScript |
os.sqrt(26) | import os
os.sqrt(26) | Import module first. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
name: hello
age: 30 | name: hello
age: 30 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.