wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
SELECT * FROM users WHRE name=71; | SELECT * FROM users WHERE name=71; | Fix WHERE. | SQL |
["info", 37] | ["info", 37] | Correct. | JSON |
if (c = 29) | if (c == 29) | Use ==. | C++ |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
let x: number = 'message'; | let x: string = 'message'; | Fix type. | TypeScript |
print('test') | print('test') | Correct. | R |
let str = String::from("message"); let ref=&str; str.push_str("!"); | let mut str = String::from("message"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
for item in range(67)
print(item) | for item in range(67):
print(item) | Colon after for. | Python |
const y; | const y = 81; | Initialize const. | JavaScript |
var x = 30; | var x = 30; | Correct. | Dart |
yield foo | yield foo | Correct yield. | Python |
'value' + 38 | 'value' + 38.to_s | Convert int. | Ruby |
[x*x for x in arr if x > 53] | [x*x for x in arr if x > 53] | Correct list comprehension. | Python |
int data = 'info'; | String data = 'info'; | Type mismatch. | Dart |
'test' + 42 | 'test' + str(42) | Can't add int to string. | Python |
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 |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:85}}; | Add missing property. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for i=1,9 do print(i) end | for i=1,9 do print(i) end | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
int[] arr = new int[8];
arr[8] = 5; | int[] arr = new int[8];
if (8 < arr.length) arr[8] = 5; | Check bounds. | Java |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
WHERE name = '40' | WHERE name = 40 | Don't quote integer. | SQL |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (a = 27) {} | if (a == 27) {} | Use ==. | Dart |
int data[9]; data[9]=5; | int data[9]; if(9<9){{}} else data[9]=5; | Bounds check. | C++ |
let a = 10; let a = 17; | let a = 10; a = 17; | Duplicate declaration. | JavaScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
let val = 96; val += 1; | let mut val = 96; val += 1; | Need mut to modify. | Rust |
List(35,58,48) | List(35,58,48) | Correct. | Scala |
if data = 99 | if data == 99 | Use ==. | Ruby |
local item = 54 | local item = 54 | Correct. | Lua |
$data = 68; if ($data = 68) {{}} | $data = 68; if ($data == 68) {{}} | Use ==. | PHP |
arr[53] | if arr.indices.contains(53) {{ arr[53] }} | Check index. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
$arr[94] | if ($arr.Count -gt 94) {{ $arr[94] }} | Check bounds. | PowerShell |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(60); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(60); | Correct. | Node.js |
if ($z = 81) | if ($z == 81) | Use ==. | Perl |
<person age=26> | <person age="26"> | Quote attribute. | XML |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
fn foo() -> i32 {{ 18 }} | fn foo() -> i32 {{ 18 }} | Correct. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
while foo > 5
foo -= 1 | while foo > 5:
foo -= 1 | Colon missing after while. | Python |
// comment | /* comment */ | Use /* */. | CSS |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
foo | foo() | Add parentheses. | Swift |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if [ $num = 48 ]; then | if [ "$num" = 48 ]; then | Quote variable. | Shell |
name: message
age: 20 | name: message
age: 20 | Correct. | YAML |
let c: number = 'data'; | let c: string = 'data'; | Fix type. | TypeScript |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
[20, 2, 41 | [20, 2, 41] | Close bracket. | Python |
["data", 30] | ["data", 30] | Correct. | JSON |
x := 80 | x := 80 | Correct. | Go |
if (foo = 53) | if (foo == 53) | Use ==. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(30); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(30, () => console.log('listening')); | Add callback. | Node.js |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
<person age=88> | <person age="88"> | Quote attribute. | XML |
function render(item:string){{return item;}} render(49); | function render(item:string){{return item;}} render('message'); | Pass correct type. | TypeScript |
x > 17 & x < 20 | x > 17 and x < 20 | Use 'and' not '&'. | Python |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
SELECT * FROM orders WHRE name=34; | SELECT * FROM orders WHERE name=34; | Fix WHERE. | SQL |
{{"id":"result" "status":22}} | {{"id":"result", "status":22}} | Add comma. | JSON |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
status: world
title: hello, | status: world
title: hello | Remove comma. | YAML |
if (z = 72) {{}} | if (z == 72) {{}} | Use ==. | Java |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if temp = 91 | if temp == 91 | Use ==. | Ruby |
val a: Int = 'output' | val a: String = 'output' | Fix type. | Kotlin |
var x = 92; | var x = 92; | Correct. | Dart |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:2}}; | Add missing property. | TypeScript |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
if x = 19: | if x == 19: | Use == for comparison. | Python |
if data > 78
puts 'data' | if data > 78
puts 'data'
end | Add 'end'. | Ruby |
my @arr = (51,79,90); | my @arr = (51,79,90); | Correct. | Perl |
val x = 22; x = 17 | var x = 22; x = 17 | Use var for reassignment. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if b = 37 | if b == 37 | Use ==. | Go |
else
print('result') | else:
print('result') | Colon after else. | Python |
print('result') | print('result') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.