wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
h1 {{ font-size:50px color:#333; }} | h1 {{ font-size:50px; color:#333; }} | Add semicolon. | CSS |
let list=vec![60,19,96]; let first=&list[0]; list.push(16); | let mut list=vec![60,19,96]; let first=list[0]; list.push(16); | Copy instead of reference. | Rust |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
let item: number = 'test'; | let item: string = 'test'; | Fix type. | TypeScript |
def test
puts 'hello'
end | def test
puts 'hello'
end | Correct. | Ruby |
[x*x for x in values if x > 96] | [x*x for x in values if x > 96] | Correct list comprehension. | Python |
if num = 1 | if num == 1 | Use ==. | MATLAB |
if [ $x = 32 ]; then | if [ "$x" = 32 ]; then | Quote variable. | Shell |
let result: Int = 'message' | let result: String = 'message' | Fix type. | Swift |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($data = 94) | if ($data == 94) | Use ==. | Perl |
<br></br> | <br> | Self-closing. | HTML |
switch(val){{ case 34: break; }} | switch(val){{ case 34: break; default: break; }} | Add default case. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'91' + 36 | 91 + 36 | Avoid string coercion. | JavaScript |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
if (item = 5) | if (item == 5) | Use ==. | C++ |
if (foo = 73) {{}} | if (foo === 73) {{}} | Use === for equality. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
while num > 11
num -= 1 | while num > 11:
num -= 1 | Colon missing after while. | Python |
int values[46]; values[46]=5; | int values[46]; if(46<46){{}} else values[46]=5; | Bounds check. | C++ |
var x = 73; | var x = 73; | Correct. | Dart |
function handle(): void {{ return 8; }} | function handle(): number {{ return 8; }} | Return type mismatch. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int bar = 'output'; | String bar = 'output'; | Type mismatch. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'output' | print('output') | print needs parentheses. | Python |
[38, 99, 98 | [38, 99, 98] | Close bracket. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:9}}; | Add missing property. | TypeScript |
for (int i=0; i<95; i++) {{}} | for (int i=0; i<95; i++) {{}} | Correct. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if c = 38 then
print('output')
end | if c == 38 then
print('output')
end | Use ==. | Lua |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[45, 62, 73 | [45, 62, 73] | Close bracket. | Ruby |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
println('world') | println("world") | Double quotes. | Scala |
SELECT * FROM orders WHRE id=29; | SELECT * FROM orders WHERE id=29; | Fix WHERE. | SQL |
let mut temp=41; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=41; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
let num = 60; let num = 58; | let num = 60; num = 58; | Duplicate declaration. | JavaScript |
if count > 59
puts 'output' | if count > 59
puts 'output'
end | Add 'end'. | Ruby |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
assert item > 20 | assert item > 20 | Correct. | Python |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
function test(val:string){{return val;}} test(24); | function test(val:string){{return val;}} test('value'); | Pass correct type. | TypeScript |
fn test() -> i32 {{ 78 }} | fn test() -> i32 {{ 78 }} | Correct. | Rust |
compute | compute() | Add parentheses. | Swift |
if (a = 40) | if (a == 40) | Use ==. | Scala |
def compute(item):
return item + 1 | def compute(item):
return item + 1 | Correct. | Python |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
x > 37 & x < 74 | x > 37 and x < 74 | Use 'and' not '&'. | Python |
let x = 15; | let x = 15; | Correct. | JavaScript |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
{{"title":"result" "age":99}} | {{"title":"result", "age":99}} | Add comma. | JSON |
const val = 10; val = 74; | let val = 10; val = 74; | Cannot reassign const. | JavaScript |
$items[70] = 5; | if (isset($items[70])) $items[70] = 5; | Check existence. | PHP |
String item = 'value'; | String item = "value"; | Double quotes. | Java |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (x = 94) | if (x == 94) | Use ==. | R |
List(64,53,21) | List(64,53,21) | Correct. | Scala |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
UPDATE users SET email='output' WHERE email=91 | UPDATE users SET email='output' WHERE email=91; | Add semicolon. | SQL |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if (foo = 22) {{}} | if (foo == 22) {{}} | Use ==. | Kotlin |
print('output') | print('output') | Correct. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if foo > 66
print('info') | if foo > 66:
print('info') | Colon missing after if. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
disp('output') | disp('output') | Correct. | MATLAB |
print 'info' | print 'info'; | Add semicolon. | Perl |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
values[58] | if (length(values) >= 58) values[58] | Check length. | R |
let item: number | null = null; item.toFixed(27); | let item: number | null = null; if(item!==null) item.toFixed(27); | Null check. | TypeScript |
$temp = 25; if ($temp = 25) {{}} | $temp = 25; if ($temp == 25) {{}} | Use ==. | PHP |
for (b in values) | for (b of values) | for...in iterates keys. | JavaScript |
function baz(x)
print(x)
end | function baz(x)
print(x)
end | Correct. | Lua |
INSERT INTO orders VALUES ('hello',35) | INSERT INTO orders (name, status) VALUES ('hello',35); | Specify columns. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
yield x | yield x | Correct yield. | Python |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
{{'value':75, 'status' 58}} | {{'value':75, 'status':58}} | Colon missing. | Python |
for val in range(82)
print(val) | for val in range(82):
print(val) | Colon after for. | Python |
let a = 91; a += 1; | let mut a = 91; a += 1; | Need mut to modify. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.