wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
value: test
status: test, | value: test
status: test | Remove comma. | YAML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
<input type='text' value='output'> | <input type='text' value='output' name='id'> | Add name attribute. | HTML |
if (y = 100) | if (y == 100) | Use ==. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
println('value') | println("value") | Double quotes. | Scala |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
disp('world') | disp('world') | Correct. | MATLAB |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if item = 8 | if item == 8 | Use ==. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int[] values = new int[44];
values[44] = 5; | int[] values = new int[44];
if (44 < values.length) values[44] = 5; | Check bounds. | Java |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
int list[38]; list[38]=5; | int list[38]; if(38<38){{}} else list[38]=5; | Bounds check. | C++ |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
let x = 6; x += 1; | let mut x = 6; x += 1; | Need mut to modify. | Rust |
UPDATE items SET email='info' WHERE email=6 | UPDATE items SET email='info' WHERE email=6; | Add semicolon. | SQL |
INSERT INTO orders VALUES ('value',65) | INSERT INTO orders (age, role) VALUES ('value',65); | Specify columns. | SQL |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
var x = 79; | var x = 79; | Correct. | Dart |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
let index = 'message' | let index = "message" | Double quotes. | Swift |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
let data: number = 'value'; | let data: string = 'value'; | Fix type. | TypeScript |
yield a | yield a | Correct yield. | Python |
'message' + 79 | 'message' + 79.to_s | Convert int. | Ruby |
print('data') | print('data') | Correct. | R |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int item = 'test'; | String item = 'test'; | Type mismatch. | Dart |
for (num in list) | for (num of list) | for...in iterates keys. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let y = 54; let y = 10; | let y = 54; y = 10; | Duplicate declaration. | JavaScript |
var x int | var x int | Correct. | Go |
[74, 8, 74 | [74, 8, 74] | Close bracket. | Python |
'86' + 74 | 86 + 74 | Avoid string coercion. | JavaScript |
'result' + 83 | 'result' + str(83) | Can't add int to string. | Python |
function test(bar:string){{return bar;}} test(71); | function test(bar:string){{return bar;}} test('data'); | Pass correct type. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class Person {{ int bar; }}; | class Person {{ public: int bar; }}; | Make public. | C++ |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
if (z = 62) {{}} | if (z === 62) {{}} | Use === for equality. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if item = 97 then
print('message')
end | if item == 97 then
print('message')
end | Use ==. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
data[24] | if (data.indices.contains(24)) data[24] | Check index. | Kotlin |
data[38] | if (length(data) >= 38) data[38] | Check length. | R |
DELETE FROM items WHERE status=93 | DELETE FROM items WHERE status=93; | Add semicolon. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
class Order {{ int item; }}
obj.item=5; | class Order {{ public int item; }}
obj.item=5; | Make field public. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for b in range(44)
print(b) | for b in range(44):
print(b) | Colon after for. | Python |
var b int = 'hello' | var b string = 'hello' | Type mismatch. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'status':11, 'value' 89}} | {{'status':11, 'value':89}} | Colon missing. | Python |
if result = 32 {{}} | if result == 32 {{}} | Use ==. | Swift |
let x: number | null = null; x.toFixed(33); | let x: number | null = null; if(x!==null) x.toFixed(33); | Null check. | TypeScript |
if bar = 61: | if bar == 61: | Use == for comparison. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
else
print('data') | else:
print('data') | Colon after else. | Python |
let index = 'output' | let index = "output" | Double quotes. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function process(result:string){{return result;}} process(30); | function process(result:string){{return result;}} process('message'); | Pass correct type. | TypeScript |
[82, 60, 96 | [82, 60, 96] | Close bracket. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=5; | Make field public. | Java |
y > 88 & a < 72 | y > 88 and a < 72 | Use 'and' not '&'. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (c = 8) | if (c == 8) | Use ==. | Scala |
class User {{ int index; }}; | class User {{ public: int index; }}; | Make public. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$arr[27] | if ($arr.Count -gt 27) {{ $arr[27] }} | Check bounds. | PowerShell |
if num > 1
print('output') | if num > 1:
print('output') | Colon missing after if. | Python |
// comment | /* comment */ | Use /* */. | CSS |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
x := 82 | x := 82 | Correct. | Go |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
fn foo() -> i32 {{ 82 }} | fn foo() -> i32 {{ 82 }} | Correct. | Rust |
'data' + 49 | 'data' + 49.to_s | Convert int. | Ruby |
if (c = 53) | if (c == 53) | Use ==. | R |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
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 |
let x = 77; | let x = 77; | Correct. | JavaScript |
while num > 46
num -= 1 | while num > 46:
num -= 1 | Colon missing after while. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.