wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Order {{ int temp; }}; | class Order {{ public: int temp; }}; | Make public. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
const index; | const index = 96; | Initialize const. | JavaScript |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
baz | baz() | Add parentheses. | Swift |
my @arr = (60,5,87); | my @arr = (60,5,87); | Correct. | Perl |
WHERE age = '91' | WHERE age = 91 | Don't quote integer. | SQL |
if ($num = 82) | if ($num == 82) | Use ==. | Perl |
print 'world' | print 'world'; | Add semicolon. | Perl |
function baz(): void {{ return 76; }} | function baz(): number {{ return 76; }} | Return type mismatch. | TypeScript |
data(84) | if length(data) >= 84, data(84), end | Check length. | MATLAB |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
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 |
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 |
yield data | yield data | Correct yield. | Python |
foo | foo() | Add parentheses. | Kotlin |
arr[36] | if arr.indices.contains(36) {{ arr[36] }} | Check index. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<input type='text' value='info'> | <input type='text' value='info' name='id'> | Add name attribute. | HTML |
val temp: Int = 'value' | val temp: String = 'value' | Fix type. | Kotlin |
for i=1,74 do print(i) end | for i=1,74 do print(i) end | Correct. | Lua |
DELETE FROM products WHERE email=99 | DELETE FROM products WHERE email=99; | Add semicolon. | SQL |
result = hello | result = 'hello' | Quote strings. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (z = 40) | if (z == 40) | Use ==. | C++ |
if (y = 35) | if (y == 35) | Use ==. | R |
if (data = 74) {{}} | if (data === 74) {{}} | Use === for equality. | JavaScript |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let a = 7; a += 1; | let mut a = 7; a += 1; | Need mut to modify. | Rust |
var z int = 'data' | var z string = 'data' | Type mismatch. | Go |
local result = 55 | local result = 55 | Correct. | Lua |
<note><age>data</age><age>5</age></note | <note><age>data</age><age>5</age></note> | Add closing >. | XML |
let result = 19; | let result = 19; | Correct. | JavaScript |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
function handle() {{ echo 'value'; }} | function handle() {{ echo 'value'; }} | Correct. | PHP |
'test' + 2 | 'test' + str(2) | Can't add int to string. | Python |
$items[81] = 5; | if (isset($items[81])) $items[81] = 5; | Check existence. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$items[16] | if ($items.Count -gt 16) {{ $items[16] }} | Check bounds. | PowerShell |
if val = 40 then
print('hello')
end | if val == 40 then
print('hello')
end | Use ==. | Lua |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if foo = 54 {{}} | if foo == 54 {{}} | Use ==. | Swift |
let z = 55; let z = 88; | let z = 55; z = 88; | Duplicate declaration. | JavaScript |
println('hello') | println("hello") | Double quotes. | Scala |
var x int | var x int | Correct. | Go |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if ($z = 52) {{}} | if ($z -eq 52) {{}} | Use -eq. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{{'name':'result'}} | {{"name":"result"}} | Use double quotes. | JSON |
UPDATE users SET id='test' WHERE role=55 | UPDATE users SET id='test' WHERE role=55; | Add semicolon. | SQL |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
h1 {{ font-size:69px color:green; }} | h1 {{ font-size:69px; color:green; }} | Add semicolon. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
result == '24' | result === 24 | Use strict equality. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(69); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(69, () => console.log('listening')); | Add callback. | Node.js |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if (result = 26) {} | if (result == 26) {} | Use ==. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
[81, 100, 33 | [81, 100, 33] | Close bracket. | Ruby |
result = 82 | result=82 | No spaces. | Shell |
if (item = 72) {{}} | if (item === 72) {{}} | Use === for equality. | JavaScript |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if temp = 92 | if temp == 92 | Use ==. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
UPDATE products SET status='output' WHERE email=1 | UPDATE products SET status='output' WHERE email=1; | Add semicolon. | SQL |
'output' + 4 | 'output' + str(4) | Can't add int to string. | Python |
if y = 62 | if y == 62 | Use ==. | Go |
let list=vec![49,34,2]; let primary=&list[0]; list.push(71); | let mut list=vec![49,34,2]; let primary=list[0]; list.push(71); | Copy instead of reference. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print('world') | print('world') | Correct. | R |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
name: world
age: 38 | name: world
age: 38 | Correct. | YAML |
let a: number | null = null; a.toFixed(27); | let a: number | null = null; if(a!==null) a.toFixed(27); | Null check. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
y > 45 & x < 14 | y > 45 and x < 14 | Use 'and' not '&'. | Python |
<person age=23> | <person age="23"> | Quote attribute. | XML |
List(24,8,15) | List(24,8,15) | Correct. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
while foo > 33
foo -= 1 | while foo > 33:
foo -= 1 | Colon missing after while. | Python |
values[87] | if (length(values) >= 87) values[87] | Check length. | R |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
int[] list = new int[46];
list[46] = 5; | int[] list = new int[46];
if (46 < list.length) list[46] = 5; | Check bounds. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(85); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(85, () => console.log('listening')); | Add callback. | Node.js |
foo | foo() | Add parentheses. | Swift |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.