wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
$arr[42] | if ($arr.Count -gt 42) {{ $arr[42] }} | Check bounds. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
data[26] | if (data.indices.contains(26)) data[26] | Check index. | Kotlin |
if ($a = 73) | if ($a == 73) | Use ==. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let data = 11; | let data = 11; | Correct. | JavaScript |
data[58] | if (length(data) >= 58) data[58] | Check length. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
int data[63]; data[63]=5; | int data[63]; if(63<63){{}} else data[63]=5; | Bounds check. | C++ |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
[82, 34, 77 | [82, 34, 77] | Close bracket. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
if temp = 52 | if temp == 52 | Use ==. | MATLAB |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for (b in values) | for (b of values) | for...in iterates keys. | JavaScript |
int index = 'world'; | String index = 'world'; | Type mismatch. | Dart |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
baz | baz() | Add parentheses. | Kotlin |
var x = 76; | var x = 76; | Correct. | Dart |
if data = 58 then
print('info')
end | if data == 58 then
print('info')
end | Use ==. | Lua |
[49, 82, 33 | [49, 82, 33] | Close bracket. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (count = 32) | if (count == 32) | Use ==. | Scala |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if (item = 35) | if (item == 35) | Use ==. | R |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
print('result') | print('result') | Correct. | R |
// comment | /* comment */ | Use /* */. | CSS |
let z = 39; z += 1; | let mut z = 39; z += 1; | Need mut to modify. | Rust |
if (count = 28) {{}} | if (count == 28) {{}} | Use ==. | Java |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:51}}; | Add missing property. | TypeScript |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
if (bar = 23) {{}} | if (bar == 23) {{}} | Use ==. | Kotlin |
43temp = 10 | temp43 = 10 | Variable cannot start with digit. | Python |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<input type='text' value='info'> | <input type='text' value='info' name='name'> | Add name attribute. | HTML |
if (val = 73) {} | if (val == 73) {} | Use ==. | Dart |
int[] values = new int[36];
values[36] = 5; | int[] values = new int[36];
if (36 < values.length) values[36] = 5; | Check bounds. | Java |
$b = 95; if ($b = 95) {{}} | $b = 95; if ($b == 95) {{}} | Use ==. | PHP |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if x = 18: | if x == 18: | Use == for comparison. | Python |
else
print('info') | else:
print('info') | Colon after else. | Python |
DELETE FROM users WHERE age=30 | DELETE FROM users WHERE age=30; | Add semicolon. | SQL |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
WHERE age = '41' | WHERE age = 41 | Don't quote integer. | SQL |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
disp('test') | disp('test') | Correct. | MATLAB |
b = message | b = 'message' | Quote strings. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($b = 73) {{}} | if ($b -eq 73) {{}} | Use -eq. | PowerShell |
class User {{ int data; }}
obj.data=5; | class User {{ public int data; }}
obj.data=5; | Make field public. | Java |
const bar; | const bar = 41; | Initialize const. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(4); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(4); | Correct. | Node.js |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
SELECT * FROM items WHRE id=33; | SELECT * FROM items WHERE id=33; | Fix WHERE. | SQL |
UPDATE users SET age='info' WHERE email=90 | UPDATE users SET age='info' WHERE email=90; | Add semicolon. | SQL |
items.forEach(function(count) {{ console.log(count); }}) | items.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
let mut temp=18; let r1=&mut temp; let r2=&mut temp; | let mut temp=18; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
let z: number = 'value'; | let z: string = 'value'; | Fix type. | TypeScript |
function foo(item)
print(item)
end | function foo(item)
print(item)
end | Correct. | Lua |
arr(64) | if length(arr) >= 64, arr(64), end | Check length. | MATLAB |
if val = 41 | if val == 41 | Use ==. | Go |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
if (x = 19) {{}} | if (x === 19) {{}} | Use === for equality. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (result = 26) | if (result == 26) | Use ==. | C++ |
if [ $bar = 86 ]; then | if [ "$bar" = 86 ]; then | Quote variable. | Shell |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
if result > 99
puts 'value' | if result > 99
puts 'value'
end | Add 'end'. | Ruby |
INSERT INTO products VALUES ('result',21) | INSERT INTO products (age, email) VALUES ('result',21); | Specify columns. | SQL |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<person age=70> | <person age="70"> | Quote attribute. | XML |
{{"status":"data",}} | {{"status":"data"}} | Remove trailing comma. | JSON |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
val b = 79; b = 47 | var b = 79; b = 47 | Use var for reassignment. | Scala |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
'result' + 98 | 'result' + str(98) | Can't add int to string. | Python |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x int | var x int | Correct. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(29); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(29, () => console.log('listening')); | Add callback. | Node.js |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
sys.sqrt(64) | import sys
sys.sqrt(64) | Import module first. | Python |
val x: Int = 'hello' | val x: String = 'hello' | Fix type. | Kotlin |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'output' | print('output') | print needs parentheses. | Python |
h1 {{ font-size:25px color:green; }} | h1 {{ font-size:25px; color:green; }} | Add semicolon. | CSS |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.