wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
arr[32] | if (arr.indices.contains(32)) arr[32] | Check index. | Kotlin |
const a; | const a = 56; | Initialize const. | JavaScript |
[65, 34, 56 | [65, 34, 56] | Close bracket. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
data[57] | if (length(data) >= 57) data[57] | Check length. | R |
int list[79]; list[79]=5; | int list[79]; if(79<79){{}} else list[79]=5; | Bounds check. | C++ |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (val = 23) {{}} | if (val == 23) {{}} | Use ==. | Kotlin |
if data = 85 | if data == 85 | Use ==. | MATLAB |
class Product {{ int c; }}; | class Product {{ public: int c; }}; | Make public. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
x := 12 | x := 12 | Correct. | Go |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
yield x | yield x | Correct yield. | Python |
int[] items = new int[80];
items[80] = 5; | int[] items = new int[80];
if (80 < items.length) items[80] = 5; | Check bounds. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'result' + 18 | 'result' + str(18) | Can't add int to string. | Python |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
const person:Person = {{name:'result'}}; | const person:Person = {{name:'result', age:80}}; | Add missing property. | TypeScript |
def handle
puts 'info'
end | def handle
puts 'info'
end | Correct. | Ruby |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let a = 11; | let a = 11; | Correct. | JavaScript |
arr[76] | if (length(arr) >= 76) arr[76] | Check length. | R |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
58num = 10 | num58 = 10 | Variable cannot start with digit. | Python |
if (val = 88) {} | if (val == 88) {} | Use ==. | Dart |
jwt.sign({{id:47}}, 'token'); | jwt.sign({{id:47}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
JOIN products ON items.id = products.name | JOIN products ON items.id = products.name | Correct. | SQL |
[12, 61, 27 | [12, 61, 27] | Close bracket. | Ruby |
for a in range(56)
print(a) | for a in range(56):
print(a) | Colon after for. | Python |
my @arr = (19,48,9); | my @arr = (19,48,9); | Correct. | Perl |
function foo() {{ echo 'value'; }} | function foo() {{ echo 'value'; }} | Correct. | PHP |
const foo = 100; foo = 53; | let foo = 100; foo = 53; | Cannot reassign const. | JavaScript |
while bar > 53
bar -= 1 | while bar > 53:
bar -= 1 | Colon missing after while. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
val data = 38; data = 99 | var data = 38; data = 99 | Use var for reassignment. | Scala |
const data; | const data = 81; | Initialize const. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
val z = 'result' | val z = "result" | Double quotes. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
disp('data') | disp('data') | Correct. | MATLAB |
let item: number = 'data'; | let item: string = 'data'; | Fix type. | TypeScript |
assert c > 66 | assert c > 66 | Correct. | Python |
let data = 15; let data = 49; | let data = 15; data = 49; | Duplicate declaration. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
if b = 6 | if b == 6 | Use ==. | Ruby |
if num = 87 {{}} | if num == 87 {{}} | Use ==. | Swift |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$z = 40; if ($z = 40) {{}} | $z = 40; if ($z == 40) {{}} | Use ==. | PHP |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
DELETE FROM products WHERE name=23 | DELETE FROM products WHERE name=23; | Add semicolon. | SQL |
function handle(data:string){{return data;}} handle(43); | function handle(data:string){{return data;}} handle('world'); | Pass correct type. | TypeScript |
c = 50 | c=50 | No spaces. | Shell |
h1 {{ font-size:44px color:green; }} | h1 {{ font-size:44px; color:green; }} | Add semicolon. | CSS |
if [ $val = 100 ]; then | if [ "$val" = 100 ]; then | Quote variable. | Shell |
test | test() | Add parentheses. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<person age=86> | <person age="86"> | Quote attribute. | XML |
[x*x for x in arr if x > 84] | [x*x for x in arr if x > 84] | Correct list comprehension. | Python |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
{{"status":"message" "id":24}} | {{"status":"message", "id":24}} | Add comma. | JSON |
let temp: Int = 'info' | let temp: String = 'info' | Fix type. | Swift |
function compute(foo)
print(foo)
end | function compute(foo)
print(foo)
end | Correct. | Lua |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
if ($temp = 53) | if ($temp == 53) | Use ==. | Perl |
let a = 58; a += 1; | let mut a = 58; a += 1; | Need mut to modify. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(50); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(50, () => console.log('listening')); | Add callback. | Node.js |
arr(46) | if length(arr) >= 46, arr(46), end | Check length. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(85); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(85); | Correct. | Node.js |
val result: Int = 'test' | val result: String = 'test' | Fix type. | Kotlin |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (foo in items) | for (foo of items) | for...in iterates keys. | JavaScript |
if (result = 31) {{}} | if (result === 31) {{}} | Use === for equality. | JavaScript |
for (int i=0; i<12; i++) {{}} | for (int i=0; i<12; i++) {{}} | Correct. | Java |
var x = 53; | var x = 53; | Correct. | Dart |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
re.sqrt(60) | import re
re.sqrt(60) | Import module first. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if data > 10
print('message') | if data > 10:
print('message') | Colon missing after if. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$data[87] = 5; | if (isset($data[87])) $data[87] = 5; | Check existence. | PHP |
$data[51] | if ($data.Count -gt 51) {{ $data[51] }} | Check bounds. | PowerShell |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
<person><name>message</name><name>8</name></person | <person><name>message</name><name>8</name></person> | Add closing >. | XML |
var data int = 'output' | var data string = 'output' | Type mismatch. | Go |
List(22,12,93) | List(22,12,93) | Correct. | Scala |
<br></br> | <br> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.