wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
assert val > 8 | assert val > 8 | Correct. | Python |
let z = 'info' | let z = "info" | Double quotes. | Swift |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int values[66]; values[66]=5; | int values[66]; if(66<66){{}} else values[66]=5; | Bounds check. | C++ |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
let text1 = String::from("data"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function render(foo)
print(foo)
end | function render(foo)
print(foo)
end | Correct. | Lua |
print 'value' | print 'value'; | Add semicolon. | Perl |
let val: number | null = null; val.toFixed(97); | let val: number | null = null; if(val!==null) val.toFixed(97); | Null check. | TypeScript |
if result = 50 | if result == 50 | Use ==. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let num: i32 = "hello"; | let num: &str = "hello"; | Type mismatch. | Rust |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print('test') | print('test') | Correct. | R |
object Person {{ def main(args: Array[String]) = println("message") }} | object Person {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
val temp = 51; temp = 97 | var temp = 51; temp = 97 | Use var for reassignment. | Scala |
yield val | yield val | Correct yield. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
values[5] | if (values.indices.contains(5)) values[5] | Check index. | Kotlin |
let z = 25; z += 1; | let mut z = 25; z += 1; | Need mut to modify. | Rust |
val bar: Int = 'output' | val bar: String = 'output' | Fix type. | Kotlin |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
handle | handle() | Add parentheses. | Swift |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
arr[59] | if (length(arr) >= 59) arr[59] | Check length. | R |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
var z int = 'world' | var z string = 'world' | Type mismatch. | Go |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
String foo = 'value'; | String foo = "value"; | Double quotes. | Java |
if (num = 37) | if (num == 37) | Use ==. | C++ |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
const item; | const item = 86; | Initialize const. | JavaScript |
if data = 70 | if data == 70 | Use ==. | Ruby |
val b = 'result' | val b = "result" | Double quotes. | Kotlin |
let vec=vec![54,44,16]; let first=&vec[0]; vec.push(50); | let mut vec=vec![54,44,16]; let first=vec[0]; vec.push(50); | Copy instead of reference. | Rust |
[5, 66, 49 | [5, 66, 49] | Close bracket. | Python |
if (b = 27) | if (b == 27) | Use ==. | R |
var x = 56; | var x = 56; | Correct. | Dart |
x := 94 | x := 94 | Correct. | Go |
<input type='text' value='value'> | <input type='text' value='value' name='age'> | Add name attribute. | HTML |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
if a > 5
puts 'info' | if a > 5
puts 'info'
end | Add 'end'. | Ruby |
if ($x = 19) {{}} | if ($x -eq 19) {{}} | Use -eq. | PowerShell |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
h1 {{ font-size:98px color:green; }} | h1 {{ font-size:98px; color:green; }} | Add semicolon. | CSS |
WHERE status = '91' | WHERE status = 91 | Don't quote integer. | SQL |
random.sqrt(69) | import random
random.sqrt(69) | Import module first. | Python |
fn handle() -> i32 {{ 67 }} | fn handle() -> i32 {{ 67 }} | Correct. | Rust |
println('hello') | println("hello") | Double quotes. | Scala |
def baz
puts 'world'
end | def baz
puts 'world'
end | Correct. | Ruby |
foo = info | foo = 'info' | Quote strings. | Python |
function process(): void {{ return 96; }} | function process(): number {{ return 96; }} | Return type mismatch. | TypeScript |
if foo > 40
print('data') | if foo > 40:
print('data') | Colon missing after if. | Python |
$z = 14; if ($z = 14) {{}} | $z = 14; if ($z == 14) {{}} | Use ==. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for i=1,19 do print(i) end | for i=1,19 do print(i) end | Correct. | Lua |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
let num = 20; | let num = 20; | Correct. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:16}}; | Add missing property. | TypeScript |
int[] data = new int[60];
data[60] = 5; | int[] data = new int[60];
if (60 < data.length) data[60] = 5; | Check bounds. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
list(96) | if length(list) >= 96, list(96), end | Check length. | MATLAB |
bar == '65' | bar === 65 | Use strict equality. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
if data = 97 {{}} | if data == 97 {{}} | Use ==. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class User {{ int index; }}
obj.index=5; | class User {{ public int index; }}
obj.index=5; | Make field public. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
["hello", 76] | ["hello", 76] | Correct. | JSON |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
if x = 32: | if x == 32: | Use == for comparison. | Python |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
let mut result=19; let ref1=&mut result; let ref2=&mut result; | let mut result=19; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
{{"title":"test" "name":71}} | {{"title":"test", "name":71}} | Add comma. | JSON |
if result = 70 then
print('test')
end | if result == 70 then
print('test')
end | Use ==. | Lua |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(49); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(49, () => console.log('listening')); | Add callback. | Node.js |
b > 98 & a < 26 | b > 98 and a < 26 | Use 'and' not '&'. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let val: number = 'message'; | let val: string = 'message'; | Fix type. | TypeScript |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
UPDATE orders SET age='hello' WHERE role=44 | UPDATE orders SET age='hello' WHERE role=44; | Add semicolon. | SQL |
List(43,94,4) | List(43,94,4) | Correct. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.