node_ids
sequencelengths 4
1.4k
| edge_index
sequencelengths 1
2.22k
| text
sequencelengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
30,
4,
18,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
190,
11
],
[
190,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
32,
37
],
[
14,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
58,
60
],
[
14,
61
],
[
61,
62
],
[
61,
63
],
[
14,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
69,
70
],
[
69,
71
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
86,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
86,
98
],
[
98,
99
],
[
99,
100
],
[
86,
101
],
[
102,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
110,
112
],
[
103,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
116,
118
],
[
113,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
113,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
128,
134
],
[
113,
135
],
[
135,
136
],
[
135,
137
],
[
113,
138
],
[
138,
139
],
[
14,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
145,
147
],
[
140,
148
],
[
148,
149
],
[
149,
150
],
[
140,
151
],
[
152,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
153,
158
],
[
158,
159
],
[
158,
160
],
[
152,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
161,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
168,
173
],
[
161,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
175,
180
],
[
14,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
181,
186
],
[
12,
187
],
[
187,
188
],
[
0,
189
],
[
189,
190
],
[
189,
191
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] A = new int[n];\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] A = new int[n];\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String[] args) throws NumberFormatException, IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] A = new int[n];\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] A = new int[n];\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"int[] A = new int[n];",
"A",
"new int[n]",
"n",
"String[] str = br.readLine().split(\" \");",
"str",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}",
"{\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}",
"A[i] = Integer.parseInt(str[i])",
"A[i]",
"A",
"i",
"Integer.parseInt(str[i])",
"Integer.parseInt",
"Integer",
"str[i]",
"str",
"i",
"int count = 0;",
"count",
"0",
"for(int i = 1; i < n; i++){\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"boolean flag = true;",
"flag",
"true",
"while(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"flag",
"{\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"flag = false",
"flag",
"false",
"for(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j > i - 1",
"j",
"i - 1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}",
"{\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}",
"if(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}",
"A[j] < A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}",
"int tmp = A[j];",
"tmp",
"A[j]",
"A",
"j",
"A[j] = A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"A[j - 1] = tmp",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"tmp",
"flag = true",
"flag",
"true",
"count++",
"count",
"for(int i = 0; i < n; i++){\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"if(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"i + 1 == n",
"i + 1",
"i",
"1",
"n",
"{\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] A = new int[n];\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] A = new int[n];\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tboolean flag = true;\n\t\t\n\t\t\twhile(flag){\n\t\t\t\tflag = false;\n\t\t\t\n\t\t\t\tfor(int j = n - 1; j > i - 1; j--){\n\t\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\t\tint tmp = A[j];\n\t\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\t\tA[j - 1] = tmp;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.print(A[i]);\n\t\t\t\n\t\t\tif(i + 1 == n){\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t} else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO ?????????????????????????????????????????????
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] A = new int[n];
String[] str = br.readLine().split(" ");
for(int i = 0; i < n; i++){
A[i] = Integer.parseInt(str[i]);
}
int count = 0;
for(int i = 1; i < n; i++){
boolean flag = true;
while(flag){
flag = false;
for(int j = n - 1; j > i - 1; j--){
if(A[j] < A[j - 1]){
int tmp = A[j];
A[j] = A[j - 1];
A[j - 1] = tmp;
flag = true;
count++;
}
}
}
}
for(int i = 0; i < n; i++){
System.out.print(A[i]);
if(i + 1 == n){
System.out.print("\n");
} else {
System.out.print(" ");
}
}
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
41,
13,
20,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
0,
13,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
41,
13,
40,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
178,
5
],
[
178,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
19,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
8,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
8,
32
],
[
32,
33
],
[
32,
34
],
[
8,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
8,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
42,
47
],
[
47,
48
],
[
47,
49
],
[
42,
50
],
[
50,
51
],
[
51,
52
],
[
42,
53
],
[
54,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
62,
64
],
[
8,
65
],
[
65,
66
],
[
65,
67
],
[
8,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
8,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
72,
77
],
[
77,
78
],
[
77,
79
],
[
72,
80
],
[
80,
81
],
[
81,
82
],
[
72,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
85,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
85,
95
],
[
95,
96
],
[
96,
97
],
[
85,
98
],
[
99,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
100,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
110,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
128,
130
],
[
125,
131
],
[
110,
132
],
[
132,
133
],
[
8,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
134,
144
],
[
144,
145
],
[
145,
146
],
[
134,
147
],
[
148,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
8,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
159,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
166,
168
],
[
8,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
6,
175
],
[
175,
176
],
[
0,
177
],
[
177,
178
],
[
177,
179
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int number = Integer.parseInt(line);\n \n int[] array = new int[number];\n String line2 = sc.nextLine();\n String[] line2sp = new String[number];\n line2sp=line2.split(\" \");\n \n for(int i=0;i<number;i++){\n \tarray[i]=Integer.parseInt(line2sp[i]);\n } \n \n int count=0;\n int save=-1;\n \n for(int i=0;i<number;i++){\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \n for(int i=0;i<number-1;i++){\n \tSystem.out.print(array[i]+\" \");\n }\n \n System.out.println(array[number-1]);\n System.out.println(count);\n } \n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int number = Integer.parseInt(line);\n \n int[] array = new int[number];\n String line2 = sc.nextLine();\n String[] line2sp = new String[number];\n line2sp=line2.split(\" \");\n \n for(int i=0;i<number;i++){\n \tarray[i]=Integer.parseInt(line2sp[i]);\n } \n \n int count=0;\n int save=-1;\n \n for(int i=0;i<number;i++){\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \n for(int i=0;i<number-1;i++){\n \tSystem.out.print(array[i]+\" \");\n }\n \n System.out.println(array[number-1]);\n System.out.println(count);\n } \n}",
"Main",
"public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int number = Integer.parseInt(line);\n \n int[] array = new int[number];\n String line2 = sc.nextLine();\n String[] line2sp = new String[number];\n line2sp=line2.split(\" \");\n \n for(int i=0;i<number;i++){\n \tarray[i]=Integer.parseInt(line2sp[i]);\n } \n \n int count=0;\n int save=-1;\n \n for(int i=0;i<number;i++){\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \n for(int i=0;i<number-1;i++){\n \tSystem.out.print(array[i]+\" \");\n }\n \n System.out.println(array[number-1]);\n System.out.println(count);\n }",
"main",
"{\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int number = Integer.parseInt(line);\n \n int[] array = new int[number];\n String line2 = sc.nextLine();\n String[] line2sp = new String[number];\n line2sp=line2.split(\" \");\n \n for(int i=0;i<number;i++){\n \tarray[i]=Integer.parseInt(line2sp[i]);\n } \n \n int count=0;\n int save=-1;\n \n for(int i=0;i<number;i++){\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \n for(int i=0;i<number-1;i++){\n \tSystem.out.print(array[i]+\" \");\n }\n \n System.out.println(array[number-1]);\n System.out.println(count);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String line = sc.nextLine();",
"line",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int number = Integer.parseInt(line);",
"number",
"Integer.parseInt(line)",
"Integer.parseInt",
"Integer",
"line",
"int[] array = new int[number];",
"array",
"new int[number]",
"number",
"String line2 = sc.nextLine();",
"line2",
"sc.nextLine()",
"sc.nextLine",
"sc",
"String[] line2sp = new String[number];",
"line2sp",
"new String[number]",
"number",
"line2sp=line2.split(\" \")",
"line2sp",
"line2.split(\" \")",
"line2.split",
"line2",
"\" \"",
"for(int i=0;i<number;i++){\n \tarray[i]=Integer.parseInt(line2sp[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<number",
"i",
"number",
"i++",
"i++",
"i",
"{\n \tarray[i]=Integer.parseInt(line2sp[i]);\n }",
"{\n \tarray[i]=Integer.parseInt(line2sp[i]);\n }",
"array[i]=Integer.parseInt(line2sp[i])",
"array[i]",
"array",
"i",
"Integer.parseInt(line2sp[i])",
"Integer.parseInt",
"Integer",
"line2sp[i]",
"line2sp",
"i",
"int count=0;",
"count",
"0",
"int save=-1;",
"save",
"-1",
"1",
"for(int i=0;i<number;i++){\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<number",
"i",
"number",
"i++",
"i++",
"i",
"{\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }",
"{\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }",
"for(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}",
"int j=0;",
"int j=0;",
"j",
"0",
"j<number-1",
"j",
"number-1",
"number",
"1",
"j++",
"j++",
"j",
"{\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}",
"{\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}",
"if(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}",
"array[j]>array[j+1]",
"array[j]",
"array",
"j",
"array[j+1]",
"array",
"j+1",
"j",
"1",
"{\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}",
"save=array[j]",
"save",
"array[j]",
"array",
"j",
"array[j]=array[j+1]",
"array[j]",
"array",
"j",
"array[j+1]",
"array",
"j+1",
"j",
"1",
"array[j+1]=save",
"array[j+1]",
"array",
"j+1",
"j",
"1",
"save",
"count++",
"count",
"for(int i=0;i<number-1;i++){\n \tSystem.out.print(array[i]+\" \");\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<number-1",
"i",
"number-1",
"number",
"1",
"i++",
"i++",
"i",
"{\n \tSystem.out.print(array[i]+\" \");\n }",
"{\n \tSystem.out.print(array[i]+\" \");\n }",
"System.out.print(array[i]+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"array[i]+\" \"",
"array[i]",
"array",
"i",
"\" \"",
"System.out.println(array[number-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"array[number-1]",
"array",
"number-1",
"number",
"1",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int number = Integer.parseInt(line);\n \n int[] array = new int[number];\n String line2 = sc.nextLine();\n String[] line2sp = new String[number];\n line2sp=line2.split(\" \");\n \n for(int i=0;i<number;i++){\n \tarray[i]=Integer.parseInt(line2sp[i]);\n } \n \n int count=0;\n int save=-1;\n \n for(int i=0;i<number;i++){\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \n for(int i=0;i<number-1;i++){\n \tSystem.out.print(array[i]+\" \");\n }\n \n System.out.println(array[number-1]);\n System.out.println(count);\n } \n}",
"public class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int number = Integer.parseInt(line);\n \n int[] array = new int[number];\n String line2 = sc.nextLine();\n String[] line2sp = new String[number];\n line2sp=line2.split(\" \");\n \n for(int i=0;i<number;i++){\n \tarray[i]=Integer.parseInt(line2sp[i]);\n } \n \n int count=0;\n int save=-1;\n \n for(int i=0;i<number;i++){\n \tfor(int j=0;j<number-1;j++){\n \t\tif(array[j]>array[j+1]){\n \t\t\tsave=array[j];\n \t\t\tarray[j]=array[j+1];\n \t\t\tarray[j+1]=save;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \n for(int i=0;i<number-1;i++){\n \tSystem.out.print(array[i]+\" \");\n }\n \n System.out.println(array[number-1]);\n System.out.println(count);\n } \n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
int number = Integer.parseInt(line);
int[] array = new int[number];
String line2 = sc.nextLine();
String[] line2sp = new String[number];
line2sp=line2.split(" ");
for(int i=0;i<number;i++){
array[i]=Integer.parseInt(line2sp[i]);
}
int count=0;
int save=-1;
for(int i=0;i<number;i++){
for(int j=0;j<number-1;j++){
if(array[j]>array[j+1]){
save=array[j];
array[j]=array[j+1];
array[j+1]=save;
count++;
}
}
}
for(int i=0;i<number-1;i++){
System.out.print(array[i]+" ");
}
System.out.println(array[number-1]);
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
18,
13,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
154,
5
],
[
154,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
21,
31
],
[
31,
32
],
[
32,
33
],
[
21,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
8,
46
],
[
46,
47
],
[
46,
48
],
[
8,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
55,
62
],
[
62,
63
],
[
62,
64
],
[
55,
65
],
[
65,
66
],
[
66,
67
],
[
55,
68
],
[
69,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
70,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
80,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
96,
98
],
[
80,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
80,
104
],
[
104,
105
],
[
80,
106
],
[
106,
107
],
[
106,
108
],
[
8,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
109,
121
],
[
121,
122
],
[
122,
123
],
[
109,
124
],
[
125,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
126,
132
],
[
132,
133
],
[
132,
134
],
[
8,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
8,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
6,
151
],
[
151,
152
],
[
0,
153
],
[
153,
154
],
[
153,
155
]
] | [
"import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<A.length;i++){\n A[i] = sc.nextInt();\n }\n int count = 0;\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0;i < A.length-1;i++){\n System.out.printf(\"%d \",A[i]);\n }\n System.out.println(A[N-1]);\n System.out.println(count);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<A.length;i++){\n A[i] = sc.nextInt();\n }\n int count = 0;\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0;i < A.length-1;i++){\n System.out.printf(\"%d \",A[i]);\n }\n System.out.println(A[N-1]);\n System.out.println(count);\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<A.length;i++){\n A[i] = sc.nextInt();\n }\n int count = 0;\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0;i < A.length-1;i++){\n System.out.printf(\"%d \",A[i]);\n }\n System.out.println(A[N-1]);\n System.out.println(count);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<A.length;i++){\n A[i] = sc.nextInt();\n }\n int count = 0;\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0;i < A.length-1;i++){\n System.out.printf(\"%d \",A[i]);\n }\n System.out.println(A[N-1]);\n System.out.println(count);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int A[] = new int[N];",
"A",
"new int[N]",
"N",
"for(int i=0;i<A.length;i++){\n A[i] = sc.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<A.length",
"i",
"A.length",
"A",
"A.length",
"i++",
"i++",
"i",
"{\n A[i] = sc.nextInt();\n }",
"{\n A[i] = sc.nextInt();\n }",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count = 0;",
"count",
"0",
"boolean flag = true;",
"flag",
"true",
"while(flag){\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }",
"flag",
"{\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }",
"int j = N-1;",
"int j = N-1;",
"j",
"N-1",
"N",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }",
"{\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }",
"if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }",
"A[j] < A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"{\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }",
"int tmp;",
"tmp",
"tmp = A[j-1]",
"tmp",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j-1] = A[j]",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j]",
"A",
"j",
"A[j] = tmp",
"A[j]",
"A",
"j",
"tmp",
"count++",
"count",
"flag = true",
"flag",
"true",
"for(int i = 0;i < A.length-1;i++){\n System.out.printf(\"%d \",A[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < A.length-1",
"i",
"A.length-1",
"A.length",
"A",
"A.length",
"1",
"i++",
"i++",
"i",
"{\n System.out.printf(\"%d \",A[i]);\n }",
"{\n System.out.printf(\"%d \",A[i]);\n }",
"System.out.printf(\"%d \",A[i])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d \"",
"A[i]",
"A",
"i",
"System.out.println(A[N-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"A[N-1]",
"A",
"N-1",
"N",
"1",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<A.length;i++){\n A[i] = sc.nextInt();\n }\n int count = 0;\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0;i < A.length-1;i++){\n System.out.printf(\"%d \",A[i]);\n }\n System.out.println(A[N-1]);\n System.out.println(count);\n }\n}",
"public class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<A.length;i++){\n A[i] = sc.nextInt();\n }\n int count = 0;\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = N-1; j > 0; j--){\n if(A[j] < A[j-1]) {\n int tmp;\n tmp = A[j-1];\n A[j-1] = A[j];\n A[j] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0;i < A.length-1;i++){\n System.out.printf(\"%d \",A[i]);\n }\n System.out.println(A[N-1]);\n System.out.println(count);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int A[] = new int[N];
for(int i=0;i<A.length;i++){
A[i] = sc.nextInt();
}
int count = 0;
boolean flag = true;
while(flag){
flag = false;
for(int j = N-1; j > 0; j--){
if(A[j] < A[j-1]) {
int tmp;
tmp = A[j-1];
A[j-1] = A[j];
A[j] = tmp;
count++;
flag = true;
}
}
}
for(int i = 0;i < A.length-1;i++){
System.out.printf("%d ",A[i]);
}
System.out.println(A[N-1]);
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
149,
5
],
[
149,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
21,
23
],
[
8,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
36,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
57,
59
],
[
53,
60
],
[
60,
61
],
[
60,
62
],
[
53,
63
],
[
63,
64
],
[
64,
65
],
[
53,
66
],
[
67,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
78,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
78,
100
],
[
100,
101
],
[
78,
102
],
[
102,
103
],
[
102,
104
],
[
8,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
112,
114
],
[
105,
115
],
[
115,
116
],
[
116,
117
],
[
105,
118
],
[
119,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
8,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
130,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
137,
139
],
[
8,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
6,
146
],
[
146,
147
],
[
0,
148
],
[
148,
149
],
[
148,
150
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n int ans = 0;\n for(int i = 0; i < n; i++){\n a[i] = sc.nextInt();\n }\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(ans);\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n int ans = 0;\n for(int i = 0; i < n; i++){\n a[i] = sc.nextInt();\n }\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(ans);\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n int ans = 0;\n for(int i = 0; i < n; i++){\n a[i] = sc.nextInt();\n }\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(ans);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n int ans = 0;\n for(int i = 0; i < n; i++){\n a[i] = sc.nextInt();\n }\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(ans);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"int ans = 0;",
"ans",
"0",
"for(int i = 0; i < n; i++){\n a[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = sc.nextInt();\n }",
"{\n a[i] = sc.nextInt();\n }",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"boolean flag = true;",
"flag",
"true",
"while(flag){\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }",
"flag",
"{\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }",
"{\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }",
"if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }",
"int work = a[j];",
"work",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = work",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"work",
"ans ++",
"ans",
"flag =true",
"flag",
"true",
"for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(a[i] + \" \");\n }",
"{\n System.out.print(a[i] + \" \");\n }",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(a[n-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[n-1]",
"a",
"n-1",
"n",
"1",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n int ans = 0;\n for(int i = 0; i < n; i++){\n a[i] = sc.nextInt();\n }\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(ans);\n }\n}",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n int ans = 0;\n for(int i = 0; i < n; i++){\n a[i] = sc.nextInt();\n }\n boolean flag = true;\n while(flag){\n flag = false;\n for(int j = n-1; j > 0; j--){\n if(a[j] < a[j-1]){\n int work = a[j];\n a[j] = a[j-1];\n a[j-1] = work;\n ans ++;\n flag =true;\n }\n }\n }\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(ans);\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int ans = 0;
for(int i = 0; i < n; i++){
a[i] = sc.nextInt();
}
boolean flag = true;
while(flag){
flag = false;
for(int j = n-1; j > 0; j--){
if(a[j] < a[j-1]){
int work = a[j];
a[j] = a[j-1];
a[j-1] = work;
ans ++;
flag =true;
}
}
}
for(int i = 0; i < n-1; i++){
System.out.print(a[i] + " ");
}
System.out.println(a[n-1]);
System.out.println(ans);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
17,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
155,
5
],
[
155,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
21,
31
],
[
31,
32
],
[
32,
33
],
[
21,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
46,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
61,
68
],
[
68,
69
],
[
68,
70
],
[
61,
71
],
[
71,
72
],
[
72,
73
],
[
61,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
77,
83
],
[
83,
84
],
[
83,
85
],
[
76,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
86,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
94,
100
],
[
100,
101
],
[
100,
102
],
[
86,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
86,
108
],
[
108,
109
],
[
8,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
110,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
110,
120
],
[
120,
121
],
[
121,
122
],
[
110,
123
],
[
124,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
125,
130
],
[
125,
131
],
[
131,
132
],
[
131,
133
],
[
8,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
134,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
8,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
145,
151
],
[
6,
152
],
[
152,
153
],
[
0,
154
],
[
154,
155
],
[
154,
156
]
] | [
"import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int a[] = new int[N];\n for(int i=0;i<=N-1;i++){\n a[i] = sc.nextInt();\n }\n int count = 0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }\n for(int i=0;i<N-1;i++){\n System.out.printf(\"%d \",a[i]);\n }\n System.out.printf(\"%d\",a[N-1]);\n System.out.printf(\"\\n%d\\n\",count);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int a[] = new int[N];\n for(int i=0;i<=N-1;i++){\n a[i] = sc.nextInt();\n }\n int count = 0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }\n for(int i=0;i<N-1;i++){\n System.out.printf(\"%d \",a[i]);\n }\n System.out.printf(\"%d\",a[N-1]);\n System.out.printf(\"\\n%d\\n\",count);\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int a[] = new int[N];\n for(int i=0;i<=N-1;i++){\n a[i] = sc.nextInt();\n }\n int count = 0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }\n for(int i=0;i<N-1;i++){\n System.out.printf(\"%d \",a[i]);\n }\n System.out.printf(\"%d\",a[N-1]);\n System.out.printf(\"\\n%d\\n\",count);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int a[] = new int[N];\n for(int i=0;i<=N-1;i++){\n a[i] = sc.nextInt();\n }\n int count = 0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }\n for(int i=0;i<N-1;i++){\n System.out.printf(\"%d \",a[i]);\n }\n System.out.printf(\"%d\",a[N-1]);\n System.out.printf(\"\\n%d\\n\",count);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int a[] = new int[N];",
"a",
"new int[N]",
"N",
"for(int i=0;i<=N-1;i++){\n a[i] = sc.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<=N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n a[i] = sc.nextInt();\n }",
"{\n a[i] = sc.nextInt();\n }",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count = 0;",
"count",
"0",
"for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }",
"{\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }",
"for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }",
"int j=N-1;",
"int j=N-1;",
"j",
"N-1",
"N",
"1",
"j>i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }",
"{\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }",
"if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }",
"a[j-1] > a[j]",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j]",
"a",
"j",
"{\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }",
"int tmp = a[j-1];",
"tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = a[j]",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j]",
"a",
"j",
"a[j] = tmp",
"a[j]",
"a",
"j",
"tmp",
"count++",
"count",
"for(int i=0;i<N-1;i++){\n System.out.printf(\"%d \",a[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n System.out.printf(\"%d \",a[i]);\n }",
"{\n System.out.printf(\"%d \",a[i]);\n }",
"System.out.printf(\"%d \",a[i])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d \"",
"a[i]",
"a",
"i",
"System.out.printf(\"%d\",a[N-1])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d\"",
"a[N-1]",
"a",
"N-1",
"N",
"1",
"System.out.printf(\"\\n%d\\n\",count)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"\\n%d\\n\"",
"count",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int a[] = new int[N];\n for(int i=0;i<=N-1;i++){\n a[i] = sc.nextInt();\n }\n int count = 0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }\n for(int i=0;i<N-1;i++){\n System.out.printf(\"%d \",a[i]);\n }\n System.out.printf(\"%d\",a[N-1]);\n System.out.printf(\"\\n%d\\n\",count);\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int a[] = new int[N];\n for(int i=0;i<=N-1;i++){\n a[i] = sc.nextInt();\n }\n int count = 0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if (a[j-1] > a[j]){\n int tmp = a[j-1];\n a[j-1] = a[j];\n a[j] = tmp;\n count++;\n }\n }\n }\n for(int i=0;i<N-1;i++){\n System.out.printf(\"%d \",a[i]);\n }\n System.out.printf(\"%d\",a[N-1]);\n System.out.printf(\"\\n%d\\n\",count);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int a[] = new int[N];
for(int i=0;i<=N-1;i++){
a[i] = sc.nextInt();
}
int count = 0;
for(int i=0;i<N-1;i++){
for(int j=N-1;j>i;j--){
if (a[j-1] > a[j]){
int tmp = a[j-1];
a[j-1] = a[j];
a[j] = tmp;
count++;
}
}
}
for(int i=0;i<N-1;i++){
System.out.printf("%d ",a[i]);
}
System.out.printf("%d",a[N-1]);
System.out.printf("\n%d\n",count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
20,
17,
41,
13,
41,
13,
41,
13,
41,
13,
17,
0,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
0,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
4,
18,
18,
13,
13,
18,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
2,
17,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
8,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
8,
24
],
[
24,
25
],
[
24,
26
],
[
8,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
8,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
41,
42
],
[
32,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
48,
49
],
[
49,
50
],
[
8,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
51,
61
],
[
61,
62
],
[
62,
63
],
[
51,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
70,
72
],
[
66,
73
],
[
73,
74
],
[
73,
75
],
[
66,
76
],
[
76,
77
],
[
77,
78
],
[
66,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
88,
90
],
[
81,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
91,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
105,
106
],
[
105,
107
],
[
91,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
91,
113
],
[
113,
114
],
[
8,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
120,
121
],
[
120,
122
],
[
8,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
123,
128
],
[
128,
129
],
[
128,
130
],
[
123,
131
],
[
131,
132
],
[
132,
133
],
[
123,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
8,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
150,
151
],
[
150,
152
],
[
6,
153
],
[
153,
154
]
] | [
"import java.util.Scanner;\n\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner stdIn=new Scanner(System.in);\n\t\tint n,a[]=new int[100],i,j,t,s=0;\n\t\tn=stdIn.nextInt();\n\t\tfor(i=0;i<n;i++)a[i]=stdIn.nextInt();\n\t\tfor(i=0;i<n-1;i++){\n\t\t\tfor(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(a[0]);\n\t\tfor(i=1;i<n;i++)System.out.print(\" \"+a[i]);\n\t\tSystem.out.println(\"\\n\"+s);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n\tpublic static void main(String[] args){\n\t\tScanner stdIn=new Scanner(System.in);\n\t\tint n,a[]=new int[100],i,j,t,s=0;\n\t\tn=stdIn.nextInt();\n\t\tfor(i=0;i<n;i++)a[i]=stdIn.nextInt();\n\t\tfor(i=0;i<n-1;i++){\n\t\t\tfor(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(a[0]);\n\t\tfor(i=1;i<n;i++)System.out.print(\" \"+a[i]);\n\t\tSystem.out.println(\"\\n\"+s);\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner stdIn=new Scanner(System.in);\n\t\tint n,a[]=new int[100],i,j,t,s=0;\n\t\tn=stdIn.nextInt();\n\t\tfor(i=0;i<n;i++)a[i]=stdIn.nextInt();\n\t\tfor(i=0;i<n-1;i++){\n\t\t\tfor(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(a[0]);\n\t\tfor(i=1;i<n;i++)System.out.print(\" \"+a[i]);\n\t\tSystem.out.println(\"\\n\"+s);\n\t}",
"main",
"{\n\t\tScanner stdIn=new Scanner(System.in);\n\t\tint n,a[]=new int[100],i,j,t,s=0;\n\t\tn=stdIn.nextInt();\n\t\tfor(i=0;i<n;i++)a[i]=stdIn.nextInt();\n\t\tfor(i=0;i<n-1;i++){\n\t\t\tfor(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(a[0]);\n\t\tfor(i=1;i<n;i++)System.out.print(\" \"+a[i]);\n\t\tSystem.out.println(\"\\n\"+s);\n\t}",
"Scanner stdIn=new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"int n",
"n",
"a[]=new int[100]",
"a",
"new int[100]",
"100",
"i",
"i",
"j",
"j",
"t",
"t",
"s=0;",
"s",
"0",
"n=stdIn.nextInt()",
"n",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"for(i=0;i<n;i++)a[i]=stdIn.nextInt();",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=stdIn.nextInt();",
"a[i]=stdIn.nextInt()",
"a[i]",
"a",
"i",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"for(i=0;i<n-1;i++){\n\t\t\tfor(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(j=n-1;j>i;j--){\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}",
"j=n-1;",
"j=n-1",
"j",
"n-1",
"n",
"1",
"j>i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}",
"if(a[j-1]>a[j]){\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}",
"a[j-1]>a[j]",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j]",
"a",
"j",
"{\n\t\t\t\t\tt=a[j-1];\n\t\t\t\t\ta[j-1]=a[j];\n\t\t\t\t\ta[j]=t;\n\t\t\t\t\ts++;\n\t\t\t\t}",
"t=a[j-1]",
"t",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1]=a[j]",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j]",
"a",
"j",
"a[j]=t",
"a[j]",
"a",
"j",
"t",
"s++",
"s",
"System.out.print(a[0])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[0]",
"a",
"0",
"for(i=1;i<n;i++)System.out.print(\" \"+a[i]);",
"i=1;",
"i=1",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"System.out.print(\" \"+a[i]);",
"System.out.print(\" \"+a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"+a[i]",
"\" \"",
"a[i]",
"a",
"i",
"System.out.println(\"\\n\"+s)",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\\n\"+s",
"\"\\n\"",
"s",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner stdIn=new Scanner(System.in);
int n,a[]=new int[100],i,j,t,s=0;
n=stdIn.nextInt();
for(i=0;i<n;i++)a[i]=stdIn.nextInt();
for(i=0;i<n-1;i++){
for(j=n-1;j>i;j--){
if(a[j-1]>a[j]){
t=a[j-1];
a[j-1]=a[j];
a[j]=t;
s++;
}
}
}
System.out.print(a[0]);
for(i=1;i<n;i++)System.out.print(" "+a[i]);
System.out.println("\n"+s);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
42,
17,
30,
41,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
14,
40,
13,
30,
3,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
13,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
177,
14
],
[
177,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
31,
33
],
[
27,
34
],
[
34,
35
],
[
34,
36
],
[
27,
37
],
[
37,
38
],
[
38,
39
],
[
27,
40
],
[
41,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
42,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
55,
57
],
[
52,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
52,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
70,
72
],
[
67,
73
],
[
52,
74
],
[
74,
75
],
[
52,
76
],
[
76,
77
],
[
76,
78
],
[
23,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
82,
83
],
[
17,
84
],
[
84,
85
],
[
15,
86
],
[
86,
87
],
[
15,
88
],
[
88,
89
],
[
177,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
99,
100
],
[
92,
101
],
[
101,
102
],
[
101,
103
],
[
92,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
110,
111
],
[
110,
112
],
[
105,
113
],
[
113,
114
],
[
114,
115
],
[
105,
116
],
[
117,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
122,
123
],
[
123,
124
],
[
92,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
127,
130
],
[
92,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
136,
137
],
[
136,
138
],
[
131,
139
],
[
139,
140
],
[
140,
141
],
[
131,
142
],
[
143,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
143,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
160,
161
],
[
160,
162
],
[
92,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
92,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
168,
173
],
[
90,
174
],
[
174,
175
],
[
0,
176
],
[
176,
177
],
[
176,
178
]
] | [
"import java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static int BubbleSort(final int N, int[] A){\n\t\t\n\t\tint count = 0;\n\t\twhile(true){\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn count;\n\t}\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfinal int times = BubbleSort(N, A);\n\t\t\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tSystem.out.println(times);\n\t}\n}",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.Map;",
"Map",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tpublic static int BubbleSort(final int N, int[] A){\n\t\t\n\t\tint count = 0;\n\t\twhile(true){\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn count;\n\t}\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfinal int times = BubbleSort(N, A);\n\t\t\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tSystem.out.println(times);\n\t}\n}",
"Main",
"public static int BubbleSort(final int N, int[] A){\n\t\t\n\t\tint count = 0;\n\t\twhile(true){\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn count;\n\t}",
"BubbleSort",
"{\n\t\t\n\t\tint count = 0;\n\t\twhile(true){\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn count;\n\t}",
"int count = 0;",
"count",
"0",
"while(true){\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"true",
"{\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"boolean update = false;",
"update",
"false",
"for(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}",
"int i = N - 1;",
"int i = N - 1;",
"i",
"N - 1",
"N",
"1",
"i >= 1",
"i",
"1",
"i--",
"i--",
"i",
"{\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}",
"if(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}",
"A[i] < A[i - 1]",
"A[i]",
"A",
"i",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"{\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}",
"int tmp = A[i];",
"tmp",
"A[i]",
"A",
"i",
"A[i] = A[i - 1]",
"A[i]",
"A",
"i",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"A[i - 1] = tmp",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"tmp",
"count++",
"count",
"update = true",
"update",
"true",
"if(!update){\n\t\t\t\tbreak;\n\t\t\t}",
"!update",
"update",
"{\n\t\t\t\tbreak;\n\t\t\t}",
"break;",
"return count;",
"count",
"final int N",
"N",
"int[] A",
"A",
"public static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfinal int times = BubbleSort(N, A);\n\t\t\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tSystem.out.println(times);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfinal int times = BubbleSort(N, A);\n\t\t\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tSystem.out.println(times);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"final int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] A = new int[N];",
"A",
"new int[N]",
"N",
"for(int i = 0; i < N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"final int times = BubbleSort(N, A);",
"times",
"BubbleSort(N, A)",
"BubbleSort",
"N",
"A",
"for(int i = 0; i < N; i++){\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"{\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"if(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"i != 0",
"i",
"0",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(times)",
"System.out.println",
"System.out",
"System",
"System.out",
"times",
"String args[]",
"args",
"public class Main {\n\t\n\tpublic static int BubbleSort(final int N, int[] A){\n\t\t\n\t\tint count = 0;\n\t\twhile(true){\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn count;\n\t}\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfinal int times = BubbleSort(N, A);\n\t\t\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tSystem.out.println(times);\n\t}\n}",
"public class Main {\n\t\n\tpublic static int BubbleSort(final int N, int[] A){\n\t\t\n\t\tint count = 0;\n\t\twhile(true){\n\t\t\tboolean update = false;\n\t\t\t\n\t\t\tfor(int i = N - 1; i >= 1; i--){\n\t\t\t\tif(A[i] < A[i - 1]){\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = tmp;\n\t\t\t\t\t\n\t\t\t\t\tcount++;\n\t\t\t\t\tupdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(!update){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn count;\n\t}\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfinal int times = BubbleSort(N, A);\n\t\t\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i != 0){\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tSystem.out.println(times);\n\t}\n}",
"Main"
] | import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static int BubbleSort(final int N, int[] A){
int count = 0;
while(true){
boolean update = false;
for(int i = N - 1; i >= 1; i--){
if(A[i] < A[i - 1]){
int tmp = A[i];
A[i] = A[i - 1];
A[i - 1] = tmp;
count++;
update = true;
}
}
if(!update){
break;
}
}
return count;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
final int N = sc.nextInt();
int[] A = new int[N];
for(int i = 0; i < N; i++){
A[i] = sc.nextInt();
}
final int times = BubbleSort(N, A);
for(int i = 0; i < N; i++){
if(i != 0){
System.out.print(" ");
}
System.out.print(A[i]);
}
System.out.println();
System.out.println(times);
}
} |
[
7,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
0,
13,
4,
18,
13,
0,
13,
20,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
17,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
0,
13,
17,
2,
13,
2,
2,
13,
17,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
23,
13,
12,
13,
30,
4,
18,
20,
18,
13,
13,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
182,
2
],
[
182,
3
],
[
3,
4
],
[
3,
5
],
[
5,
6
],
[
6,
7
],
[
6,
8
],
[
5,
9
],
[
9,
10
],
[
5,
11
],
[
11,
12
],
[
5,
13
],
[
13,
14
],
[
5,
15
],
[
15,
16
],
[
5,
17
],
[
17,
18
],
[
5,
19
],
[
19,
20
],
[
5,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
5,
26
],
[
26,
27
],
[
26,
28
],
[
5,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
30,
35
],
[
35,
36
],
[
35,
37
],
[
30,
38
],
[
38,
39
],
[
39,
40
],
[
30,
41
],
[
42,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
5,
50
],
[
50,
51
],
[
50,
52
],
[
5,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
53,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
53,
63
],
[
63,
64
],
[
64,
65
],
[
53,
66
],
[
67,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
76,
76
],
[
76,
77
],
[
76,
78
],
[
76,
79
],
[
68,
80
],
[
80,
81
],
[
81,
82
],
[
68,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
85,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
95,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
110,
116
],
[
95,
117
],
[
117,
118
],
[
5,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
119,
129
],
[
129,
130
],
[
130,
131
],
[
119,
132
],
[
133,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
5,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
144,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
151,
153
],
[
5,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
5,
160
],
[
160,
161
],
[
161,
162
],
[
3,
163
],
[
163,
164
],
[
3,
165
],
[
165,
166
],
[
182,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
170,
173
],
[
173,
174
],
[
173,
175
],
[
170,
176
],
[
176,
177
],
[
176,
178
],
[
167,
179
],
[
179,
180
],
[
0,
181
],
[
181,
182
],
[
181,
183
]
] | [
"public class Main{\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n;\n int[] a;\n int i, j, count, tmp;\n\n n = sc.nextInt();\n a = new int[n];\n for(i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n\n count = 0;\n\n for(i = 0;i < n - 1;i++){\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }\n\n for(i = 0;i < n - 1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n - 1]);\n System.out.println(count);\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n}",
"public class Main{\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n;\n int[] a;\n int i, j, count, tmp;\n\n n = sc.nextInt();\n a = new int[n];\n for(i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n\n count = 0;\n\n for(i = 0;i < n - 1;i++){\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }\n\n for(i = 0;i < n - 1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n - 1]);\n System.out.println(count);\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n}",
"Main",
"public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n;\n int[] a;\n int i, j, count, tmp;\n\n n = sc.nextInt();\n a = new int[n];\n for(i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n\n count = 0;\n\n for(i = 0;i < n - 1;i++){\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }\n\n for(i = 0;i < n - 1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n - 1]);\n System.out.println(count);\n\n sc.close();\n }",
"run",
"{\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n;\n int[] a;\n int i, j, count, tmp;\n\n n = sc.nextInt();\n a = new int[n];\n for(i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n\n count = 0;\n\n for(i = 0;i < n - 1;i++){\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }\n\n for(i = 0;i < n - 1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n - 1]);\n System.out.println(count);\n\n sc.close();\n }",
"java.util.Scanner sc = new java.util.Scanner(in);",
"sc",
"new java.util.Scanner(in)",
"int n;",
"n",
"int[] a;",
"a",
"int i",
"i",
"j",
"j",
"count",
"count",
"tmp;",
"tmp",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"a = new int[n]",
"a",
"new int[n]",
"n",
"for(i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = sc.nextInt();\n }",
"{\n a[i] = sc.nextInt();\n }",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"count = 0",
"count",
"0",
"for(i = 0;i < n - 1;i++){\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }",
"{\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }",
"for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }",
"j = 0;",
"j = 0",
"j",
"0",
"j < n - 1 - i",
"j",
"n - 1 - i",
"n - 1 - i",
"n",
"1",
"i",
"j++",
"j++",
"j",
"{\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }",
"{\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }",
"if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }",
"a[j] > a[j + 1]",
"a[j]",
"a",
"j",
"a[j + 1]",
"a",
"j + 1",
"j",
"1",
"{\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }",
"tmp = a[j]",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j + 1]",
"a[j]",
"a",
"j",
"a[j + 1]",
"a",
"j + 1",
"j",
"1",
"a[j + 1] = tmp",
"a[j + 1]",
"a",
"j + 1",
"j",
"1",
"tmp",
"count++",
"count",
"for(i = 0;i < n - 1;i++){\n System.out.print(a[i] + \" \");\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(a[i] + \" \");\n }",
"{\n System.out.print(a[i] + \" \");\n }",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(a[n - 1])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[n - 1]",
"a",
"n - 1",
"n",
"1",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"sc.close()",
"sc.close",
"sc",
"java.io.InputStream in",
"in",
"java.io.PrintStream out",
"out",
"public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }",
"main",
"{\n (new Main()).run(System.in, System.out);\n }",
"(new Main()).run(System.in, System.out)",
"(new Main()).run",
"(new Main())",
"System.in",
"System",
"System.in",
"System.out",
"System",
"System.out",
"String[] args",
"args",
"public class Main{\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n;\n int[] a;\n int i, j, count, tmp;\n\n n = sc.nextInt();\n a = new int[n];\n for(i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n\n count = 0;\n\n for(i = 0;i < n - 1;i++){\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }\n\n for(i = 0;i < n - 1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n - 1]);\n System.out.println(count);\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n}",
"public class Main{\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n;\n int[] a;\n int i, j, count, tmp;\n\n n = sc.nextInt();\n a = new int[n];\n for(i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n\n count = 0;\n\n for(i = 0;i < n - 1;i++){\n for(j = 0;j < n - 1 - i;j++){\n if(a[j] > a[j + 1]){\n tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n count++;\n }\n }\n }\n\n for(i = 0;i < n - 1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n - 1]);\n System.out.println(count);\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n}",
"Main"
] | public class Main{
public void run(java.io.InputStream in, java.io.PrintStream out){
java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
int n;
int[] a;
int i, j, count, tmp;
n = sc.nextInt();
a = new int[n];
for(i = 0;i < n;i++){
a[i] = sc.nextInt();
}
count = 0;
for(i = 0;i < n - 1;i++){
for(j = 0;j < n - 1 - i;j++){
if(a[j] > a[j + 1]){
tmp = a[j];
a[j] = a[j + 1];
a[j + 1] = tmp;
count++;
}
}
}
for(i = 0;i < n - 1;i++){
System.out.print(a[i] + " ");
}
System.out.println(a[n - 1]);
System.out.println(count);
sc.close();
}
public static void main(String[] args){
(new Main()).run(System.in, System.out);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
14,
2,
13,
13,
30,
29,
13,
30,
29,
13,
23,
13,
23,
13,
12,
13,
30,
14,
2,
13,
13,
30,
29,
13,
30,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
38,
5,
13,
30,
4,
18,
18,
13,
13,
13,
30,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
42,
17,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
13,
17,
14,
2,
13,
17,
30,
3,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
10,
11
],
[
10,
12
],
[
9,
13
],
[
13,
14
],
[
14,
15
],
[
9,
16
],
[
16,
17
],
[
17,
18
],
[
6,
19
],
[
19,
20
],
[
6,
21
],
[
21,
22
],
[
4,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
30,
31
],
[
31,
32
],
[
26,
33
],
[
33,
34
],
[
34,
35
],
[
23,
36
],
[
36,
37
],
[
23,
38
],
[
38,
39
],
[
4,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
42,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
63,
64
],
[
56,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
56,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
56,
76
],
[
76,
77
],
[
76,
78
],
[
56,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
80,
85
],
[
85,
86
],
[
85,
87
],
[
80,
88
],
[
88,
89
],
[
89,
90
],
[
80,
91
],
[
92,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
56,
103
],
[
103,
104
],
[
103,
105
],
[
56,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
112,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
119,
121
],
[
112,
122
],
[
122,
123
],
[
123,
124
],
[
112,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
128,
134
],
[
134,
135
],
[
134,
136
],
[
127,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
140,
142
],
[
137,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
149,
151
],
[
137,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
155,
157
],
[
152,
158
],
[
137,
159
],
[
159,
160
],
[
159,
161
],
[
137,
162
],
[
162,
163
],
[
162,
164
],
[
108,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
169,
170
],
[
56,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
171,
176
],
[
176,
177
],
[
176,
178
],
[
171,
179
],
[
179,
180
],
[
180,
181
],
[
171,
182
],
[
183,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
184,
189
],
[
189,
190
],
[
189,
191
],
[
183,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
195,
197
],
[
192,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
199,
204
],
[
56,
205
],
[
205,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
56,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
210,
215
],
[
40,
216
],
[
216,
217
]
] | [
"import java.io.*;\n\nclass Main{\n \n public static int maxv(int x, int y){\n if(x >= y){\n return x;\n }else{\n return y;\n }\n }\n\n public static int minv(int x, int y){\n if(x <= y){\n return x;\n }else{\n return y;\n }\n }\n\n public static void main(String[] args){\n\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n try { \n int N = Integer.parseInt(reader.readLine());;\n\t\t \tString line = reader.readLine();\n\t\t\t String[] strAry = line.split(\" \");\n \n\t\t\t int[] a = new int[N];\n\t\t\t\n\t\t\t for (int i = 0;i < N; i++){\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }\n\n int count = 0;\n\n while(true){\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }\n \n for(int i = 0; i < N; i++){\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }\n System.out.println();\n\n System.out.println(count);\n \n } catch (IOException e) {\n //TODO: handle exception\n System.out.println(e);\n }\n }\n}",
"import java.io.*;",
"io.*",
"java",
"class Main{\n \n public static int maxv(int x, int y){\n if(x >= y){\n return x;\n }else{\n return y;\n }\n }\n\n public static int minv(int x, int y){\n if(x <= y){\n return x;\n }else{\n return y;\n }\n }\n\n public static void main(String[] args){\n\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n try { \n int N = Integer.parseInt(reader.readLine());;\n\t\t \tString line = reader.readLine();\n\t\t\t String[] strAry = line.split(\" \");\n \n\t\t\t int[] a = new int[N];\n\t\t\t\n\t\t\t for (int i = 0;i < N; i++){\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }\n\n int count = 0;\n\n while(true){\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }\n \n for(int i = 0; i < N; i++){\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }\n System.out.println();\n\n System.out.println(count);\n \n } catch (IOException e) {\n //TODO: handle exception\n System.out.println(e);\n }\n }\n}",
"Main",
"public static int maxv(int x, int y){\n if(x >= y){\n return x;\n }else{\n return y;\n }\n }",
"maxv",
"{\n if(x >= y){\n return x;\n }else{\n return y;\n }\n }",
"if(x >= y){\n return x;\n }else{\n return y;\n }",
"x >= y",
"x",
"y",
"{\n return x;\n }",
"return x;",
"x",
"{\n return y;\n }",
"return y;",
"y",
"int x",
"x",
"int y",
"y",
"public static int minv(int x, int y){\n if(x <= y){\n return x;\n }else{\n return y;\n }\n }",
"minv",
"{\n if(x <= y){\n return x;\n }else{\n return y;\n }\n }",
"if(x <= y){\n return x;\n }else{\n return y;\n }",
"x <= y",
"x",
"y",
"{\n return x;\n }",
"return x;",
"x",
"{\n return y;\n }",
"return y;",
"y",
"int x",
"x",
"int y",
"y",
"public static void main(String[] args){\n\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n try { \n int N = Integer.parseInt(reader.readLine());;\n\t\t \tString line = reader.readLine();\n\t\t\t String[] strAry = line.split(\" \");\n \n\t\t\t int[] a = new int[N];\n\t\t\t\n\t\t\t for (int i = 0;i < N; i++){\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }\n\n int count = 0;\n\n while(true){\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }\n \n for(int i = 0; i < N; i++){\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }\n System.out.println();\n\n System.out.println(count);\n \n } catch (IOException e) {\n //TODO: handle exception\n System.out.println(e);\n }\n }",
"main",
"{\n\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n try { \n int N = Integer.parseInt(reader.readLine());;\n\t\t \tString line = reader.readLine();\n\t\t\t String[] strAry = line.split(\" \");\n \n\t\t\t int[] a = new int[N];\n\t\t\t\n\t\t\t for (int i = 0;i < N; i++){\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }\n\n int count = 0;\n\n while(true){\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }\n \n for(int i = 0; i < N; i++){\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }\n System.out.println();\n\n System.out.println(count);\n \n } catch (IOException e) {\n //TODO: handle exception\n System.out.println(e);\n }\n }",
"BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));",
"reader",
"new BufferedReader(new InputStreamReader(System.in))",
"try { \n int N = Integer.parseInt(reader.readLine());;\n\t\t \tString line = reader.readLine();\n\t\t\t String[] strAry = line.split(\" \");\n \n\t\t\t int[] a = new int[N];\n\t\t\t\n\t\t\t for (int i = 0;i < N; i++){\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }\n\n int count = 0;\n\n while(true){\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }\n \n for(int i = 0; i < N; i++){\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }\n System.out.println();\n\n System.out.println(count);\n \n } catch (IOException e) {\n //TODO: handle exception\n System.out.println(e);\n }",
"catch (IOException e) {\n //TODO: handle exception\n System.out.println(e);\n }",
"IOException e",
"{\n //TODO: handle exception\n System.out.println(e);\n }",
"System.out.println(e)",
"System.out.println",
"System.out",
"System",
"System.out",
"e",
"{ \n int N = Integer.parseInt(reader.readLine());;\n\t\t \tString line = reader.readLine();\n\t\t\t String[] strAry = line.split(\" \");\n \n\t\t\t int[] a = new int[N];\n\t\t\t\n\t\t\t for (int i = 0;i < N; i++){\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }\n\n int count = 0;\n\n while(true){\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }\n \n for(int i = 0; i < N; i++){\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }\n System.out.println();\n\n System.out.println(count);\n \n }",
"int N = Integer.parseInt(reader.readLine());",
"N",
"Integer.parseInt(reader.readLine())",
"Integer.parseInt",
"Integer",
"reader.readLine()",
"reader.readLine",
"reader",
"String line = reader.readLine();",
"line",
"reader.readLine()",
"reader.readLine",
"reader",
"String[] strAry = line.split(\" \");",
"strAry",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"int[] a = new int[N];",
"a",
"new int[N]",
"N",
"for (int i = 0;i < N; i++){\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }",
"{\n\t\t\t\t a[i] = Integer.parseInt(strAry[i]);\n\t\t\t }",
"a[i] = Integer.parseInt(strAry[i])",
"a[i]",
"a",
"i",
"Integer.parseInt(strAry[i])",
"Integer.parseInt",
"Integer",
"strAry[i]",
"strAry",
"i",
"int count = 0;",
"count",
"0",
"while(true){\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }",
"true",
"{\n int v = 0;\n for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }\n\n if(v == 0){\n break;\n }\n }",
"int v = 0;",
"v",
"0",
"for(int i = 0; i < (N -1); i++){\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < (N -1)",
"i",
"(N -1)",
"N",
"1",
"i++",
"i++",
"i",
"{\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }",
"{\n if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }\n }",
"if(a[i + 1] < a[i]){\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }",
"a[i + 1] < a[i]",
"a[i + 1]",
"a",
"i + 1",
"i",
"1",
"a[i]",
"a",
"i",
"{\n int k = a[i];\n a[i] = a[i+1];\n a[i + 1] = k;\n count += 1;\n v = 1;\n }",
"int k = a[i];",
"k",
"a[i]",
"a",
"i",
"a[i] = a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"a[i + 1] = k",
"a[i + 1]",
"a",
"i + 1",
"i",
"1",
"k",
"count += 1",
"count",
"1",
"v = 1",
"v",
"1",
"if(v == 0){\n break;\n }",
"v == 0",
"v",
"0",
"{\n break;\n }",
"break;",
"for(int i = 0; i < N; i++){\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }",
"{\n System.out.print(a[i]);\n if(i != (N - 1)){\n System.out.print(\" \");\n }\n }",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"if(i != (N - 1)){\n System.out.print(\" \");\n }",
"i != (N - 1)",
"i",
"(N - 1)",
"N",
"1",
"{\n System.out.print(\" \");\n }",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args"
] | import java.io.*;
class Main{
public static int maxv(int x, int y){
if(x >= y){
return x;
}else{
return y;
}
}
public static int minv(int x, int y){
if(x <= y){
return x;
}else{
return y;
}
}
public static void main(String[] args){
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
int N = Integer.parseInt(reader.readLine());;
String line = reader.readLine();
String[] strAry = line.split(" ");
int[] a = new int[N];
for (int i = 0;i < N; i++){
a[i] = Integer.parseInt(strAry[i]);
}
int count = 0;
while(true){
int v = 0;
for(int i = 0; i < (N -1); i++){
if(a[i + 1] < a[i]){
int k = a[i];
a[i] = a[i+1];
a[i + 1] = k;
count += 1;
v = 1;
}
}
if(v == 0){
break;
}
}
for(int i = 0; i < N; i++){
System.out.print(a[i]);
if(i != (N - 1)){
System.out.print(" ");
}
}
System.out.println();
System.out.println(count);
} catch (IOException e) {
//TODO: handle exception
System.out.println(e);
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
0,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
173,
5
],
[
173,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
8,
13
],
[
13,
14
],
[
8,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
27,
30
],
[
30,
31
],
[
31,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
8,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
37,
42
],
[
42,
43
],
[
42,
44
],
[
37,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
56,
57
],
[
57,
58
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
59,
72
],
[
73,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
74,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
74,
86
],
[
86,
87
],
[
87,
88
],
[
74,
89
],
[
90,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
91,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
101,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
112,
114
],
[
109,
115
],
[
115,
116
],
[
115,
117
],
[
101,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
101,
123
],
[
123,
124
],
[
8,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
125,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
125,
135
],
[
135,
136
],
[
136,
137
],
[
125,
138
],
[
139,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
8,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
153,
155
],
[
150,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
8,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
6,
170
],
[
170,
171
],
[
0,
172
],
[
172,
173
],
[
172,
174
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tint m,i,j,big,k;\n\t\tint count = 0;\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = Integer.parseInt(in.nextLine());\n\t\tint array[] = new int[n];\n\n\t\tfor(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());\n\n\tfor (i=0; i<n-1; i++){ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}\n\tfor(k = 0;k<n-1;k++){\n\t\tSystem.out.print(array[k]+\" \");\n\t}\n if(k==(n-1))System.out.println(array[k]);\n\t\t\tSystem.out.println(count);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tint m,i,j,big,k;\n\t\tint count = 0;\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = Integer.parseInt(in.nextLine());\n\t\tint array[] = new int[n];\n\n\t\tfor(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());\n\n\tfor (i=0; i<n-1; i++){ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}\n\tfor(k = 0;k<n-1;k++){\n\t\tSystem.out.print(array[k]+\" \");\n\t}\n if(k==(n-1))System.out.println(array[k]);\n\t\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tint m,i,j,big,k;\n\t\tint count = 0;\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = Integer.parseInt(in.nextLine());\n\t\tint array[] = new int[n];\n\n\t\tfor(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());\n\n\tfor (i=0; i<n-1; i++){ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}\n\tfor(k = 0;k<n-1;k++){\n\t\tSystem.out.print(array[k]+\" \");\n\t}\n if(k==(n-1))System.out.println(array[k]);\n\t\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tint m,i,j,big,k;\n\t\tint count = 0;\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = Integer.parseInt(in.nextLine());\n\t\tint array[] = new int[n];\n\n\t\tfor(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());\n\n\tfor (i=0; i<n-1; i++){ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}\n\tfor(k = 0;k<n-1;k++){\n\t\tSystem.out.print(array[k]+\" \");\n\t}\n if(k==(n-1))System.out.println(array[k]);\n\t\t\tSystem.out.println(count);\n\t}",
"int m",
"m",
"i",
"i",
"j",
"j",
"big",
"big",
"k;",
"k",
"int count = 0;",
"count",
"0",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int n = Integer.parseInt(in.nextLine());",
"n",
"Integer.parseInt(in.nextLine())",
"Integer.parseInt",
"Integer",
"in.nextLine()",
"in.nextLine",
"in",
"int array[] = new int[n];",
"array",
"new int[n]",
"n",
"for(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());",
"m=0;",
"m=0",
"m",
"0",
"m<n",
"m",
"n",
"m++",
"m++",
"m",
"array[m] = Integer.parseInt(in.next());",
"array[m] = Integer.parseInt(in.next())",
"array[m]",
"array",
"m",
"Integer.parseInt(in.next())",
"Integer.parseInt",
"Integer",
"in.next()",
"in.next",
"in",
"for (i=0; i<n-1; i++){ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}",
"{ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}",
"for (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}",
"j=n-1;",
"j=n-1",
"j",
"n-1",
"n",
"1",
"j>=i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}",
"{ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}",
"if (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}",
"array[j] < array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"{\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}",
"big = array[j-1]",
"big",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1] = array[j]",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j]",
"array",
"j",
"array[j] = big",
"array[j]",
"array",
"j",
"big",
"count++",
"count",
"for(k = 0;k<n-1;k++){\n\t\tSystem.out.print(array[k]+\" \");\n\t}",
"k = 0;",
"k = 0",
"k",
"0",
"k<n-1",
"k",
"n-1",
"n",
"1",
"k++",
"k++",
"k",
"{\n\t\tSystem.out.print(array[k]+\" \");\n\t}",
"{\n\t\tSystem.out.print(array[k]+\" \");\n\t}",
"System.out.print(array[k]+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"array[k]+\" \"",
"array[k]",
"array",
"k",
"\" \"",
"if(k==(n-1))System.out.println(array[k]);",
"k==(n-1)",
"k",
"(n-1)",
"n",
"1",
"System.out.println(array[k])",
"System.out.println",
"System.out",
"System",
"System.out",
"array[k]",
"array",
"k",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tint m,i,j,big,k;\n\t\tint count = 0;\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = Integer.parseInt(in.nextLine());\n\t\tint array[] = new int[n];\n\n\t\tfor(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());\n\n\tfor (i=0; i<n-1; i++){ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}\n\tfor(k = 0;k<n-1;k++){\n\t\tSystem.out.print(array[k]+\" \");\n\t}\n if(k==(n-1))System.out.println(array[k]);\n\t\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tint m,i,j,big,k;\n\t\tint count = 0;\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = Integer.parseInt(in.nextLine());\n\t\tint array[] = new int[n];\n\n\t\tfor(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());\n\n\tfor (i=0; i<n-1; i++){ //???????????????????????????????????°i\n\t\tfor (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\\????´???¨??????????????????????????°j\n\t\t\tif (array[j] < array[j-1]){\n\t\t\t\tbig = array[j-1]; //??§???????????????????´????????????????????????????????????°big\n\t\t\t\tarray[j-1] = array[j]; //??????????????§??\\???????????????\n\t\t\t\tarray[j] = big;\n\t\t\t\tcount++; //???????????\\??????????????°?????????????????????\n\t\t\t}\n\t\t}\n\t}\n\tfor(k = 0;k<n-1;k++){\n\t\tSystem.out.print(array[k]+\" \");\n\t}\n if(k==(n-1))System.out.println(array[k]);\n\t\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int m,i,j,big,k;
int count = 0;
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(in.nextLine());
int array[] = new int[n];
for(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());
for (i=0; i<n-1; i++){ //???????????????????????????????????°i
for (j=n-1; j>=i+1; j--){ //?????????????°?????????£??\????´???¨??????????????????????????°j
if (array[j] < array[j-1]){
big = array[j-1]; //??§???????????????????´????????????????????????????????????°big
array[j-1] = array[j]; //??????????????§??\???????????????
array[j] = big;
count++; //???????????\??????????????°?????????????????????
}
}
}
for(k = 0;k<n-1;k++){
System.out.print(array[k]+" ");
}
if(k==(n-1))System.out.println(array[k]);
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
17,
4,
13,
13,
4,
18,
18,
13,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
12,
13,
30,
4,
18,
20,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
173,
5
],
[
173,
6
],
[
6,
7
],
[
6,
8
],
[
173,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
25,
29
],
[
21,
30
],
[
30,
31
],
[
30,
32
],
[
21,
33
],
[
33,
34
],
[
34,
35
],
[
21,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
45,
47
],
[
38,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
48,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
48,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
63,
69
],
[
48,
70
],
[
70,
71
],
[
70,
72
],
[
48,
73
],
[
73,
74
],
[
9,
75
],
[
75,
76
],
[
173,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
79,
88
],
[
88,
89
],
[
88,
90
],
[
79,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
92,
102
],
[
102,
103
],
[
103,
104
],
[
92,
105
],
[
106,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
112,
113
],
[
79,
114
],
[
114,
115
],
[
114,
116
],
[
79,
117
],
[
117,
118
],
[
117,
119
],
[
79,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
125,
126
],
[
125,
127
],
[
79,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
128,
138
],
[
138,
139
],
[
139,
140
],
[
128,
141
],
[
142,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
150,
152
],
[
79,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
79,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
173,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
164,
170
],
[
170,
171
],
[
0,
172
],
[
172,
173
],
[
172,
174
]
] | [
"import java.util.*;\n\npublic class Main {\n\t\n\tint count = 0;\n\t\n\tvoid bubbleSort(int[] A) {\n\t\tboolean f = true;\n\t\twhile (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tSystem.out.print(A[0]);\n\t\tfor (int i = 1; i < A.length; i++) {\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}\n\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\t\n\tint count = 0;\n\t\n\tvoid bubbleSort(int[] A) {\n\t\tboolean f = true;\n\t\twhile (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tSystem.out.print(A[0]);\n\t\tfor (int i = 1; i < A.length; i++) {\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}\n\n}",
"Main",
"int count = 0;",
"count",
"0",
"void bubbleSort(int[] A) {\n\t\tboolean f = true;\n\t\twhile (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"bubbleSort",
"{\n\t\tboolean f = true;\n\t\twhile (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"boolean f = true;",
"f",
"true",
"while (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"f",
"{\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"f = false",
"f",
"false",
"for (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int i = A.length - 1;",
"int i = A.length - 1;",
"i",
"A.length - 1",
"A.length",
"A",
"A.length",
"1",
"i >= 1",
"i",
"1",
"i--",
"i--",
"i",
"{\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"A[i] < A[i-1]",
"A[i]",
"A",
"i",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"{\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"int tmp = A[i];",
"tmp",
"A[i]",
"A",
"i",
"A[i] = A[i-1]",
"A[i]",
"A",
"i",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i-1] = tmp",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"tmp",
"f = true",
"f",
"true",
"count++",
"count",
"int[] A",
"A",
"void run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tSystem.out.print(A[0]);\n\t\tfor (int i = 1; i < A.length; i++) {\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"run",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tSystem.out.print(A[0]);\n\t\tfor (int i = 1; i < A.length; i++) {\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int[] A = new int[n];",
"A",
"new int[n]",
"n",
"for (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < A.length",
"i",
"A.length",
"A",
"A.length",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = scan.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = scan.nextInt();\n\t\t}",
"A[i] = scan.nextInt()",
"A[i]",
"A",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"count = 0",
"count",
"0",
"bubbleSort(A)",
"bubbleSort",
"A",
"System.out.print(A[0])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[0]",
"A",
"0",
"for (int i = 1; i < A.length; i++) {\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < A.length",
"i",
"A.length",
"A",
"A.length",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}",
"{\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}",
"System.out.print(\" \" + A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \" + A[i]",
"\" \"",
"A[i]",
"A",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"public static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}",
"main",
"{\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}",
"new Main().run()",
"new Main().run",
"new Main()",
"String[] args",
"args",
"public class Main {\n\t\n\tint count = 0;\n\t\n\tvoid bubbleSort(int[] A) {\n\t\tboolean f = true;\n\t\twhile (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tSystem.out.print(A[0]);\n\t\tfor (int i = 1; i < A.length; i++) {\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}\n\n}",
"public class Main {\n\t\n\tint count = 0;\n\t\n\tvoid bubbleSort(int[] A) {\n\t\tboolean f = true;\n\t\twhile (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tSystem.out.print(A[0]);\n\t\tfor (int i = 1; i < A.length; i++) {\n\t\t\tSystem.out.print(\" \" + A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}\n\n}",
"Main"
] | import java.util.*;
public class Main {
int count = 0;
void bubbleSort(int[] A) {
boolean f = true;
while (f) {
f = false;
for (int i = A.length - 1; i >= 1; i--) {
if (A[i] < A[i-1]) {
int tmp = A[i];
A[i] = A[i-1];
A[i-1] = tmp;
f = true;
count++;
}
}
}
}
void run() {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] A = new int[n];
for (int i = 0; i < A.length; i++) {
A[i] = scan.nextInt();
}
count = 0;
bubbleSort(A);
System.out.print(A[0]);
for (int i = 1; i < A.length; i++) {
System.out.print(" " + A[i]);
}
System.out.println();
System.out.println(count);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main().run();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
38,
30,
41,
13,
20,
41,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
0,
13,
4,
13,
13,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
41,
13,
17,
41,
13,
2,
2,
13,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
28,
13,
13,
30,
30,
4,
18,
4,
18,
13,
13,
17,
4,
18,
13,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
206,
11
],
[
206,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
20,
22
],
[
16,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
29,
30
],
[
16,
31
],
[
31,
32
],
[
31,
33
],
[
16,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
37,
42
],
[
16,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
43,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
62,
64
],
[
16,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
67,
70
],
[
16,
71
],
[
71,
72
],
[
71,
73
],
[
16,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
74,
79
],
[
12,
80
],
[
80,
81
],
[
206,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
93,
95
],
[
89,
96
],
[
96,
97
],
[
88,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
102,
104
],
[
88,
105
],
[
105,
106
],
[
106,
107
],
[
88,
108
],
[
109,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
113,
120
],
[
120,
121
],
[
120,
122
],
[
113,
123
],
[
123,
124
],
[
124,
125
],
[
113,
126
],
[
127,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
128,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
138,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
150,
152
],
[
138,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
156,
158
],
[
153,
159
],
[
138,
160
],
[
160,
161
],
[
138,
162
],
[
162,
163
],
[
162,
164
],
[
84,
165
],
[
165,
166
],
[
82,
167
],
[
167,
168
],
[
82,
169
],
[
169,
170
],
[
206,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
177,
178
],
[
177,
179
],
[
177,
180
],
[
181,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
184,
187
],
[
182,
188
],
[
173,
189
],
[
189,
190
],
[
190,
191
],
[
189,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
192,
196
],
[
173,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
197,
202
],
[
171,
203
],
[
203,
204
],
[
0,
205
],
[
205,
206
],
[
205,
207
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }\n }\n\n static int bubbleSort(int[] a, int n) {\n int count=0;\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n return count;\n }\n\n public static void dispIntArray(int a[]) {\n StringBuilder s = new StringBuilder();\n\n for (int i : a) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n\n System.out.println(s);\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }\n }\n\n static int bubbleSort(int[] a, int n) {\n int count=0;\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n return count;\n }\n\n public static void dispIntArray(int a[]) {\n StringBuilder s = new StringBuilder();\n\n for (int i : a) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n\n System.out.println(s);\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }\n }",
"main",
"{\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }\n }",
"try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }",
"{\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"new BufferedReader(new InputStreamReader(System.in))",
"int count=0;",
"count",
"0",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"int[] seq = new int[n];",
"seq",
"new int[n]",
"n",
"String[] line = br.readLine().split(\" \");",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);",
"int i=0;",
"int i=0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"seq[i] = Integer.parseInt(line[i]);",
"seq[i] = Integer.parseInt(line[i])",
"seq[i]",
"seq",
"i",
"Integer.parseInt(line[i])",
"Integer.parseInt",
"Integer",
"line[i]",
"line",
"i",
"count = bubbleSort(seq, n)",
"count",
"bubbleSort(seq, n)",
"bubbleSort",
"seq",
"n",
"dispIntArray(seq)",
"dispIntArray",
"seq",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"static int bubbleSort(int[] a, int n) {\n int count=0;\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n return count;\n }",
"bubbleSort",
"{\n int count=0;\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n return count;\n }",
"int count=0;",
"count",
"0",
"for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }",
"int i=0,f=1,t;",
"int i=0",
"i",
"0",
"f=1",
"f",
"1",
"t;",
"t",
"i<n || f==1",
"i<n",
"i",
"n",
"f==1",
"f",
"1",
"i++",
"i++",
"i",
"{\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }",
"{\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }",
"f=0",
"f",
"0",
"for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }",
"int j=n-1;",
"int j=n-1;",
"j",
"n-1",
"n",
"1",
"j>0",
"j",
"0",
"j--",
"j--",
"j",
"{\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }",
"{\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }",
"if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }",
"t = a[j]",
"t",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = t",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"t",
"count++",
"count",
"f=1",
"f",
"1",
"return count;",
"count",
"int[] a",
"a",
"int n",
"n",
"public static void dispIntArray(int a[]) {\n StringBuilder s = new StringBuilder();\n\n for (int i : a) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n\n System.out.println(s);\n }",
"dispIntArray",
"{\n StringBuilder s = new StringBuilder();\n\n for (int i : a) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n\n System.out.println(s);\n }",
"StringBuilder s = new StringBuilder();",
"s",
"new StringBuilder()",
"for (int i : a) { s.append(i).append(\" \"); }",
"int i",
"a",
"{ s.append(i).append(\" \"); }",
"{ s.append(i).append(\" \"); }",
"s.append(i).append(\" \")",
"s.append(i).append",
"s.append(i)",
"s.append",
"s",
"i",
"\" \"",
"s.setLength(s.length()-1)",
"s.setLength",
"s",
"s.length()-1",
"s.length()",
"s.length",
"s",
"1",
"System.out.println(s)",
"System.out.println",
"System.out",
"System",
"System.out",
"s",
"int a[]",
"a",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }\n }\n\n static int bubbleSort(int[] a, int n) {\n int count=0;\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n return count;\n }\n\n public static void dispIntArray(int a[]) {\n StringBuilder s = new StringBuilder();\n\n for (int i : a) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n\n System.out.println(s);\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++)\n seq[i] = Integer.parseInt(line[i]);\n\n count = bubbleSort(seq, n);\n\n dispIntArray(seq);\n System.out.println(count);\n }\n }\n\n static int bubbleSort(int[] a, int n) {\n int count=0;\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( a[j] < a[j-1]) {\n t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n return count;\n }\n\n public static void dispIntArray(int a[]) {\n StringBuilder s = new StringBuilder();\n\n for (int i : a) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n\n System.out.println(s);\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int count=0;
int n = Integer.parseInt(br.readLine());
int[] seq = new int[n];
String[] line = br.readLine().split(" ");
for (int i=0; i < n; i++)
seq[i] = Integer.parseInt(line[i]);
count = bubbleSort(seq, n);
dispIntArray(seq);
System.out.println(count);
}
}
static int bubbleSort(int[] a, int n) {
int count=0;
for(int i=0,f=1,t; i<n || f==1; i++ ) {
f=0;
for(int j=n-1; j>0; j-- ) {
if( a[j] < a[j-1]) {
t = a[j];
a[j] = a[j-1];
a[j-1] = t;
count++;
f=1;
}
}
}
return count;
}
public static void dispIntArray(int a[]) {
StringBuilder s = new StringBuilder();
for (int i : a) { s.append(i).append(" "); }
s.setLength(s.length()-1);
System.out.println(s);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
152,
5
],
[
152,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
57,
59
],
[
53,
60
],
[
60,
61
],
[
60,
62
],
[
53,
63
],
[
63,
64
],
[
64,
65
],
[
53,
66
],
[
67,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
78,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
78,
100
],
[
100,
101
],
[
100,
102
],
[
78,
103
],
[
103,
104
],
[
8,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
110,
111
],
[
110,
112
],
[
105,
113
],
[
113,
114
],
[
114,
115
],
[
105,
116
],
[
117,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
123,
128
],
[
117,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
129,
134
],
[
134,
135
],
[
134,
136
],
[
8,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
8,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
6,
149
],
[
149,
150
],
[
0,
151
],
[
151,
152
],
[
151,
153
]
] | [
"import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n boolean flag = true;\n int ans = 0;\n while(flag){\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }\n for(int i=0;i<N;i++){\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }\n System.out.print(\"\\n\");\n System.out.println(ans);\n }\n\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n boolean flag = true;\n int ans = 0;\n while(flag){\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }\n for(int i=0;i<N;i++){\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }\n System.out.print(\"\\n\");\n System.out.println(ans);\n }\n\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n boolean flag = true;\n int ans = 0;\n while(flag){\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }\n for(int i=0;i<N;i++){\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }\n System.out.print(\"\\n\");\n System.out.println(ans);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n boolean flag = true;\n int ans = 0;\n while(flag){\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }\n for(int i=0;i<N;i++){\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }\n System.out.print(\"\\n\");\n System.out.println(ans);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int A[] = new int[N];",
"A",
"new int[N]",
"N",
"for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n A[i] = sc.nextInt();\n }",
"{\n A[i] = sc.nextInt();\n }",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"boolean flag = true;",
"flag",
"true",
"int ans = 0;",
"ans",
"0",
"while(flag){\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }",
"flag",
"{\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }",
"int j=N-1;",
"int j=N-1;",
"j",
"N-1",
"N",
"1",
"j>=1",
"j",
"1",
"j--",
"j--",
"j",
"{\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }",
"{\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }",
"if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }",
"A[j]<A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"{\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }",
"int tmp = A[j];",
"tmp",
"A[j]",
"A",
"j",
"A[j] = A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j-1] = tmp",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"tmp",
"flag = true",
"flag",
"true",
"ans++",
"ans",
"for(int i=0;i<N;i++){\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }",
"{\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }",
"if(i>0){\n System.out.print(\" \");\n }",
"i>0",
"i",
"0",
"{\n System.out.print(\" \");\n }",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n boolean flag = true;\n int ans = 0;\n while(flag){\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }\n for(int i=0;i<N;i++){\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }\n System.out.print(\"\\n\");\n System.out.println(ans);\n }\n\n}",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A[] = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n boolean flag = true;\n int ans = 0;\n while(flag){\n flag = false;\n for(int j=N-1;j>=1;j--){\n if(A[j]<A[j-1]){\n int tmp = A[j];\n A[j] = A[j-1];\n A[j-1] = tmp;\n flag = true;\n ans++;\n }\n }\n }\n for(int i=0;i<N;i++){\n if(i>0){\n System.out.print(\" \");\n }\n System.out.print(A[i]);\n }\n System.out.print(\"\\n\");\n System.out.println(ans);\n }\n\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int A[] = new int[N];
for(int i=0;i<N;i++){
A[i] = sc.nextInt();
}
boolean flag = true;
int ans = 0;
while(flag){
flag = false;
for(int j=N-1;j>=1;j--){
if(A[j]<A[j-1]){
int tmp = A[j];
A[j] = A[j-1];
A[j-1] = tmp;
flag = true;
ans++;
}
}
}
for(int i=0;i<N;i++){
if(i>0){
System.out.print(" ");
}
System.out.print(A[i]);
}
System.out.print("\n");
System.out.println(ans);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
42,
2,
2,
17,
13,
2,
13,
17,
30,
0,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
2,
13,
17,
30,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
182,
5
],
[
182,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
15,
19
],
[
19,
20
],
[
19,
21
],
[
14,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
8,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
41,
42
],
[
32,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
48,
49
],
[
49,
50
],
[
8,
51
],
[
51,
52
],
[
51,
53
],
[
8,
54
],
[
54,
55
],
[
54,
56
],
[
8,
57
],
[
57,
58
],
[
57,
59
],
[
8,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
65,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
65,
75
],
[
75,
76
],
[
76,
77
],
[
65,
78
],
[
79,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
80,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
80,
92
],
[
92,
93
],
[
93,
94
],
[
80,
95
],
[
96,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
97,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
110,
112
],
[
107,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
119,
121
],
[
107,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
122,
128
],
[
107,
129
],
[
129,
130
],
[
107,
131
],
[
131,
132
],
[
131,
133
],
[
79,
134
],
[
134,
135
],
[
79,
136
],
[
136,
137
],
[
136,
138
],
[
8,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
139,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
146,
148
],
[
139,
149
],
[
149,
150
],
[
150,
151
],
[
139,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
153,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
8,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
163,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
170,
172
],
[
8,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
173,
178
],
[
6,
179
],
[
179,
180
],
[
0,
181
],
[
181,
182
],
[
181,
183
]
] | [
"import java.util.Scanner;\n\npublic class Main\n{\n public static void main(String[] args)\n {\n\tScanner In = new Scanner(System.in);\n\n\tint n;\n\n\tdo\n\t {\n\t\tn = In.nextInt();\n\t }while(1 >= n && n >= 100);\n\n\tint []a = new int[n];\n\n\tfor(int i = 0; i < n; i++)\n\t a[i] = In.nextInt();\n\t\n\t\n\tint h = 0;\n\tint count = 0;\n\tint flag = 1;\n\n\twhile(flag == 1)\n\t {\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }\n\tfor(int u = 0; u < n-1; u++)\n\t System.out.print(a[u] + \" \");\n\t\n\tSystem.out.println(a[n - 1]);\n\tSystem.out.println(count);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main\n{\n public static void main(String[] args)\n {\n\tScanner In = new Scanner(System.in);\n\n\tint n;\n\n\tdo\n\t {\n\t\tn = In.nextInt();\n\t }while(1 >= n && n >= 100);\n\n\tint []a = new int[n];\n\n\tfor(int i = 0; i < n; i++)\n\t a[i] = In.nextInt();\n\t\n\t\n\tint h = 0;\n\tint count = 0;\n\tint flag = 1;\n\n\twhile(flag == 1)\n\t {\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }\n\tfor(int u = 0; u < n-1; u++)\n\t System.out.print(a[u] + \" \");\n\t\n\tSystem.out.println(a[n - 1]);\n\tSystem.out.println(count);\n }\n}",
"Main",
"public static void main(String[] args)\n {\n\tScanner In = new Scanner(System.in);\n\n\tint n;\n\n\tdo\n\t {\n\t\tn = In.nextInt();\n\t }while(1 >= n && n >= 100);\n\n\tint []a = new int[n];\n\n\tfor(int i = 0; i < n; i++)\n\t a[i] = In.nextInt();\n\t\n\t\n\tint h = 0;\n\tint count = 0;\n\tint flag = 1;\n\n\twhile(flag == 1)\n\t {\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }\n\tfor(int u = 0; u < n-1; u++)\n\t System.out.print(a[u] + \" \");\n\t\n\tSystem.out.println(a[n - 1]);\n\tSystem.out.println(count);\n }",
"main",
"{\n\tScanner In = new Scanner(System.in);\n\n\tint n;\n\n\tdo\n\t {\n\t\tn = In.nextInt();\n\t }while(1 >= n && n >= 100);\n\n\tint []a = new int[n];\n\n\tfor(int i = 0; i < n; i++)\n\t a[i] = In.nextInt();\n\t\n\t\n\tint h = 0;\n\tint count = 0;\n\tint flag = 1;\n\n\twhile(flag == 1)\n\t {\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }\n\tfor(int u = 0; u < n-1; u++)\n\t System.out.print(a[u] + \" \");\n\t\n\tSystem.out.println(a[n - 1]);\n\tSystem.out.println(count);\n }",
"Scanner In = new Scanner(System.in);",
"In",
"new Scanner(System.in)",
"int n;",
"n",
"do\n\t {\n\t\tn = In.nextInt();\n\t }while(1 >= n && n >= 100);",
"1 >= n && n >= 100",
"1 >= n",
"1",
"n",
"n >= 100",
"n",
"100",
"{\n\t\tn = In.nextInt();\n\t }",
"n = In.nextInt()",
"n",
"In.nextInt()",
"In.nextInt",
"In",
"int []a = new int[n];",
"a",
"new int[n]",
"n",
"for(int i = 0; i < n; i++)\n\t a[i] = In.nextInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = In.nextInt();",
"a[i] = In.nextInt()",
"a[i]",
"a",
"i",
"In.nextInt()",
"In.nextInt",
"In",
"int h = 0;",
"h",
"0",
"int count = 0;",
"count",
"0",
"int flag = 1;",
"flag",
"1",
"while(flag == 1)\n\t {\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }",
"flag == 1",
"flag",
"1",
"{\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }",
"for(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i <= n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }",
"{\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }",
"for(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j >= h + 1",
"j",
"h + 1",
"h",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }",
"{\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }",
"if(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }",
"int v = a[j];",
"v",
"a[j]",
"a",
"j",
"a[j] = a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"a[j - 1] = v",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"v",
"count++",
"count",
"flag = 1",
"flag",
"1",
"h++",
"h",
"flag = 0",
"flag",
"0",
"for(int u = 0; u < n-1; u++)\n\t System.out.print(a[u] + \" \");",
"int u = 0;",
"int u = 0;",
"u",
"0",
"u < n-1",
"u",
"n-1",
"n",
"1",
"u++",
"u++",
"u",
"System.out.print(a[u] + \" \");",
"System.out.print(a[u] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[u] + \" \"",
"a[u]",
"a",
"u",
"\" \"",
"System.out.println(a[n - 1])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[n - 1]",
"a",
"n - 1",
"n",
"1",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main\n{\n public static void main(String[] args)\n {\n\tScanner In = new Scanner(System.in);\n\n\tint n;\n\n\tdo\n\t {\n\t\tn = In.nextInt();\n\t }while(1 >= n && n >= 100);\n\n\tint []a = new int[n];\n\n\tfor(int i = 0; i < n; i++)\n\t a[i] = In.nextInt();\n\t\n\t\n\tint h = 0;\n\tint count = 0;\n\tint flag = 1;\n\n\twhile(flag == 1)\n\t {\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }\n\tfor(int u = 0; u < n-1; u++)\n\t System.out.print(a[u] + \" \");\n\t\n\tSystem.out.println(a[n - 1]);\n\tSystem.out.println(count);\n }\n}",
"public class Main\n{\n public static void main(String[] args)\n {\n\tScanner In = new Scanner(System.in);\n\n\tint n;\n\n\tdo\n\t {\n\t\tn = In.nextInt();\n\t }while(1 >= n && n >= 100);\n\n\tint []a = new int[n];\n\n\tfor(int i = 0; i < n; i++)\n\t a[i] = In.nextInt();\n\t\n\t\n\tint h = 0;\n\tint count = 0;\n\tint flag = 1;\n\n\twhile(flag == 1)\n\t {\n\t\tfor(int i = 0; i <= n - 1; i++)\n\t\t {\n\t\t\tfor(int j = n - 1; j >= h + 1; j--)\n\t\t\t {\n\t\t\t\tif(a[j] < a[j-1])\n\t\t\t\t {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t }\n\t\t\t\t\n\t\t\t }\n\t\t\th++;\n\t\t\tflag = 0;\n\t\t }\n\t\t\n\t }\n\tfor(int u = 0; u < n-1; u++)\n\t System.out.print(a[u] + \" \");\n\t\n\tSystem.out.println(a[n - 1]);\n\tSystem.out.println(count);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner In = new Scanner(System.in);
int n;
do
{
n = In.nextInt();
}while(1 >= n && n >= 100);
int []a = new int[n];
for(int i = 0; i < n; i++)
a[i] = In.nextInt();
int h = 0;
int count = 0;
int flag = 1;
while(flag == 1)
{
for(int i = 0; i <= n - 1; i++)
{
for(int j = n - 1; j >= h + 1; j--)
{
if(a[j] < a[j-1])
{
int v = a[j];
a[j] = a[j - 1];
a[j - 1] = v;
count++;
flag = 1;
}
}
h++;
flag = 0;
}
}
for(int u = 0; u < n-1; u++)
System.out.print(a[u] + " ");
System.out.println(a[n - 1]);
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
17,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
14,
2,
13,
17,
30,
3,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
156,
5
],
[
156,
6
],
[
6,
7
],
[
6,
8
],
[
156,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
17,
19
],
[
11,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
11,
41
],
[
41,
42
],
[
41,
43
],
[
11,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
57,
59
],
[
50,
60
],
[
60,
61
],
[
61,
62
],
[
50,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
66,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
65,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
75,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
75,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
75,
97
],
[
97,
98
],
[
97,
99
],
[
75,
100
],
[
100,
101
],
[
46,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
11,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
117,
118
],
[
108,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
126,
127
],
[
126,
128
],
[
120,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
11,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
11,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
9,
153
],
[
153,
154
],
[
0,
155
],
[
155,
156
],
[
155,
157
]
] | [
"import java.util.*;\n\npublic class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ints = new int[n];\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tints[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\twhile (true) {\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}\n\t\t\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n}\t\t\t",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ints = new int[n];\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tints[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\twhile (true) {\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}\n\t\t\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ints = new int[n];\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tints[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\twhile (true) {\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}\n\t\t\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tint n = sc.nextInt();\n\t\tint[] ints = new int[n];\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tints[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\twhile (true) {\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}\n\t\t\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] ints = new int[n];",
"ints",
"new int[n]",
"n",
"for (int i=0; i<n; i++) {\n\t\t\tints[i] = sc.nextInt();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tints[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tints[i] = sc.nextInt();\n\t\t}",
"ints[i] = sc.nextInt()",
"ints[i]",
"ints",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count = 0;",
"count",
"0",
"while (true) {\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}",
"true",
"{\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}",
"boolean flag = false;",
"flag",
"false",
"for (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"ints[i] > ints[i+1]",
"ints[i]",
"ints",
"i",
"ints[i+1]",
"ints",
"i+1",
"i",
"1",
"{\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"int temp = ints[i];",
"temp",
"ints[i]",
"ints",
"i",
"ints[i] = ints[i+1]",
"ints[i]",
"ints",
"i",
"ints[i+1]",
"ints",
"i+1",
"i",
"1",
"ints[i+1] = temp",
"ints[i+1]",
"ints",
"i+1",
"i",
"1",
"temp",
"flag = true",
"flag",
"true",
"count++",
"count",
"if (flag==false) {break;}",
"flag==false",
"flag",
"false",
"{break;}",
"break;",
"for (int i=0; i<n; i++) {\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}",
"{\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}",
"System.out.print(ints[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"ints[i]",
"ints",
"i",
"if (i!=n-1) {System.out.print(\" \");}",
"i!=n-1",
"i",
"n-1",
"n",
"1",
"{System.out.print(\" \");}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ints = new int[n];\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tints[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\twhile (true) {\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}\n\t\t\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ints = new int[n];\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tints[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint count = 0;\n\t\twhile (true) {\n\t\t\tboolean flag = false;\n\t\t\tfor (int i=0; i<n-1; i++) {\n\t\t\t\tif (ints[i] > ints[i+1]) {\n\t\t\t\t\tint temp = ints[i];\n\t\t\t\t\tints[i] = ints[i+1];\n\t\t\t\t\tints[i+1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag==false) {break;}\n\t\t}\n\t\t\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tSystem.out.print(ints[i]);\n\t\t\tif (i!=n-1) {System.out.print(\" \");}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
int[] ints = new int[n];
for (int i=0; i<n; i++) {
ints[i] = sc.nextInt();
}
int count = 0;
while (true) {
boolean flag = false;
for (int i=0; i<n-1; i++) {
if (ints[i] > ints[i+1]) {
int temp = ints[i];
ints[i] = ints[i+1];
ints[i+1] = temp;
flag = true;
count++;
}
}
if (flag==false) {break;}
}
for (int i=0; i<n; i++) {
System.out.print(ints[i]);
if (i!=n-1) {System.out.print(" ");}
}
System.out.println();
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
13,
4,
18,
18,
13,
13,
4,
13,
4,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
40,
13,
41,
13,
20,
28,
13,
13,
30,
30,
4,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
4,
18,
4,
18,
13,
29,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
167,
5
],
[
167,
6
],
[
6,
7
],
[
6,
8
],
[
167,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
17,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
24,
26
],
[
9,
27
],
[
27,
28
],
[
167,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
31,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
36,
41
],
[
41,
42
],
[
41,
43
],
[
36,
44
],
[
44,
45
],
[
45,
46
],
[
36,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
31,
56
],
[
56,
57
],
[
29,
58
],
[
58,
59
],
[
167,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
66,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
66,
76
],
[
76,
77
],
[
77,
78
],
[
66,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
81,
90
],
[
90,
91
],
[
90,
92
],
[
81,
93
],
[
93,
94
],
[
94,
95
],
[
81,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
98,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
115,
117
],
[
108,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
121,
123
],
[
118,
124
],
[
124,
125
],
[
124,
126
],
[
108,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
108,
136
],
[
136,
137
],
[
62,
138
],
[
138,
139
],
[
138,
140
],
[
62,
141
],
[
141,
142
],
[
141,
143
],
[
141,
144
],
[
145,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
146,
149
],
[
149,
150
],
[
149,
151
],
[
62,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
152,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
62,
162
],
[
162,
163
],
[
60,
164
],
[
164,
165
],
[
0,
166
],
[
166,
167
],
[
166,
168
]
] | [
"import java.util.*;\n\npublic class Main {\n private static final Scanner scn = new Scanner(System.in);\n \n public static void main(String[] args) {\n int n = scn.nextInt();\n System.out.println(bubbleSort(createArray(n)));\n }\n \n private static int[] createArray(int n) {\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) {\n ary[i] = scn.nextInt();\n }\n return ary;\n }\n \n private static int bubbleSort(int[] ary) {\n int cnt = 0;\n for(int i = 0; i < ary.length; i++) {\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for(int elm : ary) {\n sb.append(elm + \" \");\n }\n System.out.println(sb.toString().trim());\n return cnt;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n private static final Scanner scn = new Scanner(System.in);\n \n public static void main(String[] args) {\n int n = scn.nextInt();\n System.out.println(bubbleSort(createArray(n)));\n }\n \n private static int[] createArray(int n) {\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) {\n ary[i] = scn.nextInt();\n }\n return ary;\n }\n \n private static int bubbleSort(int[] ary) {\n int cnt = 0;\n for(int i = 0; i < ary.length; i++) {\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for(int elm : ary) {\n sb.append(elm + \" \");\n }\n System.out.println(sb.toString().trim());\n return cnt;\n }\n}",
"Main",
"private static final Scanner scn = new Scanner(System.in);",
"scn",
"new Scanner(System.in)",
"public static void main(String[] args) {\n int n = scn.nextInt();\n System.out.println(bubbleSort(createArray(n)));\n }",
"main",
"{\n int n = scn.nextInt();\n System.out.println(bubbleSort(createArray(n)));\n }",
"int n = scn.nextInt();",
"n",
"scn.nextInt()",
"scn.nextInt",
"scn",
"System.out.println(bubbleSort(createArray(n)))",
"System.out.println",
"System.out",
"System",
"System.out",
"bubbleSort(createArray(n))",
"bubbleSort",
"createArray(n)",
"createArray",
"n",
"String[] args",
"args",
"private static int[] createArray(int n) {\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) {\n ary[i] = scn.nextInt();\n }\n return ary;\n }",
"createArray",
"{\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) {\n ary[i] = scn.nextInt();\n }\n return ary;\n }",
"int[] ary = new int[n];",
"ary",
"new int[n]",
"n",
"for(int i = 0; i < n; i++) {\n ary[i] = scn.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n ary[i] = scn.nextInt();\n }",
"{\n ary[i] = scn.nextInt();\n }",
"ary[i] = scn.nextInt()",
"ary[i]",
"ary",
"i",
"scn.nextInt()",
"scn.nextInt",
"scn",
"return ary;",
"ary",
"int n",
"n",
"private static int bubbleSort(int[] ary) {\n int cnt = 0;\n for(int i = 0; i < ary.length; i++) {\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for(int elm : ary) {\n sb.append(elm + \" \");\n }\n System.out.println(sb.toString().trim());\n return cnt;\n }",
"bubbleSort",
"{\n int cnt = 0;\n for(int i = 0; i < ary.length; i++) {\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for(int elm : ary) {\n sb.append(elm + \" \");\n }\n System.out.println(sb.toString().trim());\n return cnt;\n }",
"int cnt = 0;",
"cnt",
"0",
"for(int i = 0; i < ary.length; i++) {\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < ary.length",
"i",
"ary.length",
"ary",
"ary.length",
"i++",
"i++",
"i",
"{\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }",
"{\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }",
"for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }",
"int j = ary.length - 1;",
"int j = ary.length - 1;",
"j",
"ary.length - 1",
"ary.length",
"ary",
"ary.length",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }",
"{\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }",
"if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }",
"ary[j] < ary[j - 1]",
"ary[j]",
"ary",
"j",
"ary[j - 1]",
"ary",
"j - 1",
"j",
"1",
"{\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }",
"ary[j] ^= ary[j - 1]",
"ary[j]",
"ary",
"j",
"ary[j - 1]",
"ary",
"j - 1",
"j",
"1",
"ary[j - 1] ^= ary[j]",
"ary[j - 1]",
"ary",
"j - 1",
"j",
"1",
"ary[j]",
"ary",
"j",
"ary[j] ^= ary[j - 1]",
"ary[j]",
"ary",
"j",
"ary[j - 1]",
"ary",
"j - 1",
"j",
"1",
"cnt++",
"cnt",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"for(int elm : ary) {\n sb.append(elm + \" \");\n }",
"int elm",
"ary",
"{\n sb.append(elm + \" \");\n }",
"{\n sb.append(elm + \" \");\n }",
"sb.append(elm + \" \")",
"sb.append",
"sb",
"elm + \" \"",
"elm",
"\" \"",
"System.out.println(sb.toString().trim())",
"System.out.println",
"System.out",
"System",
"System.out",
"sb.toString().trim()",
"sb.toString().trim",
"sb.toString()",
"sb.toString",
"sb",
"return cnt;",
"cnt",
"int[] ary",
"ary",
"public class Main {\n private static final Scanner scn = new Scanner(System.in);\n \n public static void main(String[] args) {\n int n = scn.nextInt();\n System.out.println(bubbleSort(createArray(n)));\n }\n \n private static int[] createArray(int n) {\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) {\n ary[i] = scn.nextInt();\n }\n return ary;\n }\n \n private static int bubbleSort(int[] ary) {\n int cnt = 0;\n for(int i = 0; i < ary.length; i++) {\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for(int elm : ary) {\n sb.append(elm + \" \");\n }\n System.out.println(sb.toString().trim());\n return cnt;\n }\n}",
"public class Main {\n private static final Scanner scn = new Scanner(System.in);\n \n public static void main(String[] args) {\n int n = scn.nextInt();\n System.out.println(bubbleSort(createArray(n)));\n }\n \n private static int[] createArray(int n) {\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) {\n ary[i] = scn.nextInt();\n }\n return ary;\n }\n \n private static int bubbleSort(int[] ary) {\n int cnt = 0;\n for(int i = 0; i < ary.length; i++) {\n for(int j = ary.length - 1; j > i; j--) {\n if(ary[j] < ary[j - 1]) {\n ary[j] ^= ary[j - 1];\n ary[j - 1] ^= ary[j];\n ary[j] ^= ary[j - 1];\n cnt++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for(int elm : ary) {\n sb.append(elm + \" \");\n }\n System.out.println(sb.toString().trim());\n return cnt;\n }\n}",
"Main"
] | import java.util.*;
public class Main {
private static final Scanner scn = new Scanner(System.in);
public static void main(String[] args) {
int n = scn.nextInt();
System.out.println(bubbleSort(createArray(n)));
}
private static int[] createArray(int n) {
int[] ary = new int[n];
for(int i = 0; i < n; i++) {
ary[i] = scn.nextInt();
}
return ary;
}
private static int bubbleSort(int[] ary) {
int cnt = 0;
for(int i = 0; i < ary.length; i++) {
for(int j = ary.length - 1; j > i; j--) {
if(ary[j] < ary[j - 1]) {
ary[j] ^= ary[j - 1];
ary[j - 1] ^= ary[j];
ary[j] ^= ary[j - 1];
cnt++;
}
}
}
StringBuilder sb = new StringBuilder();
for(int elm : ary) {
sb.append(elm + " ");
}
System.out.println(sb.toString().trim());
return cnt;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
165,
5
],
[
165,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
27,
29
],
[
23,
30
],
[
30,
31
],
[
30,
32
],
[
23,
33
],
[
33,
34
],
[
34,
35
],
[
23,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
45,
47
],
[
38,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
48,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
48,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
63,
69
],
[
48,
70
],
[
70,
71
],
[
48,
72
],
[
72,
73
],
[
72,
74
],
[
8,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
80,
81
],
[
80,
82
],
[
75,
83
],
[
83,
84
],
[
84,
85
],
[
75,
86
],
[
87,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
88,
93
],
[
93,
94
],
[
93,
95
],
[
87,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
8,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
113,
118
],
[
6,
119
],
[
119,
120
],
[
6,
121
],
[
121,
122
],
[
165,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
125,
134
],
[
134,
135
],
[
134,
136
],
[
125,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
138,
143
],
[
143,
144
],
[
143,
145
],
[
138,
146
],
[
146,
147
],
[
147,
148
],
[
138,
149
],
[
150,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
156,
157
],
[
125,
158
],
[
158,
159
],
[
158,
160
],
[
158,
161
],
[
123,
162
],
[
162,
163
],
[
0,
164
],
[
164,
165
],
[
164,
166
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n}",
"Main",
"public static void bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"bubbleSort",
"{\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"boolean flag = true;",
"flag",
"true",
"int tmp",
"tmp",
"count = 0;",
"count",
"0",
"while (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"if (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"array[j] < array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"{\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"tmp = array[j]",
"tmp",
"array[j]",
"array",
"j",
"array[j] = array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1] = tmp",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"tmp",
"count++",
"count",
"flag = true",
"flag",
"true",
"for (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}",
"{\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}",
"System.out.print(array[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"array[i]",
"array",
"i",
"if (i < n - 1) System.out.print(\" \");",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"int[] array",
"array",
"int n",
"n",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] array = new int[n];",
"array",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarray[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tarray[i] = sc.nextInt();\n\t\t}",
"array[i] = sc.nextInt()",
"array[i]",
"array",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"bubbleSort(array, n)",
"bubbleSort",
"array",
"n",
"String[] args",
"args",
"public class Main {\n\tpublic static void bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n}",
"public class Main {\n\tpublic static void bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void bubbleSort(int[] array, int n) {
boolean flag = true;
int tmp, count = 0;
while (flag) {
flag = false;
for (int j = n - 1; j > 0; j--) {
if (array[j] < array[j-1]) {
tmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;
count++;
flag = true;
}
}
}
for (int i = 0; i < n; i++) {
System.out.print(array[i]);
if (i < n - 1) System.out.print(" ");;
}
System.out.println();
System.out.println(count);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] array = new int[n];
for (int i = 0; i < n; i++) {
array[i] = sc.nextInt();
}
bubbleSort(array, n);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
156,
5
],
[
156,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
57,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
57,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
72,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
82,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
96,
98
],
[
82,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
82,
104
],
[
104,
105
],
[
8,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
111,
112
],
[
111,
113
],
[
106,
114
],
[
114,
115
],
[
115,
116
],
[
106,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
119,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
6,
153
],
[
153,
154
],
[
0,
155
],
[
155,
156
],
[
155,
157
]
] | [
"import java.util.*;\npublic class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tInteger length = s.nextInt();\n\t\tInteger[] seq = new Integer[length];\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tseq[i] = s.nextInt();\n\t\t}\n\t\tInteger count = 0;\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tInteger length = s.nextInt();\n\t\tInteger[] seq = new Integer[length];\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tseq[i] = s.nextInt();\n\t\t}\n\t\tInteger count = 0;\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main",
"/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tInteger length = s.nextInt();\n\t\tInteger[] seq = new Integer[length];\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tseq[i] = s.nextInt();\n\t\t}\n\t\tInteger count = 0;\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tScanner s = new Scanner(System.in);\n\t\tInteger length = s.nextInt();\n\t\tInteger[] seq = new Integer[length];\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tseq[i] = s.nextInt();\n\t\t}\n\t\tInteger count = 0;\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"Integer length = s.nextInt();",
"length",
"s.nextInt()",
"s.nextInt",
"s",
"Integer[] seq = new Integer[length];",
"seq",
"new Integer[length]",
"length",
"for(int i = 0; i < length; i++){\n\t\t\tseq[i] = s.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < length",
"i",
"length",
"i++",
"i++",
"i",
"{\n\t\t\tseq[i] = s.nextInt();\n\t\t}",
"{\n\t\t\tseq[i] = s.nextInt();\n\t\t}",
"seq[i] = s.nextInt()",
"seq[i]",
"seq",
"i",
"s.nextInt()",
"s.nextInt",
"s",
"Integer count = 0;",
"count",
"0",
"for(int i = 0; i < length; i++){\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < length",
"i",
"length",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int j = length - 1;",
"int j = length - 1;",
"j",
"length - 1",
"length",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"seq[j] < seq[j-1]",
"seq[j]",
"seq",
"j",
"seq[j-1]",
"seq",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"Integer bkp = seq[j-1];",
"bkp",
"seq[j-1]",
"seq",
"j-1",
"j",
"1",
"seq[j-1] = seq[j]",
"seq[j-1]",
"seq",
"j-1",
"j",
"1",
"seq[j]",
"seq",
"j",
"seq[j] = bkp",
"seq[j]",
"seq",
"j",
"bkp",
"count++",
"count",
"for(int i = 0; i < length; i++){\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < length",
"i",
"length",
"i++",
"i++",
"i",
"{\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}",
"if(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}",
"i == length - 1",
"i",
"length - 1",
"length",
"1",
"{\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}",
"System.out.print(seq[i] + \"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"seq[i] + \"\\n\"",
"seq[i]",
"seq",
"i",
"\"\\n\"",
"{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}",
"System.out.print(seq[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"seq[i] + \" \"",
"seq[i]",
"seq",
"i",
"\" \"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tInteger length = s.nextInt();\n\t\tInteger[] seq = new Integer[length];\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tseq[i] = s.nextInt();\n\t\t}\n\t\tInteger count = 0;\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tInteger length = s.nextInt();\n\t\tInteger[] seq = new Integer[length];\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tseq[i] = s.nextInt();\n\t\t}\n\t\tInteger count = 0;\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tfor(int j = length - 1; j > 0; j--){\n\t\t\t\tif(seq[j] < seq[j-1]){\n\t\t\t\t\tInteger bkp = seq[j-1];\n\t\t\t\t\tseq[j-1] = seq[j];\n\t\t\t\t\tseq[j] = bkp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < length; i++){\n\t\t\tif(i == length - 1){\n\t\t\t\tSystem.out.print(seq[i] + \"\\n\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.print(seq[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main"
] | import java.util.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Integer length = s.nextInt();
Integer[] seq = new Integer[length];
for(int i = 0; i < length; i++){
seq[i] = s.nextInt();
}
Integer count = 0;
for(int i = 0; i < length; i++){
for(int j = length - 1; j > 0; j--){
if(seq[j] < seq[j-1]){
Integer bkp = seq[j-1];
seq[j-1] = seq[j];
seq[j] = bkp;
count++;
}
}
}
for(int i = 0; i < length; i++){
if(i == length - 1){
System.out.print(seq[i] + "\n");
}
else{
System.out.print(seq[i] + " ");
}
}
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
23,
28
],
[
28,
29
],
[
28,
30
],
[
23,
31
],
[
31,
32
],
[
32,
33
],
[
23,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
46,
54
],
[
54,
55
],
[
55,
56
],
[
46,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
59,
72
],
[
73,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
74,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
84,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
84,
106
],
[
106,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
117,
118
],
[
108,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
126,
127
],
[
126,
128
],
[
120,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
8,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
8,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
6,
152
],
[
152,
153
]
] | [
"import java.util.Scanner;\n\nclass Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int tmp;\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n int change = 0;\n for(int i=N;i>=1;i--){\n for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }\n }\n for(int i=0;i<N;i++){\n System.out.print(A[i]);\n if(i<N-1) System.out.print(\" \");\n }\n System.out.println();\n System.out.println(change);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int tmp;\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n int change = 0;\n for(int i=N;i>=1;i--){\n for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }\n }\n for(int i=0;i<N;i++){\n System.out.print(A[i]);\n if(i<N-1) System.out.print(\" \");\n }\n System.out.println();\n System.out.println(change);\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int tmp;\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n int change = 0;\n for(int i=N;i>=1;i--){\n for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }\n }\n for(int i=0;i<N;i++){\n System.out.print(A[i]);\n if(i<N-1) System.out.print(\" \");\n }\n System.out.println();\n System.out.println(change);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int tmp;\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }\n int change = 0;\n for(int i=N;i>=1;i--){\n for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }\n }\n for(int i=0;i<N;i++){\n System.out.print(A[i]);\n if(i<N-1) System.out.print(\" \");\n }\n System.out.println();\n System.out.println(change);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int tmp;",
"tmp",
"int[] A = new int[N];",
"A",
"new int[N]",
"N",
"for(int i=0;i<N;i++){\n A[i] = sc.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n A[i] = sc.nextInt();\n }",
"{\n A[i] = sc.nextInt();\n }",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int change = 0;",
"change",
"0",
"for(int i=N;i>=1;i--){\n for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }\n }",
"int i=N;",
"int i=N;",
"i",
"N",
"i>=1",
"i",
"1",
"i--",
"i--",
"i",
"{\n for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }\n }",
"{\n for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }\n }",
"for(int j=0;j<i-1;j++){\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }",
"int j=0;",
"int j=0;",
"j",
"0",
"j<i-1",
"j",
"i-1",
"i",
"1",
"j++",
"j++",
"j",
"{\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }",
"{\n if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }\n }",
"if(A[j] > A[j+1]){\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }",
"A[j] > A[j+1]",
"A[j]",
"A",
"j",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"{\n tmp = A[j];\n A[j] = A[j+1];\n A[j+1] = tmp;\n change++;\n }",
"tmp = A[j]",
"tmp",
"A[j]",
"A",
"j",
"A[j] = A[j+1]",
"A[j]",
"A",
"j",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"A[j+1] = tmp",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"tmp",
"change++",
"change",
"for(int i=0;i<N;i++){\n System.out.print(A[i]);\n if(i<N-1) System.out.print(\" \");\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n System.out.print(A[i]);\n if(i<N-1) System.out.print(\" \");\n }",
"{\n System.out.print(A[i]);\n if(i<N-1) System.out.print(\" \");\n }",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"if(i<N-1) System.out.print(\" \");",
"i<N-1",
"i",
"N-1",
"N",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(change)",
"System.out.println",
"System.out",
"System",
"System.out",
"change",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int tmp;
int[] A = new int[N];
for(int i=0;i<N;i++){
A[i] = sc.nextInt();
}
int change = 0;
for(int i=N;i>=1;i--){
for(int j=0;j<i-1;j++){
if(A[j] > A[j+1]){
tmp = A[j];
A[j] = A[j+1];
A[j+1] = tmp;
change++;
}
}
}
for(int i=0;i<N;i++){
System.out.print(A[i]);
if(i<N-1) System.out.print(" ");
}
System.out.println();
System.out.println(change);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
154,
5
],
[
154,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
53,
55
],
[
49,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
56,
61
],
[
61,
62
],
[
61,
63
],
[
56,
64
],
[
64,
65
],
[
65,
66
],
[
56,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
70,
76
],
[
76,
77
],
[
76,
78
],
[
69,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
79,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
94,
100
],
[
79,
101
],
[
101,
102
],
[
79,
103
],
[
103,
104
],
[
103,
105
],
[
8,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
111,
112
],
[
111,
113
],
[
106,
114
],
[
114,
115
],
[
115,
116
],
[
106,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
131,
132
],
[
131,
133
],
[
119,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
8,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
6,
151
],
[
151,
152
],
[
0,
153
],
[
153,
154
],
[
153,
155
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int A[] = new int[N];",
"A",
"new int[N]",
"N",
"for (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"boolean flag = true;",
"flag",
"true",
"int count = 0;",
"count",
"0",
"while (flag) {\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"int temp = 0;",
"temp",
"0",
"for (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"if (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"A[i - 1] > A[i]",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"A[i]",
"A",
"i",
"{\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"temp = A[i]",
"temp",
"A[i]",
"A",
"i",
"A[i] = A[i - 1]",
"A[i]",
"A",
"i",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"A[i - 1] = temp",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"temp",
"count++",
"count",
"flag = true",
"flag",
"true",
"for (int i = 0; i < N; i++) {\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}",
"if (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}",
"i == N - 1",
"i",
"N - 1",
"N",
"1",
"{\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t}",
"System.out.println(A[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"{\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}",
"System.out.print(A[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i] + \" \"",
"A[i]",
"A",
"i",
"\" \"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tint temp = 0;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tif (A[i - 1] > A[i]) {\n\t\t\t\t\ttemp = A[i];\n\t\t\t\t\tA[i] = A[i - 1];\n\t\t\t\t\tA[i - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (i == N - 1) {\n\t\t\t\tSystem.out.println(A[i]);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(A[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int A[] = new int[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextInt();
}
boolean flag = true;
int count = 0;
while (flag) {
flag = false;
int temp = 0;
for (int i = 1; i < N; i++) {
if (A[i - 1] > A[i]) {
temp = A[i];
A[i] = A[i - 1];
A[i - 1] = temp;
count++;
flag = true;
}
}
}
for (int i = 0; i < N; i++) {
if (i == N - 1) {
System.out.println(A[i]);
} else {
System.out.print(A[i] + " ");
}
}
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
160,
5
],
[
160,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
21,
23
],
[
8,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
36,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
44,
54
],
[
54,
55
],
[
55,
56
],
[
44,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
59,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
59,
72
],
[
73,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
74,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
84,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
84,
106
],
[
106,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
117,
118
],
[
108,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
121,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
127,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
121,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
148,
149
],
[
148,
150
],
[
8,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
6,
157
],
[
157,
158
],
[
0,
159
],
[
159,
160
],
[
159,
161
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] ary = new int[n];\n int res = 0;\n for (int i = 0; i < n; i++) {\n ary[i] = sc.nextInt();\n }\n \n for (int i = 0; i < n-1; i++) {\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }\n \n for (int i = 0; i < n; i++) {\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }\n System.out.println(res);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] ary = new int[n];\n int res = 0;\n for (int i = 0; i < n; i++) {\n ary[i] = sc.nextInt();\n }\n \n for (int i = 0; i < n-1; i++) {\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }\n \n for (int i = 0; i < n; i++) {\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }\n System.out.println(res);\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] ary = new int[n];\n int res = 0;\n for (int i = 0; i < n; i++) {\n ary[i] = sc.nextInt();\n }\n \n for (int i = 0; i < n-1; i++) {\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }\n \n for (int i = 0; i < n; i++) {\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }\n System.out.println(res);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] ary = new int[n];\n int res = 0;\n for (int i = 0; i < n; i++) {\n ary[i] = sc.nextInt();\n }\n \n for (int i = 0; i < n-1; i++) {\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }\n \n for (int i = 0; i < n; i++) {\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }\n System.out.println(res);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] ary = new int[n];",
"ary",
"new int[n]",
"n",
"int res = 0;",
"res",
"0",
"for (int i = 0; i < n; i++) {\n ary[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n ary[i] = sc.nextInt();\n }",
"{\n ary[i] = sc.nextInt();\n }",
"ary[i] = sc.nextInt()",
"ary[i]",
"ary",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < n-1; i++) {\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }",
"{\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }",
"for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }",
"{\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }",
"if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }",
"ary[j] < ary[j-1]",
"ary[j]",
"ary",
"j",
"ary[j-1]",
"ary",
"j-1",
"j",
"1",
"{\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }",
"int t = ary[j];",
"t",
"ary[j]",
"ary",
"j",
"ary[j] = ary[j-1]",
"ary[j]",
"ary",
"j",
"ary[j-1]",
"ary",
"j-1",
"j",
"1",
"ary[j-1] = t",
"ary[j-1]",
"ary",
"j-1",
"j",
"1",
"t",
"res++",
"res",
"for (int i = 0; i < n; i++) {\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }",
"{\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }",
"if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }",
"i != n-1",
"i",
"n-1",
"n",
"1",
"{\n System.out.print(ary[i]);\n System.out.print(\" \");\n }",
"System.out.print(ary[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"ary[i]",
"ary",
"i",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"{\n System.out.println(ary[i]);\n }",
"System.out.println(ary[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"ary[i]",
"ary",
"i",
"System.out.println(res)",
"System.out.println",
"System.out",
"System",
"System.out",
"res",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] ary = new int[n];\n int res = 0;\n for (int i = 0; i < n; i++) {\n ary[i] = sc.nextInt();\n }\n \n for (int i = 0; i < n-1; i++) {\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }\n \n for (int i = 0; i < n; i++) {\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }\n System.out.println(res);\n }\n}",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] ary = new int[n];\n int res = 0;\n for (int i = 0; i < n; i++) {\n ary[i] = sc.nextInt();\n }\n \n for (int i = 0; i < n-1; i++) {\n for (int j = n-1; j > i; j--) {\n if (ary[j] < ary[j-1]) {\n int t = ary[j];\n ary[j] = ary[j-1];\n ary[j-1] = t;\n res++;\n }\n }\n }\n \n for (int i = 0; i < n; i++) {\n if (i != n-1) {\n System.out.print(ary[i]);\n System.out.print(\" \");\n } else {\n System.out.println(ary[i]);\n }\n }\n System.out.println(res);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] ary = new int[n];
int res = 0;
for (int i = 0; i < n; i++) {
ary[i] = sc.nextInt();
}
for (int i = 0; i < n-1; i++) {
for (int j = n-1; j > i; j--) {
if (ary[j] < ary[j-1]) {
int t = ary[j];
ary[j] = ary[j-1];
ary[j-1] = t;
res++;
}
}
}
for (int i = 0; i < n; i++) {
if (i != n-1) {
System.out.print(ary[i]);
System.out.print(" ");
} else {
System.out.println(ary[i]);
}
}
System.out.println(res);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
0,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
40,
13,
0,
18,
13,
13,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
4,
18,
18,
13,
13,
17,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
167,
5
],
[
167,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
37,
38
],
[
38,
39
],
[
8,
40
],
[
40,
41
],
[
40,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
8,
46
],
[
46,
47
],
[
46,
48
],
[
8,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
62,
69
],
[
69,
70
],
[
69,
71
],
[
62,
72
],
[
72,
73
],
[
73,
74
],
[
62,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
77,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
87,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
101,
103
],
[
87,
104
],
[
104,
105
],
[
87,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
8,
111
],
[
111,
112
],
[
111,
113
],
[
8,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
6,
120
],
[
120,
121
],
[
167,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
125,
130
],
[
125,
131
],
[
131,
132
],
[
131,
133
],
[
124,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
134,
144
],
[
144,
145
],
[
145,
146
],
[
134,
147
],
[
148,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
149,
155
],
[
155,
156
],
[
155,
157
],
[
124,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
122,
164
],
[
164,
165
],
[
0,
166
],
[
166,
167
],
[
166,
168
]
] | [
"import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t int length = scanner.nextInt();\n\t\tint A[] = new int[length];\n for(int i = 0; i < length; i++)\n \tA[i] = scanner.nextInt();\n \n int key = 1000;\n\t\tint j = 1000;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < length; i++) {\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}\n\t\tout_put(A);\n\t\tSystem.out.println(count);\t\n\t}\n\t\n\tprivate static void out_put(int A[]){\n System.out.printf(\"%d\", A[0]);\n for(int i = 1; i < A.length; i++){\n System.out.printf(\" %d\", A[i]);\n }\n System.out.printf(\"\\n\");\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t int length = scanner.nextInt();\n\t\tint A[] = new int[length];\n for(int i = 0; i < length; i++)\n \tA[i] = scanner.nextInt();\n \n int key = 1000;\n\t\tint j = 1000;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < length; i++) {\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}\n\t\tout_put(A);\n\t\tSystem.out.println(count);\t\n\t}\n\t\n\tprivate static void out_put(int A[]){\n System.out.printf(\"%d\", A[0]);\n for(int i = 1; i < A.length; i++){\n System.out.printf(\" %d\", A[i]);\n }\n System.out.printf(\"\\n\");\n }\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t int length = scanner.nextInt();\n\t\tint A[] = new int[length];\n for(int i = 0; i < length; i++)\n \tA[i] = scanner.nextInt();\n \n int key = 1000;\n\t\tint j = 1000;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < length; i++) {\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}\n\t\tout_put(A);\n\t\tSystem.out.println(count);\t\n\t}",
"main",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t int length = scanner.nextInt();\n\t\tint A[] = new int[length];\n for(int i = 0; i < length; i++)\n \tA[i] = scanner.nextInt();\n \n int key = 1000;\n\t\tint j = 1000;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < length; i++) {\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}\n\t\tout_put(A);\n\t\tSystem.out.println(count);\t\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int length = scanner.nextInt();",
"length",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int A[] = new int[length];",
"A",
"new int[length]",
"length",
"for(int i = 0; i < length; i++)\n \tA[i] = scanner.nextInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < length",
"i",
"length",
"i++",
"i++",
"i",
"A[i] = scanner.nextInt();",
"A[i] = scanner.nextInt()",
"A[i]",
"A",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int key = 1000;",
"key",
"1000",
"int j = 1000;",
"j",
"1000",
"int count = 0;",
"count",
"0",
"for (int i = 0; i < length; i++) {\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < length",
"i",
"length",
"i++",
"i++",
"i",
"{\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}",
"for (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}",
"j = length-1;",
"j = length-1",
"j",
"length-1",
"length",
"1",
"j>i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}",
"{\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}",
"if (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}",
"A[j] < A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}",
"key = A[j-1]",
"key",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j-1] = A[j]",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j]",
"A",
"j",
"count++",
"count",
"A[j] = key",
"A[j]",
"A",
"j",
"key",
"out_put(A)",
"out_put",
"A",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"private static void out_put(int A[]){\n System.out.printf(\"%d\", A[0]);\n for(int i = 1; i < A.length; i++){\n System.out.printf(\" %d\", A[i]);\n }\n System.out.printf(\"\\n\");\n }",
"out_put",
"{\n System.out.printf(\"%d\", A[0]);\n for(int i = 1; i < A.length; i++){\n System.out.printf(\" %d\", A[i]);\n }\n System.out.printf(\"\\n\");\n }",
"System.out.printf(\"%d\", A[0])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d\"",
"A[0]",
"A",
"0",
"for(int i = 1; i < A.length; i++){\n System.out.printf(\" %d\", A[i]);\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < A.length",
"i",
"A.length",
"A",
"A.length",
"i++",
"i++",
"i",
"{\n System.out.printf(\" %d\", A[i]);\n }",
"{\n System.out.printf(\" %d\", A[i]);\n }",
"System.out.printf(\" %d\", A[i])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\" %d\"",
"A[i]",
"A",
"i",
"System.out.printf(\"\\n\")",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"\\n\"",
"int A[]",
"A",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t int length = scanner.nextInt();\n\t\tint A[] = new int[length];\n for(int i = 0; i < length; i++)\n \tA[i] = scanner.nextInt();\n \n int key = 1000;\n\t\tint j = 1000;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < length; i++) {\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}\n\t\tout_put(A);\n\t\tSystem.out.println(count);\t\n\t}\n\t\n\tprivate static void out_put(int A[]){\n System.out.printf(\"%d\", A[0]);\n for(int i = 1; i < A.length; i++){\n System.out.printf(\" %d\", A[i]);\n }\n System.out.printf(\"\\n\");\n }\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t int length = scanner.nextInt();\n\t\tint A[] = new int[length];\n for(int i = 0; i < length; i++)\n \tA[i] = scanner.nextInt();\n \n int key = 1000;\n\t\tint j = 1000;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < length; i++) {\n\t\t\tfor (j = length-1; j>i; j--) {\n\t\t\t\tif (A[j] < A[j-1]){\n\t\t\t\t\tkey = A[j-1];\n\t\t\t\t\tA[j-1] = A[j];\n\t\t\t\t\tcount++;\n\t\t\t\t\tA[j] = key;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}\n\t\tout_put(A);\n\t\tSystem.out.println(count);\t\n\t}\n\t\n\tprivate static void out_put(int A[]){\n System.out.printf(\"%d\", A[0]);\n for(int i = 1; i < A.length; i++){\n System.out.printf(\" %d\", A[i]);\n }\n System.out.printf(\"\\n\");\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int length = scanner.nextInt();
int A[] = new int[length];
for(int i = 0; i < length; i++)
A[i] = scanner.nextInt();
int key = 1000;
int j = 1000;
int count = 0;
for (int i = 0; i < length; i++) {
for (j = length-1; j>i; j--) {
if (A[j] < A[j-1]){
key = A[j-1];
A[j-1] = A[j];
count++;
A[j] = key;
}
}
}
out_put(A);
System.out.println(count);
}
private static void out_put(int A[]){
System.out.printf("%d", A[0]);
for(int i = 1; i < A.length; i++){
System.out.printf(" %d", A[i]);
}
System.out.printf("\n");
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
0,
13,
4,
18,
4,
18,
13,
17,
14,
2,
13,
17,
4,
18,
13,
17,
0,
13,
20,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
8,
2,
13,
2,
18,
13,
13,
17,
17,
17,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
11,
19
],
[
19,
20
],
[
19,
21
],
[
11,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
22,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
32,
35
],
[
35,
36
],
[
36,
37
],
[
29,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
40,
45
],
[
11,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
11,
54
],
[
54,
55
],
[
54,
56
],
[
57,
58
],
[
57,
59
],
[
11,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
60,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
60,
70
],
[
70,
71
],
[
71,
72
],
[
60,
73
],
[
74,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
82,
83
],
[
82,
84
],
[
11,
85
],
[
85,
86
],
[
11,
87
],
[
87,
88
],
[
87,
89
],
[
11,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
90,
100
],
[
100,
101
],
[
101,
102
],
[
90,
103
],
[
104,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
105,
114
],
[
114,
115
],
[
114,
116
],
[
105,
117
],
[
117,
118
],
[
118,
119
],
[
105,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
129,
131
],
[
122,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
132,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
132,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
150,
152
],
[
147,
153
],
[
132,
154
],
[
154,
155
],
[
11,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
156,
166
],
[
166,
167
],
[
167,
168
],
[
156,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
170,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
179,
187
],
[
179,
188
],
[
11,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
189,
194
],
[
9,
195
],
[
195,
196
]
] | [
"import java.io.*;\nimport java.util.Arrays;\n\nclass Main{\n public static void main(String[] args){\n\tBufferedReader br\n\t = new BufferedReader(new InputStreamReader(System.in), 1);\n\tint n;\n\tint[] array;\n\tString[] tmp = null;\n\n\ttry{\n\t n = Integer.parseInt(br.readLine());\n\t tmp = br.readLine().split(\" \");\n\t}catch(IOException e){\n\t e.getStackTrace();\n\t}\n\tif(tmp == null)\n\t System.exit(1);\n\n\tarray = new int[tmp.length];\n\tfor(int i=0; i<tmp.length; i++){\n\t array[i] = Integer.parseInt(tmp[i]);\n\t}\n\t \n\t\n\t//sort\n\tint t;\n\tint cnt = 0;\n\tfor(int i = 0; i < array.length; i++){\n\t for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }\n\t}\n\tfor(int i = 0; i < array.length; i++)\n\t System.out.print(array[i] + (i != array.length-1 ? \" \" : \"\\n\") );\n\tSystem.out.println(cnt);\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.Arrays;",
"Arrays",
"java.util",
"class Main{\n public static void main(String[] args){\n\tBufferedReader br\n\t = new BufferedReader(new InputStreamReader(System.in), 1);\n\tint n;\n\tint[] array;\n\tString[] tmp = null;\n\n\ttry{\n\t n = Integer.parseInt(br.readLine());\n\t tmp = br.readLine().split(\" \");\n\t}catch(IOException e){\n\t e.getStackTrace();\n\t}\n\tif(tmp == null)\n\t System.exit(1);\n\n\tarray = new int[tmp.length];\n\tfor(int i=0; i<tmp.length; i++){\n\t array[i] = Integer.parseInt(tmp[i]);\n\t}\n\t \n\t\n\t//sort\n\tint t;\n\tint cnt = 0;\n\tfor(int i = 0; i < array.length; i++){\n\t for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }\n\t}\n\tfor(int i = 0; i < array.length; i++)\n\t System.out.print(array[i] + (i != array.length-1 ? \" \" : \"\\n\") );\n\tSystem.out.println(cnt);\n }\n}",
"Main",
"public static void main(String[] args){\n\tBufferedReader br\n\t = new BufferedReader(new InputStreamReader(System.in), 1);\n\tint n;\n\tint[] array;\n\tString[] tmp = null;\n\n\ttry{\n\t n = Integer.parseInt(br.readLine());\n\t tmp = br.readLine().split(\" \");\n\t}catch(IOException e){\n\t e.getStackTrace();\n\t}\n\tif(tmp == null)\n\t System.exit(1);\n\n\tarray = new int[tmp.length];\n\tfor(int i=0; i<tmp.length; i++){\n\t array[i] = Integer.parseInt(tmp[i]);\n\t}\n\t \n\t\n\t//sort\n\tint t;\n\tint cnt = 0;\n\tfor(int i = 0; i < array.length; i++){\n\t for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }\n\t}\n\tfor(int i = 0; i < array.length; i++)\n\t System.out.print(array[i] + (i != array.length-1 ? \" \" : \"\\n\") );\n\tSystem.out.println(cnt);\n }",
"main",
"{\n\tBufferedReader br\n\t = new BufferedReader(new InputStreamReader(System.in), 1);\n\tint n;\n\tint[] array;\n\tString[] tmp = null;\n\n\ttry{\n\t n = Integer.parseInt(br.readLine());\n\t tmp = br.readLine().split(\" \");\n\t}catch(IOException e){\n\t e.getStackTrace();\n\t}\n\tif(tmp == null)\n\t System.exit(1);\n\n\tarray = new int[tmp.length];\n\tfor(int i=0; i<tmp.length; i++){\n\t array[i] = Integer.parseInt(tmp[i]);\n\t}\n\t \n\t\n\t//sort\n\tint t;\n\tint cnt = 0;\n\tfor(int i = 0; i < array.length; i++){\n\t for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }\n\t}\n\tfor(int i = 0; i < array.length; i++)\n\t System.out.print(array[i] + (i != array.length-1 ? \" \" : \"\\n\") );\n\tSystem.out.println(cnt);\n }",
"BufferedReader br\n\t = new BufferedReader(new InputStreamReader(System.in), 1);",
"br",
"new BufferedReader(new InputStreamReader(System.in), 1)",
"int n;",
"n",
"int[] array;",
"array",
"String[] tmp = null;",
"tmp",
"null",
"try{\n\t n = Integer.parseInt(br.readLine());\n\t tmp = br.readLine().split(\" \");\n\t}catch(IOException e){\n\t e.getStackTrace();\n\t}",
"catch(IOException e){\n\t e.getStackTrace();\n\t}",
"IOException e",
"{\n\t e.getStackTrace();\n\t}",
"e.getStackTrace()",
"e.getStackTrace",
"e",
"{\n\t n = Integer.parseInt(br.readLine());\n\t tmp = br.readLine().split(\" \");\n\t}",
"n = Integer.parseInt(br.readLine())",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"tmp = br.readLine().split(\" \")",
"tmp",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"if(tmp == null)\n\t System.exit(1);",
"tmp == null",
"tmp",
"null",
"System.exit(1)",
"System.exit",
"System",
"1",
"array = new int[tmp.length]",
"array",
"new int[tmp.length]",
"tmp.length",
"tmp",
"tmp.length",
"for(int i=0; i<tmp.length; i++){\n\t array[i] = Integer.parseInt(tmp[i]);\n\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<tmp.length",
"i",
"tmp.length",
"tmp",
"tmp.length",
"i++",
"i++",
"i",
"{\n\t array[i] = Integer.parseInt(tmp[i]);\n\t}",
"{\n\t array[i] = Integer.parseInt(tmp[i]);\n\t}",
"array[i] = Integer.parseInt(tmp[i])",
"array[i]",
"array",
"i",
"Integer.parseInt(tmp[i])",
"Integer.parseInt",
"Integer",
"tmp[i]",
"tmp",
"i",
"int t;",
"t",
"int cnt = 0;",
"cnt",
"0",
"for(int i = 0; i < array.length; i++){\n\t for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < array.length",
"i",
"array.length",
"array",
"array.length",
"i++",
"i++",
"i",
"{\n\t for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }\n\t}",
"{\n\t for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }\n\t}",
"for(int j = array.length-1; j > i; j--){\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }",
"int j = array.length-1;",
"int j = array.length-1;",
"j",
"array.length-1",
"array.length",
"array",
"array.length",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }",
"{\n\t\tif( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}\n\t }",
"if( array[j] < array[j-1]){\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}",
"array[j] < array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"{\n\t\t t = array[j];\n\t\t array[j] = array[j-1];\n\t\t array[j-1] = t;\n\t\t cnt++;\n\t\t}",
"t = array[j]",
"t",
"array[j]",
"array",
"j",
"array[j] = array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1] = t",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"t",
"cnt++",
"cnt",
"for(int i = 0; i < array.length; i++)\n\t System.out.print(array[i] + (i != array.length-1 ? \" \" : \"\\n\") );",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < array.length",
"i",
"array.length",
"array",
"array.length",
"i++",
"i++",
"i",
"System.out.print(array[i] + (i != array.length-1 ? \" \" : \"\\n\") );",
"System.out.print(array[i] + (i != array.length-1 ? \" \" : \"\\n\") )",
"System.out.print",
"System.out",
"System",
"System.out",
"array[i] + (i != array.length-1 ? \" \" : \"\\n\")",
"array[i]",
"array",
"i",
"(i != array.length-1 ? \" \" : \"\\n\")",
"i != array.length-1",
"i",
"array.length-1",
"array.length",
"array",
"array.length",
"1",
"\" \"",
"\"\\n\"",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String[] args",
"args"
] | import java.io.*;
import java.util.Arrays;
class Main{
public static void main(String[] args){
BufferedReader br
= new BufferedReader(new InputStreamReader(System.in), 1);
int n;
int[] array;
String[] tmp = null;
try{
n = Integer.parseInt(br.readLine());
tmp = br.readLine().split(" ");
}catch(IOException e){
e.getStackTrace();
}
if(tmp == null)
System.exit(1);
array = new int[tmp.length];
for(int i=0; i<tmp.length; i++){
array[i] = Integer.parseInt(tmp[i]);
}
//sort
int t;
int cnt = 0;
for(int i = 0; i < array.length; i++){
for(int j = array.length-1; j > i; j--){
if( array[j] < array[j-1]){
t = array[j];
array[j] = array[j-1];
array[j-1] = t;
cnt++;
}
}
}
for(int i = 0; i < array.length; i++)
System.out.print(array[i] + (i != array.length-1 ? " " : "\n") );
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
32,
37
],
[
14,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
58,
60
],
[
14,
61
],
[
61,
62
],
[
61,
63
],
[
14,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
64,
74
],
[
74,
75
],
[
75,
76
],
[
64,
77
],
[
78,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
83,
87
],
[
79,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
79,
93
],
[
93,
94
],
[
94,
95
],
[
79,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
98,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
108,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
108,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
123,
129
],
[
108,
130
],
[
130,
131
],
[
14,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
132,
142
],
[
142,
143
],
[
143,
144
],
[
132,
145
],
[
146,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
147,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
147,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
165,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
170,
174
],
[
14,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
175,
180
],
[
12,
181
],
[
181,
182
]
] | [
"import java.io.*;\nimport java.util.Arrays;\nimport java.util.Scanner;\n\nclass Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] num = new int[n];\n\t\tString[] str = (br.readLine()).split(\" \");\n\t\tfor (int i = 0; i<n ; i++ ) {\n\t\t\tnum[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\tint count = 0;\n\t\tfor (int i = 0 ; i<num.length ; i++ ) {\n\t\t\tfor (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i<num.length ; i++ ) {\n\t\t\tif ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] num = new int[n];\n\t\tString[] str = (br.readLine()).split(\" \");\n\t\tfor (int i = 0; i<n ; i++ ) {\n\t\t\tnum[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\tint count = 0;\n\t\tfor (int i = 0 ; i<num.length ; i++ ) {\n\t\t\tfor (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i<num.length ; i++ ) {\n\t\t\tif ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] num = new int[n];\n\t\tString[] str = (br.readLine()).split(\" \");\n\t\tfor (int i = 0; i<n ; i++ ) {\n\t\t\tnum[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\tint count = 0;\n\t\tfor (int i = 0 ; i<num.length ; i++ ) {\n\t\t\tfor (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i<num.length ; i++ ) {\n\t\t\tif ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] num = new int[n];\n\t\tString[] str = (br.readLine()).split(\" \");\n\t\tfor (int i = 0; i<n ; i++ ) {\n\t\t\tnum[i] = Integer.parseInt(str[i]);\n\t\t}\n\t\tint count = 0;\n\t\tfor (int i = 0 ; i<num.length ; i++ ) {\n\t\t\tfor (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i<num.length ; i++ ) {\n\t\t\tif ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"int[] num = new int[n];",
"num",
"new int[n]",
"n",
"String[] str = (br.readLine()).split(\" \");",
"str",
"(br.readLine()).split(\" \")",
"(br.readLine()).split",
"(br.readLine())",
"br.readLine",
"br",
"\" \"",
"for (int i = 0; i<n ; i++ ) {\n\t\t\tnum[i] = Integer.parseInt(str[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tnum[i] = Integer.parseInt(str[i]);\n\t\t}",
"{\n\t\t\tnum[i] = Integer.parseInt(str[i]);\n\t\t}",
"num[i] = Integer.parseInt(str[i])",
"num[i]",
"num",
"i",
"Integer.parseInt(str[i])",
"Integer.parseInt",
"Integer",
"str[i]",
"str",
"i",
"int count = 0;",
"count",
"0",
"for (int i = 0 ; i<num.length ; i++ ) {\n\t\t\tfor (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i<num.length",
"i",
"num.length",
"num",
"num.length",
"i++",
"i++",
"i",
"{\n\t\t\tfor (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for (int j = num.length-1; j>=i+1 ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}",
"int j = num.length-1;",
"int j = num.length-1;",
"j",
"num.length-1",
"num.length",
"num",
"num.length",
"1",
"j>=i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}\n\t\t\t}",
"if ( num[j] < num[j-1]) {\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}",
"num[j] < num[j-1]",
"num[j]",
"num",
"j",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tint work = num[j];\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = work;\n\t\t\t\t\tcount++; \n\t\t\t\t}",
"int work = num[j];",
"work",
"num[j]",
"num",
"j",
"num[j] = num[j-1]",
"num[j]",
"num",
"j",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"num[j-1] = work",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"work",
"count++",
"count",
"for (int i = 0; i<num.length ; i++ ) {\n\t\t\tif ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<num.length",
"i",
"num.length",
"num",
"num.length",
"i++",
"i++",
"i",
"{\n\t\t\tif ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tif ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}\n\t\t}",
"if ( i == num.length-1) {\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}",
"i == num.length-1",
"i",
"num.length-1",
"num.length",
"num",
"num.length",
"1",
"{\n\t\t\t\tSystem.out.println(num[i]);\n\t\t\t}",
"System.out.println(num[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"num[i]",
"num",
"i",
"{\n\t\t\t\tSystem.out.print(num[i] + \" \");\n\t\t\t}",
"System.out.print(num[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"num[i] + \" \"",
"num[i]",
"num",
"i",
"\" \"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args"
] | import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] num = new int[n];
String[] str = (br.readLine()).split(" ");
for (int i = 0; i<n ; i++ ) {
num[i] = Integer.parseInt(str[i]);
}
int count = 0;
for (int i = 0 ; i<num.length ; i++ ) {
for (int j = num.length-1; j>=i+1 ; j-- ) {
if ( num[j] < num[j-1]) {
int work = num[j];
num[j] = num[j-1];
num[j-1] = work;
count++;
}
}
}
for (int i = 0; i<num.length ; i++ ) {
if ( i == num.length-1) {
System.out.println(num[i]);
}else{
System.out.print(num[i] + " ");
}
}
System.out.println(count);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
17,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
4,
18,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
2,
17,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
4,
13,
13,
13,
2,
13,
17,
23,
13,
12,
13,
30,
40,
13,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
6,
13,
41,
13,
18,
13,
13,
41,
13,
20,
17,
41,
13,
17,
41,
13,
17,
12,
13,
30,
14,
2,
13,
13,
30,
29,
17,
30,
0,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
13,
14,
2,
13,
17,
30,
29,
17,
29,
17,
12,
13,
30,
14,
4,
13,
29,
18,
13,
40,
13,
29,
40,
17,
12,
13,
30,
29,
2,
2,
17,
13,
2,
13,
17,
23,
13,
12,
13,
30,
42,
2,
4,
13,
40,
4,
13,
18,
13,
13,
40,
13,
12,
13,
30,
4,
13,
29,
4,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
20,
41,
13,
4,
13,
42,
4,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
17,
41,
13,
17,
41,
13,
4,
13,
14,
2,
13,
17,
30,
0,
13,
17,
0,
13,
4,
13,
14,
2,
2,
13,
17,
2,
17,
13,
30,
37,
20,
42,
17,
30,
14,
2,
2,
17,
13,
2,
13,
17,
30,
0,
13,
17,
0,
13,
2,
13,
17,
14,
2,
2,
13,
40,
17,
40,
4,
13,
13,
30,
29,
8,
13,
40,
13,
13,
30,
37,
20,
0,
13,
4,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
17,
41,
13,
17,
41,
13,
4,
13,
14,
2,
13,
17,
30,
0,
13,
17,
0,
13,
4,
13,
14,
2,
2,
13,
17,
2,
17,
13,
30,
37,
20,
42,
17,
30,
14,
2,
2,
17,
13,
2,
13,
17,
30,
0,
13,
17,
0,
13,
2,
13,
17,
14,
2,
2,
13,
40,
17,
40,
4,
13,
13,
30,
29,
8,
13,
40,
13,
13,
30,
37,
20,
0,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
22,
23
],
[
22,
24
],
[
0,
25
],
[
25,
26
],
[
25,
27
],
[
0,
28
],
[
28,
29
],
[
28,
30
],
[
0,
31
],
[
31,
32
],
[
31,
33
],
[
0,
34
],
[
34,
35
],
[
34,
36
],
[
0,
37
],
[
37,
38
],
[
37,
39
],
[
0,
40
],
[
40,
41
],
[
40,
42
],
[
0,
43
],
[
43,
44
],
[
43,
45
],
[
0,
46
],
[
46,
47
],
[
46,
48
],
[
0,
49
],
[
49,
50
],
[
49,
51
],
[
0,
52
],
[
543,
53
],
[
543,
54
],
[
54,
55
],
[
54,
56
],
[
543,
57
],
[
57,
58
],
[
57,
59
],
[
543,
60
],
[
60,
61
],
[
60,
62
],
[
543,
63
],
[
63,
64
],
[
63,
65
],
[
543,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
68,
74
],
[
74,
75
],
[
74,
76
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
78,
83
],
[
83,
84
],
[
83,
85
],
[
78,
86
],
[
86,
87
],
[
87,
88
],
[
78,
89
],
[
90,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
68,
98
],
[
98,
99
],
[
98,
100
],
[
68,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
104,
105
],
[
104,
106
],
[
68,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
112,
113
],
[
112,
114
],
[
107,
115
],
[
115,
116
],
[
116,
117
],
[
107,
118
],
[
119,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
68,
128
],
[
128,
129
],
[
129,
130
],
[
68,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
68,
135
],
[
135,
136
],
[
136,
137
],
[
66,
138
],
[
138,
139
],
[
543,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
150,
152
],
[
143,
153
],
[
153,
154
],
[
154,
155
],
[
143,
156
],
[
157,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
158,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
169,
171
],
[
158,
172
],
[
172,
173
],
[
173,
174
],
[
158,
175
],
[
176,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
184,
186
],
[
177,
187
],
[
187,
188
],
[
187,
189
],
[
187,
190
],
[
187,
191
],
[
191,
192
],
[
191,
193
],
[
140,
194
],
[
194,
195
],
[
543,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
198,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
203,
205
],
[
198,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
206,
210
],
[
210,
211
],
[
210,
212
],
[
198,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
213,
217
],
[
196,
218
],
[
218,
219
],
[
196,
220
],
[
220,
221
],
[
196,
222
],
[
222,
223
],
[
0,
224
],
[
224,
225
],
[
224,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
228,
230
],
[
224,
231
],
[
231,
232
],
[
231,
233
],
[
224,
235
],
[
235,
236
],
[
235,
237
],
[
224,
238
],
[
238,
239
],
[
238,
240
],
[
224,
241
],
[
241,
242
],
[
241,
243
],
[
243,
244
],
[
244,
245
],
[
245,
246
],
[
245,
247
],
[
244,
248
],
[
248,
249
],
[
249,
250
],
[
244,
251
],
[
251,
252
],
[
252,
253
],
[
252,
254
],
[
251,
255
],
[
255,
256
],
[
256,
257
],
[
256,
258
],
[
258,
259
],
[
259,
260
],
[
260,
261
],
[
255,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
265,
266
],
[
266,
267
],
[
265,
268
],
[
251,
269
],
[
269,
270
],
[
270,
271
],
[
270,
272
],
[
269,
273
],
[
273,
274
],
[
274,
275
],
[
243,
276
],
[
276,
277
],
[
224,
278
],
[
278,
279
],
[
278,
280
],
[
280,
281
],
[
281,
282
],
[
282,
283
],
[
281,
284
],
[
284,
285
],
[
285,
286
],
[
285,
287
],
[
287,
288
],
[
281,
289
],
[
289,
290
],
[
290,
291
],
[
224,
292
],
[
292,
293
],
[
292,
294
],
[
294,
295
],
[
295,
296
],
[
296,
297
],
[
297,
298
],
[
297,
299
],
[
296,
300
],
[
300,
301
],
[
300,
302
],
[
292,
303
],
[
303,
304
],
[
224,
305
],
[
305,
306
],
[
305,
307
],
[
307,
308
],
[
308,
309
],
[
309,
310
],
[
310,
311
],
[
309,
312
],
[
312,
313
],
[
313,
314
],
[
313,
315
],
[
315,
316
],
[
315,
317
],
[
308,
318
],
[
318,
319
],
[
224,
320
],
[
320,
321
],
[
320,
322
],
[
322,
323
],
[
323,
324
],
[
322,
325
],
[
325,
326
],
[
326,
327
],
[
224,
328
],
[
328,
329
],
[
328,
330
],
[
330,
331
],
[
331,
332
],
[
332,
333
],
[
333,
334
],
[
331,
335
],
[
335,
336
],
[
330,
337
],
[
337,
338
],
[
337,
339
],
[
330,
340
],
[
340,
341
],
[
340,
342
],
[
342,
343
],
[
330,
344
],
[
344,
345
],
[
345,
346
],
[
345,
347
],
[
344,
348
],
[
348,
349
],
[
349,
350
],
[
350,
351
],
[
349,
352
],
[
348,
353
],
[
353,
354
],
[
353,
355
],
[
355,
356
],
[
330,
357
],
[
357,
358
],
[
358,
359
],
[
359,
360
],
[
224,
361
],
[
361,
362
],
[
361,
363
],
[
363,
364
],
[
364,
365
],
[
365,
366
],
[
366,
367
],
[
364,
368
],
[
368,
369
],
[
363,
370
],
[
370,
371
],
[
370,
372
],
[
363,
373
],
[
373,
374
],
[
373,
375
],
[
363,
376
],
[
376,
377
],
[
376,
378
],
[
378,
379
],
[
363,
380
],
[
380,
381
],
[
381,
382
],
[
381,
383
],
[
380,
384
],
[
384,
385
],
[
385,
386
],
[
385,
387
],
[
384,
388
],
[
388,
389
],
[
388,
390
],
[
390,
391
],
[
363,
392
],
[
392,
393
],
[
393,
394
],
[
394,
395
],
[
394,
396
],
[
393,
397
],
[
397,
398
],
[
397,
399
],
[
392,
400
],
[
400,
401
],
[
401,
402
],
[
363,
403
],
[
403,
404
],
[
403,
405
],
[
405,
406
],
[
406,
407
],
[
407,
408
],
[
408,
409
],
[
408,
410
],
[
407,
411
],
[
411,
412
],
[
411,
413
],
[
406,
414
],
[
414,
415
],
[
415,
416
],
[
415,
417
],
[
414,
418
],
[
418,
419
],
[
418,
420
],
[
420,
421
],
[
420,
422
],
[
406,
423
],
[
423,
424
],
[
424,
425
],
[
425,
426
],
[
425,
427
],
[
427,
428
],
[
424,
429
],
[
429,
430
],
[
430,
431
],
[
430,
432
],
[
423,
433
],
[
433,
434
],
[
434,
435
],
[
435,
436
],
[
435,
437
],
[
437,
438
],
[
435,
439
],
[
423,
440
],
[
440,
441
],
[
441,
442
],
[
405,
443
],
[
443,
444
],
[
443,
445
],
[
445,
446
],
[
224,
447
],
[
447,
448
],
[
447,
449
],
[
449,
450
],
[
450,
451
],
[
451,
452
],
[
452,
453
],
[
450,
454
],
[
454,
455
],
[
449,
456
],
[
456,
457
],
[
456,
458
],
[
449,
459
],
[
459,
460
],
[
459,
461
],
[
449,
462
],
[
462,
463
],
[
462,
464
],
[
464,
465
],
[
449,
466
],
[
466,
467
],
[
467,
468
],
[
467,
469
],
[
466,
470
],
[
470,
471
],
[
471,
472
],
[
471,
473
],
[
470,
474
],
[
474,
475
],
[
474,
476
],
[
476,
477
],
[
449,
478
],
[
478,
479
],
[
479,
480
],
[
480,
481
],
[
480,
482
],
[
479,
483
],
[
483,
484
],
[
483,
485
],
[
478,
486
],
[
486,
487
],
[
487,
488
],
[
449,
489
],
[
489,
490
],
[
489,
491
],
[
491,
492
],
[
492,
493
],
[
493,
494
],
[
494,
495
],
[
494,
496
],
[
493,
497
],
[
497,
498
],
[
497,
499
],
[
492,
500
],
[
500,
501
],
[
501,
502
],
[
501,
503
],
[
500,
504
],
[
504,
505
],
[
504,
506
],
[
506,
507
],
[
506,
508
],
[
492,
509
],
[
509,
510
],
[
510,
511
],
[
511,
512
],
[
511,
513
],
[
513,
514
],
[
510,
515
],
[
515,
516
],
[
516,
517
],
[
516,
518
],
[
509,
519
],
[
519,
520
],
[
520,
521
],
[
521,
522
],
[
521,
523
],
[
523,
524
],
[
521,
525
],
[
509,
526
],
[
526,
527
],
[
527,
528
],
[
491,
529
],
[
529,
530
],
[
529,
531
],
[
531,
532
],
[
224,
533
],
[
533,
534
],
[
533,
535
],
[
535,
536
],
[
536,
537
],
[
537,
538
],
[
538,
539
],
[
537,
540
],
[
540,
541
],
[
0,
542
],
[
542,
543
],
[
542,
544
]
] | [
"\nimport java.awt.geom.Point2D;\nimport java.io.*;\nimport java.math.BigInteger;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.NoSuchElementException;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\nimport java.util.Stack;\nimport java.util.TreeMap;\n\n\n\npublic class Main {\n\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tstatic FastScanner sc = new FastScanner();\n\tstatic Scanner stdIn = new Scanner(System.in);\n\tstatic int ans = 0;\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tar[i] = sc.nextInt();\n\t\t}\n\t\tsort(ar);\n\t\tout.print(ar[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}\n\t\tout.println();\n\t\tout.println(ans);\t\t\n\t\tout.flush();\n\t\t\n\t}\n\t\n\tstatic void sort(int[] a) {\n\t\tfor(int i = 0; i < a.length; i++) {\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic void swap(int[] a, int b, int c) {\n\t\tans++;\n\t\tint tmp = a[b];\n\t\ta[b] = a[c];\n\t\ta[c] = tmp;\n\t}\n\t\t \n\n}\n\n//------------------------------//\n//-----------//\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public int nextInt() {\n \t if (!hasNext()) throw new NoSuchElementException();\n int n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public double nextDouble() {\n \treturn Double.parseDouble(next());\n }\n \n\n}",
"import java.awt.geom.Point2D;",
"Point2D",
"java.awt.geom",
"import java.io.*;",
"io.*",
"java",
"import java.math.BigInteger;",
"BigInteger",
"java.math",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.Collections;",
"Collections",
"java.util",
"import java.util.Comparator;",
"Comparator",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.HashSet;",
"HashSet",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.NoSuchElementException;",
"NoSuchElementException",
"java.util",
"import java.util.PriorityQueue;",
"PriorityQueue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Stack;",
"Stack",
"java.util",
"import java.util.TreeMap;",
"TreeMap",
"java.util",
"public class Main {\n\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tstatic FastScanner sc = new FastScanner();\n\tstatic Scanner stdIn = new Scanner(System.in);\n\tstatic int ans = 0;\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tar[i] = sc.nextInt();\n\t\t}\n\t\tsort(ar);\n\t\tout.print(ar[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}\n\t\tout.println();\n\t\tout.println(ans);\t\t\n\t\tout.flush();\n\t\t\n\t}\n\t\n\tstatic void sort(int[] a) {\n\t\tfor(int i = 0; i < a.length; i++) {\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic void swap(int[] a, int b, int c) {\n\t\tans++;\n\t\tint tmp = a[b];\n\t\ta[b] = a[c];\n\t\ta[c] = tmp;\n\t}\n\t\t \n\n}",
"Main",
"static PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"static FastScanner sc = new FastScanner();",
"sc",
"new FastScanner()",
"static Scanner stdIn = new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"static int ans = 0;",
"ans",
"0",
"public static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tar[i] = sc.nextInt();\n\t\t}\n\t\tsort(ar);\n\t\tout.print(ar[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}\n\t\tout.println();\n\t\tout.println(ans);\t\t\n\t\tout.flush();\n\t\t\n\t}",
"main",
"{\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tar[i] = sc.nextInt();\n\t\t}\n\t\tsort(ar);\n\t\tout.print(ar[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}\n\t\tout.println();\n\t\tout.println(ans);\t\t\n\t\tout.flush();\n\t\t\n\t}",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] ar = new int[n];",
"ar",
"new int[n]",
"n",
"for(int i = 0; i < n; i++) {\n\t\t\tar[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tar[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tar[i] = sc.nextInt();\n\t\t}",
"ar[i] = sc.nextInt()",
"ar[i]",
"ar",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sort(ar)",
"sort",
"ar",
"out.print(ar[0])",
"out.print",
"out",
"ar[0]",
"ar",
"0",
"for(int i = 1; i < n; i++) {\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}",
"{\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}",
"out.print(\" \" + ar[i])",
"out.print",
"out",
"\" \" + ar[i]",
"\" \"",
"ar[i]",
"ar",
"i",
"out.println()",
"out.println",
"out",
"out.println(ans)",
"out.println",
"out",
"ans",
"out.flush()",
"out.flush",
"out",
"String[] args",
"args",
"static void sort(int[] a) {\n\t\tfor(int i = 0; i < a.length; i++) {\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}\n\t}",
"sort",
"{\n\t\tfor(int i = 0; i < a.length; i++) {\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}\n\t}",
"for(int i = 0; i < a.length; i++) {\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}",
"for(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}",
"int j = a.length-1;",
"int j = a.length-1;",
"j",
"a.length-1",
"a.length",
"a",
"a.length",
"1",
"j >= i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}",
"{\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}",
"if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"swap(a,j,j-1)",
"swap",
"a",
"j",
"j-1",
"j",
"1",
"int[] a",
"a",
"static void swap(int[] a, int b, int c) {\n\t\tans++;\n\t\tint tmp = a[b];\n\t\ta[b] = a[c];\n\t\ta[c] = tmp;\n\t}",
"swap",
"{\n\t\tans++;\n\t\tint tmp = a[b];\n\t\ta[b] = a[c];\n\t\ta[c] = tmp;\n\t}",
"ans++",
"ans",
"int tmp = a[b];",
"tmp",
"a[b]",
"a",
"b",
"a[b] = a[c]",
"a[b]",
"a",
"b",
"a[c]",
"a",
"c",
"a[c] = tmp",
"a[c]",
"a",
"c",
"tmp",
"int[] a",
"a",
"int b",
"b",
"int c",
"c",
"class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public int nextInt() {\n \t if (!hasNext()) throw new NoSuchElementException();\n int n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public double nextDouble() {\n \treturn Double.parseDouble(next());\n }\n \n\n}",
"FastScanner",
"private final InputStream in = System.in;",
"in",
"System.in",
"System",
"System.in",
"private final byte[] buffer = new byte[1024];",
"buffer",
"new byte[1024]",
"1024",
"private int ptr = 0;",
"ptr",
"0",
"private int buflen = 0;",
"buflen",
"0",
"private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }",
"hasNextByte",
"{\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }",
"if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }",
"ptr < buflen",
"ptr",
"buflen",
"{\n return true;\n }",
"return true;",
"true",
"{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }",
"ptr = 0",
"ptr",
"0",
"try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }",
"catch (IOException e) {\n e.printStackTrace();\n }",
"IOException e",
"{\n e.printStackTrace();\n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n buflen = in.read(buffer);\n }",
"buflen = in.read(buffer)",
"buflen",
"in.read(buffer)",
"in.read",
"in",
"buffer",
"if (buflen <= 0) {\n return false;\n }",
"buflen <= 0",
"buflen",
"0",
"{\n return false;\n }",
"return false;",
"false",
"return true;",
"true",
"private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}",
"readByte",
"{ if (hasNextByte()) return buffer[ptr++]; else return -1;}",
"if (hasNextByte()) return buffer[ptr++]; else return -1;",
"hasNextByte()",
"hasNextByte",
"return buffer[ptr++];",
"buffer[ptr++]",
"buffer",
"ptr++",
"ptr",
"return -1;",
"-1",
"1",
"private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}",
"isPrintableChar",
"{ return 33 <= c && c <= 126;}",
"return 33 <= c && c <= 126;",
"33 <= c && c <= 126",
"33 <= c",
"33",
"c",
"c <= 126",
"c",
"126",
"int c",
"c",
"private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}",
"skipUnprintable",
"{ while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}",
"while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;",
"hasNextByte() && !isPrintableChar(buffer[ptr])",
"hasNextByte()",
"hasNextByte",
"!isPrintableChar(buffer[ptr])",
"isPrintableChar(buffer[ptr])",
"isPrintableChar",
"buffer[ptr]",
"buffer",
"ptr",
"ptr++",
"ptr",
"public boolean hasNext() { skipUnprintable(); return hasNextByte();}",
"hasNext",
"{ skipUnprintable(); return hasNextByte();}",
"skipUnprintable()",
"skipUnprintable",
"return hasNextByte();",
"hasNextByte()",
"hasNextByte",
"public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }",
"next",
"{\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }",
"if (!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int b = readByte();",
"b",
"readByte()",
"readByte",
"while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }",
"isPrintableChar(b)",
"isPrintableChar",
"b",
"{\n sb.appendCodePoint(b);\n b = readByte();\n }",
"sb.appendCodePoint(b)",
"sb.appendCodePoint",
"sb",
"b",
"b = readByte()",
"b",
"readByte()",
"readByte",
"return sb.toString();",
"sb.toString()",
"sb.toString",
"sb",
"public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }",
"nextLong",
"{\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }",
"if (!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"long n = 0;",
"n",
"0",
"boolean minus = false;",
"minus",
"false",
"int b = readByte();",
"b",
"readByte()",
"readByte",
"if (b == '-') {\n minus = true;\n b = readByte();\n }",
"b == '-'",
"b",
"'-'",
"{\n minus = true;\n b = readByte();\n }",
"minus = true",
"minus",
"true",
"b = readByte()",
"b",
"readByte()",
"readByte",
"if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }",
"b < '0' || '9' < b",
"b < '0'",
"b",
"'0'",
"'9' < b",
"'9'",
"b",
"{\n throw new NumberFormatException();\n }",
"throw new NumberFormatException();",
"new NumberFormatException()",
"while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }",
"true",
"{\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }",
"if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }",
"'0' <= b && b <= '9'",
"'0' <= b",
"'0'",
"b",
"b <= '9'",
"b",
"'9'",
"{\n n *= 10;\n n += b - '0';\n }",
"n *= 10",
"n",
"10",
"n += b - '0'",
"n",
"b - '0'",
"b",
"'0'",
"if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }",
"b == -1 || !isPrintableChar(b)",
"b == -1",
"b",
"-1",
"1",
"!isPrintableChar(b)",
"isPrintableChar(b)",
"isPrintableChar",
"b",
"{\n return minus ? -n : n;\n }",
"return minus ? -n : n;",
"minus ? -n : n",
"minus",
"-n",
"n",
"n",
"{\n throw new NumberFormatException();\n }",
"throw new NumberFormatException();",
"new NumberFormatException()",
"b = readByte()",
"b",
"readByte()",
"readByte",
"public int nextInt() {\n \t if (!hasNext()) throw new NoSuchElementException();\n int n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }",
"nextInt",
"{\n \t if (!hasNext()) throw new NoSuchElementException();\n int n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }",
"if (!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"int n = 0;",
"n",
"0",
"boolean minus = false;",
"minus",
"false",
"int b = readByte();",
"b",
"readByte()",
"readByte",
"if (b == '-') {\n minus = true;\n b = readByte();\n }",
"b == '-'",
"b",
"'-'",
"{\n minus = true;\n b = readByte();\n }",
"minus = true",
"minus",
"true",
"b = readByte()",
"b",
"readByte()",
"readByte",
"if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }",
"b < '0' || '9' < b",
"b < '0'",
"b",
"'0'",
"'9' < b",
"'9'",
"b",
"{\n throw new NumberFormatException();\n }",
"throw new NumberFormatException();",
"new NumberFormatException()",
"while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }",
"true",
"{\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }",
"if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }",
"'0' <= b && b <= '9'",
"'0' <= b",
"'0'",
"b",
"b <= '9'",
"b",
"'9'",
"{\n n *= 10;\n n += b - '0';\n }",
"n *= 10",
"n",
"10",
"n += b - '0'",
"n",
"b - '0'",
"b",
"'0'",
"if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }",
"b == -1 || !isPrintableChar(b)",
"b == -1",
"b",
"-1",
"1",
"!isPrintableChar(b)",
"isPrintableChar(b)",
"isPrintableChar",
"b",
"{\n return minus ? -n : n;\n }",
"return minus ? -n : n;",
"minus ? -n : n",
"minus",
"-n",
"n",
"n",
"{\n throw new NumberFormatException();\n }",
"throw new NumberFormatException();",
"new NumberFormatException()",
"b = readByte()",
"b",
"readByte()",
"readByte",
"public double nextDouble() {\n \treturn Double.parseDouble(next());\n }",
"nextDouble",
"{\n \treturn Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"public class Main {\n\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tstatic FastScanner sc = new FastScanner();\n\tstatic Scanner stdIn = new Scanner(System.in);\n\tstatic int ans = 0;\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tar[i] = sc.nextInt();\n\t\t}\n\t\tsort(ar);\n\t\tout.print(ar[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}\n\t\tout.println();\n\t\tout.println(ans);\t\t\n\t\tout.flush();\n\t\t\n\t}\n\t\n\tstatic void sort(int[] a) {\n\t\tfor(int i = 0; i < a.length; i++) {\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic void swap(int[] a, int b, int c) {\n\t\tans++;\n\t\tint tmp = a[b];\n\t\ta[b] = a[c];\n\t\ta[c] = tmp;\n\t}\n\t\t \n\n}",
"public class Main {\n\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tstatic FastScanner sc = new FastScanner();\n\tstatic Scanner stdIn = new Scanner(System.in);\n\tstatic int ans = 0;\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tar[i] = sc.nextInt();\n\t\t}\n\t\tsort(ar);\n\t\tout.print(ar[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tout.print(\" \" + ar[i]);\n\t\t}\n\t\tout.println();\n\t\tout.println(ans);\t\t\n\t\tout.flush();\n\t\t\n\t}\n\t\n\tstatic void sort(int[] a) {\n\t\tfor(int i = 0; i < a.length; i++) {\n\t\t\tfor(int j = a.length-1; j >= i+1; j--) {\n\t\t\t\t if (a[j] < a[j-1])\n\t\t\t\t\t swap(a,j,j-1);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic void swap(int[] a, int b, int c) {\n\t\tans++;\n\t\tint tmp = a[b];\n\t\ta[b] = a[c];\n\t\ta[c] = tmp;\n\t}\n\t\t \n\n}",
"Main"
] |
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;
public class Main {
static PrintWriter out = new PrintWriter(System.out);
static FastScanner sc = new FastScanner();
static Scanner stdIn = new Scanner(System.in);
static int ans = 0;
public static void main(String[] args) {
int n = sc.nextInt();
int[] ar = new int[n];
for(int i = 0; i < n; i++) {
ar[i] = sc.nextInt();
}
sort(ar);
out.print(ar[0]);
for(int i = 1; i < n; i++) {
out.print(" " + ar[i]);
}
out.println();
out.println(ans);
out.flush();
}
static void sort(int[] a) {
for(int i = 0; i < a.length; i++) {
for(int j = a.length-1; j >= i+1; j--) {
if (a[j] < a[j-1])
swap(a,j,j-1);
}
}
}
static void swap(int[] a, int b, int c) {
ans++;
int tmp = a[b];
a[b] = a[c];
a[c] = tmp;
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
public boolean hasNext() { skipUnprintable(); return hasNextByte();}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true){
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
if (!hasNext()) throw new NoSuchElementException();
int n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true){
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public double nextDouble() {
return Double.parseDouble(next());
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
164,
5
],
[
164,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
41,
44
],
[
6,
45
],
[
45,
46
],
[
164,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
53,
55
],
[
49,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
62,
69
],
[
69,
70
],
[
69,
71
],
[
62,
72
],
[
72,
73
],
[
73,
74
],
[
62,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
84,
85
],
[
84,
86
],
[
77,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
87,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
101,
103
],
[
87,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
87,
109
],
[
109,
110
],
[
87,
111
],
[
111,
112
],
[
111,
113
],
[
49,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
119,
120
],
[
119,
121
],
[
114,
122
],
[
122,
123
],
[
123,
124
],
[
114,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
130,
132
],
[
127,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
127,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
150,
151
],
[
150,
152
],
[
49,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
153,
158
],
[
47,
159
],
[
159,
160
],
[
47,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic void bubbleSort(int[] a, int n) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic void bubbleSort(int[] a, int n) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"bubbleSort(a, n)",
"bubbleSort",
"a",
"n",
"String[] args",
"args",
"static void bubbleSort(int[] a, int n) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}",
"bubbleSort",
"{\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}",
"boolean flg = true;",
"flg",
"true",
"int cnt = 0;",
"cnt",
"0",
"while(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg",
"{\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg = false",
"flg",
"false",
"for(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1 ;",
"int j = n - 1 ;",
"j",
"n - 1",
"n",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}",
"if(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}",
"a[j - 1] > a[j]",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"a[j]",
"a",
"j",
"{\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}",
"int v = a[j - 1];",
"v",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"a[j - 1] = a[j]",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"a[j]",
"a",
"j",
"a[j] = v",
"a[j]",
"a",
"j",
"v",
"cnt++",
"cnt",
"flg = true",
"flg",
"true",
"for(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}",
"if(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}",
"i != n - 1",
"i",
"n - 1",
"n",
"1",
"{\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t}",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"{\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}",
"System.out.println(a[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"int[] a",
"a",
"int n",
"n",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic void bubbleSort(int[] a, int n) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic void bubbleSort(int[] a, int n) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j - 1] > a[j]) {\n\t\t\t\t\tint v = a[j - 1];\n\t\t\t\t\ta[j - 1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for(int i = 0 ; i < n ; i++) {
a[i] = sc.nextInt();
}
bubbleSort(a, n);
}
static void bubbleSort(int[] a, int n) {
boolean flg = true;
int cnt = 0;
while(flg) {
flg = false;
for(int j = n - 1 ; j >= 1 ; j--) {
if(a[j - 1] > a[j]) {
int v = a[j - 1];
a[j - 1] = a[j];
a[j] = v;
cnt++;
flg = true;
}
}
}
for(int i = 0 ; i < n ; i++) {
if(i != n - 1) {
System.out.print(a[i] + " ");
} else {
System.out.println(a[i]);
}
}
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
4,
13,
13,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
2,
13,
17,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
2,
13,
17,
2,
18,
13,
2,
13,
17,
18,
13,
13,
40,
13,
23,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
198,
5
],
[
198,
6
],
[
6,
7
],
[
6,
8
],
[
198,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
11,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
36,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
11,
44
],
[
44,
45
],
[
45,
46
],
[
11,
47
],
[
47,
48
],
[
47,
49
],
[
47,
50
],
[
11,
51
],
[
51,
52
],
[
51,
53
],
[
11,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
9,
60
],
[
60,
61
],
[
198,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
65,
70
],
[
70,
71
],
[
70,
72
],
[
65,
73
],
[
73,
74
],
[
74,
75
],
[
65,
76
],
[
77,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
78,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
78,
91
],
[
92,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
93,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
110,
116
],
[
116,
117
],
[
116,
118
],
[
103,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
123,
129
],
[
129,
130
],
[
129,
131
],
[
103,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
132,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
138,
144
],
[
144,
145
],
[
144,
146
],
[
103,
147
],
[
147,
148
],
[
62,
149
],
[
149,
150
],
[
62,
151
],
[
151,
152
],
[
198,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
156,
166
],
[
166,
167
],
[
167,
168
],
[
156,
169
],
[
170,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
171,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
175,
180
],
[
170,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
181,
186
],
[
186,
187
],
[
186,
188
],
[
155,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
189,
194
],
[
153,
195
],
[
195,
196
],
[
0,
197
],
[
197,
198
],
[
197,
199
]
] | [
"\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static int count = 0;\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint length = scanner.nextInt();\n\t\tint[] array = new int[length];\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\tbubbleSort(array, length);\n\t\tprintArray(array);\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void bubbleSort(int[] array, int length) {\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void printArray(int[] array) {\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static int count = 0;\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint length = scanner.nextInt();\n\t\tint[] array = new int[length];\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\tbubbleSort(array, length);\n\t\tprintArray(array);\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void bubbleSort(int[] array, int length) {\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void printArray(int[] array) {\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}",
"Main",
"public static int count = 0;",
"count",
"0",
"public static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint length = scanner.nextInt();\n\t\tint[] array = new int[length];\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\tbubbleSort(array, length);\n\t\tprintArray(array);\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint length = scanner.nextInt();\n\t\tint[] array = new int[length];\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\tbubbleSort(array, length);\n\t\tprintArray(array);\n\t\tSystem.out.println(count);\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int length = scanner.nextInt();",
"length",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int[] array = new int[length];",
"array",
"new int[length]",
"length",
"for (int i=0; i<length; i++) {\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<length",
"i",
"length",
"i++",
"i++",
"i",
"{\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}",
"{\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}",
"array[i] = scanner.nextInt()",
"array[i]",
"array",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"scanner.close()",
"scanner.close",
"scanner",
"bubbleSort(array, length)",
"bubbleSort",
"array",
"length",
"printArray(array)",
"printArray",
"array",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public static void bubbleSort(int[] array, int length) {\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"bubbleSort",
"{\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"for (int i=0; i<length; i++) {\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<length",
"i",
"length",
"i++",
"i++",
"i",
"{\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int j=length-1;",
"int j=length-1;",
"j",
"length-1",
"length",
"1",
"j>i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"array[j] < array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"array[j-1] = array[j-1] + array[j]",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1] + array[j]",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j]",
"array",
"j",
"array[j] = array[j-1] - array[j]",
"array[j]",
"array",
"j",
"array[j-1] - array[j]",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j]",
"array",
"j",
"array[j-1] = array[j-1] - array[j]",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1] - array[j]",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j]",
"array",
"j",
"count++",
"count",
"int[] array",
"array",
"int length",
"length",
"public static void printArray(int[] array) {\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}",
"printArray",
"{\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}",
"for (int i = 0; i < array.length; i++) {\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < array.length",
"i",
"array.length",
"array",
"array.length",
"i++",
"i++",
"i",
"{\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}",
"{\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}",
"if (i>0) System.out.print(\" \");",
"i>0",
"i",
"0",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(array[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"array[i]",
"array",
"i",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"int[] array",
"array",
"public class Main {\n\n\tpublic static int count = 0;\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint length = scanner.nextInt();\n\t\tint[] array = new int[length];\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\tbubbleSort(array, length);\n\t\tprintArray(array);\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void bubbleSort(int[] array, int length) {\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void printArray(int[] array) {\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}",
"public class Main {\n\n\tpublic static int count = 0;\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint length = scanner.nextInt();\n\t\tint[] array = new int[length];\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\tbubbleSort(array, length);\n\t\tprintArray(array);\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static void bubbleSort(int[] array, int length) {\n\t\tfor (int i=0; i<length; i++) {\n\t\t\tfor (int j=length-1; j>i; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\tarray[j-1] = array[j-1] + array[j];\n\t\t\t\t\tarray[j] = array[j-1] - array[j];\n\t\t\t\t\tarray[j-1] = array[j-1] - array[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void printArray(int[] array) {\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t\tif (i>0) System.out.print(\" \");\n\t\t\tSystem.out.print(array[i]);\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}",
"Main"
] |
import java.util.Scanner;
public class Main {
public static int count = 0;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int length = scanner.nextInt();
int[] array = new int[length];
for (int i=0; i<length; i++) {
array[i] = scanner.nextInt();
}
scanner.close();
bubbleSort(array, length);
printArray(array);
System.out.println(count);
}
public static void bubbleSort(int[] array, int length) {
for (int i=0; i<length; i++) {
for (int j=length-1; j>i; j--) {
if (array[j] < array[j-1]) {
array[j-1] = array[j-1] + array[j];
array[j] = array[j-1] - array[j];
array[j-1] = array[j-1] - array[j];
count++;
}
}
}
}
public static void printArray(int[] array) {
for (int i = 0; i < array.length; i++) {
if (i>0) System.out.print(" ");
System.out.print(array[i]);
}
System.out.print("\n");
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
13,
13,
13,
4,
18,
18,
13,
13,
18,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
41,
13,
41,
13,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
0,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
29,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
171,
5
],
[
171,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
23,
28
],
[
28,
29
],
[
28,
30
],
[
23,
31
],
[
31,
32
],
[
32,
33
],
[
23,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
39,
40
],
[
40,
41
],
[
8,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
44,
46
],
[
44,
47
],
[
8,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
48,
53
],
[
53,
54
],
[
53,
55
],
[
8,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
56,
61
],
[
61,
62
],
[
61,
63
],
[
56,
64
],
[
64,
65
],
[
65,
66
],
[
56,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
8,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
8,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
6,
89
],
[
89,
90
],
[
171,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
97,
99
],
[
93,
100
],
[
100,
101
],
[
93,
102
],
[
102,
103
],
[
93,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
116,
118
],
[
112,
119
],
[
119,
120
],
[
119,
121
],
[
112,
122
],
[
122,
123
],
[
123,
124
],
[
112,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
127,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
140,
142
],
[
137,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
149,
151
],
[
137,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
155,
157
],
[
152,
158
],
[
137,
159
],
[
159,
160
],
[
137,
161
],
[
161,
162
],
[
161,
163
],
[
93,
164
],
[
164,
165
],
[
91,
166
],
[
166,
167
],
[
91,
168
],
[
168,
169
],
[
0,
170
],
[
170,
171
],
[
170,
172
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint[] a = new int[n];\n\t\tint i;\n\t\t\n\t\tfor (i = 0; i < n; i++)\n\t\t\ta[i] =stdIn.nextInt();\n\t\t\n\t\tint count = BubbleSort(a, n);\n\t\t\n\t\tSystem.out.print(a[0]);\n\t\tfor(i = 1; i < n; i++)\n\t\t\tSystem.out.print(\" \" + a[i]);\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static int BubbleSort(int[] a, int n) {\n\t\tint flag = 1, count = 0, i, t;\n\t\twhile (flag != 0) {\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint[] a = new int[n];\n\t\tint i;\n\t\t\n\t\tfor (i = 0; i < n; i++)\n\t\t\ta[i] =stdIn.nextInt();\n\t\t\n\t\tint count = BubbleSort(a, n);\n\t\t\n\t\tSystem.out.print(a[0]);\n\t\tfor(i = 1; i < n; i++)\n\t\t\tSystem.out.print(\" \" + a[i]);\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static int BubbleSort(int[] a, int n) {\n\t\tint flag = 1, count = 0, i, t;\n\t\twhile (flag != 0) {\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint[] a = new int[n];\n\t\tint i;\n\t\t\n\t\tfor (i = 0; i < n; i++)\n\t\t\ta[i] =stdIn.nextInt();\n\t\t\n\t\tint count = BubbleSort(a, n);\n\t\t\n\t\tSystem.out.print(a[0]);\n\t\tfor(i = 1; i < n; i++)\n\t\t\tSystem.out.print(\" \" + a[i]);\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint[] a = new int[n];\n\t\tint i;\n\t\t\n\t\tfor (i = 0; i < n; i++)\n\t\t\ta[i] =stdIn.nextInt();\n\t\t\n\t\tint count = BubbleSort(a, n);\n\t\t\n\t\tSystem.out.print(a[0]);\n\t\tfor(i = 1; i < n; i++)\n\t\t\tSystem.out.print(\" \" + a[i]);\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"Scanner stdIn = new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"int n = stdIn.nextInt();",
"n",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"int i;",
"i",
"for (i = 0; i < n; i++)\n\t\t\ta[i] =stdIn.nextInt();",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] =stdIn.nextInt();",
"a[i] =stdIn.nextInt()",
"a[i]",
"a",
"i",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int count = BubbleSort(a, n);",
"count",
"BubbleSort(a, n)",
"BubbleSort",
"a",
"n",
"System.out.print(a[0])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[0]",
"a",
"0",
"for(i = 1; i < n; i++)\n\t\t\tSystem.out.print(\" \" + a[i]);",
"i = 1;",
"i = 1",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"System.out.print(\" \" + a[i]);",
"System.out.print(\" \" + a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \" + a[i]",
"\" \"",
"a[i]",
"a",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public static int BubbleSort(int[] a, int n) {\n\t\tint flag = 1, count = 0, i, t;\n\t\twhile (flag != 0) {\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}",
"BubbleSort",
"{\n\t\tint flag = 1, count = 0, i, t;\n\t\twhile (flag != 0) {\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}",
"int flag = 1",
"flag",
"1",
"count = 0",
"count",
"0",
"i",
"i",
"t;",
"t",
"while (flag != 0) {\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag != 0",
"flag",
"0",
"{\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = 0",
"flag",
"0",
"for (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}",
"i = n - 1;",
"i = n - 1",
"i",
"n - 1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}",
"if (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}",
"a[i] < a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"{\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}",
"t = a[i]",
"t",
"a[i]",
"a",
"i",
"a[i] = a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i-1] = t",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"t",
"count++",
"count",
"flag = 1",
"flag",
"1",
"return count;",
"count",
"int[] a",
"a",
"int n",
"n",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint[] a = new int[n];\n\t\tint i;\n\t\t\n\t\tfor (i = 0; i < n; i++)\n\t\t\ta[i] =stdIn.nextInt();\n\t\t\n\t\tint count = BubbleSort(a, n);\n\t\t\n\t\tSystem.out.print(a[0]);\n\t\tfor(i = 1; i < n; i++)\n\t\t\tSystem.out.print(\" \" + a[i]);\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static int BubbleSort(int[] a, int n) {\n\t\tint flag = 1, count = 0, i, t;\n\t\twhile (flag != 0) {\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint[] a = new int[n];\n\t\tint i;\n\t\t\n\t\tfor (i = 0; i < n; i++)\n\t\t\ta[i] =stdIn.nextInt();\n\t\t\n\t\tint count = BubbleSort(a, n);\n\t\t\n\t\tSystem.out.print(a[0]);\n\t\tfor(i = 1; i < n; i++)\n\t\t\tSystem.out.print(\" \" + a[i]);\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tpublic static int BubbleSort(int[] a, int n) {\n\t\tint flag = 1, count = 0, i, t;\n\t\twhile (flag != 0) {\n\t\t\tflag = 0;\n\t\t\tfor (i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i-1]) {\n\t\t\t\t\tt = a[i];\n\t\t\t\t\ta[i] = a[i-1];\n\t\t\t\t\ta[i-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int n = stdIn.nextInt();
int[] a = new int[n];
int i;
for (i = 0; i < n; i++)
a[i] =stdIn.nextInt();
int count = BubbleSort(a, n);
System.out.print(a[0]);
for(i = 1; i < n; i++)
System.out.print(" " + a[i]);
System.out.println();
System.out.println(count);
}
public static int BubbleSort(int[] a, int n) {
int flag = 1, count = 0, i, t;
while (flag != 0) {
flag = 0;
for (i = n - 1; i > 0; i--) {
if (a[i] < a[i-1]) {
t = a[i];
a[i] = a[i-1];
a[i-1] = t;
count++;
flag = 1;
}
}
}
return count;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
30,
4,
18,
13,
17,
4,
18,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
152,
5
],
[
152,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
57,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
57,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
72,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
82,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
82,
104
],
[
104,
105
],
[
8,
106
],
[
106,
107
],
[
106,
108
],
[
8,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
114,
115
],
[
114,
116
],
[
109,
117
],
[
117,
118
],
[
118,
119
],
[
109,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
121,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
134,
136
],
[
8,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
8,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
6,
149
],
[
149,
150
],
[
0,
151
],
[
151,
152
],
[
151,
153
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] arr = new int[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n int count = 0;\n for (int i = 0; i < n; i++) {\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++) {\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }\n System.out.println(sb);\n System.out.println(count);\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] arr = new int[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n int count = 0;\n for (int i = 0; i < n; i++) {\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++) {\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }\n System.out.println(sb);\n System.out.println(count);\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] arr = new int[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n int count = 0;\n for (int i = 0; i < n; i++) {\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++) {\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }\n System.out.println(sb);\n System.out.println(count);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] arr = new int[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n int count = 0;\n for (int i = 0; i < n; i++) {\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++) {\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }\n System.out.println(sb);\n System.out.println(count);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] arr = new int[n];",
"arr",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n arr[i] = sc.nextInt();\n }",
"{\n arr[i] = sc.nextInt();\n }",
"arr[i] = sc.nextInt()",
"arr[i]",
"arr",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count = 0;",
"count",
"0",
"for (int i = 0; i < n; i++) {\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }",
"{\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }",
"for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }",
"int j = n - 2;",
"int j = n - 2;",
"j",
"n - 2",
"n",
"2",
"j >= i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }",
"{\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }",
"if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }",
"arr[j] > arr[j + 1]",
"arr[j]",
"arr",
"j",
"arr[j + 1]",
"arr",
"j + 1",
"j",
"1",
"{\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }",
"int tmp = arr[j];",
"tmp",
"arr[j]",
"arr",
"j",
"arr[j] = arr[j + 1]",
"arr[j]",
"arr",
"j",
"arr[j + 1]",
"arr",
"j + 1",
"j",
"1",
"arr[j + 1] = tmp",
"arr[j + 1]",
"arr",
"j + 1",
"j",
"1",
"tmp",
"count++",
"count",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"for (int i = 0; i < n; i++) {\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }",
"{\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }",
"if (i > 0) {\n sb.append(\" \");\n }",
"i > 0",
"i",
"0",
"{\n sb.append(\" \");\n }",
"sb.append(\" \")",
"sb.append",
"sb",
"\" \"",
"sb.append(arr[i])",
"sb.append",
"sb",
"arr[i]",
"arr",
"i",
"System.out.println(sb)",
"System.out.println",
"System.out",
"System",
"System.out",
"sb",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] arr = new int[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n int count = 0;\n for (int i = 0; i < n; i++) {\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++) {\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }\n System.out.println(sb);\n System.out.println(count);\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] arr = new int[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n int count = 0;\n for (int i = 0; i < n; i++) {\n for (int j = n - 2; j >= i; j--) {\n if (arr[j] > arr[j + 1]) {\n int tmp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = tmp;\n count++;\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++) {\n if (i > 0) {\n sb.append(\" \");\n }\n sb.append(arr[i]);\n }\n System.out.println(sb);\n System.out.println(count);\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = n - 2; j >= i; j--) {
if (arr[j] > arr[j + 1]) {
int tmp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = tmp;
count++;
}
}
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
if (i > 0) {
sb.append(" ");
}
sb.append(arr[i]);
}
System.out.println(sb);
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
4,
13,
13,
13,
2,
13,
17,
40,
13,
41,
13,
20,
28,
13,
13,
30,
30,
4,
18,
13,
2,
13,
17,
41,
13,
4,
18,
13,
4,
18,
18,
13,
13,
4,
18,
13,
17,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
39,
17,
17,
17,
17,
17,
29,
13,
12,
13,
30,
41,
13,
18,
13,
13,
41,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
192,
5
],
[
192,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
8,
13
],
[
13,
14
],
[
13,
15
],
[
8,
16
],
[
16,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
16,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
23,
25
],
[
16,
26
],
[
26,
27
],
[
27,
28
],
[
16,
29
],
[
30,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
31,
40
],
[
40,
41
],
[
40,
42
],
[
31,
43
],
[
43,
44
],
[
44,
45
],
[
31,
46
],
[
47,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
55,
57
],
[
48,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
59,
62
],
[
59,
63
],
[
63,
64
],
[
63,
65
],
[
58,
66
],
[
66,
67
],
[
8,
68
],
[
68,
69
],
[
68,
70
],
[
8,
71
],
[
71,
72
],
[
71,
73
],
[
71,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
79,
80
],
[
79,
81
],
[
8,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
8,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
87,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
92,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
96,
100
],
[
8,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
6,
107
],
[
107,
108
],
[
192,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
114,
117
],
[
114,
118
],
[
114,
119
],
[
111,
120
],
[
120,
121
],
[
192,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
124,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
124,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
124,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
122,
145
],
[
145,
146
],
[
122,
147
],
[
147,
148
],
[
122,
149
],
[
149,
150
],
[
192,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
153,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
153,
162
],
[
162,
163
],
[
162,
164
],
[
153,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
166,
171
],
[
171,
172
],
[
171,
173
],
[
166,
174
],
[
174,
175
],
[
175,
176
],
[
166,
177
],
[
178,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
183,
184
],
[
184,
185
],
[
153,
186
],
[
186,
187
],
[
187,
188
],
[
153,
189
],
[
189,
190
],
[
0,
191
],
[
191,
192
],
[
191,
193
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String args[]) {\n\n int[] inputs = input();\n// int[] inputs = mockup();\n int swapCount = 0;\n\n for (int i = 0; i < inputs.length; i++) {\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }\n StringBuilder output = new StringBuilder();\n for (int i : inputs) {\n output.append(i + \" \");\n }\n String outputString = output.toString();\n System.out.println(outputString.substring(0,outputString.length() - 1));\n System.out.println(swapCount);\n }\n\n private static int[] mockup() {\n int a[] = {1,2,3,4,5};\n return a;\n }\n\n private static void swap(int[] inputs, int j, int i) {\n int a = inputs[j];\n int b = inputs[i];\n inputs[i] = a;\n inputs[j] = b;\n }\n\n\n public static int[] input() {\n Scanner in = new Scanner(System.in);\n int count = in.nextInt();\n int[] inputs = new int[count];\n for (int i = 0; i < count; i++) {\n inputs[i] = in.nextInt();\n }\n in.close();\n return inputs;\n }\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n public static void main(String args[]) {\n\n int[] inputs = input();\n// int[] inputs = mockup();\n int swapCount = 0;\n\n for (int i = 0; i < inputs.length; i++) {\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }\n StringBuilder output = new StringBuilder();\n for (int i : inputs) {\n output.append(i + \" \");\n }\n String outputString = output.toString();\n System.out.println(outputString.substring(0,outputString.length() - 1));\n System.out.println(swapCount);\n }\n\n private static int[] mockup() {\n int a[] = {1,2,3,4,5};\n return a;\n }\n\n private static void swap(int[] inputs, int j, int i) {\n int a = inputs[j];\n int b = inputs[i];\n inputs[i] = a;\n inputs[j] = b;\n }\n\n\n public static int[] input() {\n Scanner in = new Scanner(System.in);\n int count = in.nextInt();\n int[] inputs = new int[count];\n for (int i = 0; i < count; i++) {\n inputs[i] = in.nextInt();\n }\n in.close();\n return inputs;\n }\n\n}",
"Main",
"public static void main(String args[]) {\n\n int[] inputs = input();\n// int[] inputs = mockup();\n int swapCount = 0;\n\n for (int i = 0; i < inputs.length; i++) {\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }\n StringBuilder output = new StringBuilder();\n for (int i : inputs) {\n output.append(i + \" \");\n }\n String outputString = output.toString();\n System.out.println(outputString.substring(0,outputString.length() - 1));\n System.out.println(swapCount);\n }",
"main",
"{\n\n int[] inputs = input();\n// int[] inputs = mockup();\n int swapCount = 0;\n\n for (int i = 0; i < inputs.length; i++) {\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }\n StringBuilder output = new StringBuilder();\n for (int i : inputs) {\n output.append(i + \" \");\n }\n String outputString = output.toString();\n System.out.println(outputString.substring(0,outputString.length() - 1));\n System.out.println(swapCount);\n }",
"int[] inputs = input();",
"inputs",
"input()",
"input",
"int swapCount = 0;",
"swapCount",
"0",
"for (int i = 0; i < inputs.length; i++) {\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < inputs.length",
"i",
"inputs.length",
"inputs",
"inputs.length",
"i++",
"i++",
"i",
"{\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }",
"{\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }",
"for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }",
"int j = inputs.length - 1;",
"int j = inputs.length - 1;",
"j",
"inputs.length - 1",
"inputs.length",
"inputs",
"inputs.length",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }",
"{\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }",
"if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }",
"inputs[j] < inputs[j-1]",
"inputs[j]",
"inputs",
"j",
"inputs[j-1]",
"inputs",
"j-1",
"j",
"1",
"{\n swap(inputs, j, j-1);\n swapCount++;\n }",
"swap(inputs, j, j-1)",
"swap",
"inputs",
"j",
"j-1",
"j",
"1",
"swapCount++",
"swapCount",
"StringBuilder output = new StringBuilder();",
"output",
"new StringBuilder()",
"for (int i : inputs) {\n output.append(i + \" \");\n }",
"int i",
"inputs",
"{\n output.append(i + \" \");\n }",
"{\n output.append(i + \" \");\n }",
"output.append(i + \" \")",
"output.append",
"output",
"i + \" \"",
"i",
"\" \"",
"String outputString = output.toString();",
"outputString",
"output.toString()",
"output.toString",
"output",
"System.out.println(outputString.substring(0,outputString.length() - 1))",
"System.out.println",
"System.out",
"System",
"System.out",
"outputString.substring(0,outputString.length() - 1)",
"outputString.substring",
"outputString",
"0",
"outputString.length() - 1",
"outputString.length()",
"outputString.length",
"outputString",
"1",
"System.out.println(swapCount)",
"System.out.println",
"System.out",
"System",
"System.out",
"swapCount",
"String args[]",
"args",
"private static int[] mockup() {\n int a[] = {1,2,3,4,5};\n return a;\n }",
"mockup",
"{\n int a[] = {1,2,3,4,5};\n return a;\n }",
"int a[] = {1,2,3,4,5};",
"a",
"{1,2,3,4,5}",
"1",
"2",
"3",
"4",
"5",
"return a;",
"a",
"private static void swap(int[] inputs, int j, int i) {\n int a = inputs[j];\n int b = inputs[i];\n inputs[i] = a;\n inputs[j] = b;\n }",
"swap",
"{\n int a = inputs[j];\n int b = inputs[i];\n inputs[i] = a;\n inputs[j] = b;\n }",
"int a = inputs[j];",
"a",
"inputs[j]",
"inputs",
"j",
"int b = inputs[i];",
"b",
"inputs[i]",
"inputs",
"i",
"inputs[i] = a",
"inputs[i]",
"inputs",
"i",
"a",
"inputs[j] = b",
"inputs[j]",
"inputs",
"j",
"b",
"int[] inputs",
"inputs",
"int j",
"j",
"int i",
"i",
"public static int[] input() {\n Scanner in = new Scanner(System.in);\n int count = in.nextInt();\n int[] inputs = new int[count];\n for (int i = 0; i < count; i++) {\n inputs[i] = in.nextInt();\n }\n in.close();\n return inputs;\n }",
"input",
"{\n Scanner in = new Scanner(System.in);\n int count = in.nextInt();\n int[] inputs = new int[count];\n for (int i = 0; i < count; i++) {\n inputs[i] = in.nextInt();\n }\n in.close();\n return inputs;\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int count = in.nextInt();",
"count",
"in.nextInt()",
"in.nextInt",
"in",
"int[] inputs = new int[count];",
"inputs",
"new int[count]",
"count",
"for (int i = 0; i < count; i++) {\n inputs[i] = in.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < count",
"i",
"count",
"i++",
"i++",
"i",
"{\n inputs[i] = in.nextInt();\n }",
"{\n inputs[i] = in.nextInt();\n }",
"inputs[i] = in.nextInt()",
"inputs[i]",
"inputs",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"in.close()",
"in.close",
"in",
"return inputs;",
"inputs",
"public class Main {\n\n public static void main(String args[]) {\n\n int[] inputs = input();\n// int[] inputs = mockup();\n int swapCount = 0;\n\n for (int i = 0; i < inputs.length; i++) {\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }\n StringBuilder output = new StringBuilder();\n for (int i : inputs) {\n output.append(i + \" \");\n }\n String outputString = output.toString();\n System.out.println(outputString.substring(0,outputString.length() - 1));\n System.out.println(swapCount);\n }\n\n private static int[] mockup() {\n int a[] = {1,2,3,4,5};\n return a;\n }\n\n private static void swap(int[] inputs, int j, int i) {\n int a = inputs[j];\n int b = inputs[i];\n inputs[i] = a;\n inputs[j] = b;\n }\n\n\n public static int[] input() {\n Scanner in = new Scanner(System.in);\n int count = in.nextInt();\n int[] inputs = new int[count];\n for (int i = 0; i < count; i++) {\n inputs[i] = in.nextInt();\n }\n in.close();\n return inputs;\n }\n\n}",
"public class Main {\n\n public static void main(String args[]) {\n\n int[] inputs = input();\n// int[] inputs = mockup();\n int swapCount = 0;\n\n for (int i = 0; i < inputs.length; i++) {\n for (int j = inputs.length - 1; j > i; j--) {\n if (inputs[j] < inputs[j-1]) {\n swap(inputs, j, j-1);\n swapCount++;\n }\n }\n }\n StringBuilder output = new StringBuilder();\n for (int i : inputs) {\n output.append(i + \" \");\n }\n String outputString = output.toString();\n System.out.println(outputString.substring(0,outputString.length() - 1));\n System.out.println(swapCount);\n }\n\n private static int[] mockup() {\n int a[] = {1,2,3,4,5};\n return a;\n }\n\n private static void swap(int[] inputs, int j, int i) {\n int a = inputs[j];\n int b = inputs[i];\n inputs[i] = a;\n inputs[j] = b;\n }\n\n\n public static int[] input() {\n Scanner in = new Scanner(System.in);\n int count = in.nextInt();\n int[] inputs = new int[count];\n for (int i = 0; i < count; i++) {\n inputs[i] = in.nextInt();\n }\n in.close();\n return inputs;\n }\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String args[]) {
int[] inputs = input();
// int[] inputs = mockup();
int swapCount = 0;
for (int i = 0; i < inputs.length; i++) {
for (int j = inputs.length - 1; j > i; j--) {
if (inputs[j] < inputs[j-1]) {
swap(inputs, j, j-1);
swapCount++;
}
}
}
StringBuilder output = new StringBuilder();
for (int i : inputs) {
output.append(i + " ");
}
String outputString = output.toString();
System.out.println(outputString.substring(0,outputString.length() - 1));
System.out.println(swapCount);
}
private static int[] mockup() {
int a[] = {1,2,3,4,5};
return a;
}
private static void swap(int[] inputs, int j, int i) {
int a = inputs[j];
int b = inputs[i];
inputs[i] = a;
inputs[j] = b;
}
public static int[] input() {
Scanner in = new Scanner(System.in);
int count = in.nextInt();
int[] inputs = new int[count];
for (int i = 0; i < count; i++) {
inputs[i] = in.nextInt();
}
in.close();
return inputs;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
0,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
8,
27
],
[
27,
28
],
[
27,
29
],
[
8,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
30,
35
],
[
35,
36
],
[
35,
37
],
[
30,
38
],
[
38,
39
],
[
39,
40
],
[
30,
41
],
[
42,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
8,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
57,
59
],
[
50,
60
],
[
60,
61
],
[
61,
62
],
[
50,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
65,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
65,
77
],
[
77,
78
],
[
78,
79
],
[
65,
80
],
[
81,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
83,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
82,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
92,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
110,
112
],
[
107,
113
],
[
92,
114
],
[
114,
115
],
[
8,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
121,
122
],
[
121,
123
],
[
116,
124
],
[
124,
125
],
[
125,
126
],
[
116,
127
],
[
128,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
128,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
139,
144
],
[
144,
145
],
[
144,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
8,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
152,
157
],
[
6,
158
],
[
158,
159
]
] | [
"import java.util.Scanner;\n\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tint i, j, w, cnt=0;\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tfor(i=0; i<N-1; i++){\n\t\t\tfor(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i=0; i<N; i++){\n\t\t\tif(i!=0) System.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tint i, j, w, cnt=0;\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tfor(i=0; i<N-1; i++){\n\t\t\tfor(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i=0; i<N; i++){\n\t\t\tif(i!=0) System.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tint i, j, w, cnt=0;\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tfor(i=0; i<N-1; i++){\n\t\t\tfor(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i=0; i<N; i++){\n\t\t\tif(i!=0) System.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint A[] = new int[N];\n\t\tint i, j, w, cnt=0;\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tfor(i=0; i<N-1; i++){\n\t\t\tfor(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i=0; i<N; i++){\n\t\t\tif(i!=0) System.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int A[] = new int[N];",
"A",
"new int[N]",
"N",
"int i",
"i",
"j",
"j",
"w",
"w",
"cnt=0;",
"cnt",
"0",
"for(i=0; i<N; i++){\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(i=0; i<N-1; i++){\n\t\t\tfor(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(j=N-1; j>=i+1; j--){\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"j=N-1;",
"j=N-1",
"j",
"N-1",
"N",
"1",
"j>=i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"if(A[j]<A[j-1]){\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}",
"A[j]<A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tw = A[j];\n\t\t\t\t\tA[j] = A[j-1];\n\t\t\t\t\tA[j-1] = w;\n\t\t\t\t\tcnt++;\n\t\t\t\t}",
"w = A[j]",
"w",
"A[j]",
"A",
"j",
"A[j] = A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j-1] = w",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"w",
"cnt++",
"cnt",
"for(i=0; i<N; i++){\n\t\t\tif(i!=0) System.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tif(i!=0) System.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"{\n\t\t\tif(i!=0) System.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"if(i!=0) System.out.print(\" \");",
"i!=0",
"i",
"0",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int A[] = new int[N];
int i, j, w, cnt=0;
for(i=0; i<N; i++){
A[i] = sc.nextInt();
}
for(i=0; i<N-1; i++){
for(j=N-1; j>=i+1; j--){
if(A[j]<A[j-1]){
w = A[j];
A[j] = A[j-1];
A[j-1] = w;
cnt++;
}
}
}
for(i=0; i<N; i++){
if(i!=0) System.out.print(" ");
System.out.print(A[i]);
}
System.out.println();
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
42,
13,
30,
0,
13,
17,
11,
1,
0,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
17,
40,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
157,
5
],
[
157,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
8,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
48,
49
],
[
49,
50
],
[
8,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
57,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
57,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
72,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
82,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
96,
98
],
[
82,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
82,
104
],
[
104,
105
],
[
104,
106
],
[
82,
107
],
[
107,
108
],
[
8,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
114,
115
],
[
114,
116
],
[
109,
117
],
[
117,
118
],
[
118,
119
],
[
109,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
127,
128
],
[
127,
129
],
[
121,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
8,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
8,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
6,
154
],
[
154,
155
],
[
0,
156
],
[
156,
157
],
[
156,
158
]
] | [
"import java.util.*;\n//import java.util.Math.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int A[] = new int[n];\n int i;\n boolean flag = true;\n int tmp;\n int count = 0;\n \n for(i = 0; i < n; i++){\n A[i] = sc.nextInt();\n }\n \n while(flag){\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }\n \n for(i = 0; i < n; i++){\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }\n System.out.println();\n System.out.println(count);\n\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) throws Exception {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int A[] = new int[n];\n int i;\n boolean flag = true;\n int tmp;\n int count = 0;\n \n for(i = 0; i < n; i++){\n A[i] = sc.nextInt();\n }\n \n while(flag){\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }\n \n for(i = 0; i < n; i++){\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }\n System.out.println();\n System.out.println(count);\n\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int A[] = new int[n];\n int i;\n boolean flag = true;\n int tmp;\n int count = 0;\n \n for(i = 0; i < n; i++){\n A[i] = sc.nextInt();\n }\n \n while(flag){\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }\n \n for(i = 0; i < n; i++){\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }\n System.out.println();\n System.out.println(count);\n\n }",
"main",
"{\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int A[] = new int[n];\n int i;\n boolean flag = true;\n int tmp;\n int count = 0;\n \n for(i = 0; i < n; i++){\n A[i] = sc.nextInt();\n }\n \n while(flag){\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }\n \n for(i = 0; i < n; i++){\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }\n System.out.println();\n System.out.println(count);\n\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int A[] = new int[n];",
"A",
"new int[n]",
"n",
"int i;",
"i",
"boolean flag = true;",
"flag",
"true",
"int tmp;",
"tmp",
"int count = 0;",
"count",
"0",
"for(i = 0; i < n; i++){\n A[i] = sc.nextInt();\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n A[i] = sc.nextInt();\n }",
"{\n A[i] = sc.nextInt();\n }",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(flag){\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }",
"flag",
"{\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }",
"i = n-1;",
"i = n-1",
"i",
"n-1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }",
"{\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }",
"if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }",
"A[i] < A[i-1]",
"A[i]",
"A",
"i",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"{\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }",
"tmp = A[i-1]",
"tmp",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i-1] = A[i]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"A[i] = tmp",
"A[i]",
"A",
"i",
"tmp",
"flag = true",
"flag",
"true",
"count++",
"count",
"for(i = 0; i < n; i++){\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }",
"{\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"if(i < (n-1)){ System.out.print(\" \"); }",
"i < (n-1)",
"i",
"(n-1)",
"n",
"1",
"{ System.out.print(\" \"); }",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) throws Exception {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int A[] = new int[n];\n int i;\n boolean flag = true;\n int tmp;\n int count = 0;\n \n for(i = 0; i < n; i++){\n A[i] = sc.nextInt();\n }\n \n while(flag){\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }\n \n for(i = 0; i < n; i++){\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }\n System.out.println();\n System.out.println(count);\n\n }\n}",
"public class Main {\n public static void main(String[] args) throws Exception {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int A[] = new int[n];\n int i;\n boolean flag = true;\n int tmp;\n int count = 0;\n \n for(i = 0; i < n; i++){\n A[i] = sc.nextInt();\n }\n \n while(flag){\n flag = false;\n for(i = n-1; i > 0; i--){\n if(A[i] < A[i-1]){\n tmp = A[i-1];\n A[i-1] = A[i];\n A[i] = tmp;\n flag = true;\n //System.out.println(\"test\");\n count++;\n }\n }\n }\n \n for(i = 0; i < n; i++){\n System.out.print(A[i]);\n if(i < (n-1)){ System.out.print(\" \"); }\n }\n System.out.println();\n System.out.println(count);\n\n }\n}",
"Main"
] | import java.util.*;
//import java.util.Math.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int A[] = new int[n];
int i;
boolean flag = true;
int tmp;
int count = 0;
for(i = 0; i < n; i++){
A[i] = sc.nextInt();
}
while(flag){
flag = false;
for(i = n-1; i > 0; i--){
if(A[i] < A[i-1]){
tmp = A[i-1];
A[i-1] = A[i];
A[i] = tmp;
flag = true;
//System.out.println("test");
count++;
}
}
}
for(i = 0; i < n; i++){
System.out.print(A[i]);
if(i < (n-1)){ System.out.print(" "); }
}
System.out.println();
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
17,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
0,
13,
17,
2,
13,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
18,
18,
13,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
2,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
162,
5
],
[
162,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
8,
13
],
[
13,
14
],
[
8,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
8,
27
],
[
27,
28
],
[
27,
29
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
48,
49
],
[
49,
50
],
[
8,
51
],
[
51,
52
],
[
51,
53
],
[
8,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
54,
64
],
[
64,
65
],
[
65,
66
],
[
54,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
69,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
69,
81
],
[
81,
82
],
[
82,
83
],
[
69,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
86,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
96,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
111,
117
],
[
96,
118
],
[
118,
119
],
[
8,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
125,
126
],
[
125,
127
],
[
8,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
128,
136
],
[
136,
137
],
[
137,
138
],
[
128,
139
],
[
140,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
148,
150
],
[
8,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
156,
157
],
[
156,
158
],
[
6,
159
],
[
159,
160
],
[
0,
161
],
[
161,
162
],
[
161,
163
]
] | [
"import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,j,N,tmp,cnt;\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\n\t\tint [] A = new int [N];\n\t\t\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] =sc.nextInt();\n\t\t}\n\t\tcnt =0;\n\t\tfor(i=0;i<N-1;i++){\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(A[0]);\n\t\tfor(int r=1; r<N; r++){\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}\n\t\tSystem.out.println(\"\\r\\n\"+cnt);\n\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,j,N,tmp,cnt;\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\n\t\tint [] A = new int [N];\n\t\t\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] =sc.nextInt();\n\t\t}\n\t\tcnt =0;\n\t\tfor(i=0;i<N-1;i++){\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(A[0]);\n\t\tfor(int r=1; r<N; r++){\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}\n\t\tSystem.out.println(\"\\r\\n\"+cnt);\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,j,N,tmp,cnt;\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\n\t\tint [] A = new int [N];\n\t\t\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] =sc.nextInt();\n\t\t}\n\t\tcnt =0;\n\t\tfor(i=0;i<N-1;i++){\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(A[0]);\n\t\tfor(int r=1; r<N; r++){\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}\n\t\tSystem.out.println(\"\\r\\n\"+cnt);\n\n\t}",
"main",
"{\n\t\t// TODO Auto-generated method stub\n\t\tint i,j,N,tmp,cnt;\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\n\t\tint [] A = new int [N];\n\t\t\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] =sc.nextInt();\n\t\t}\n\t\tcnt =0;\n\t\tfor(i=0;i<N-1;i++){\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(A[0]);\n\t\tfor(int r=1; r<N; r++){\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}\n\t\tSystem.out.println(\"\\r\\n\"+cnt);\n\n\t}",
"int i",
"i",
"j",
"j",
"N",
"N",
"tmp",
"tmp",
"cnt;",
"cnt",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"N = sc.nextInt()",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int [] A = new int [N];",
"A",
"new int [N]",
"N",
"for(i=0; i<N; i++){\n\t\t\tA[i] =sc.nextInt();\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] =sc.nextInt();\n\t\t}",
"{\n\t\t\tA[i] =sc.nextInt();\n\t\t}",
"A[i] =sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"cnt =0",
"cnt",
"0",
"for(i=0;i<N-1;i++){\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"j=0;",
"j=0",
"j",
"0",
"j<N-(i+1)",
"j",
"N-(i+1)",
"N",
"(i+1)",
"i",
"1",
"j++",
"j++",
"j",
"{\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"if(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}",
"A[j] > A[j+1]",
"A[j]",
"A",
"j",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"{\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}",
"tmp = A[j]",
"tmp",
"A[j]",
"A",
"j",
"A[j] = A[j+1]",
"A[j]",
"A",
"j",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"A[j+1] = tmp",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"tmp",
"cnt++",
"cnt",
"System.out.print(A[0])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[0]",
"A",
"0",
"for(int r=1; r<N; r++){\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}",
"int r=1;",
"int r=1;",
"r",
"1",
"r<N",
"r",
"N",
"r++",
"r++",
"r",
"{\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}",
"{\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}",
"System.out.print(\" \"+A[r])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"+A[r]",
"\" \"",
"A[r]",
"A",
"r",
"System.out.println(\"\\r\\n\"+cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\\r\\n\"+cnt",
"\"\\r\\n\"",
"cnt",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,j,N,tmp,cnt;\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\n\t\tint [] A = new int [N];\n\t\t\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] =sc.nextInt();\n\t\t}\n\t\tcnt =0;\n\t\tfor(i=0;i<N-1;i++){\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(A[0]);\n\t\tfor(int r=1; r<N; r++){\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}\n\t\tSystem.out.println(\"\\r\\n\"+cnt);\n\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,j,N,tmp,cnt;\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\n\t\tint [] A = new int [N];\n\t\t\n\t\tfor(i=0; i<N; i++){\n\t\t\tA[i] =sc.nextInt();\n\t\t}\n\t\tcnt =0;\n\t\tfor(i=0;i<N-1;i++){\n\t\t\tfor(j=0;j<N-(i+1);j++){\n\t\t\t\tif(A[j] > A[j+1]){\n\t\t\t\t\ttmp = A[j];\n\t\t\t\t\tA[j] = A[j+1];\n\t\t\t\t\tA[j+1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(A[0]);\n\t\tfor(int r=1; r<N; r++){\n\t\t\tSystem.out.print(\" \"+A[r]);\n\t\t}\n\t\tSystem.out.println(\"\\r\\n\"+cnt);\n\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,j,N,tmp,cnt;
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
int [] A = new int [N];
for(i=0; i<N; i++){
A[i] =sc.nextInt();
}
cnt =0;
for(i=0;i<N-1;i++){
for(j=0;j<N-(i+1);j++){
if(A[j] > A[j+1]){
tmp = A[j];
A[j] = A[j+1];
A[j+1] = tmp;
cnt++;
}
}
}
System.out.print(A[0]);
for(int r=1; r<N; r++){
System.out.print(" "+A[r]);
}
System.out.println("\r\n"+cnt);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
4,
13,
41,
13,
4,
13,
41,
13,
4,
13,
13,
41,
13,
4,
18,
13,
17,
13,
4,
18,
18,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
4,
18,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
4,
18,
13,
13,
41,
13,
4,
18,
13,
4,
18,
13,
2,
13,
17,
14,
2,
13,
13,
30,
41,
13,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
2,
13,
17,
4,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
29,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
29,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
17,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
175,
14
],
[
175,
15
],
[
15,
16
],
[
15,
17
],
[
175,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
29,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
34,
38
],
[
20,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
20,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
18,
51
],
[
51,
52
],
[
175,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
59,
61
],
[
55,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
72,
76
],
[
68,
77
],
[
77,
78
],
[
77,
79
],
[
68,
80
],
[
80,
81
],
[
81,
82
],
[
68,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
84,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
102,
103
],
[
102,
104
],
[
84,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
109,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
116,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
123,
124
],
[
123,
125
],
[
109,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
129,
130
],
[
129,
131
],
[
126,
132
],
[
109,
133
],
[
133,
134
],
[
109,
135
],
[
135,
136
],
[
135,
137
],
[
55,
138
],
[
138,
139
],
[
53,
140
],
[
140,
141
],
[
175,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
144,
150
],
[
150,
151
],
[
175,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
154,
162
],
[
162,
163
],
[
163,
164
],
[
162,
165
],
[
165,
166
],
[
166,
167
],
[
165,
168
],
[
168,
169
],
[
169,
170
],
[
168,
171
],
[
154,
172
],
[
172,
173
],
[
0,
174
],
[
174,
175
],
[
174,
176
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main{\n private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n public static void main(String[] args) throws IOException{\n //キー入力\n getLine();\n List<String> strings = getStrOnLine();\n //計算\n int n = bubbleSort(strings);\n //出力\n String out = String.join(\" \",strings);\n System.out.println(out);\n System.out.println(n);\n }\n\n private static int bubbleSort(List<String> list){ \n boolean flag = true;\n int n = 0;\n while (flag){\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }\n return n;\n }\n \n\n //キー入力メソッド\n public static String getLine() throws IOException {\n String str = br.readLine();\n return str;\n }\n \n //キー入力メソッド\n public static List<String> getStrOnLine() throws IOException {\n List<String> list = new ArrayList<>();\n String line = getLine();\n \n list.addAll(Arrays.asList(line.split(\" \")));\n return list;\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n public static void main(String[] args) throws IOException{\n //キー入力\n getLine();\n List<String> strings = getStrOnLine();\n //計算\n int n = bubbleSort(strings);\n //出力\n String out = String.join(\" \",strings);\n System.out.println(out);\n System.out.println(n);\n }\n\n private static int bubbleSort(List<String> list){ \n boolean flag = true;\n int n = 0;\n while (flag){\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }\n return n;\n }\n \n\n //キー入力メソッド\n public static String getLine() throws IOException {\n String str = br.readLine();\n return str;\n }\n \n //キー入力メソッド\n public static List<String> getStrOnLine() throws IOException {\n List<String> list = new ArrayList<>();\n String line = getLine();\n \n list.addAll(Arrays.asList(line.split(\" \")));\n return list;\n }\n}",
"Main",
"private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"public static void main(String[] args) throws IOException{\n //キー入力\n getLine();\n List<String> strings = getStrOnLine();\n //計算\n int n = bubbleSort(strings);\n //出力\n String out = String.join(\" \",strings);\n System.out.println(out);\n System.out.println(n);\n }",
"main",
"{\n //キー入力\n getLine();\n List<String> strings = getStrOnLine();\n //計算\n int n = bubbleSort(strings);\n //出力\n String out = String.join(\" \",strings);\n System.out.println(out);\n System.out.println(n);\n }",
"getLine()",
"getLine",
"List<String> strings = getStrOnLine();",
"strings",
"getStrOnLine()",
"getStrOnLine",
"int n = bubbleSort(strings);",
"n",
"bubbleSort(strings)",
"bubbleSort",
"strings",
"String out = String.join(\" \",strings);",
"out",
"String.join(\" \",strings)",
"String.join",
"String",
"\" \"",
"strings",
"System.out.println(out)",
"System.out.println",
"System.out",
"System",
"System.out",
"out",
"System.out.println(n)",
"System.out.println",
"System.out",
"System",
"System.out",
"n",
"String[] args",
"args",
"private static int bubbleSort(List<String> list){ \n boolean flag = true;\n int n = 0;\n while (flag){\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }\n return n;\n }",
"bubbleSort",
"{ \n boolean flag = true;\n int n = 0;\n while (flag){\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }\n return n;\n }",
"boolean flag = true;",
"flag",
"true",
"int n = 0;",
"n",
"0",
"while (flag){\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }",
"flag",
"{\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }",
"int j = list.size() - 1 ;",
"int j = list.size() - 1 ;",
"j",
"list.size() - 1",
"list.size()",
"list.size",
"list",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }",
"{\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }",
"int a = Integer.parseInt(list.get(j));",
"a",
"Integer.parseInt(list.get(j))",
"Integer.parseInt",
"Integer",
"list.get(j)",
"list.get",
"list",
"j",
"int b = Integer.parseInt(list.get(j - 1));",
"b",
"Integer.parseInt(list.get(j - 1))",
"Integer.parseInt",
"Integer",
"list.get(j - 1)",
"list.get",
"list",
"j - 1",
"j",
"1",
"if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }",
"a < b",
"a",
"b",
"{\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }",
"String tmp = list.get(j);",
"tmp",
"list.get(j)",
"list.get",
"list",
"j",
"list.set(j, list.get(j-1))",
"list.set",
"list",
"j",
"list.get(j-1)",
"list.get",
"list",
"j-1",
"j",
"1",
"list.set(j - 1, tmp)",
"list.set",
"list",
"j - 1",
"j",
"1",
"tmp",
"n++",
"n",
"flag = true",
"flag",
"true",
"return n;",
"n",
"List<String> list",
"list",
"//キー入力メソッド\n public static String getLine() throws IOException {\n String str = br.readLine();\n return str;\n }",
"getLine",
"{\n String str = br.readLine();\n return str;\n }",
"String str = br.readLine();",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"//キー入力メソッド\n public static List<String> getStrOnLine() throws IOException {\n List<String> list = new ArrayList<>();\n String line = getLine();\n \n list.addAll(Arrays.asList(line.split(\" \")));\n return list;\n }",
"getStrOnLine",
"{\n List<String> list = new ArrayList<>();\n String line = getLine();\n \n list.addAll(Arrays.asList(line.split(\" \")));\n return list;\n }",
"List<String> list = new ArrayList<>();",
"list",
"new ArrayList<>()",
"String line = getLine();",
"line",
"getLine()",
"getLine",
"list.addAll(Arrays.asList(line.split(\" \")))",
"list.addAll",
"list",
"Arrays.asList(line.split(\" \"))",
"Arrays.asList",
"Arrays",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"return list;",
"list",
"public class Main{\n private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n public static void main(String[] args) throws IOException{\n //キー入力\n getLine();\n List<String> strings = getStrOnLine();\n //計算\n int n = bubbleSort(strings);\n //出力\n String out = String.join(\" \",strings);\n System.out.println(out);\n System.out.println(n);\n }\n\n private static int bubbleSort(List<String> list){ \n boolean flag = true;\n int n = 0;\n while (flag){\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }\n return n;\n }\n \n\n //キー入力メソッド\n public static String getLine() throws IOException {\n String str = br.readLine();\n return str;\n }\n \n //キー入力メソッド\n public static List<String> getStrOnLine() throws IOException {\n List<String> list = new ArrayList<>();\n String line = getLine();\n \n list.addAll(Arrays.asList(line.split(\" \")));\n return list;\n }\n}",
"public class Main{\n private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n public static void main(String[] args) throws IOException{\n //キー入力\n getLine();\n List<String> strings = getStrOnLine();\n //計算\n int n = bubbleSort(strings);\n //出力\n String out = String.join(\" \",strings);\n System.out.println(out);\n System.out.println(n);\n }\n\n private static int bubbleSort(List<String> list){ \n boolean flag = true;\n int n = 0;\n while (flag){\n flag = false;\n for (int j = list.size() - 1 ; j >= 1; j--){\n int a = Integer.parseInt(list.get(j));\n int b = Integer.parseInt(list.get(j - 1));\n if (a < b){\n String tmp = list.get(j);\n list.set(j, list.get(j-1));\n list.set(j - 1, tmp);\n n++;\n flag = true;\n }\n }\n }\n return n;\n }\n \n\n //キー入力メソッド\n public static String getLine() throws IOException {\n String str = br.readLine();\n return str;\n }\n \n //キー入力メソッド\n public static List<String> getStrOnLine() throws IOException {\n List<String> list = new ArrayList<>();\n String line = getLine();\n \n list.addAll(Arrays.asList(line.split(\" \")));\n return list;\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;
public class Main{
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException{
//キー入力
getLine();
List<String> strings = getStrOnLine();
//計算
int n = bubbleSort(strings);
//出力
String out = String.join(" ",strings);
System.out.println(out);
System.out.println(n);
}
private static int bubbleSort(List<String> list){
boolean flag = true;
int n = 0;
while (flag){
flag = false;
for (int j = list.size() - 1 ; j >= 1; j--){
int a = Integer.parseInt(list.get(j));
int b = Integer.parseInt(list.get(j - 1));
if (a < b){
String tmp = list.get(j);
list.set(j, list.get(j-1));
list.set(j - 1, tmp);
n++;
flag = true;
}
}
}
return n;
}
//キー入力メソッド
public static String getLine() throws IOException {
String str = br.readLine();
return str;
}
//キー入力メソッド
public static List<String> getStrOnLine() throws IOException {
List<String> list = new ArrayList<>();
String line = getLine();
list.addAll(Arrays.asList(line.split(" ")));
return list;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
0,
13,
4,
18,
13,
41,
13,
0,
13,
20,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
0,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
157,
5
],
[
157,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
8,
16
],
[
16,
17
],
[
8,
18
],
[
18,
19
],
[
18,
20
],
[
8,
21
],
[
21,
22
],
[
21,
23
],
[
8,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
8,
29
],
[
29,
30
],
[
8,
31
],
[
31,
32
],
[
31,
33
],
[
8,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
35,
40
],
[
40,
41
],
[
40,
42
],
[
35,
43
],
[
43,
44
],
[
44,
45
],
[
35,
46
],
[
47,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
8,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
63,
70
],
[
70,
71
],
[
70,
72
],
[
63,
73
],
[
73,
74
],
[
74,
75
],
[
63,
76
],
[
77,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
88,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
88,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
103,
109
],
[
88,
110
],
[
110,
111
],
[
88,
112
],
[
112,
113
],
[
112,
114
],
[
8,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
115,
125
],
[
125,
126
],
[
126,
127
],
[
115,
128
],
[
129,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
130,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
8,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
145,
147
],
[
8,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
6,
154
],
[
154,
155
],
[
0,
156
],
[
156,
157
],
[
156,
158
]
] | [
"import java.util.Scanner;\n\npublic class Main{\n public static void main(String args[]){\n int flag=1,i,j,N,cnt=0;\n \n //scanf N\n Scanner scan = new Scanner(System.in);\n N = scan.nextInt();\n \n //making array\n int[] A;\n A = new int[N];\n \n //complete array\n for(i=0;i<N;i++){\n A[i] = scan.nextInt();\n }\n \n //bubbling \n while(flag==1){\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }\n \n for(i=0;i<N-1;i++){\n System.out.print(A[i] + \" \");\n }\n System.out.println(A[i]);\n System.out.println(cnt);\n\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n public static void main(String args[]){\n int flag=1,i,j,N,cnt=0;\n \n //scanf N\n Scanner scan = new Scanner(System.in);\n N = scan.nextInt();\n \n //making array\n int[] A;\n A = new int[N];\n \n //complete array\n for(i=0;i<N;i++){\n A[i] = scan.nextInt();\n }\n \n //bubbling \n while(flag==1){\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }\n \n for(i=0;i<N-1;i++){\n System.out.print(A[i] + \" \");\n }\n System.out.println(A[i]);\n System.out.println(cnt);\n\n }\n}",
"Main",
"public static void main(String args[]){\n int flag=1,i,j,N,cnt=0;\n \n //scanf N\n Scanner scan = new Scanner(System.in);\n N = scan.nextInt();\n \n //making array\n int[] A;\n A = new int[N];\n \n //complete array\n for(i=0;i<N;i++){\n A[i] = scan.nextInt();\n }\n \n //bubbling \n while(flag==1){\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }\n \n for(i=0;i<N-1;i++){\n System.out.print(A[i] + \" \");\n }\n System.out.println(A[i]);\n System.out.println(cnt);\n\n }",
"main",
"{\n int flag=1,i,j,N,cnt=0;\n \n //scanf N\n Scanner scan = new Scanner(System.in);\n N = scan.nextInt();\n \n //making array\n int[] A;\n A = new int[N];\n \n //complete array\n for(i=0;i<N;i++){\n A[i] = scan.nextInt();\n }\n \n //bubbling \n while(flag==1){\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }\n \n for(i=0;i<N-1;i++){\n System.out.print(A[i] + \" \");\n }\n System.out.println(A[i]);\n System.out.println(cnt);\n\n }",
"int flag=1",
"flag",
"1",
"i",
"i",
"j",
"j",
"N",
"N",
"cnt=0;",
"cnt",
"0",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"N = scan.nextInt()",
"N",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int[] A;",
"A",
"A = new int[N]",
"A",
"new int[N]",
"N",
"for(i=0;i<N;i++){\n A[i] = scan.nextInt();\n }",
"i=0;",
"i=0",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n A[i] = scan.nextInt();\n }",
"{\n A[i] = scan.nextInt();\n }",
"A[i] = scan.nextInt()",
"A[i]",
"A",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(flag==1){\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }",
"flag==1",
"flag",
"1",
"{\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }",
"flag = 0",
"flag",
"0",
"for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }",
"j=N-1;",
"j=N-1",
"j",
"N-1",
"N",
"1",
"j>0",
"j",
"0",
"j--",
"j--",
"j",
"{\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }",
"{\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }",
"if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }",
"A[j]<A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"{\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }",
"int swap = A[j];",
"swap",
"A[j]",
"A",
"j",
"A[j] = A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j-1] = swap",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"swap",
"cnt++",
"cnt",
"flag = 1",
"flag",
"1",
"for(i=0;i<N-1;i++){\n System.out.print(A[i] + \" \");\n }",
"i=0;",
"i=0",
"i",
"0",
"i<N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(A[i] + \" \");\n }",
"{\n System.out.print(A[i] + \" \");\n }",
"System.out.print(A[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i] + \" \"",
"A[i]",
"A",
"i",
"\" \"",
"System.out.println(A[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String args[]",
"args",
"public class Main{\n public static void main(String args[]){\n int flag=1,i,j,N,cnt=0;\n \n //scanf N\n Scanner scan = new Scanner(System.in);\n N = scan.nextInt();\n \n //making array\n int[] A;\n A = new int[N];\n \n //complete array\n for(i=0;i<N;i++){\n A[i] = scan.nextInt();\n }\n \n //bubbling \n while(flag==1){\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }\n \n for(i=0;i<N-1;i++){\n System.out.print(A[i] + \" \");\n }\n System.out.println(A[i]);\n System.out.println(cnt);\n\n }\n}",
"public class Main{\n public static void main(String args[]){\n int flag=1,i,j,N,cnt=0;\n \n //scanf N\n Scanner scan = new Scanner(System.in);\n N = scan.nextInt();\n \n //making array\n int[] A;\n A = new int[N];\n \n //complete array\n for(i=0;i<N;i++){\n A[i] = scan.nextInt();\n }\n \n //bubbling \n while(flag==1){\n flag = 0;\n for(j=N-1;j>0;j--){\n if(A[j]<A[j-1]){\n int swap = A[j];\n A[j] = A[j-1];\n A[j-1] = swap;\n cnt++; //count\n flag = 1; //to be continue\n }\n }\n }\n \n for(i=0;i<N-1;i++){\n System.out.print(A[i] + \" \");\n }\n System.out.println(A[i]);\n System.out.println(cnt);\n\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String args[]){
int flag=1,i,j,N,cnt=0;
//scanf N
Scanner scan = new Scanner(System.in);
N = scan.nextInt();
//making array
int[] A;
A = new int[N];
//complete array
for(i=0;i<N;i++){
A[i] = scan.nextInt();
}
//bubbling
while(flag==1){
flag = 0;
for(j=N-1;j>0;j--){
if(A[j]<A[j-1]){
int swap = A[j];
A[j] = A[j-1];
A[j-1] = swap;
cnt++; //count
flag = 1; //to be continue
}
}
}
for(i=0;i<N-1;i++){
System.out.print(A[i] + " ");
}
System.out.println(A[i]);
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
11,
1,
0,
13,
17,
2,
13,
2,
18,
13,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
13,
13,
41,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
13,
1,
40,
13,
30,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
18,
13,
13,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
188,
5
],
[
188,
6
],
[
6,
7
],
[
6,
8
],
[
188,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
11,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
14,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
14,
26
],
[
26,
27
],
[
27,
28
],
[
14,
29
],
[
30,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
11,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
41,
46
],
[
46,
47
],
[
46,
48
],
[
11,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
9,
54
],
[
54,
55
],
[
188,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
63,
68
],
[
68,
69
],
[
68,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
63,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
81,
82
],
[
58,
83
],
[
83,
84
],
[
56,
85
],
[
85,
86
],
[
188,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
89,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
89,
100
],
[
100,
101
],
[
89,
102
],
[
102,
103
],
[
102,
104
],
[
89,
105
],
[
105,
106
],
[
105,
107
],
[
89,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
108,
114
],
[
114,
115
],
[
115,
116
],
[
108,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
122,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
122,
134
],
[
134,
135
],
[
135,
136
],
[
122,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
138,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
151,
153
],
[
144,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
154,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
167,
169
],
[
164,
170
],
[
154,
171
],
[
171,
172
],
[
154,
173
],
[
173,
174
],
[
173,
175
],
[
89,
176
],
[
176,
177
],
[
176,
178
],
[
89,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
179,
184
],
[
87,
185
],
[
185,
186
],
[
0,
187
],
[
187,
188
],
[
187,
189
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n static Scanner sc = new Scanner(System.in);\n\n static void checkArray(int[] a){\n int i ;\n for( i = 0; i < a.length -1; i++){\n System.out.print(a[i] +\" \");\n }\n System.out.print(a[i]);\n System.out.println();\n }\n\n static int[] makeArray(int num){\n int[] arr = new int[num];\n for( int i = 0; i < num; i++){\n arr[i] = sc.nextInt();\n }\n return arr;\n } \n\n public static void main(String[] args) {\n int N = sc.nextInt();\n int[] arr = makeArray(N);\n \n int temp;\n int count=0;\n boolean flag = true;\n \n for(int j = 0; flag; j++ ){\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }\n checkArray(arr);\n System.out.println(count);\n }\n \n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n static Scanner sc = new Scanner(System.in);\n\n static void checkArray(int[] a){\n int i ;\n for( i = 0; i < a.length -1; i++){\n System.out.print(a[i] +\" \");\n }\n System.out.print(a[i]);\n System.out.println();\n }\n\n static int[] makeArray(int num){\n int[] arr = new int[num];\n for( int i = 0; i < num; i++){\n arr[i] = sc.nextInt();\n }\n return arr;\n } \n\n public static void main(String[] args) {\n int N = sc.nextInt();\n int[] arr = makeArray(N);\n \n int temp;\n int count=0;\n boolean flag = true;\n \n for(int j = 0; flag; j++ ){\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }\n checkArray(arr);\n System.out.println(count);\n }\n \n}",
"Main",
"static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"static void checkArray(int[] a){\n int i ;\n for( i = 0; i < a.length -1; i++){\n System.out.print(a[i] +\" \");\n }\n System.out.print(a[i]);\n System.out.println();\n }",
"checkArray",
"{\n int i ;\n for( i = 0; i < a.length -1; i++){\n System.out.print(a[i] +\" \");\n }\n System.out.print(a[i]);\n System.out.println();\n }",
"int i ;",
"i",
"for( i = 0; i < a.length -1; i++){\n System.out.print(a[i] +\" \");\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < a.length -1",
"i",
"a.length -1",
"a.length",
"a",
"a.length",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(a[i] +\" \");\n }",
"{\n System.out.print(a[i] +\" \");\n }",
"System.out.print(a[i] +\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] +\" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"int[] a",
"a",
"static int[] makeArray(int num){\n int[] arr = new int[num];\n for( int i = 0; i < num; i++){\n arr[i] = sc.nextInt();\n }\n return arr;\n }",
"makeArray",
"{\n int[] arr = new int[num];\n for( int i = 0; i < num; i++){\n arr[i] = sc.nextInt();\n }\n return arr;\n }",
"int[] arr = new int[num];",
"arr",
"new int[num]",
"num",
"for( int i = 0; i < num; i++){\n arr[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n arr[i] = sc.nextInt();\n }",
"{\n arr[i] = sc.nextInt();\n }",
"arr[i] = sc.nextInt()",
"arr[i]",
"arr",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"return arr;",
"arr",
"int num",
"num",
"public static void main(String[] args) {\n int N = sc.nextInt();\n int[] arr = makeArray(N);\n \n int temp;\n int count=0;\n boolean flag = true;\n \n for(int j = 0; flag; j++ ){\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }\n checkArray(arr);\n System.out.println(count);\n }",
"main",
"{\n int N = sc.nextInt();\n int[] arr = makeArray(N);\n \n int temp;\n int count=0;\n boolean flag = true;\n \n for(int j = 0; flag; j++ ){\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }\n checkArray(arr);\n System.out.println(count);\n }",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] arr = makeArray(N);",
"arr",
"makeArray(N)",
"makeArray",
"N",
"int temp;",
"temp",
"int count=0;",
"count",
"0",
"boolean flag = true;",
"flag",
"true",
"for(int j = 0; flag; j++ ){\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }",
"int j = 0;",
"int j = 0;",
"j",
"0",
"flag",
"j++",
"j++",
"j",
"{\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }",
"{\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }",
"flag = false",
"flag",
"false",
"for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }",
"int i = N-1;",
"int i = N-1;",
"i",
"N-1",
"N",
"1",
"i >= j+1",
"i",
"j+1",
"j",
"1",
"i--",
"i--",
"i",
"{\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }",
"{\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }",
"temp = arr[i]",
"temp",
"arr[i]",
"arr",
"i",
"if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }",
"arr[i] < arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"{\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }",
"arr[i] = arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i-1] = temp",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"temp",
"count++",
"count",
"flag = true",
"flag",
"true",
"checkArray(arr)",
"checkArray",
"arr",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n static Scanner sc = new Scanner(System.in);\n\n static void checkArray(int[] a){\n int i ;\n for( i = 0; i < a.length -1; i++){\n System.out.print(a[i] +\" \");\n }\n System.out.print(a[i]);\n System.out.println();\n }\n\n static int[] makeArray(int num){\n int[] arr = new int[num];\n for( int i = 0; i < num; i++){\n arr[i] = sc.nextInt();\n }\n return arr;\n } \n\n public static void main(String[] args) {\n int N = sc.nextInt();\n int[] arr = makeArray(N);\n \n int temp;\n int count=0;\n boolean flag = true;\n \n for(int j = 0; flag; j++ ){\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }\n checkArray(arr);\n System.out.println(count);\n }\n \n}",
"public class Main {\n\n static Scanner sc = new Scanner(System.in);\n\n static void checkArray(int[] a){\n int i ;\n for( i = 0; i < a.length -1; i++){\n System.out.print(a[i] +\" \");\n }\n System.out.print(a[i]);\n System.out.println();\n }\n\n static int[] makeArray(int num){\n int[] arr = new int[num];\n for( int i = 0; i < num; i++){\n arr[i] = sc.nextInt();\n }\n return arr;\n } \n\n public static void main(String[] args) {\n int N = sc.nextInt();\n int[] arr = makeArray(N);\n \n int temp;\n int count=0;\n boolean flag = true;\n \n for(int j = 0; flag; j++ ){\n flag = false;\n for(int i = N-1; i >= j+1 ; i--) {\n temp = arr[i];\n if(arr[i] < arr[i-1]) {\n arr[i] = arr[i-1];\n arr[i-1] = temp;\n count++;\n flag = true;\n }\n \n }\n }\n checkArray(arr);\n System.out.println(count);\n }\n \n}",
"Main"
] | import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static void checkArray(int[] a){
int i ;
for( i = 0; i < a.length -1; i++){
System.out.print(a[i] +" ");
}
System.out.print(a[i]);
System.out.println();
}
static int[] makeArray(int num){
int[] arr = new int[num];
for( int i = 0; i < num; i++){
arr[i] = sc.nextInt();
}
return arr;
}
public static void main(String[] args) {
int N = sc.nextInt();
int[] arr = makeArray(N);
int temp;
int count=0;
boolean flag = true;
for(int j = 0; flag; j++ ){
flag = false;
for(int i = N-1; i >= j+1 ; i--) {
temp = arr[i];
if(arr[i] < arr[i-1]) {
arr[i] = arr[i-1];
arr[i-1] = temp;
count++;
flag = true;
}
}
}
checkArray(arr);
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
0,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
165,
5
],
[
165,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
8,
16
],
[
16,
17
],
[
16,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
8,
24
],
[
24,
25
],
[
24,
26
],
[
8,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
40,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
8,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
48,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
55,
57
],
[
48,
58
],
[
58,
59
],
[
59,
60
],
[
48,
61
],
[
62,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
63,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
70,
72
],
[
63,
73
],
[
73,
74
],
[
74,
75
],
[
63,
76
],
[
77,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
88,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
98,
104
],
[
104,
105
],
[
104,
106
],
[
88,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
88,
116
],
[
116,
117
],
[
8,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
118,
123
],
[
123,
124
],
[
123,
125
],
[
118,
126
],
[
126,
127
],
[
127,
128
],
[
118,
129
],
[
130,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
136,
137
],
[
136,
138
],
[
130,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
139,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
8,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
8,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
6,
162
],
[
162,
163
],
[
0,
164
],
[
164,
165
],
[
164,
166
]
] | [
"import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n,p,q=0;\n n=scan.nextInt();\n int[] sort=new int[n];\n for(int i=0; i<n; i++){\n sort[i]=scan.nextInt();\n }\n \n for(int i=0; i<n-1; i++){\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }\n //System.out.println(Arrays.toString(sort));\n for(int i=0; i<n; i++){\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }\n System.out.println();\n System.out.println(q);\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n,p,q=0;\n n=scan.nextInt();\n int[] sort=new int[n];\n for(int i=0; i<n; i++){\n sort[i]=scan.nextInt();\n }\n \n for(int i=0; i<n-1; i++){\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }\n //System.out.println(Arrays.toString(sort));\n for(int i=0; i<n; i++){\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }\n System.out.println();\n System.out.println(q);\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n,p,q=0;\n n=scan.nextInt();\n int[] sort=new int[n];\n for(int i=0; i<n; i++){\n sort[i]=scan.nextInt();\n }\n \n for(int i=0; i<n-1; i++){\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }\n //System.out.println(Arrays.toString(sort));\n for(int i=0; i<n; i++){\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }\n System.out.println();\n System.out.println(q);\n }",
"main",
"{\n Scanner scan=new Scanner(System.in);\n int n,p,q=0;\n n=scan.nextInt();\n int[] sort=new int[n];\n for(int i=0; i<n; i++){\n sort[i]=scan.nextInt();\n }\n \n for(int i=0; i<n-1; i++){\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }\n //System.out.println(Arrays.toString(sort));\n for(int i=0; i<n; i++){\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }\n System.out.println();\n System.out.println(q);\n }",
"Scanner scan=new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n",
"n",
"p",
"p",
"q=0;",
"q",
"0",
"n=scan.nextInt()",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int[] sort=new int[n];",
"sort",
"new int[n]",
"n",
"for(int i=0; i<n; i++){\n sort[i]=scan.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n sort[i]=scan.nextInt();\n }",
"{\n sort[i]=scan.nextInt();\n }",
"sort[i]=scan.nextInt()",
"sort[i]",
"sort",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for(int i=0; i<n-1; i++){\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }",
"{\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }",
"for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }",
"int j=0;",
"int j=0;",
"j",
"0",
"j<n-1",
"j",
"n-1",
"n",
"1",
"j++",
"j++",
"j",
"{\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }",
"{\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }",
"if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }",
"sort[j]>sort[j+1]",
"sort[j]",
"sort",
"j",
"sort[j+1]",
"sort",
"j+1",
"j",
"1",
"{\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }",
"sort[j]^=sort[j+1]",
"sort[j]",
"sort",
"j",
"sort[j+1]",
"sort",
"j+1",
"j",
"1",
"sort[j+1]^=sort[j]",
"sort[j+1]",
"sort",
"j+1",
"j",
"1",
"sort[j]",
"sort",
"j",
"sort[j]^=sort[j+1]",
"sort[j]",
"sort",
"j",
"sort[j+1]",
"sort",
"j+1",
"j",
"1",
"q++",
"q",
"for(int i=0; i<n; i++){\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }",
"{\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }",
"System.out.print(sort[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"sort[i]",
"sort",
"i",
"if(i!=n-1)\n System.out.print(\" \");",
"i!=n-1",
"i",
"n-1",
"n",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(q)",
"System.out.println",
"System.out",
"System",
"System.out",
"q",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n,p,q=0;\n n=scan.nextInt();\n int[] sort=new int[n];\n for(int i=0; i<n; i++){\n sort[i]=scan.nextInt();\n }\n \n for(int i=0; i<n-1; i++){\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }\n //System.out.println(Arrays.toString(sort));\n for(int i=0; i<n; i++){\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }\n System.out.println();\n System.out.println(q);\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n,p,q=0;\n n=scan.nextInt();\n int[] sort=new int[n];\n for(int i=0; i<n; i++){\n sort[i]=scan.nextInt();\n }\n \n for(int i=0; i<n-1; i++){\n for(int j=0; j<n-1; j++){\n if(sort[j]>sort[j+1]){\n sort[j]^=sort[j+1];\n sort[j+1]^=sort[j];\n sort[j]^=sort[j+1];\n q++;\n }\n }\n }\n //System.out.println(Arrays.toString(sort));\n for(int i=0; i<n; i++){\n System.out.print(sort[i]);\n if(i!=n-1)\n System.out.print(\" \");\n }\n System.out.println();\n System.out.println(q);\n }\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int n,p,q=0;
n=scan.nextInt();
int[] sort=new int[n];
for(int i=0; i<n; i++){
sort[i]=scan.nextInt();
}
for(int i=0; i<n-1; i++){
for(int j=0; j<n-1; j++){
if(sort[j]>sort[j+1]){
sort[j]^=sort[j+1];
sort[j+1]^=sort[j];
sort[j]^=sort[j+1];
q++;
}
}
}
//System.out.println(Arrays.toString(sort));
for(int i=0; i<n; i++){
System.out.print(sort[i]);
if(i!=n-1)
System.out.print(" ");
}
System.out.println();
System.out.println(q);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
156,
5
],
[
156,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
8,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
36,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
8,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
56,
63
],
[
63,
64
],
[
63,
65
],
[
56,
66
],
[
66,
67
],
[
67,
68
],
[
56,
69
],
[
70,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
71,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
81,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
96,
102
],
[
81,
103
],
[
103,
104
],
[
81,
105
],
[
105,
106
],
[
105,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
117,
118
],
[
108,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
126,
127
],
[
126,
128
],
[
120,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
8,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
6,
153
],
[
153,
154
],
[
0,
155
],
[
155,
156
],
[
155,
157
]
] | [
"import java.util.*;\n\n/**\n * A\n */\n\n// bubble sort\n\npublic class Main {\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int count=0;\n int array[] = new int[n];\n\n for(int i=0; i<n; i++) {\n array[i] = sc.nextInt();\n }\n\n sc.close();\n\n /**\n * 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A\n * 2 flag = 1 // 逆の隣接要素が存在する\n * 3 while flag\n * 4 flag = 0\n * 5 for j が N-1 から 1 まで\n * 6 if A[j] < A[j-1]\n * 7 A[j] と A[j-1] を交換\n * 8 flag = 1\n */\n\n boolean flag = true;\n\n while(flag) {\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }\n\n for(int i=0; i<n; i++) {\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }\n\n System.out.println();\n System.out.println(count);\n \n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int count=0;\n int array[] = new int[n];\n\n for(int i=0; i<n; i++) {\n array[i] = sc.nextInt();\n }\n\n sc.close();\n\n /**\n * 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A\n * 2 flag = 1 // 逆の隣接要素が存在する\n * 3 while flag\n * 4 flag = 0\n * 5 for j が N-1 から 1 まで\n * 6 if A[j] < A[j-1]\n * 7 A[j] と A[j-1] を交換\n * 8 flag = 1\n */\n\n boolean flag = true;\n\n while(flag) {\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }\n\n for(int i=0; i<n; i++) {\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }\n\n System.out.println();\n System.out.println(count);\n \n }\n}",
"Main",
"public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int count=0;\n int array[] = new int[n];\n\n for(int i=0; i<n; i++) {\n array[i] = sc.nextInt();\n }\n\n sc.close();\n\n /**\n * 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A\n * 2 flag = 1 // 逆の隣接要素が存在する\n * 3 while flag\n * 4 flag = 0\n * 5 for j が N-1 から 1 まで\n * 6 if A[j] < A[j-1]\n * 7 A[j] と A[j-1] を交換\n * 8 flag = 1\n */\n\n boolean flag = true;\n\n while(flag) {\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }\n\n for(int i=0; i<n; i++) {\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }\n\n System.out.println();\n System.out.println(count);\n \n }",
"main",
"{\n \n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int count=0;\n int array[] = new int[n];\n\n for(int i=0; i<n; i++) {\n array[i] = sc.nextInt();\n }\n\n sc.close();\n\n /**\n * 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A\n * 2 flag = 1 // 逆の隣接要素が存在する\n * 3 while flag\n * 4 flag = 0\n * 5 for j が N-1 から 1 まで\n * 6 if A[j] < A[j-1]\n * 7 A[j] と A[j-1] を交換\n * 8 flag = 1\n */\n\n boolean flag = true;\n\n while(flag) {\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }\n\n for(int i=0; i<n; i++) {\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }\n\n System.out.println();\n System.out.println(count);\n \n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count=0;",
"count",
"0",
"int array[] = new int[n];",
"array",
"new int[n]",
"n",
"for(int i=0; i<n; i++) {\n array[i] = sc.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n array[i] = sc.nextInt();\n }",
"{\n array[i] = sc.nextInt();\n }",
"array[i] = sc.nextInt()",
"array[i]",
"array",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.close()",
"sc.close",
"sc",
"boolean flag = true;",
"flag",
"true",
"while(flag) {\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }",
"flag",
"{\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }",
"flag = false",
"flag",
"false",
"for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }",
"int j=n-1;",
"int j=n-1;",
"j",
"n-1",
"n",
"1",
"j>=1",
"j",
"1",
"j--",
"j--",
"j",
"{\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }",
"{\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }",
"if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }",
"array[j] < array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"{\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }",
"int tmp = array[j];",
"tmp",
"array[j]",
"array",
"j",
"array[j] = array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1] = tmp",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"tmp",
"count++",
"count",
"flag = true",
"flag",
"true",
"for(int i=0; i<n; i++) {\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }",
"{\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }",
"System.out.print(array[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"array[i]",
"array",
"i",
"if(i != n-1) {\n System.out.print(\" \");\n }",
"i != n-1",
"i",
"n-1",
"n",
"1",
"{\n System.out.print(\" \");\n }",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int count=0;\n int array[] = new int[n];\n\n for(int i=0; i<n; i++) {\n array[i] = sc.nextInt();\n }\n\n sc.close();\n\n /**\n * 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A\n * 2 flag = 1 // 逆の隣接要素が存在する\n * 3 while flag\n * 4 flag = 0\n * 5 for j が N-1 から 1 まで\n * 6 if A[j] < A[j-1]\n * 7 A[j] と A[j-1] を交換\n * 8 flag = 1\n */\n\n boolean flag = true;\n\n while(flag) {\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }\n\n for(int i=0; i<n; i++) {\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }\n\n System.out.println();\n System.out.println(count);\n \n }\n}",
"public class Main {\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int count=0;\n int array[] = new int[n];\n\n for(int i=0; i<n; i++) {\n array[i] = sc.nextInt();\n }\n\n sc.close();\n\n /**\n * 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A\n * 2 flag = 1 // 逆の隣接要素が存在する\n * 3 while flag\n * 4 flag = 0\n * 5 for j が N-1 から 1 まで\n * 6 if A[j] < A[j-1]\n * 7 A[j] と A[j-1] を交換\n * 8 flag = 1\n */\n\n boolean flag = true;\n\n while(flag) {\n\n flag = false;\n \n for(int j=n-1; j>=1; j--) {\n\n if(array[j] < array[j-1]) {\n\n int tmp = array[j];\n array[j] = array[j-1];\n array[j-1] = tmp;\n\n count++;\n flag = true;\n \n }\n\n }\n\n }\n\n for(int i=0; i<n; i++) {\n \n System.out.print(array[i]);\n\n if(i != n-1) {\n System.out.print(\" \");\n }\n\n }\n\n System.out.println();\n System.out.println(count);\n \n }\n}",
"Main"
] | import java.util.*;
/**
* A
*/
// bubble sort
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int count=0;
int array[] = new int[n];
for(int i=0; i<n; i++) {
array[i] = sc.nextInt();
}
sc.close();
/**
* 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
* 2 flag = 1 // 逆の隣接要素が存在する
* 3 while flag
* 4 flag = 0
* 5 for j が N-1 から 1 まで
* 6 if A[j] < A[j-1]
* 7 A[j] と A[j-1] を交換
* 8 flag = 1
*/
boolean flag = true;
while(flag) {
flag = false;
for(int j=n-1; j>=1; j--) {
if(array[j] < array[j-1]) {
int tmp = array[j];
array[j] = array[j-1];
array[j-1] = tmp;
count++;
flag = true;
}
}
}
for(int i=0; i<n; i++) {
System.out.print(array[i]);
if(i != n-1) {
System.out.print(" ");
}
}
System.out.println();
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
17,
0,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
26,
31
],
[
31,
32
],
[
31,
33
],
[
26,
34
],
[
34,
35
],
[
35,
36
],
[
26,
37
],
[
38,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
44,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
46,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
61,
68
],
[
68,
69
],
[
68,
70
],
[
61,
71
],
[
71,
72
],
[
72,
73
],
[
61,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
76,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
86,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
101,
107
],
[
86,
108
],
[
108,
109
],
[
8,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
110,
115
],
[
115,
116
],
[
115,
117
],
[
110,
118
],
[
118,
119
],
[
119,
120
],
[
110,
121
],
[
122,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
122,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
138,
139
],
[
138,
140
],
[
8,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
6,
153
],
[
153,
154
]
] | [
"import java.util.Scanner;\n\nclass Main{\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n ;\n\t\tint count = 0;\n\t\tn = in.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i<n;i++){\n\t\t\ta[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int i=0;i<n-1;i++){\n\t\t\tfor(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tif(i>0)System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n ;\n\t\tint count = 0;\n\t\tn = in.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i<n;i++){\n\t\t\ta[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int i=0;i<n-1;i++){\n\t\t\tfor(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tif(i>0)System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n ;\n\t\tint count = 0;\n\t\tn = in.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i<n;i++){\n\t\t\ta[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int i=0;i<n-1;i++){\n\t\t\tfor(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tif(i>0)System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(System.in);\n\t\tint n ;\n\t\tint count = 0;\n\t\tn = in.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i<n;i++){\n\t\t\ta[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int i=0;i<n-1;i++){\n\t\t\tfor(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tif(i>0)System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int n ;",
"n",
"int count = 0;",
"count",
"0",
"n = in.nextInt()",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for(int i = 0;i<n;i++){\n\t\t\ta[i] = in.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = in.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = in.nextInt();\n\t\t}",
"a[i] = in.nextInt()",
"a[i]",
"a",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"for(int i=0;i<n-1;i++){\n\t\t\tfor(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"{\n\t\t\tfor(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"for(int j = n-1;j>i;j--){\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j>i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if(a[j] <a[j-1]){\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"a[j] <a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tint temp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"int temp = a[j];",
"temp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = temp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"temp",
"count++",
"count",
"for(int i = 0;i<n;i++){\n\t\t\tif(i>0)System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif(i>0)System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}",
"{\n\t\t\tif(i>0)System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}",
"if(i>0)System.out.print(\" \");",
"i>0",
"i",
"0",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.println(\"\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n ;
int count = 0;
n = in.nextInt();
int[] a = new int[n];
for(int i = 0;i<n;i++){
a[i] = in.nextInt();
}
for(int i=0;i<n-1;i++){
for(int j = n-1;j>i;j--){
if(a[j] <a[j-1]){
int temp = a[j];
a[j] = a[j-1];
a[j-1] = temp;
count++;
}
}
}
for(int i = 0;i<n;i++){
if(i>0)System.out.print(" ");
System.out.print(a[i]);
}
System.out.println("");
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
17,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
157,
5
],
[
157,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
8,
21
],
[
21,
22
],
[
21,
23
],
[
8,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
50,
52
],
[
43,
53
],
[
53,
54
],
[
54,
55
],
[
43,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
58,
65
],
[
65,
66
],
[
65,
67
],
[
58,
68
],
[
68,
69
],
[
69,
70
],
[
58,
71
],
[
72,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
74,
80
],
[
80,
81
],
[
80,
82
],
[
73,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
83,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
91,
97
],
[
97,
98
],
[
97,
99
],
[
83,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
83,
105
],
[
105,
106
],
[
8,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
112,
113
],
[
112,
114
],
[
107,
115
],
[
115,
116
],
[
116,
117
],
[
107,
118
],
[
119,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
124,
129
],
[
124,
130
],
[
130,
131
],
[
130,
132
],
[
120,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
133,
139
],
[
139,
140
],
[
139,
141
],
[
8,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
142,
147
],
[
8,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
6,
154
],
[
154,
155
],
[
0,
156
],
[
156,
157
],
[
156,
158
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N[] = new int[100];\n int n = sc.nextInt();\n int m = 0;\n for (int i = 0; i < n; i++) N[i] = sc.nextInt();\n for (int i = 0; i < (n - 1); i++) {\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }\n for (int i = 0; i < n; i++) {\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }\n System.out.printf(\"\\n\");\n System.out.println(m);\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N[] = new int[100];\n int n = sc.nextInt();\n int m = 0;\n for (int i = 0; i < n; i++) N[i] = sc.nextInt();\n for (int i = 0; i < (n - 1); i++) {\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }\n for (int i = 0; i < n; i++) {\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }\n System.out.printf(\"\\n\");\n System.out.println(m);\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N[] = new int[100];\n int n = sc.nextInt();\n int m = 0;\n for (int i = 0; i < n; i++) N[i] = sc.nextInt();\n for (int i = 0; i < (n - 1); i++) {\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }\n for (int i = 0; i < n; i++) {\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }\n System.out.printf(\"\\n\");\n System.out.println(m);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N[] = new int[100];\n int n = sc.nextInt();\n int m = 0;\n for (int i = 0; i < n; i++) N[i] = sc.nextInt();\n for (int i = 0; i < (n - 1); i++) {\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }\n for (int i = 0; i < n; i++) {\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }\n System.out.printf(\"\\n\");\n System.out.println(m);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N[] = new int[100];",
"N",
"new int[100]",
"100",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int m = 0;",
"m",
"0",
"for (int i = 0; i < n; i++) N[i] = sc.nextInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"N[i] = sc.nextInt();",
"N[i] = sc.nextInt()",
"N[i]",
"N",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < (n - 1); i++) {\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < (n - 1)",
"i",
"(n - 1)",
"n",
"1",
"i++",
"i++",
"i",
"{\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }",
"{\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }",
"for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }",
"int j = (n - 1);",
"int j = (n - 1);",
"j",
"(n - 1)",
"n",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }",
"{\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }",
"if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }",
"N[j-1] > N[j]",
"N[j-1]",
"N",
"j-1",
"j",
"1",
"N[j]",
"N",
"j",
"{\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }",
"int t = N[j-1];",
"t",
"N[j-1]",
"N",
"j-1",
"j",
"1",
"N[j-1] = N[j]",
"N[j-1]",
"N",
"j-1",
"j",
"1",
"N[j]",
"N",
"j",
"N[j] = t",
"N[j]",
"N",
"j",
"t",
"m++",
"m",
"for (int i = 0; i < n; i++) {\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }",
"{\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }",
"if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);",
"i == 0",
"i",
"0",
"System.out.printf(\"%d\", N[i])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d\"",
"N[i]",
"N",
"i",
"System.out.printf(\" %d\", N[i])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\" %d\"",
"N[i]",
"N",
"i",
"System.out.printf(\"\\n\")",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"\\n\"",
"System.out.println(m)",
"System.out.println",
"System.out",
"System",
"System.out",
"m",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N[] = new int[100];\n int n = sc.nextInt();\n int m = 0;\n for (int i = 0; i < n; i++) N[i] = sc.nextInt();\n for (int i = 0; i < (n - 1); i++) {\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }\n for (int i = 0; i < n; i++) {\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }\n System.out.printf(\"\\n\");\n System.out.println(m);\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N[] = new int[100];\n int n = sc.nextInt();\n int m = 0;\n for (int i = 0; i < n; i++) N[i] = sc.nextInt();\n for (int i = 0; i < (n - 1); i++) {\n for (int j = (n - 1); j > i; j--) {\n if (N[j-1] > N[j]) {\n int t = N[j-1];\n N[j-1] = N[j];\n N[j] = t;\n m++;\n }\n }\n }\n for (int i = 0; i < n; i++) {\n if (i == 0) System.out.printf(\"%d\", N[i]);\n else System.out.printf(\" %d\", N[i]);\n }\n System.out.printf(\"\\n\");\n System.out.println(m);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N[] = new int[100];
int n = sc.nextInt();
int m = 0;
for (int i = 0; i < n; i++) N[i] = sc.nextInt();
for (int i = 0; i < (n - 1); i++) {
for (int j = (n - 1); j > i; j--) {
if (N[j-1] > N[j]) {
int t = N[j-1];
N[j-1] = N[j];
N[j] = t;
m++;
}
}
}
for (int i = 0; i < n; i++) {
if (i == 0) System.out.printf("%d", N[i]);
else System.out.printf(" %d", N[i]);
}
System.out.printf("\n");
System.out.println(m);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
2,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
0,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
3,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
176,
5
],
[
176,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
8,
13
],
[
13,
14
],
[
8,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
8,
21
],
[
21,
22
],
[
21,
23
],
[
8,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
26,
29
],
[
29,
30
],
[
30,
31
],
[
8,
32
],
[
32,
33
],
[
32,
34
],
[
35,
36
],
[
35,
37
],
[
8,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
59,
60
],
[
8,
61
],
[
61,
62
],
[
61,
63
],
[
8,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
69,
70
],
[
69,
71
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
77,
84
],
[
84,
85
],
[
84,
86
],
[
77,
87
],
[
87,
88
],
[
88,
89
],
[
77,
90
],
[
91,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
92,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
102,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
117,
123
],
[
102,
124
],
[
124,
125
],
[
8,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
131,
132
],
[
131,
133
],
[
126,
134
],
[
134,
135
],
[
135,
136
],
[
126,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
139,
144
],
[
144,
145
],
[
144,
146
],
[
138,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
150,
152
],
[
147,
153
],
[
153,
154
],
[
138,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
8,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
161,
166
],
[
8,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
167,
172
],
[
6,
173
],
[
173,
174
],
[
0,
175
],
[
175,
176
],
[
175,
177
]
] | [
"import java.util.Scanner;\n\npublic class Main{\n\n\tpublic static void main(String args[]){\n\t\tint i,j,k,n,c,count;\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=Integer.parseInt(sc.next());\n\t\tint a[]=new int[n+1];\n\t\tfor(i=0;i<n;i++){\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}\n\t\t\n\t\tcount=0;\n\tfor(i=0;i<n;i++){\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\t\tfor(i=0;i<n;i++){\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\n\tpublic static void main(String args[]){\n\t\tint i,j,k,n,c,count;\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=Integer.parseInt(sc.next());\n\t\tint a[]=new int[n+1];\n\t\tfor(i=0;i<n;i++){\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}\n\t\t\n\t\tcount=0;\n\tfor(i=0;i<n;i++){\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\t\tfor(i=0;i<n;i++){\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String args[]){\n\t\tint i,j,k,n,c,count;\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=Integer.parseInt(sc.next());\n\t\tint a[]=new int[n+1];\n\t\tfor(i=0;i<n;i++){\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}\n\t\t\n\t\tcount=0;\n\tfor(i=0;i<n;i++){\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\t\tfor(i=0;i<n;i++){\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tint i,j,k,n,c,count;\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=Integer.parseInt(sc.next());\n\t\tint a[]=new int[n+1];\n\t\tfor(i=0;i<n;i++){\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}\n\t\t\n\t\tcount=0;\n\tfor(i=0;i<n;i++){\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\t\tfor(i=0;i<n;i++){\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}",
"int i",
"i",
"j",
"j",
"k",
"k",
"n",
"n",
"c",
"c",
"count;",
"count",
"Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"n=Integer.parseInt(sc.next())",
"n",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"int a[]=new int[n+1];",
"a",
"new int[n+1]",
"n+1",
"n",
"1",
"for(i=0;i<n;i++){\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}",
"{\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}",
"a[i]=Integer.parseInt(sc.next())",
"a[i]",
"a",
"i",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"count=0",
"count",
"0",
"for(i=0;i<n;i++){\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}",
"{\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}",
"for(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}",
"j=n-1;",
"j=n-1",
"j",
"n-1",
"n",
"1",
"j>0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}",
"if(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}",
"a[j]<a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}",
"c=a[j]",
"c",
"a[j]",
"a",
"j",
"a[j]=a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1]=c",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"c",
"count++",
"count",
"for(i=0;i<n;i++){\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"if(i==n-1){break;}",
"i==n-1",
"i",
"n-1",
"n",
"1",
"{break;}",
"break;",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(\"\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String args[]",
"args",
"public class Main{\n\n\tpublic static void main(String args[]){\n\t\tint i,j,k,n,c,count;\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=Integer.parseInt(sc.next());\n\t\tint a[]=new int[n+1];\n\t\tfor(i=0;i<n;i++){\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}\n\t\t\n\t\tcount=0;\n\tfor(i=0;i<n;i++){\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\t\tfor(i=0;i<n;i++){\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main{\n\n\tpublic static void main(String args[]){\n\t\tint i,j,k,n,c,count;\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=Integer.parseInt(sc.next());\n\t\tint a[]=new int[n+1];\n\t\tfor(i=0;i<n;i++){\n\t\t\ta[i]=Integer.parseInt(sc.next());\n\t\t}\n\t\t\n\t\tcount=0;\n\tfor(i=0;i<n;i++){\n\t\t\n\t\tfor(j=n-1;j>0;j--){\n\t\t\tif(a[j]<a[j-1]){\n\t\t\tc=a[j];\n\t\t\ta[j]=a[j-1];\n\t\t\ta[j-1]=c;\n\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\t\tfor(i=0;i<n;i++){\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif(i==n-1){break;}\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String args[]){
int i,j,k,n,c,count;
Scanner sc=new Scanner(System.in);
n=Integer.parseInt(sc.next());
int a[]=new int[n+1];
for(i=0;i<n;i++){
a[i]=Integer.parseInt(sc.next());
}
count=0;
for(i=0;i<n;i++){
for(j=n-1;j>0;j--){
if(a[j]<a[j-1]){
c=a[j];
a[j]=a[j-1];
a[j-1]=c;
count++;
}
}
}
for(i=0;i<n;i++){
System.out.print(a[i]);
if(i==n-1){break;}
System.out.print(" ");
}
System.out.println("");
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
146,
5
],
[
146,
6
],
[
6,
7
],
[
6,
8
],
[
146,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
17,
19
],
[
11,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
37,
38
],
[
38,
39
],
[
11,
40
],
[
40,
41
],
[
40,
42
],
[
11,
43
],
[
43,
44
],
[
43,
45
],
[
11,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
56,
58
],
[
52,
59
],
[
59,
60
],
[
59,
61
],
[
52,
62
],
[
62,
63
],
[
63,
64
],
[
52,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
67,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
83,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
77,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
92,
98
],
[
77,
99
],
[
99,
100
],
[
77,
101
],
[
101,
102
],
[
101,
103
],
[
11,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
104,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
104,
114
],
[
114,
115
],
[
115,
116
],
[
104,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
118,
123
],
[
118,
124
],
[
124,
125
],
[
124,
126
],
[
11,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
11,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
9,
143
],
[
143,
144
],
[
0,
145
],
[
145,
146
],
[
145,
147
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n int n=sc.nextInt();\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=sc.nextInt();\n boolean flag=true;\n int counter=0;\n while(flag){\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }\n for(int i=0;i<=n-2;i++) System.out.printf(\"%d \",a[i]);\n System.out.println(a[n-1]);\n System.out.println(counter);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n int n=sc.nextInt();\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=sc.nextInt();\n boolean flag=true;\n int counter=0;\n while(flag){\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }\n for(int i=0;i<=n-2;i++) System.out.printf(\"%d \",a[i]);\n System.out.println(a[n-1]);\n System.out.println(counter);\n }\n}",
"Main",
"private static Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args){\n int n=sc.nextInt();\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=sc.nextInt();\n boolean flag=true;\n int counter=0;\n while(flag){\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }\n for(int i=0;i<=n-2;i++) System.out.printf(\"%d \",a[i]);\n System.out.println(a[n-1]);\n System.out.println(counter);\n }",
"main",
"{\n int n=sc.nextInt();\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=sc.nextInt();\n boolean flag=true;\n int counter=0;\n while(flag){\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }\n for(int i=0;i<=n-2;i++) System.out.printf(\"%d \",a[i]);\n System.out.println(a[n-1]);\n System.out.println(counter);\n }",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a=new int[n];",
"a",
"new int[n]",
"n",
"for(int i=0;i<n;i++) a[i]=sc.nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=sc.nextInt();",
"a[i]=sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"boolean flag=true;",
"flag",
"true",
"int counter=0;",
"counter",
"0",
"while(flag){\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }",
"flag",
"{\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }",
"flag=false",
"flag",
"false",
"for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n }",
"int j=n-1;",
"int j=n-1;",
"j",
"n-1",
"n",
"1",
"j>=1",
"j",
"1",
"j--",
"j--",
"j",
"{\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n }",
"{\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n }",
"if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }",
"a[j]<a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }",
"int t=a[j];",
"t",
"a[j]",
"a",
"j",
"a[j]=a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1]=t",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"t",
"counter++",
"counter",
"flag=true",
"flag",
"true",
"for(int i=0;i<=n-2;i++) System.out.printf(\"%d \",a[i]);",
"int i=0;",
"int i=0;",
"i",
"0",
"i<=n-2",
"i",
"n-2",
"n",
"2",
"i++",
"i++",
"i",
"System.out.printf(\"%d \",a[i]);",
"System.out.printf(\"%d \",a[i])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d \"",
"a[i]",
"a",
"i",
"System.out.println(a[n-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[n-1]",
"a",
"n-1",
"n",
"1",
"System.out.println(counter)",
"System.out.println",
"System.out",
"System",
"System.out",
"counter",
"String[] args",
"args",
"public class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n int n=sc.nextInt();\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=sc.nextInt();\n boolean flag=true;\n int counter=0;\n while(flag){\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }\n for(int i=0;i<=n-2;i++) System.out.printf(\"%d \",a[i]);\n System.out.println(a[n-1]);\n System.out.println(counter);\n }\n}",
"public class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n int n=sc.nextInt();\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=sc.nextInt();\n boolean flag=true;\n int counter=0;\n while(flag){\n flag=false;\n for(int j=n-1;j>=1;j--){\n if(a[j]<a[j-1]){\n int t=a[j];\n a[j]=a[j-1];\n a[j-1]=t;\n counter++;\n flag=true;\n }\n } \n }\n for(int i=0;i<=n-2;i++) System.out.printf(\"%d \",a[i]);\n System.out.println(a[n-1]);\n System.out.println(counter);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
private static Scanner sc=new Scanner(System.in);
public static void main(String[] args){
int n=sc.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=sc.nextInt();
boolean flag=true;
int counter=0;
while(flag){
flag=false;
for(int j=n-1;j>=1;j--){
if(a[j]<a[j-1]){
int t=a[j];
a[j]=a[j-1];
a[j-1]=t;
counter++;
flag=true;
}
}
}
for(int i=0;i<=n-2;i++) System.out.printf("%d ",a[i]);
System.out.println(a[n-1]);
System.out.println(counter);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
0,
13,
17,
4,
18,
18,
13,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
168,
5
],
[
168,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
21,
31
],
[
31,
32
],
[
32,
33
],
[
21,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
6,
46
],
[
46,
47
],
[
168,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
54,
56
],
[
50,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
63,
72
],
[
72,
73
],
[
72,
74
],
[
63,
75
],
[
75,
76
],
[
76,
77
],
[
63,
78
],
[
79,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
80,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
90,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
105,
111
],
[
90,
112
],
[
112,
113
],
[
90,
114
],
[
114,
115
],
[
114,
116
],
[
50,
117
],
[
117,
118
],
[
117,
119
],
[
50,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
120,
130
],
[
130,
131
],
[
131,
132
],
[
120,
133
],
[
134,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
137,
139
],
[
134,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
145,
146
],
[
145,
147
],
[
140,
148
],
[
148,
149
],
[
148,
150
],
[
50,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
156,
157
],
[
156,
158
],
[
50,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
159,
164
],
[
48,
165
],
[
165,
166
],
[
0,
167
],
[
167,
168
],
[
167,
169
]
] | [
"import java.util.Scanner;\n\n\npublic class Main{\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = s.nextInt();\n\t\tint[] values = new int[a];\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tvalues[i] = s.nextInt();\n\t\t}\n\t\tsolve(values);\n\t}\n\n\tpublic static void solve(int[] values) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString disp = \"\";\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}\n\t\tSystem.out.print(disp+\"\\n\");\n\t\tSystem.out.println(cnt);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = s.nextInt();\n\t\tint[] values = new int[a];\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tvalues[i] = s.nextInt();\n\t\t}\n\t\tsolve(values);\n\t}\n\n\tpublic static void solve(int[] values) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString disp = \"\";\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}\n\t\tSystem.out.print(disp+\"\\n\");\n\t\tSystem.out.println(cnt);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = s.nextInt();\n\t\tint[] values = new int[a];\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tvalues[i] = s.nextInt();\n\t\t}\n\t\tsolve(values);\n\t}",
"main",
"{\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = s.nextInt();\n\t\tint[] values = new int[a];\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tvalues[i] = s.nextInt();\n\t\t}\n\t\tsolve(values);\n\t}",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int a = s.nextInt();",
"a",
"s.nextInt()",
"s.nextInt",
"s",
"int[] values = new int[a];",
"values",
"new int[a]",
"a",
"for(int i=0 ; i<values.length ; i++) {\n\t\t\tvalues[i] = s.nextInt();\n\t\t}",
"int i=0 ;",
"int i=0 ;",
"i",
"0",
"i<values.length",
"i",
"values.length",
"values",
"values.length",
"i++",
"i++",
"i",
"{\n\t\t\tvalues[i] = s.nextInt();\n\t\t}",
"{\n\t\t\tvalues[i] = s.nextInt();\n\t\t}",
"values[i] = s.nextInt()",
"values[i]",
"values",
"i",
"s.nextInt()",
"s.nextInt",
"s",
"solve(values)",
"solve",
"values",
"String[] args",
"args",
"public static void solve(int[] values) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString disp = \"\";\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}\n\t\tSystem.out.print(disp+\"\\n\");\n\t\tSystem.out.println(cnt);\n\t}",
"solve",
"{\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString disp = \"\";\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}\n\t\tSystem.out.print(disp+\"\\n\");\n\t\tSystem.out.println(cnt);\n\t}",
"boolean flg = true;",
"flg",
"true",
"int cnt = 0;",
"cnt",
"0",
"while(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg",
"{\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg = false",
"flg",
"false",
"for(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}",
"int i = values.length - 1 ;",
"int i = values.length - 1 ;",
"i",
"values.length - 1",
"values.length",
"values",
"values.length",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}",
"if(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}",
"values[i] < values[i-1]",
"values[i]",
"values",
"i",
"values[i-1]",
"values",
"i-1",
"i",
"1",
"{\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}",
"int tmp = values[i];",
"tmp",
"values[i]",
"values",
"i",
"values[i] = values[i-1]",
"values[i]",
"values",
"i",
"values[i-1]",
"values",
"i-1",
"i",
"1",
"values[i-1] = tmp",
"values[i-1]",
"values",
"i-1",
"i",
"1",
"tmp",
"cnt++",
"cnt",
"flg = true",
"flg",
"true",
"String disp = \"\";",
"disp",
"\"\"",
"for(int i=0 ; i<values.length ; i++) {\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}",
"int i=0 ;",
"int i=0 ;",
"i",
"0",
"i<values.length",
"i",
"values.length",
"values",
"values.length",
"i++",
"i++",
"i",
"{\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}",
"{\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}",
"disp += values[i]",
"disp",
"values[i]",
"values",
"i",
"if(i+1<values.length)\n\t\t\t\tdisp += \" \";",
"i+1<values.length",
"i+1",
"i",
"1",
"values.length",
"values",
"values.length",
"disp += \" \"",
"disp",
"\" \"",
"System.out.print(disp+\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"disp+\"\\n\"",
"disp",
"\"\\n\"",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"int[] values",
"values",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = s.nextInt();\n\t\tint[] values = new int[a];\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tvalues[i] = s.nextInt();\n\t\t}\n\t\tsolve(values);\n\t}\n\n\tpublic static void solve(int[] values) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString disp = \"\";\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}\n\t\tSystem.out.print(disp+\"\\n\");\n\t\tSystem.out.println(cnt);\n\t}\n}",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = s.nextInt();\n\t\tint[] values = new int[a];\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tvalues[i] = s.nextInt();\n\t\t}\n\t\tsolve(values);\n\t}\n\n\tpublic static void solve(int[] values) {\n\t\tboolean flg = true;\n\t\tint cnt = 0;\n\t\twhile(flg) {\n\t\t\tflg = false;\n\t\t\tfor(int i = values.length - 1 ; i > 0 ; i--) {\n\t\t\t\tif(values[i] < values[i-1]) {\n\t\t\t\t\tint tmp = values[i];\n\t\t\t\t\tvalues[i] = values[i-1];\n\t\t\t\t\tvalues[i-1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\tflg = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString disp = \"\";\n\t\tfor(int i=0 ; i<values.length ; i++) {\n\t\t\tdisp += values[i];\n\t\t\tif(i+1<values.length)\n\t\t\t\tdisp += \" \";\n\t\t}\n\t\tSystem.out.print(disp+\"\\n\");\n\t\tSystem.out.println(cnt);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a = s.nextInt();
int[] values = new int[a];
for(int i=0 ; i<values.length ; i++) {
values[i] = s.nextInt();
}
solve(values);
}
public static void solve(int[] values) {
boolean flg = true;
int cnt = 0;
while(flg) {
flg = false;
for(int i = values.length - 1 ; i > 0 ; i--) {
if(values[i] < values[i-1]) {
int tmp = values[i];
values[i] = values[i-1];
values[i-1] = tmp;
cnt++;
flg = true;
}
}
}
String disp = "";
for(int i=0 ; i<values.length ; i++) {
disp += values[i];
if(i+1<values.length)
disp += " ";
}
System.out.print(disp+"\n");
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
17,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
20,
17,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
40,
17,
37,
20,
14,
2,
13,
13,
30,
0,
13,
17,
38,
5,
13,
30,
37,
20,
30,
0,
13,
4,
18,
13,
13,
14,
2,
13,
17,
29,
40,
17,
29,
18,
13,
40,
13,
12,
13,
30,
41,
13,
4,
13,
42,
4,
13,
13,
30,
0,
13,
4,
13,
41,
13,
20,
42,
40,
4,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
41,
13,
4,
13,
42,
4,
13,
13,
0,
13,
4,
13,
41,
13,
17,
14,
2,
13,
17,
30,
0,
13,
40,
17,
0,
13,
4,
13,
41,
13,
17,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
37,
20,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
29,
2,
13,
13,
12,
13,
30,
14,
2,
13,
17,
29,
4,
18,
13,
13,
29,
2,
2,
2,
2,
2,
13,
17,
2,
13,
17,
2,
13,
17,
2,
13,
17,
2,
13,
40,
17,
23,
13,
6,
13,
12,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
382,
23
],
[
382,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
26,
35
],
[
35,
36
],
[
35,
37
],
[
26,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
44,
45
],
[
44,
46
],
[
39,
47
],
[
47,
48
],
[
48,
49
],
[
39,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
26,
59
],
[
59,
60
],
[
59,
61
],
[
26,
62
],
[
62,
63
],
[
62,
64
],
[
26,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
71,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
71,
81
],
[
81,
82
],
[
82,
83
],
[
71,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
86,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
96,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
96,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
114,
120
],
[
96,
121
],
[
121,
122
],
[
26,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
123,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
130,
132
],
[
123,
133
],
[
133,
134
],
[
134,
135
],
[
123,
136
],
[
137,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
138,
143
],
[
143,
144
],
[
143,
145
],
[
137,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
26,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
152,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
159,
161
],
[
26,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
162,
167
],
[
24,
168
],
[
168,
169
],
[
382,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
170,
174
],
[
174,
175
],
[
174,
176
],
[
170,
178
],
[
178,
179
],
[
170,
180
],
[
180,
181
],
[
170,
182
],
[
182,
183
],
[
170,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
184,
192
],
[
192,
193
],
[
170,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
197,
202
],
[
202,
203
],
[
196,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
204,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
208,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
215,
216
],
[
216,
217
],
[
212,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
221,
222
],
[
222,
223
],
[
221,
224
],
[
208,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
],
[
225,
229
],
[
229,
230
],
[
230,
231
],
[
196,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
235,
236
],
[
170,
237
],
[
237,
238
],
[
237,
239
],
[
239,
240
],
[
240,
241
],
[
240,
242
],
[
242,
243
],
[
239,
244
],
[
244,
245
],
[
245,
246
],
[
245,
247
],
[
244,
248
],
[
248,
249
],
[
249,
250
],
[
249,
251
],
[
251,
252
],
[
239,
253
],
[
253,
254
],
[
253,
255
],
[
239,
256
],
[
256,
257
],
[
257,
258
],
[
258,
259
],
[
258,
260
],
[
256,
261
],
[
261,
262
],
[
262,
263
],
[
263,
264
],
[
262,
265
],
[
261,
266
],
[
266,
267
],
[
266,
268
],
[
268,
269
],
[
239,
270
],
[
270,
271
],
[
271,
272
],
[
272,
273
],
[
170,
274
],
[
274,
275
],
[
274,
276
],
[
276,
277
],
[
277,
278
],
[
277,
279
],
[
279,
280
],
[
276,
281
],
[
281,
282
],
[
282,
283
],
[
282,
284
],
[
281,
285
],
[
285,
286
],
[
285,
287
],
[
287,
288
],
[
276,
289
],
[
289,
290
],
[
289,
291
],
[
276,
292
],
[
292,
293
],
[
293,
294
],
[
293,
295
],
[
292,
296
],
[
296,
297
],
[
297,
298
],
[
297,
299
],
[
299,
300
],
[
296,
301
],
[
301,
302
],
[
301,
303
],
[
303,
304
],
[
276,
305
],
[
305,
306
],
[
305,
307
],
[
276,
308
],
[
308,
309
],
[
309,
310
],
[
310,
311
],
[
310,
312
],
[
308,
313
],
[
313,
314
],
[
314,
315
],
[
315,
316
],
[
316,
317
],
[
316,
318
],
[
315,
319
],
[
319,
320
],
[
319,
321
],
[
314,
322
],
[
322,
323
],
[
313,
324
],
[
324,
325
],
[
324,
326
],
[
313,
327
],
[
327,
328
],
[
327,
329
],
[
329,
330
],
[
329,
331
],
[
313,
332
],
[
332,
333
],
[
332,
334
],
[
334,
335
],
[
276,
336
],
[
336,
337
],
[
337,
338
],
[
337,
339
],
[
170,
340
],
[
340,
341
],
[
340,
342
],
[
342,
343
],
[
343,
344
],
[
344,
345
],
[
344,
346
],
[
343,
347
],
[
347,
348
],
[
348,
349
],
[
349,
350
],
[
348,
351
],
[
342,
352
],
[
352,
353
],
[
356,
354
],
[
366,
355
],
[
363,
356
],
[
356,
357
],
[
357,
358
],
[
357,
359
],
[
356,
360
],
[
360,
361
],
[
360,
362
],
[
363,
363
],
[
363,
364
],
[
363,
365
],
[
366,
366
],
[
366,
367
],
[
366,
368
],
[
356,
369
],
[
369,
370
],
[
369,
371
],
[
371,
372
],
[
340,
373
],
[
373,
374
],
[
170,
375
],
[
375,
376
],
[
375,
377
],
[
377,
378
],
[
377,
379
],
[
379,
380
],
[
0,
381
],
[
381,
382
],
[
381,
383
]
] | [
"import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.LinkedList;\nimport java.util.PriorityQueue;\n\n \npublic class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int[] numbers = new int[n];\n for(int i = 0; i < n; i++){\n numbers[i] = sc.nextInt();\n }\n\n boolean notok = true;\n int count = 0;\n while(notok){\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }\n\n for(int i = 0; i < n-1; i++){\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }\n System.out.println(numbers[n-1]);\n System.out.println(count);\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.InputMismatchException;",
"InputMismatchException",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.PriorityQueue;",
"PriorityQueue",
"java.util",
"public class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int[] numbers = new int[n];\n for(int i = 0; i < n; i++){\n numbers[i] = sc.nextInt();\n }\n\n boolean notok = true;\n int count = 0;\n while(notok){\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }\n\n for(int i = 0; i < n-1; i++){\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }\n System.out.println(numbers[n-1]);\n System.out.println(count);\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int[] numbers = new int[n];\n for(int i = 0; i < n; i++){\n numbers[i] = sc.nextInt();\n }\n\n boolean notok = true;\n int count = 0;\n while(notok){\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }\n\n for(int i = 0; i < n-1; i++){\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }\n System.out.println(numbers[n-1]);\n System.out.println(count);\n }",
"main",
"{\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int[] numbers = new int[n];\n for(int i = 0; i < n; i++){\n numbers[i] = sc.nextInt();\n }\n\n boolean notok = true;\n int count = 0;\n while(notok){\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }\n\n for(int i = 0; i < n-1; i++){\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }\n System.out.println(numbers[n-1]);\n System.out.println(count);\n }",
"InputReader sc = new InputReader(System.in);",
"sc",
"new InputReader(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] numbers = new int[n];",
"numbers",
"new int[n]",
"n",
"for(int i = 0; i < n; i++){\n numbers[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n numbers[i] = sc.nextInt();\n }",
"{\n numbers[i] = sc.nextInt();\n }",
"numbers[i] = sc.nextInt()",
"numbers[i]",
"numbers",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"boolean notok = true;",
"notok",
"true",
"int count = 0;",
"count",
"0",
"while(notok){\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }",
"notok",
"{\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }",
"notok = false",
"notok",
"false",
"for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }",
"{\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }",
"if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }",
"numbers[i] > numbers[i+1]",
"numbers[i]",
"numbers",
"i",
"numbers[i+1]",
"numbers",
"i+1",
"i",
"1",
"{\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }",
"notok = true",
"notok",
"true",
"int keep = numbers[i];",
"keep",
"numbers[i]",
"numbers",
"i",
"numbers[i] = numbers[i+1]",
"numbers[i]",
"numbers",
"i",
"numbers[i+1]",
"numbers",
"i+1",
"i",
"1",
"numbers[i+1] = keep",
"numbers[i+1]",
"numbers",
"i+1",
"i",
"1",
"keep",
"count++",
"count",
"for(int i = 0; i < n-1; i++){\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }",
"{\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }",
"System.out.print(numbers[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"numbers[i]",
"numbers",
"i",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(numbers[n-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"numbers[n-1]",
"numbers",
"n-1",
"n",
"1",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
" static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }",
"InputReader",
"private InputStream stream;",
"stream",
"private byte[] buf = new byte[1024];",
"buf",
"new byte[1024]",
"1024",
"private int curChar;",
"curChar",
"private int numChars;",
"numChars",
"private SpaceCharFilter filter;",
"filter",
"public InputReader(InputStream stream) {\n this.stream = stream;\n }",
"InputReader",
"{\n this.stream = stream;\n }",
"this.stream = stream",
"this.stream",
"this",
"this.stream",
"stream",
"InputStream stream",
"stream",
"public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }",
"next",
"{\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }",
"if (numChars == -1)\n throw new InputMismatchException();",
"numChars == -1",
"numChars",
"-1",
"1",
"throw new InputMismatchException();",
"new InputMismatchException()",
"if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }",
"curChar >= numChars",
"curChar",
"numChars",
"{\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }",
"curChar = 0",
"curChar",
"0",
"try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }",
"catch (IOException e) {\n throw new InputMismatchException();\n }",
"IOException e",
"{\n throw new InputMismatchException();\n }",
"throw new InputMismatchException();",
"new InputMismatchException()",
"{\n numChars = stream.read(buf);\n }",
"numChars = stream.read(buf)",
"numChars",
"stream.read(buf)",
"stream.read",
"stream",
"buf",
"if (numChars <= 0)\n return -1;",
"numChars <= 0",
"numChars",
"0",
"return -1;",
"-1",
"1",
"return buf[curChar++];",
"buf[curChar++]",
"buf",
"curChar++",
"curChar",
"public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }",
"nextStr",
"{\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }",
"int c = next();",
"c",
"next()",
"next",
"while(isSpaceChar(c)){c = next();}",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{c = next();}",
"c = next()",
"c",
"next()",
"next",
"StringBuffer str = new StringBuffer();",
"str",
"new StringBuffer()",
"do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n str.append((char)c);\n c = next();\n }",
"str.append((char)c)",
"str.append",
"str",
"(char)c",
"c = next()",
"c",
"next()",
"next",
"return str.toString();",
"str.toString()",
"str.toString",
"str",
"public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }",
"nextInt",
"{\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }",
"int c = next();",
"c",
"next()",
"next",
"while (isSpaceChar(c))\n c = next();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c = next()",
"c",
"next()",
"next",
"int sgn = 1;",
"sgn",
"1",
"if (c == '-') {\n sgn = -1;\n c = next();\n }",
"c == '-'",
"c",
"'-'",
"{\n sgn = -1;\n c = next();\n }",
"sgn = -1",
"sgn",
"-1",
"1",
"c = next()",
"c",
"next()",
"next",
"int res = 0;",
"res",
"0",
"do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n }",
"if (c < '0' || c > '9')\n throw new InputMismatchException();",
"c < '0' || c > '9'",
"c < '0'",
"c",
"'0'",
"c > '9'",
"c",
"'9'",
"throw new InputMismatchException();",
"new InputMismatchException()",
"res *= 10",
"res",
"10",
"res += c - '0'",
"res",
"c - '0'",
"c",
"'0'",
"c = next()",
"c",
"next()",
"next",
"return res * sgn;",
"res * sgn",
"res",
"sgn",
"public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }",
"isSpaceChar",
"{\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }",
"if (filter != null)\n return filter.isSpaceChar(c);",
"filter != null",
"filter",
"null",
"return filter.isSpaceChar(c);",
"filter.isSpaceChar(c)",
"filter.isSpaceChar",
"filter",
"c",
"return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;",
"c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1",
"c == '\\t'",
"c == '\\r'",
"c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1",
"c == ' '",
"c",
"' '",
"c == '\\n'",
"c",
"'\\n'",
"c == '\\r'",
"c",
"'\\r'",
"c == '\\t'",
"c",
"'\\t'",
"c == -1",
"c",
"-1",
"1",
"int c",
"c",
"public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }",
"SpaceCharFilter",
"public boolean isSpaceChar(int ch);",
"isSpaceChar",
"int ch",
"ch",
"public class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int[] numbers = new int[n];\n for(int i = 0; i < n; i++){\n numbers[i] = sc.nextInt();\n }\n\n boolean notok = true;\n int count = 0;\n while(notok){\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }\n\n for(int i = 0; i < n-1; i++){\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }\n System.out.println(numbers[n-1]);\n System.out.println(count);\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int[] numbers = new int[n];\n for(int i = 0; i < n; i++){\n numbers[i] = sc.nextInt();\n }\n\n boolean notok = true;\n int count = 0;\n while(notok){\n notok = false;\n for(int i = 0; i < n - 1; i++){\n if(numbers[i] > numbers[i+1]){\n notok = true;\n int keep = numbers[i];\n numbers[i] = numbers[i+1];\n numbers[i+1] = keep;\n count++;\n }\n }\n }\n\n for(int i = 0; i < n-1; i++){\n System.out.print(numbers[i]);\n System.out.print(\" \");\n }\n System.out.println(numbers[n-1]);\n System.out.println(count);\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"Main"
] | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
public class Main {
public static void main(String[] args) {
InputReader sc = new InputReader(System.in);
int n = sc.nextInt();
int[] numbers = new int[n];
for(int i = 0; i < n; i++){
numbers[i] = sc.nextInt();
}
boolean notok = true;
int count = 0;
while(notok){
notok = false;
for(int i = 0; i < n - 1; i++){
if(numbers[i] > numbers[i+1]){
notok = true;
int keep = numbers[i];
numbers[i] = numbers[i+1];
numbers[i+1] = keep;
count++;
}
}
}
for(int i = 0; i < n-1; i++){
System.out.print(numbers[i]);
System.out.print(" ");
}
System.out.println(numbers[n-1]);
System.out.println(count);
}
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
// setsu[i] = new LinkedList<Integer>();
// }
//ここからテンプレ
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int next() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public String nextStr() {
int c = next();
while(isSpaceChar(c)){c = next();}
StringBuffer str = new StringBuffer();
do{
str.append((char)c);
c = next();
}while(!isSpaceChar(c));
return str.toString();
}
public int nextInt() {
int c = next();
while (isSpaceChar(c))
c = next();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = next();
} while (!isSpaceChar(c));
return res * sgn;
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
162,
5
],
[
162,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
57,
59
],
[
53,
60
],
[
60,
61
],
[
60,
62
],
[
53,
63
],
[
63,
64
],
[
64,
65
],
[
53,
66
],
[
67,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
78,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
78,
100
],
[
100,
101
],
[
100,
102
],
[
78,
103
],
[
103,
104
],
[
8,
105
],
[
105,
106
],
[
105,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
6,
114
],
[
114,
115
],
[
162,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
121,
123
],
[
118,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
124,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
124,
134
],
[
134,
135
],
[
135,
136
],
[
124,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
139,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
118,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
156,
158
],
[
116,
159
],
[
159,
160
],
[
0,
161
],
[
161,
162
],
[
161,
163
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint swapCount = 0;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintArray(nums);\n\t\tSystem.out.println(swapCount);\n\t}\n\tpublic static void printArray(int[] array) {\n\t\tint arrayLength = array.length;\n\t\tfor(int index = 0; index < arrayLength - 1; index++) {\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}\n\t\tSystem.out.println(array[arrayLength - 1]);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint swapCount = 0;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintArray(nums);\n\t\tSystem.out.println(swapCount);\n\t}\n\tpublic static void printArray(int[] array) {\n\t\tint arrayLength = array.length;\n\t\tfor(int index = 0; index < arrayLength - 1; index++) {\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}\n\t\tSystem.out.println(array[arrayLength - 1]);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint swapCount = 0;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintArray(nums);\n\t\tSystem.out.println(swapCount);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint swapCount = 0;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintArray(nums);\n\t\tSystem.out.println(swapCount);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] nums = new int[n];",
"nums",
"new int[n]",
"n",
"for(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}",
"int arrayIndex = 0;",
"int arrayIndex = 0;",
"arrayIndex",
"0",
"arrayIndex < n",
"arrayIndex",
"n",
"arrayIndex++",
"arrayIndex++",
"arrayIndex",
"{\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}",
"{\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}",
"nums[arrayIndex] = sc.nextInt()",
"nums[arrayIndex]",
"nums",
"arrayIndex",
"sc.nextInt()",
"sc.nextInt",
"sc",
"boolean flag = true;",
"flag",
"true",
"int swapCount = 0;",
"swapCount",
"0",
"while(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}",
"if(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}",
"nums[j] < nums[j - 1]",
"nums[j]",
"nums",
"j",
"nums[j - 1]",
"nums",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}",
"int work = nums[j];",
"work",
"nums[j]",
"nums",
"j",
"nums[j] = nums[j - 1]",
"nums[j]",
"nums",
"j",
"nums[j - 1]",
"nums",
"j - 1",
"j",
"1",
"nums[j - 1] = work",
"nums[j - 1]",
"nums",
"j - 1",
"j",
"1",
"work",
"flag = true",
"flag",
"true",
"swapCount++",
"swapCount",
"printArray(nums)",
"printArray",
"nums",
"System.out.println(swapCount)",
"System.out.println",
"System.out",
"System",
"System.out",
"swapCount",
"String[] args",
"args",
"public static void printArray(int[] array) {\n\t\tint arrayLength = array.length;\n\t\tfor(int index = 0; index < arrayLength - 1; index++) {\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}\n\t\tSystem.out.println(array[arrayLength - 1]);\n\t}",
"printArray",
"{\n\t\tint arrayLength = array.length;\n\t\tfor(int index = 0; index < arrayLength - 1; index++) {\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}\n\t\tSystem.out.println(array[arrayLength - 1]);\n\t}",
"int arrayLength = array.length;",
"arrayLength",
"array.length",
"array",
"array.length",
"for(int index = 0; index < arrayLength - 1; index++) {\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}",
"int index = 0;",
"int index = 0;",
"index",
"0",
"index < arrayLength - 1",
"index",
"arrayLength - 1",
"arrayLength",
"1",
"index++",
"index++",
"index",
"{\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}",
"{\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}",
"System.out.print(array[index] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"array[index] + \" \"",
"array[index]",
"array",
"index",
"\" \"",
"System.out.println(array[arrayLength - 1])",
"System.out.println",
"System.out",
"System",
"System.out",
"array[arrayLength - 1]",
"array",
"arrayLength - 1",
"arrayLength",
"1",
"int[] array",
"array",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint swapCount = 0;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintArray(nums);\n\t\tSystem.out.println(swapCount);\n\t}\n\tpublic static void printArray(int[] array) {\n\t\tint arrayLength = array.length;\n\t\tfor(int index = 0; index < arrayLength - 1; index++) {\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}\n\t\tSystem.out.println(array[arrayLength - 1]);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {\n\t\t\tnums[arrayIndex] = sc.nextInt();\n\t\t}\n\t\tboolean flag = true;\n\t\tint swapCount = 0;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n - 1; j > 0; j--) {\n\t\t\t\tif(nums[j] < nums[j - 1]) {\n\t\t\t\t\tint work = nums[j];\n\t\t\t\t\tnums[j] = nums[j - 1];\n\t\t\t\t\tnums[j - 1] = work;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tswapCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintArray(nums);\n\t\tSystem.out.println(swapCount);\n\t}\n\tpublic static void printArray(int[] array) {\n\t\tint arrayLength = array.length;\n\t\tfor(int index = 0; index < arrayLength - 1; index++) {\n\t\t\tSystem.out.print(array[index] + \" \");\n\t\t}\n\t\tSystem.out.println(array[arrayLength - 1]);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] nums = new int[n];
for(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {
nums[arrayIndex] = sc.nextInt();
}
boolean flag = true;
int swapCount = 0;
while(flag) {
flag = false;
for(int j = n - 1; j > 0; j--) {
if(nums[j] < nums[j - 1]) {
int work = nums[j];
nums[j] = nums[j - 1];
nums[j - 1] = work;
flag = true;
swapCount++;
}
}
}
printArray(nums);
System.out.println(swapCount);
}
public static void printArray(int[] array) {
int arrayLength = array.length;
for(int index = 0; index < arrayLength - 1; index++) {
System.out.print(array[index] + " ");
}
System.out.println(array[arrayLength - 1]);
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
12,
13,
30,
0,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
158,
5
],
[
158,
6
],
[
6,
7
],
[
158,
8
],
[
8,
9
],
[
8,
10
],
[
10,
11
],
[
11,
12
],
[
11,
13
],
[
10,
14
],
[
14,
15
],
[
14,
16
],
[
16,
17
],
[
17,
18
],
[
10,
19
],
[
19,
20
],
[
19,
21
],
[
10,
23
],
[
23,
24
],
[
23,
25
],
[
10,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
26,
31
],
[
31,
32
],
[
31,
33
],
[
26,
34
],
[
34,
35
],
[
35,
36
],
[
26,
37
],
[
38,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
44,
45
],
[
10,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
46,
54
],
[
54,
55
],
[
55,
56
],
[
46,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
59,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
59,
72
],
[
73,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
74,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
84,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
84,
106
],
[
106,
107
],
[
10,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
117,
118
],
[
108,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
126,
127
],
[
126,
128
],
[
120,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
129,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
10,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
8,
155
],
[
155,
156
],
[
0,
157
],
[
157,
158
],
[
157,
159
]
] | [
"import java.util.Scanner;\npublic class Main{\nprivate static Scanner scanner;\npublic static void main(String args[]) {\n\tscanner = new Scanner(System.in);\n\tint a = scanner.nextInt();\n\tint[] b = new int[a];\n\tint count = 0;\n\t//int flag = 1;\n\tfor(int i = 0;i < a;i++) {\n\t\tb[i] = scanner.nextInt();\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}\n\tSystem.out.println(count);\n}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\nprivate static Scanner scanner;\npublic static void main(String args[]) {\n\tscanner = new Scanner(System.in);\n\tint a = scanner.nextInt();\n\tint[] b = new int[a];\n\tint count = 0;\n\t//int flag = 1;\n\tfor(int i = 0;i < a;i++) {\n\t\tb[i] = scanner.nextInt();\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}\n\tSystem.out.println(count);\n}\n}",
"Main",
"private static Scanner scanner;",
"scanner",
"public static void main(String args[]) {\n\tscanner = new Scanner(System.in);\n\tint a = scanner.nextInt();\n\tint[] b = new int[a];\n\tint count = 0;\n\t//int flag = 1;\n\tfor(int i = 0;i < a;i++) {\n\t\tb[i] = scanner.nextInt();\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}\n\tSystem.out.println(count);\n}",
"main",
"{\n\tscanner = new Scanner(System.in);\n\tint a = scanner.nextInt();\n\tint[] b = new int[a];\n\tint count = 0;\n\t//int flag = 1;\n\tfor(int i = 0;i < a;i++) {\n\t\tb[i] = scanner.nextInt();\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}\n\tSystem.out.println(count);\n}",
"scanner = new Scanner(System.in)",
"scanner",
"new Scanner(System.in)",
"int a = scanner.nextInt();",
"a",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int[] b = new int[a];",
"b",
"new int[a]",
"a",
"int count = 0;",
"count",
"0",
"for(int i = 0;i < a;i++) {\n\t\tb[i] = scanner.nextInt();\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a",
"i",
"a",
"i++",
"i++",
"i",
"{\n\t\tb[i] = scanner.nextInt();\n\t}",
"{\n\t\tb[i] = scanner.nextInt();\n\t}",
"b[i] = scanner.nextInt()",
"b[i]",
"b",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"for(int i = 0;i < a;i++) {\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a",
"i",
"a",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}",
"{\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}",
"for(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}",
"int j = a-1;",
"int j = a-1;",
"j",
"a-1",
"a",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}",
"{\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}",
"if(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}",
"b[j] < b[j-1]",
"b[j]",
"b",
"j",
"b[j-1]",
"b",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}",
"int tmp = b[j];",
"tmp",
"b[j]",
"b",
"j",
"b[j] = b[j-1]",
"b[j]",
"b",
"j",
"b[j-1]",
"b",
"j-1",
"j",
"1",
"b[j-1] = tmp",
"b[j-1]",
"b",
"j-1",
"j",
"1",
"tmp",
"count++",
"count",
"for(int i = 0;i < a;i++) {\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a",
"i",
"a",
"i++",
"i++",
"i",
"{\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}",
"{\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}",
"System.out.print(b[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"b[i]",
"b",
"i",
"if(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}",
"i == a - 1",
"i",
"a - 1",
"a",
"1",
"{\n\t\t\tSystem.out.println(\"\");\n\t\t}",
"System.out.println(\"\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\"",
"{\n\t\t\tSystem.out.print(\" \");\n\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String args[]",
"args",
"public class Main{\nprivate static Scanner scanner;\npublic static void main(String args[]) {\n\tscanner = new Scanner(System.in);\n\tint a = scanner.nextInt();\n\tint[] b = new int[a];\n\tint count = 0;\n\t//int flag = 1;\n\tfor(int i = 0;i < a;i++) {\n\t\tb[i] = scanner.nextInt();\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}\n\tSystem.out.println(count);\n}\n}",
"public class Main{\nprivate static Scanner scanner;\npublic static void main(String args[]) {\n\tscanner = new Scanner(System.in);\n\tint a = scanner.nextInt();\n\tint[] b = new int[a];\n\tint count = 0;\n\t//int flag = 1;\n\tfor(int i = 0;i < a;i++) {\n\t\tb[i] = scanner.nextInt();\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\t\tfor(int j = a-1;j >= 1;j--) {\n\t\t\t\tif(b[j] < b[j-1]) {\n\t\t\t\t\tint tmp = b[j];\n\t\t\t\t\tb[j] = b[j-1];\n\t\t\t\t\tb[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0;i < a;i++) {\n\t\tSystem.out.print(b[i]);\n\t\tif(i == a - 1) {\n\t\t\tSystem.out.println(\"\");\n\t\t}else {\n\t\t\tSystem.out.print(\" \");\n\t\t}\n\t}\n\tSystem.out.println(count);\n}\n}",
"Main"
] | import java.util.Scanner;
public class Main{
private static Scanner scanner;
public static void main(String args[]) {
scanner = new Scanner(System.in);
int a = scanner.nextInt();
int[] b = new int[a];
int count = 0;
//int flag = 1;
for(int i = 0;i < a;i++) {
b[i] = scanner.nextInt();
}
for(int i = 0;i < a;i++) {
for(int j = a-1;j >= 1;j--) {
if(b[j] < b[j-1]) {
int tmp = b[j];
b[j] = b[j-1];
b[j-1] = tmp;
count++;
}
}
}
for(int i = 0;i < a;i++) {
System.out.print(b[i]);
if(i == a - 1) {
System.out.println("");
}else {
System.out.print(" ");
}
}
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
13,
13,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
25,
27
],
[
21,
28
],
[
28,
29
],
[
28,
30
],
[
21,
31
],
[
31,
32
],
[
32,
33
],
[
21,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
40,
42
],
[
37,
43
],
[
43,
44
],
[
43,
45
],
[
36,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
46,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
46,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
61,
67
],
[
46,
68
],
[
68,
69
],
[
68,
70
],
[
46,
71
],
[
71,
72
],
[
8,
73
],
[
73,
74
],
[
6,
75
],
[
75,
76
],
[
6,
77
],
[
77,
78
],
[
4,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
81,
90
],
[
90,
91
],
[
90,
92
],
[
81,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
94,
99
],
[
99,
100
],
[
99,
101
],
[
94,
102
],
[
102,
103
],
[
103,
104
],
[
94,
105
],
[
106,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
112,
113
],
[
81,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
116,
118
],
[
116,
119
],
[
81,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
120,
130
],
[
130,
131
],
[
131,
132
],
[
120,
133
],
[
134,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
81,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
152,
154
],
[
81,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
79,
161
],
[
161,
162
]
] | [
"import java.util.Scanner;\n\nclass Main{\n\n static int bubbleSort(int[] a, int n){\n boolean flag = true;\n int cnt = 0;\n while(flag){\n flag = false;\n for(int j = n - 1; j >= 1; j--){\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }\n }\n return cnt;\n }\n\n public static void main(String[] args){\n Scanner scn = new Scanner(System.in);\n\n int n = scn.nextInt();\n int[] a = new int[n];\n for(int i = 0; i < n; i++){\n a[i] = scn.nextInt();\n }\n\n int cnt = bubbleSort(a, n);\n\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(cnt);\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n\n static int bubbleSort(int[] a, int n){\n boolean flag = true;\n int cnt = 0;\n while(flag){\n flag = false;\n for(int j = n - 1; j >= 1; j--){\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }\n }\n return cnt;\n }\n\n public static void main(String[] args){\n Scanner scn = new Scanner(System.in);\n\n int n = scn.nextInt();\n int[] a = new int[n];\n for(int i = 0; i < n; i++){\n a[i] = scn.nextInt();\n }\n\n int cnt = bubbleSort(a, n);\n\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(cnt);\n }\n}",
"Main",
"static int bubbleSort(int[] a, int n){\n boolean flag = true;\n int cnt = 0;\n while(flag){\n flag = false;\n for(int j = n - 1; j >= 1; j--){\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }\n }\n return cnt;\n }",
"bubbleSort",
"{\n boolean flag = true;\n int cnt = 0;\n while(flag){\n flag = false;\n for(int j = n - 1; j >= 1; j--){\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }\n }\n return cnt;\n }",
"boolean flag = true;",
"flag",
"true",
"int cnt = 0;",
"cnt",
"0",
"while(flag){\n flag = false;\n for(int j = n - 1; j >= 1; j--){\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }\n }",
"flag",
"{\n flag = false;\n for(int j = n - 1; j >= 1; j--){\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for(int j = n - 1; j >= 1; j--){\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }",
"{\n if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }\n }",
"if(a[j-1] > a[j]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }",
"a[j-1] > a[j]",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j]",
"a",
"j",
"{\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n\n flag = true;\n cnt++;\n }",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"tmp",
"flag = true",
"flag",
"true",
"cnt++",
"cnt",
"return cnt;",
"cnt",
"int[] a",
"a",
"int n",
"n",
"public static void main(String[] args){\n Scanner scn = new Scanner(System.in);\n\n int n = scn.nextInt();\n int[] a = new int[n];\n for(int i = 0; i < n; i++){\n a[i] = scn.nextInt();\n }\n\n int cnt = bubbleSort(a, n);\n\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(cnt);\n }",
"main",
"{\n Scanner scn = new Scanner(System.in);\n\n int n = scn.nextInt();\n int[] a = new int[n];\n for(int i = 0; i < n; i++){\n a[i] = scn.nextInt();\n }\n\n int cnt = bubbleSort(a, n);\n\n for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[n-1]);\n System.out.println(cnt);\n }",
"Scanner scn = new Scanner(System.in);",
"scn",
"new Scanner(System.in)",
"int n = scn.nextInt();",
"n",
"scn.nextInt()",
"scn.nextInt",
"scn",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for(int i = 0; i < n; i++){\n a[i] = scn.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = scn.nextInt();\n }",
"{\n a[i] = scn.nextInt();\n }",
"a[i] = scn.nextInt()",
"a[i]",
"a",
"i",
"scn.nextInt()",
"scn.nextInt",
"scn",
"int cnt = bubbleSort(a, n);",
"cnt",
"bubbleSort(a, n)",
"bubbleSort",
"a",
"n",
"for(int i = 0; i < n-1; i++){\n System.out.print(a[i] + \" \");\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(a[i] + \" \");\n }",
"{\n System.out.print(a[i] + \" \");\n }",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(a[n-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[n-1]",
"a",
"n-1",
"n",
"1",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
static int bubbleSort(int[] a, int n){
boolean flag = true;
int cnt = 0;
while(flag){
flag = false;
for(int j = n - 1; j >= 1; j--){
if(a[j-1] > a[j]){
int tmp = a[j];
a[j] = a[j-1];
a[j-1] = tmp;
flag = true;
cnt++;
}
}
}
return cnt;
}
public static void main(String[] args){
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i++){
a[i] = scn.nextInt();
}
int cnt = bubbleSort(a, n);
for(int i = 0; i < n-1; i++){
System.out.print(a[i] + " ");
}
System.out.println(a[n-1]);
System.out.println(cnt);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
18,
13,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
2,
2,
2,
18,
13,
2,
13,
17,
17,
13,
17,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
164,
5
],
[
164,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
21,
31
],
[
31,
32
],
[
32,
33
],
[
21,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
43,
46
],
[
6,
47
],
[
47,
48
],
[
164,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
55,
57
],
[
51,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
64,
71
],
[
71,
72
],
[
71,
73
],
[
64,
74
],
[
74,
75
],
[
75,
76
],
[
64,
77
],
[
78,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
79,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
89,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
89,
111
],
[
111,
112
],
[
89,
113
],
[
113,
114
],
[
113,
115
],
[
51,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
116,
128
],
[
128,
129
],
[
129,
130
],
[
116,
131
],
[
132,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
51,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
150,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
153,
155
],
[
150,
156
],
[
149,
157
],
[
150,
158
],
[
49,
159
],
[
159,
160
],
[
49,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < a.length; i++) {\n a[i] = sc.nextInt();\n }\n bubbleSort(a, n);\n }\n\n private static void bubbleSort(int[] a, int n) {\n int sum = 0;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < a.length-1; i++) {\n System.out.print(a[i] + \" \");\n }\n System.out.print(a[n-1]+\"\\n\" + sum+\"\\n\");\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < a.length; i++) {\n a[i] = sc.nextInt();\n }\n bubbleSort(a, n);\n }\n\n private static void bubbleSort(int[] a, int n) {\n int sum = 0;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < a.length-1; i++) {\n System.out.print(a[i] + \" \");\n }\n System.out.print(a[n-1]+\"\\n\" + sum+\"\\n\");\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < a.length; i++) {\n a[i] = sc.nextInt();\n }\n bubbleSort(a, n);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < a.length; i++) {\n a[i] = sc.nextInt();\n }\n bubbleSort(a, n);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < a.length; i++) {\n a[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n a[i] = sc.nextInt();\n }",
"{\n a[i] = sc.nextInt();\n }",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"bubbleSort(a, n)",
"bubbleSort",
"a",
"n",
"String[] args",
"args",
"private static void bubbleSort(int[] a, int n) {\n int sum = 0;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < a.length-1; i++) {\n System.out.print(a[i] + \" \");\n }\n System.out.print(a[n-1]+\"\\n\" + sum+\"\\n\");\n }",
"bubbleSort",
"{\n int sum = 0;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < a.length-1; i++) {\n System.out.print(a[i] + \" \");\n }\n System.out.print(a[n-1]+\"\\n\" + sum+\"\\n\");\n }",
"int sum = 0;",
"sum",
"0",
"boolean flag = true;",
"flag",
"true",
"while (flag) {\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }",
"flag",
"{\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }",
"int i = n - 1;",
"int i = n - 1;",
"i",
"n - 1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }",
"{\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }",
"if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }",
"a[i] < a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"{\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }",
"int emp = a[i];",
"emp",
"a[i]",
"a",
"i",
"a[i] = a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i - 1] = emp",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"emp",
"sum++",
"sum",
"flag = true",
"flag",
"true",
"for (int i = 0; i < a.length-1; i++) {\n System.out.print(a[i] + \" \");\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length-1",
"i",
"a.length-1",
"a.length",
"a",
"a.length",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(a[i] + \" \");\n }",
"{\n System.out.print(a[i] + \" \");\n }",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.print(a[n-1]+\"\\n\" + sum+\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[n-1]+\"\\n\" + sum+\"\\n\"",
"sum",
"a[n-1]+\"\\n\" + sum+\"\\n\"",
"a[n-1]",
"a",
"n-1",
"n",
"1",
"\"\\n\"",
"sum",
"\"\\n\"",
"int[] a",
"a",
"int n",
"n",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < a.length; i++) {\n a[i] = sc.nextInt();\n }\n bubbleSort(a, n);\n }\n\n private static void bubbleSort(int[] a, int n) {\n int sum = 0;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < a.length-1; i++) {\n System.out.print(a[i] + \" \");\n }\n System.out.print(a[n-1]+\"\\n\" + sum+\"\\n\");\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < a.length; i++) {\n a[i] = sc.nextInt();\n }\n bubbleSort(a, n);\n }\n\n private static void bubbleSort(int[] a, int n) {\n int sum = 0;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int i = n - 1; i > 0; i--) {\n if (a[i] < a[i - 1]) {\n int emp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = emp;\n sum++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < a.length-1; i++) {\n System.out.print(a[i] + \" \");\n }\n System.out.print(a[n-1]+\"\\n\" + sum+\"\\n\");\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
}
bubbleSort(a, n);
}
private static void bubbleSort(int[] a, int n) {
int sum = 0;
boolean flag = true;
while (flag) {
flag = false;
for (int i = n - 1; i > 0; i--) {
if (a[i] < a[i - 1]) {
int emp = a[i];
a[i] = a[i - 1];
a[i - 1] = emp;
sum++;
flag = true;
}
}
}
for (int i = 0; i < a.length-1; i++) {
System.out.print(a[i] + " ");
}
System.out.print(a[n-1]+"\n" + sum+"\n");
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
4,
18,
13,
13,
4,
18,
13,
2,
13,
17,
30,
4,
18,
13,
2,
13,
17,
4,
18,
13,
13,
4,
18,
13,
2,
13,
17,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
4,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
14,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
26,
31
],
[
31,
32
],
[
31,
33
],
[
26,
34
],
[
34,
35
],
[
35,
36
],
[
26,
37
],
[
38,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
43,
44
],
[
14,
45
],
[
45,
46
],
[
46,
47
],
[
14,
48
],
[
48,
49
],
[
48,
50
],
[
14,
51
],
[
51,
52
],
[
51,
53
],
[
14,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
62,
69
],
[
69,
70
],
[
69,
71
],
[
62,
72
],
[
72,
73
],
[
73,
74
],
[
62,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
78,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
86,
88
],
[
77,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
89,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
103,
104
],
[
103,
105
],
[
89,
106
],
[
106,
107
],
[
89,
108
],
[
108,
109
],
[
108,
110
],
[
14,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
116,
117
],
[
116,
118
],
[
111,
119
],
[
119,
120
],
[
120,
121
],
[
111,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
124,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
123,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
133,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
14,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
14,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
12,
157
],
[
157,
158
]
] | [
"import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\nclass Main {\n public static void main(String[] args) {\n // 標準入力の読み込み開始\n Scanner scanner = new Scanner(System.in);\n\n // 数列の長さ\n int n = scanner.nextInt();\n\n // 数列\n List<Integer> numList = new ArrayList<Integer>();\n for (int i = 0; i < n; i++) {\n numList.add(scanner.nextInt());\n }\n\n // 標準入力の読み込み終了\n scanner.close();\n\n // 処理実行\n \n int flag = 1; // 逆の隣接要素が存在する\n int c = 0; //カウンタ\n while (flag == 1){\n flag = 0;\n for(int j = n-1; j >= 1; j--){\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }\n } \n \n for(int i =0; i<n; i++){\n\tSystem.out.print(numList.get(i));\n\tif(i < n-1){\n\t System.out.print(\" \");\n\t}\n }\n System.out.println();\n \n System.out.println(c);\n }\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n public static void main(String[] args) {\n // 標準入力の読み込み開始\n Scanner scanner = new Scanner(System.in);\n\n // 数列の長さ\n int n = scanner.nextInt();\n\n // 数列\n List<Integer> numList = new ArrayList<Integer>();\n for (int i = 0; i < n; i++) {\n numList.add(scanner.nextInt());\n }\n\n // 標準入力の読み込み終了\n scanner.close();\n\n // 処理実行\n \n int flag = 1; // 逆の隣接要素が存在する\n int c = 0; //カウンタ\n while (flag == 1){\n flag = 0;\n for(int j = n-1; j >= 1; j--){\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }\n } \n \n for(int i =0; i<n; i++){\n\tSystem.out.print(numList.get(i));\n\tif(i < n-1){\n\t System.out.print(\" \");\n\t}\n }\n System.out.println();\n \n System.out.println(c);\n }\n}",
"Main",
"public static void main(String[] args) {\n // 標準入力の読み込み開始\n Scanner scanner = new Scanner(System.in);\n\n // 数列の長さ\n int n = scanner.nextInt();\n\n // 数列\n List<Integer> numList = new ArrayList<Integer>();\n for (int i = 0; i < n; i++) {\n numList.add(scanner.nextInt());\n }\n\n // 標準入力の読み込み終了\n scanner.close();\n\n // 処理実行\n \n int flag = 1; // 逆の隣接要素が存在する\n int c = 0; //カウンタ\n while (flag == 1){\n flag = 0;\n for(int j = n-1; j >= 1; j--){\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }\n } \n \n for(int i =0; i<n; i++){\n\tSystem.out.print(numList.get(i));\n\tif(i < n-1){\n\t System.out.print(\" \");\n\t}\n }\n System.out.println();\n \n System.out.println(c);\n }",
"main",
"{\n // 標準入力の読み込み開始\n Scanner scanner = new Scanner(System.in);\n\n // 数列の長さ\n int n = scanner.nextInt();\n\n // 数列\n List<Integer> numList = new ArrayList<Integer>();\n for (int i = 0; i < n; i++) {\n numList.add(scanner.nextInt());\n }\n\n // 標準入力の読み込み終了\n scanner.close();\n\n // 処理実行\n \n int flag = 1; // 逆の隣接要素が存在する\n int c = 0; //カウンタ\n while (flag == 1){\n flag = 0;\n for(int j = n-1; j >= 1; j--){\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }\n } \n \n for(int i =0; i<n; i++){\n\tSystem.out.print(numList.get(i));\n\tif(i < n-1){\n\t System.out.print(\" \");\n\t}\n }\n System.out.println();\n \n System.out.println(c);\n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"List<Integer> numList = new ArrayList<Integer>();",
"numList",
"new ArrayList<Integer>()",
"for (int i = 0; i < n; i++) {\n numList.add(scanner.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n numList.add(scanner.nextInt());\n }",
"{\n numList.add(scanner.nextInt());\n }",
"numList.add(scanner.nextInt())",
"numList.add",
"numList",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"scanner.close()",
"scanner.close",
"scanner",
"int flag = 1;",
"flag",
"1",
"int c = 0;",
"c",
"0",
"while (flag == 1){\n flag = 0;\n for(int j = n-1; j >= 1; j--){\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }\n }",
"flag == 1",
"flag",
"1",
"{\n flag = 0;\n for(int j = n-1; j >= 1; j--){\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }\n }",
"flag = 0",
"flag",
"0",
"for(int j = n-1; j >= 1; j--){\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }",
"{\n //for j が N-1 から 1 まで\n if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }\n }",
"if(numList.get(j)<numList.get(j-1)){\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }",
"numList.get(j)<numList.get(j-1)",
"numList.get(j)",
"numList.get",
"numList",
"j",
"numList.get(j-1)",
"numList.get",
"numList",
"j-1",
"j",
"1",
"{\n //if A[j] < A[j-1]\n //A[j] と A[j-1] を交換\n \n numList.add(j-1,numList.get(j));\n numList.remove(j+1);\n \n c++;\n \n flag = 1;\n }",
"numList.add(j-1,numList.get(j))",
"numList.add",
"numList",
"j-1",
"j",
"1",
"numList.get(j)",
"numList.get",
"numList",
"j",
"numList.remove(j+1)",
"numList.remove",
"numList",
"j+1",
"j",
"1",
"c++",
"c",
"flag = 1",
"flag",
"1",
"for(int i =0; i<n; i++){\n\tSystem.out.print(numList.get(i));\n\tif(i < n-1){\n\t System.out.print(\" \");\n\t}\n }",
"int i =0;",
"int i =0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\tSystem.out.print(numList.get(i));\n\tif(i < n-1){\n\t System.out.print(\" \");\n\t}\n }",
"{\n\tSystem.out.print(numList.get(i));\n\tif(i < n-1){\n\t System.out.print(\" \");\n\t}\n }",
"System.out.print(numList.get(i))",
"System.out.print",
"System.out",
"System",
"System.out",
"numList.get(i)",
"numList.get",
"numList",
"i",
"if(i < n-1){\n\t System.out.print(\" \");\n\t}",
"i < n-1",
"i",
"n-1",
"n",
"1",
"{\n\t System.out.print(\" \");\n\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(c)",
"System.out.println",
"System.out",
"System",
"System.out",
"c",
"String[] args",
"args"
] | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// 標準入力の読み込み開始
Scanner scanner = new Scanner(System.in);
// 数列の長さ
int n = scanner.nextInt();
// 数列
List<Integer> numList = new ArrayList<Integer>();
for (int i = 0; i < n; i++) {
numList.add(scanner.nextInt());
}
// 標準入力の読み込み終了
scanner.close();
// 処理実行
int flag = 1; // 逆の隣接要素が存在する
int c = 0; //カウンタ
while (flag == 1){
flag = 0;
for(int j = n-1; j >= 1; j--){
//for j が N-1 から 1 まで
if(numList.get(j)<numList.get(j-1)){
//if A[j] < A[j-1]
//A[j] と A[j-1] を交換
numList.add(j-1,numList.get(j));
numList.remove(j+1);
c++;
flag = 1;
}
}
}
for(int i =0; i<n; i++){
System.out.print(numList.get(i));
if(i < n-1){
System.out.print(" ");
}
}
System.out.println();
System.out.println(c);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
0,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
4,
18,
13,
2,
13,
17,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
2,
13,
17,
4,
18,
13,
2,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
4,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
160,
5
],
[
160,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
8,
16
],
[
16,
17
],
[
16,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
8,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
27,
32
],
[
32,
33
],
[
32,
34
],
[
27,
35
],
[
35,
36
],
[
36,
37
],
[
27,
38
],
[
39,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
43,
44
],
[
44,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
46,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
61,
68
],
[
68,
69
],
[
68,
70
],
[
61,
71
],
[
71,
72
],
[
72,
73
],
[
61,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
81,
83
],
[
77,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
76,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
94,
96
],
[
88,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
88,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
107,
111
],
[
88,
112
],
[
112,
113
],
[
8,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
121,
123
],
[
114,
124
],
[
124,
125
],
[
125,
126
],
[
114,
127
],
[
128,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
129,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
134,
139
],
[
8,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
146,
147
],
[
145,
148
],
[
148,
149
],
[
148,
150
],
[
8,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
6,
157
],
[
157,
158
],
[
0,
159
],
[
159,
160
],
[
159,
161
]
] | [
"import java.util.*;\n\npublic class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, temp, cnt = 0;\n\t\tArrayList<Integer> A = new ArrayList<Integer>();\n\t\t\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}\n\t\tSystem.out.println(A.get(n-1));\n\t\tSystem.out.println(cnt);\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, temp, cnt = 0;\n\t\tArrayList<Integer> A = new ArrayList<Integer>();\n\t\t\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}\n\t\tSystem.out.println(A.get(n-1));\n\t\tSystem.out.println(cnt);\n\t}\n}",
"Main",
"public static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, temp, cnt = 0;\n\t\tArrayList<Integer> A = new ArrayList<Integer>();\n\t\t\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}\n\t\tSystem.out.println(A.get(n-1));\n\t\tSystem.out.println(cnt);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, temp, cnt = 0;\n\t\tArrayList<Integer> A = new ArrayList<Integer>();\n\t\t\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}\n\t\tSystem.out.println(A.get(n-1));\n\t\tSystem.out.println(cnt);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n",
"n",
"temp",
"temp",
"cnt = 0;",
"cnt",
"0",
"ArrayList<Integer> A = new ArrayList<Integer>();",
"A",
"new ArrayList<Integer>()",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i = 0; i < n; i++){\n\t\t\tA.add(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tA.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tA.add(sc.nextInt());\n\t\t}",
"A.add(sc.nextInt())",
"A.add",
"A",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i = 0; i < n - 1; i++){\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}",
"if(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}",
"A.get(j - 1) > A.get(j)",
"A.get(j - 1)",
"A.get",
"A",
"j - 1",
"j",
"1",
"A.get(j)",
"A.get",
"A",
"j",
"{\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}",
"temp = A.get(j - 1)",
"temp",
"A.get(j - 1)",
"A.get",
"A",
"j - 1",
"j",
"1",
"A.set(j - 1, A.get(j))",
"A.set",
"A",
"j - 1",
"j",
"1",
"A.get(j)",
"A.get",
"A",
"j",
"A.set(j, temp)",
"A.set",
"A",
"j",
"temp",
"cnt ++",
"cnt",
"for(int i = 0; i < n - 1; i++){\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}",
"{\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}",
"System.out.print(A.get(i) + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"A.get(i) + \" \"",
"A.get(i)",
"A.get",
"A",
"i",
"\" \"",
"System.out.println(A.get(n-1))",
"System.out.println",
"System.out",
"System",
"System.out",
"A.get(n-1)",
"A.get",
"A",
"n-1",
"n",
"1",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String args[]",
"args",
"public class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, temp, cnt = 0;\n\t\tArrayList<Integer> A = new ArrayList<Integer>();\n\t\t\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}\n\t\tSystem.out.println(A.get(n-1));\n\t\tSystem.out.println(cnt);\n\t}\n}",
"public class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, temp, cnt = 0;\n\t\tArrayList<Integer> A = new ArrayList<Integer>();\n\t\t\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tfor(int j = n - 1; j > i; j--){\n\t\t\t\tif(A.get(j - 1) > A.get(j)){\n\t\t\t\t\ttemp = A.get(j - 1);\n\t\t\t\t\tA.set(j - 1, A.get(j));\n\t\t\t\t\tA.set(j, temp);\n\t\t\t\t\tcnt ++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n - 1; i++){\n\t\t\tSystem.out.print(A.get(i) + \" \");\n\t\t}\n\t\tSystem.out.println(A.get(n-1));\n\t\tSystem.out.println(cnt);\n\t}\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n, temp, cnt = 0;
ArrayList<Integer> A = new ArrayList<Integer>();
n = sc.nextInt();
for(int i = 0; i < n; i++){
A.add(sc.nextInt());
}
for(int i = 0; i < n - 1; i++){
for(int j = n - 1; j > i; j--){
if(A.get(j - 1) > A.get(j)){
temp = A.get(j - 1);
A.set(j - 1, A.get(j));
A.set(j, temp);
cnt ++;
}
}
}
for(int i = 0; i < n - 1; i++){
System.out.print(A.get(i) + " ");
}
System.out.println(A.get(n-1));
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
38,
5,
13,
30,
4,
18,
13,
30,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
12,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
22,
25
],
[
25,
26
],
[
26,
27
],
[
19,
28
],
[
28,
29
],
[
28,
30
],
[
19,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
34,
39
],
[
19,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
40,
45
],
[
45,
46
],
[
45,
47
],
[
40,
48
],
[
48,
49
],
[
49,
50
],
[
40,
51
],
[
52,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
60,
62
],
[
19,
63
],
[
63,
64
],
[
63,
65
],
[
63,
66
],
[
6,
67
],
[
67,
68
],
[
4,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
71,
77
],
[
77,
78
],
[
77,
79
],
[
71,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
86,
93
],
[
93,
94
],
[
93,
95
],
[
86,
96
],
[
96,
97
],
[
97,
98
],
[
86,
99
],
[
100,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
101,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
123,
125
],
[
111,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
129,
131
],
[
126,
132
],
[
111,
133
],
[
133,
134
],
[
111,
135
],
[
135,
136
],
[
135,
137
],
[
71,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
138,
143
],
[
143,
144
],
[
143,
145
],
[
138,
146
],
[
146,
147
],
[
147,
148
],
[
138,
149
],
[
150,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
154,
156
],
[
151,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
163,
164
],
[
163,
165
],
[
151,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
167,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
71,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
177,
182
],
[
69,
183
],
[
183,
184
],
[
69,
185
],
[
185,
186
]
] | [
"// ALDS1_2_A Bubble Sort\nimport java.io.*;\n\nclass Main {\n public static void main(String[] args) {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n try {\n int N = Integer.parseInt(br.readLine());\n int[] A = new int[N];\n String[] inputAry = br.readLine().split(\" \");\n for (int i = 0; i < N; i++) {\n A[i] = Integer.parseInt(inputAry[i]);\n }\n bubblesort(A, N);\n }\n catch (Exception e) {\n e.printStackTrace();\n }\n }\n static void bubblesort(int[] A, int N) {\n int cnt = 0;\n int tmp;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int j = N - 1; j >= 1; j--){\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < N; i++) {\n if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }\n }\n System.out.println(cnt);\n }\n}",
"import java.io.*;",
"io.*",
"java",
"class Main {\n public static void main(String[] args) {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n try {\n int N = Integer.parseInt(br.readLine());\n int[] A = new int[N];\n String[] inputAry = br.readLine().split(\" \");\n for (int i = 0; i < N; i++) {\n A[i] = Integer.parseInt(inputAry[i]);\n }\n bubblesort(A, N);\n }\n catch (Exception e) {\n e.printStackTrace();\n }\n }\n static void bubblesort(int[] A, int N) {\n int cnt = 0;\n int tmp;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int j = N - 1; j >= 1; j--){\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < N; i++) {\n if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }\n }\n System.out.println(cnt);\n }\n}",
"Main",
"public static void main(String[] args) {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n try {\n int N = Integer.parseInt(br.readLine());\n int[] A = new int[N];\n String[] inputAry = br.readLine().split(\" \");\n for (int i = 0; i < N; i++) {\n A[i] = Integer.parseInt(inputAry[i]);\n }\n bubblesort(A, N);\n }\n catch (Exception e) {\n e.printStackTrace();\n }\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n try {\n int N = Integer.parseInt(br.readLine());\n int[] A = new int[N];\n String[] inputAry = br.readLine().split(\" \");\n for (int i = 0; i < N; i++) {\n A[i] = Integer.parseInt(inputAry[i]);\n }\n bubblesort(A, N);\n }\n catch (Exception e) {\n e.printStackTrace();\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"try {\n int N = Integer.parseInt(br.readLine());\n int[] A = new int[N];\n String[] inputAry = br.readLine().split(\" \");\n for (int i = 0; i < N; i++) {\n A[i] = Integer.parseInt(inputAry[i]);\n }\n bubblesort(A, N);\n }\n catch (Exception e) {\n e.printStackTrace();\n }",
"catch (Exception e) {\n e.printStackTrace();\n }",
"Exception e",
"{\n e.printStackTrace();\n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n int N = Integer.parseInt(br.readLine());\n int[] A = new int[N];\n String[] inputAry = br.readLine().split(\" \");\n for (int i = 0; i < N; i++) {\n A[i] = Integer.parseInt(inputAry[i]);\n }\n bubblesort(A, N);\n }",
"int N = Integer.parseInt(br.readLine());",
"N",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"int[] A = new int[N];",
"A",
"new int[N]",
"N",
"String[] inputAry = br.readLine().split(\" \");",
"inputAry",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for (int i = 0; i < N; i++) {\n A[i] = Integer.parseInt(inputAry[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n A[i] = Integer.parseInt(inputAry[i]);\n }",
"{\n A[i] = Integer.parseInt(inputAry[i]);\n }",
"A[i] = Integer.parseInt(inputAry[i])",
"A[i]",
"A",
"i",
"Integer.parseInt(inputAry[i])",
"Integer.parseInt",
"Integer",
"inputAry[i]",
"inputAry",
"i",
"bubblesort(A, N)",
"bubblesort",
"A",
"N",
"String[] args",
"args",
"static void bubblesort(int[] A, int N) {\n int cnt = 0;\n int tmp;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int j = N - 1; j >= 1; j--){\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < N; i++) {\n if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }\n }\n System.out.println(cnt);\n }",
"bubblesort",
"{\n int cnt = 0;\n int tmp;\n boolean flag = true;\n while (flag) {\n flag = false;\n for (int j = N - 1; j >= 1; j--){\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }\n }\n for (int i = 0; i < N; i++) {\n if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }\n }\n System.out.println(cnt);\n }",
"int cnt = 0;",
"cnt",
"0",
"int tmp;",
"tmp",
"boolean flag = true;",
"flag",
"true",
"while (flag) {\n flag = false;\n for (int j = N - 1; j >= 1; j--){\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }\n }",
"flag",
"{\n flag = false;\n for (int j = N - 1; j >= 1; j--){\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for (int j = N - 1; j >= 1; j--){\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }",
"int j = N - 1;",
"int j = N - 1;",
"j",
"N - 1",
"N",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }",
"{\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }\n }",
"if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }",
"A[j] < A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"{\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n cnt++;\n flag = true;\n }",
"tmp = A[j]",
"tmp",
"A[j]",
"A",
"j",
"A[j] = A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"A[j - 1] = tmp",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"tmp",
"cnt++",
"cnt",
"flag = true",
"flag",
"true",
"for (int i = 0; i < N; i++) {\n if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }\n }",
"{\n if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }\n }",
"if (i == N - 1) {\n System.out.println(A[i]);\n } else {\n System.out.print(A[i] + \" \");\n }",
"i == N - 1",
"i",
"N - 1",
"N",
"1",
"{\n System.out.println(A[i]);\n }",
"System.out.println(A[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"{\n System.out.print(A[i] + \" \");\n }",
"System.out.print(A[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i] + \" \"",
"A[i]",
"A",
"i",
"\" \"",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"int[] A",
"A",
"int N",
"N"
] | // ALDS1_2_A Bubble Sort
import java.io.*;
class Main {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
int N = Integer.parseInt(br.readLine());
int[] A = new int[N];
String[] inputAry = br.readLine().split(" ");
for (int i = 0; i < N; i++) {
A[i] = Integer.parseInt(inputAry[i]);
}
bubblesort(A, N);
}
catch (Exception e) {
e.printStackTrace();
}
}
static void bubblesort(int[] A, int N) {
int cnt = 0;
int tmp;
boolean flag = true;
while (flag) {
flag = false;
for (int j = N - 1; j >= 1; j--){
if (A[j] < A[j - 1]) {
tmp = A[j];
A[j] = A[j - 1];
A[j - 1] = tmp;
cnt++;
flag = true;
}
}
}
for (int i = 0; i < N; i++) {
if (i == N - 1) {
System.out.println(A[i]);
} else {
System.out.print(A[i] + " ");
}
}
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
154,
5
],
[
154,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
57,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
57,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
72,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
82,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
82,
104
],
[
104,
105
],
[
8,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
111,
112
],
[
111,
113
],
[
106,
114
],
[
114,
115
],
[
115,
116
],
[
106,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
124,
125
],
[
124,
126
],
[
118,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
130,
132
],
[
127,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
8,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
8,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
6,
151
],
[
151,
152
],
[
0,
153
],
[
153,
154
],
[
153,
155
]
] | [
"\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint ct = 0;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(ct);\n\t}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint ct = 0;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(ct);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint ct = 0;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(ct);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint ct = 0;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(ct);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] A = new int[N];",
"A",
"new int[N]",
"N",
"for (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int ct = 0;",
"ct",
"0",
"for (int i = 0; i < N; i++) {\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}",
"int j = N - 1;",
"int j = N - 1;",
"j",
"N - 1",
"N",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}",
"if (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}",
"A[j] < A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}",
"int k = A[j];",
"k",
"A[j]",
"A",
"j",
"A[j] = A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"A[j - 1] = k",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"k",
"ct++",
"ct",
"for (int i = 0; i < N; i++) {\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"if (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"i < N - 1",
"i",
"N - 1",
"N",
"1",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(ct)",
"System.out.println",
"System.out",
"System",
"System.out",
"ct",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint ct = 0;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(ct);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint ct = 0;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = N - 1; j > 0; j--) {\n\t\t\t\tif (A[j] < A[j - 1]) {\n\t\t\t\t\tint k = A[j];\n\t\t\t\t\tA[j] = A[j - 1];\n\t\t\t\t\tA[j - 1] = k;\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tSystem.out.print(A[i]);\n\t\t\tif (i < N - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(ct);\n\t}\n}",
"Main"
] |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextInt();
}
int ct = 0;
for (int i = 0; i < N; i++) {
for (int j = N - 1; j > 0; j--) {
if (A[j] < A[j - 1]) {
int k = A[j];
A[j] = A[j - 1];
A[j - 1] = k;
ct++;
}
}
}
for (int i = 0; i < N; i++) {
System.out.print(A[i]);
if (i < N - 1) {
System.out.print(" ");
}
}
System.out.println();
System.out.println(ct);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
42,
2,
13,
18,
13,
13,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
17,
40,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
40,
13,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
13,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
184,
5
],
[
184,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
15,
17
],
[
12,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
19,
24
],
[
24,
25
],
[
24,
26
],
[
18,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
30,
34
],
[
27,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
36,
41
],
[
27,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
18,
49
],
[
49,
50
],
[
6,
51
],
[
51,
52
],
[
184,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
55,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
69,
70
],
[
69,
71
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
77,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
77,
89
],
[
89,
90
],
[
90,
91
],
[
77,
92
],
[
93,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
94,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
104,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
114,
120
],
[
120,
121
],
[
120,
122
],
[
104,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
55,
128
],
[
128,
129
],
[
53,
130
],
[
130,
131
],
[
184,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
141,
142
],
[
134,
143
],
[
143,
144
],
[
143,
145
],
[
134,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
152,
153
],
[
152,
154
],
[
147,
155
],
[
155,
156
],
[
156,
157
],
[
147,
158
],
[
159,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
164,
165
],
[
165,
166
],
[
134,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
169,
171
],
[
134,
172
],
[
172,
173
],
[
172,
174
],
[
134,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
175,
180
],
[
132,
181
],
[
181,
182
],
[
0,
183
],
[
183,
184
],
[
183,
185
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void print_arr(int[] arr) {\n\t\tint i = 0;\n\t\twhile(i < arr.length) {\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\tpublic static int bubble_sort(int[] arr) {\n\t\tint swap_times = 0;\n\t\tint n = arr.length;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\treturn swap_times;\n\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\t\n\t\tint n = cin.nextInt();\n\t\tint [] arr = new int[n];\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tarr[i] = cin.nextInt();\n\t\t}\n\t\t\n\t\tint swap_times = bubble_sort(arr);\n\t\tprint_arr(arr);\n\t\tSystem.out.println(swap_times);\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void print_arr(int[] arr) {\n\t\tint i = 0;\n\t\twhile(i < arr.length) {\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\tpublic static int bubble_sort(int[] arr) {\n\t\tint swap_times = 0;\n\t\tint n = arr.length;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\treturn swap_times;\n\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\t\n\t\tint n = cin.nextInt();\n\t\tint [] arr = new int[n];\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tarr[i] = cin.nextInt();\n\t\t}\n\t\t\n\t\tint swap_times = bubble_sort(arr);\n\t\tprint_arr(arr);\n\t\tSystem.out.println(swap_times);\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n}",
"Main",
"public static void print_arr(int[] arr) {\n\t\tint i = 0;\n\t\twhile(i < arr.length) {\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}",
"print_arr",
"{\n\t\tint i = 0;\n\t\twhile(i < arr.length) {\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}",
"int i = 0;",
"i",
"0",
"while(i < arr.length) {\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}",
"i < arr.length",
"i",
"arr.length",
"arr",
"arr.length",
"{\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}",
"System.out.print(arr[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"arr[i]",
"arr",
"i",
"if(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}",
"i < arr.length - 1",
"i",
"arr.length - 1",
"arr.length",
"arr",
"arr.length",
"1",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"{\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"i++",
"i",
"int[] arr",
"arr",
"public static int bubble_sort(int[] arr) {\n\t\tint swap_times = 0;\n\t\tint n = arr.length;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\treturn swap_times;\n\t\t\n\t}",
"bubble_sort",
"{\n\t\tint swap_times = 0;\n\t\tint n = arr.length;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\treturn swap_times;\n\t\t\n\t}",
"int swap_times = 0;",
"swap_times",
"0",
"int n = arr.length;",
"n",
"arr.length",
"arr",
"arr.length",
"for(int i = 0; i < n; i++) {\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j >= i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}",
"if(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}",
"arr[j] < arr[j-1]",
"arr[j]",
"arr",
"j",
"arr[j-1]",
"arr",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}",
"swap_times++",
"swap_times",
"int tmp = arr[j-1];",
"tmp",
"arr[j-1]",
"arr",
"j-1",
"j",
"1",
"arr[j-1] = arr[j]",
"arr[j-1]",
"arr",
"j-1",
"j",
"1",
"arr[j]",
"arr",
"j",
"arr[j] = tmp",
"arr[j]",
"arr",
"j",
"tmp",
"return swap_times;",
"swap_times",
"int[] arr",
"arr",
"public static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\t\n\t\tint n = cin.nextInt();\n\t\tint [] arr = new int[n];\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tarr[i] = cin.nextInt();\n\t\t}\n\t\t\n\t\tint swap_times = bubble_sort(arr);\n\t\tprint_arr(arr);\n\t\tSystem.out.println(swap_times);\n\t\t\n\t\t\n\t\t\n\t\t\n\t}",
"main",
"{\n\t\tScanner cin = new Scanner(System.in);\n\t\t\n\t\tint n = cin.nextInt();\n\t\tint [] arr = new int[n];\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tarr[i] = cin.nextInt();\n\t\t}\n\t\t\n\t\tint swap_times = bubble_sort(arr);\n\t\tprint_arr(arr);\n\t\tSystem.out.println(swap_times);\n\t\t\n\t\t\n\t\t\n\t\t\n\t}",
"Scanner cin = new Scanner(System.in);",
"cin",
"new Scanner(System.in)",
"int n = cin.nextInt();",
"n",
"cin.nextInt()",
"cin.nextInt",
"cin",
"int [] arr = new int[n];",
"arr",
"new int[n]",
"n",
"for(int i = 0; i < n ; i++) {\n\t\t\tarr[i] = cin.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i] = cin.nextInt();\n\t\t}",
"{\n\t\t\tarr[i] = cin.nextInt();\n\t\t}",
"arr[i] = cin.nextInt()",
"arr[i]",
"arr",
"i",
"cin.nextInt()",
"cin.nextInt",
"cin",
"int swap_times = bubble_sort(arr);",
"swap_times",
"bubble_sort(arr)",
"bubble_sort",
"arr",
"print_arr(arr)",
"print_arr",
"arr",
"System.out.println(swap_times)",
"System.out.println",
"System.out",
"System",
"System.out",
"swap_times",
"String[] args",
"args",
"public class Main {\n\tpublic static void print_arr(int[] arr) {\n\t\tint i = 0;\n\t\twhile(i < arr.length) {\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\tpublic static int bubble_sort(int[] arr) {\n\t\tint swap_times = 0;\n\t\tint n = arr.length;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\treturn swap_times;\n\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\t\n\t\tint n = cin.nextInt();\n\t\tint [] arr = new int[n];\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tarr[i] = cin.nextInt();\n\t\t}\n\t\t\n\t\tint swap_times = bubble_sort(arr);\n\t\tprint_arr(arr);\n\t\tSystem.out.println(swap_times);\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n}",
"public class Main {\n\tpublic static void print_arr(int[] arr) {\n\t\tint i = 0;\n\t\twhile(i < arr.length) {\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i < arr.length - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\tpublic static int bubble_sort(int[] arr) {\n\t\tint swap_times = 0;\n\t\tint n = arr.length;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tfor(int j = n - 1; j >= i+1; j--) {\n\t\t\t\t// do swapping\n\t\t\t\tif(arr[j] < arr[j-1]) {\n\t\t\t\t\tswap_times++;\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\treturn swap_times;\n\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\t\n\t\tint n = cin.nextInt();\n\t\tint [] arr = new int[n];\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tarr[i] = cin.nextInt();\n\t\t}\n\t\t\n\t\tint swap_times = bubble_sort(arr);\n\t\tprint_arr(arr);\n\t\tSystem.out.println(swap_times);\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void print_arr(int[] arr) {
int i = 0;
while(i < arr.length) {
System.out.print(arr[i]);
if(i < arr.length - 1) {
System.out.print(" ");
}else {
System.out.print("\n");
}
i++;
}
}
public static int bubble_sort(int[] arr) {
int swap_times = 0;
int n = arr.length;
for(int i = 0; i < n; i++) {
for(int j = n - 1; j >= i+1; j--) {
// do swapping
if(arr[j] < arr[j-1]) {
swap_times++;
int tmp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = tmp;
}
}
}
return swap_times;
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int [] arr = new int[n];
for(int i = 0; i < n ; i++) {
arr[i] = cin.nextInt();
}
int swap_times = bubble_sort(arr);
print_arr(arr);
System.out.println(swap_times);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
17,
41,
13,
20,
17,
41,
13,
20,
0,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
4,
13,
13,
13,
4,
13,
13,
13,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
29,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
187,
5
],
[
187,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
11,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
8,
18
],
[
18,
19
],
[
18,
20
],
[
8,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
8,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
26,
31
],
[
31,
32
],
[
31,
33
],
[
26,
34
],
[
34,
35
],
[
35,
36
],
[
26,
37
],
[
38,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
44,
45
],
[
8,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
48,
50
],
[
48,
51
],
[
8,
52
],
[
52,
53
],
[
52,
54
],
[
52,
55
],
[
52,
56
],
[
6,
57
],
[
57,
58
],
[
187,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
62,
67
],
[
67,
68
],
[
67,
69
],
[
62,
70
],
[
70,
71
],
[
71,
72
],
[
62,
73
],
[
74,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
74,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
85,
90
],
[
90,
91
],
[
90,
92
],
[
61,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
61,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
59,
104
],
[
104,
105
],
[
59,
106
],
[
106,
107
],
[
59,
108
],
[
108,
109
],
[
187,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
123,
125
],
[
116,
126
],
[
126,
127
],
[
127,
128
],
[
116,
129
],
[
130,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
131,
138
],
[
138,
139
],
[
138,
140
],
[
131,
141
],
[
141,
142
],
[
142,
143
],
[
131,
144
],
[
145,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
153,
155
],
[
146,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
156,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
167,
169
],
[
164,
170
],
[
170,
171
],
[
170,
172
],
[
156,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
156,
178
],
[
178,
179
],
[
112,
180
],
[
180,
181
],
[
110,
182
],
[
182,
183
],
[
110,
184
],
[
184,
185
],
[
0,
186
],
[
186,
187
],
[
186,
188
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tint N, k = 0;\n\t\tint[] A = new int[100];\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tN = stdIn.nextInt();\n\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}\n\n\t\tk = bubbleSort(N, A);\n\t\ttrace(N, A, k);\n\t}\n\n\tpublic static void trace(int N, int[] A, int k){\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(k);\n\t}\n\n\tpublic static int bubbleSort(int N, int[] A){\n\t\tint k = 0;\n\t\tfor(int i = 0; i < N - 1; i++){\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn k;\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tint N, k = 0;\n\t\tint[] A = new int[100];\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tN = stdIn.nextInt();\n\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}\n\n\t\tk = bubbleSort(N, A);\n\t\ttrace(N, A, k);\n\t}\n\n\tpublic static void trace(int N, int[] A, int k){\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(k);\n\t}\n\n\tpublic static int bubbleSort(int N, int[] A){\n\t\tint k = 0;\n\t\tfor(int i = 0; i < N - 1; i++){\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn k;\n\t}\n\n}",
"Main",
"public static void main(String[] args){\n\t\tint N, k = 0;\n\t\tint[] A = new int[100];\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tN = stdIn.nextInt();\n\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}\n\n\t\tk = bubbleSort(N, A);\n\t\ttrace(N, A, k);\n\t}",
"main",
"{\n\t\tint N, k = 0;\n\t\tint[] A = new int[100];\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tN = stdIn.nextInt();\n\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}\n\n\t\tk = bubbleSort(N, A);\n\t\ttrace(N, A, k);\n\t}",
"int N",
"N",
"k = 0;",
"k",
"0",
"int[] A = new int[100];",
"A",
"new int[100]",
"100",
"Scanner stdIn = new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"N = stdIn.nextInt()",
"N",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"for(int i = 0; i < N; i++){\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}",
"A[i] = stdIn.nextInt()",
"A[i]",
"A",
"i",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"k = bubbleSort(N, A)",
"k",
"bubbleSort(N, A)",
"bubbleSort",
"N",
"A",
"trace(N, A, k)",
"trace",
"N",
"A",
"k",
"String[] args",
"args",
"public static void trace(int N, int[] A, int k){\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(k);\n\t}",
"trace",
"{\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(k);\n\t}",
"for(int i = 0; i < N; i++){\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"{\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}",
"if(i > 0)\tSystem.out.print(\" \");",
"i > 0",
"i",
"0",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(k)",
"System.out.println",
"System.out",
"System",
"System.out",
"k",
"int N",
"N",
"int[] A",
"A",
"int k",
"k",
"public static int bubbleSort(int N, int[] A){\n\t\tint k = 0;\n\t\tfor(int i = 0; i < N - 1; i++){\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn k;\n\t}",
"bubbleSort",
"{\n\t\tint k = 0;\n\t\tfor(int i = 0; i < N - 1; i++){\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn k;\n\t}",
"int k = 0;",
"k",
"0",
"for(int i = 0; i < N - 1; i++){\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N - 1",
"i",
"N - 1",
"N",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}",
"int j = N - 1;",
"int j = N - 1;",
"j",
"N - 1",
"N",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}",
"if(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}",
"A[j] < A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}",
"int tmp = A[j - 1];",
"tmp",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"A[j - 1] = A[j]",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"A[j]",
"A",
"j",
"A[j] = tmp",
"A[j]",
"A",
"j",
"tmp",
"k++",
"k",
"return k;",
"k",
"int N",
"N",
"int[] A",
"A",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tint N, k = 0;\n\t\tint[] A = new int[100];\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tN = stdIn.nextInt();\n\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}\n\n\t\tk = bubbleSort(N, A);\n\t\ttrace(N, A, k);\n\t}\n\n\tpublic static void trace(int N, int[] A, int k){\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(k);\n\t}\n\n\tpublic static int bubbleSort(int N, int[] A){\n\t\tint k = 0;\n\t\tfor(int i = 0; i < N - 1; i++){\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn k;\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tint N, k = 0;\n\t\tint[] A = new int[100];\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tN = stdIn.nextInt();\n\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tA[i] = stdIn.nextInt();\n\t\t}\n\n\t\tk = bubbleSort(N, A);\n\t\ttrace(N, A, k);\n\t}\n\n\tpublic static void trace(int N, int[] A, int k){\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif(i > 0)\tSystem.out.print(\" \");\n\t\t\tSystem.out.print(A[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(k);\n\t}\n\n\tpublic static int bubbleSort(int N, int[] A){\n\t\tint k = 0;\n\t\tfor(int i = 0; i < N - 1; i++){\n\t\t\tfor(int j = N - 1; j > i; j--){\n\t\t\t\tif(A[j] < A[j - 1]){\n\t\t\t\t\tint tmp = A[j - 1];\n\t\t\t\t\tA[j - 1] = A[j];\n\t\t\t\t\tA[j] = tmp;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn k;\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args){
int N, k = 0;
int[] A = new int[100];
Scanner stdIn = new Scanner(System.in);
N = stdIn.nextInt();
for(int i = 0; i < N; i++){
A[i] = stdIn.nextInt();
}
k = bubbleSort(N, A);
trace(N, A, k);
}
public static void trace(int N, int[] A, int k){
for(int i = 0; i < N; i++){
if(i > 0) System.out.print(" ");
System.out.print(A[i]);
}
System.out.println();
System.out.println(k);
}
public static int bubbleSort(int N, int[] A){
int k = 0;
for(int i = 0; i < N - 1; i++){
for(int j = N - 1; j > i; j--){
if(A[j] < A[j - 1]){
int tmp = A[j - 1];
A[j - 1] = A[j];
A[j] = tmp;
k++;
}
}
}
return k;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
17,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
17,
40,
13,
23,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
0,
13,
4,
18,
13,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
4,
13,
13,
4,
18,
18,
13,
13,
4,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
211,
5
],
[
211,
6
],
[
6,
7
],
[
6,
8
],
[
211,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
15,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
27,
29
],
[
23,
30
],
[
30,
31
],
[
30,
32
],
[
23,
33
],
[
33,
34
],
[
34,
35
],
[
23,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
45,
47
],
[
38,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
48,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
48,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
48,
90
],
[
90,
91
],
[
90,
92
],
[
48,
93
],
[
93,
94
],
[
9,
95
],
[
95,
96
],
[
9,
97
],
[
97,
98
],
[
211,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
102,
112
],
[
112,
113
],
[
113,
114
],
[
102,
115
],
[
116,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
117,
122
],
[
122,
123
],
[
122,
124
],
[
116,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
125,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
101,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
99,
144
],
[
144,
145
],
[
211,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
211,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
153,
157
],
[
157,
158
],
[
157,
159
],
[
153,
160
],
[
160,
161
],
[
153,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
153,
167
],
[
167,
168
],
[
167,
169
],
[
153,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
171,
176
],
[
176,
177
],
[
176,
178
],
[
171,
179
],
[
179,
180
],
[
180,
181
],
[
171,
182
],
[
183,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
188,
189
],
[
189,
190
],
[
153,
191
],
[
191,
192
],
[
191,
193
],
[
191,
194
],
[
153,
195
],
[
195,
196
],
[
195,
197
],
[
153,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
198,
203
],
[
203,
204
],
[
153,
205
],
[
205,
206
],
[
206,
207
],
[
151,
208
],
[
208,
209
],
[
0,
210
],
[
210,
211
],
[
210,
212
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\t// define variables & initialize\n\tprivate static int cnt = 0;\t// how many bubbleSort is used\n\t\n\t// sort method :: sort given array using insertion Sort\n\tpublic static void sort(int[] _A, int _n) {\n\t\tint flg = 1;\n\t\twhile (flg != 0) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\t// print method :: print array\n\tpublic static void print(int[] _A) {\n\t\tfor (int i = 0; i < _A.length; ++i) {\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println();\n\t}\n\t\n\t// get method :: get cnt (how many bubbleSort was used)\n\tpublic static int get() {\n\t\treturn cnt;\n\t}\npublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t////////////////////////////////////\n\t\tint n = 0;\n\t\tint[] A;\n\t\t\n\t\tn = sc.nextInt();\n\t\tA = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tsort(A, n);\n\t\tprint(A);\n\t\tSystem.out.println(get());\n\t\t\n\t\t////////////////////////////////////\n\t\tsc.close();\n\t}\n\n\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\t// define variables & initialize\n\tprivate static int cnt = 0;\t// how many bubbleSort is used\n\t\n\t// sort method :: sort given array using insertion Sort\n\tpublic static void sort(int[] _A, int _n) {\n\t\tint flg = 1;\n\t\twhile (flg != 0) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\t// print method :: print array\n\tpublic static void print(int[] _A) {\n\t\tfor (int i = 0; i < _A.length; ++i) {\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println();\n\t}\n\t\n\t// get method :: get cnt (how many bubbleSort was used)\n\tpublic static int get() {\n\t\treturn cnt;\n\t}\npublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t////////////////////////////////////\n\t\tint n = 0;\n\t\tint[] A;\n\t\t\n\t\tn = sc.nextInt();\n\t\tA = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tsort(A, n);\n\t\tprint(A);\n\t\tSystem.out.println(get());\n\t\t\n\t\t////////////////////////////////////\n\t\tsc.close();\n\t}\n\n\n\n}",
"Main",
"// define variables & initialize\n\tprivate static int cnt = 0;\t// how many bubbleSort is used",
"cnt",
"0",
"// sort method :: sort given array using insertion Sort\n\tpublic static void sort(int[] _A, int _n) {\n\t\tint flg = 1;\n\t\twhile (flg != 0) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"sort",
"{\n\t\tint flg = 1;\n\t\twhile (flg != 0) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"int flg = 1;",
"flg",
"1",
"while (flg != 0) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg != 0",
"flg",
"0",
"{\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg = 0",
"flg",
"0",
"for (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}",
"int i = _n - 1;",
"int i = _n - 1;",
"i",
"_n - 1",
"_n",
"1",
"i >= 1",
"i",
"1",
"--i",
"--i",
"i",
"{\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}",
"if (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}",
"_A[i] < _A[i - 1]",
"_A[i]",
"_A",
"i",
"_A[i - 1]",
"_A",
"i - 1",
"i",
"1",
"{\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}",
"_A[i] = _A[i] ^ _A[i - 1]",
"_A[i]",
"_A",
"i",
"_A[i] ^ _A[i - 1]",
"_A[i]",
"_A",
"i",
"_A[i - 1]",
"_A",
"i - 1",
"i",
"1",
"_A[i - 1] = _A[i] ^ _A[i - 1]",
"_A[i - 1]",
"_A",
"i - 1",
"i",
"1",
"_A[i] ^ _A[i - 1]",
"_A[i]",
"_A",
"i",
"_A[i - 1]",
"_A",
"i - 1",
"i",
"1",
"_A[i] = _A[i] ^ _A[i - 1]",
"_A[i]",
"_A",
"i",
"_A[i] ^ _A[i - 1]",
"_A[i]",
"_A",
"i",
"_A[i - 1]",
"_A",
"i - 1",
"i",
"1",
"flg = 1",
"flg",
"1",
"++cnt",
"cnt",
"int[] _A",
"_A",
"int _n",
"_n",
"// print method :: print array\n\tpublic static void print(int[] _A) {\n\t\tfor (int i = 0; i < _A.length; ++i) {\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println();\n\t}",
"print",
"{\n\t\tfor (int i = 0; i < _A.length; ++i) {\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println();\n\t}",
"for (int i = 0; i < _A.length; ++i) {\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < _A.length",
"i",
"_A.length",
"_A",
"_A.length",
"++i",
"++i",
"i",
"{\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}",
"{\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}",
"System.out.print(_A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"_A[i]",
"_A",
"i",
"if (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");",
"i != _A.length - 1",
"i",
"_A.length - 1",
"_A.length",
"_A",
"_A.length",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"int[] _A",
"_A",
"// get method :: get cnt (how many bubbleSort was used)\n\tpublic static int get() {\n\t\treturn cnt;\n\t}",
"get",
"{\n\t\treturn cnt;\n\t}",
"return cnt;",
"cnt",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t////////////////////////////////////\n\t\tint n = 0;\n\t\tint[] A;\n\t\t\n\t\tn = sc.nextInt();\n\t\tA = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tsort(A, n);\n\t\tprint(A);\n\t\tSystem.out.println(get());\n\t\t\n\t\t////////////////////////////////////\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\t////////////////////////////////////\n\t\tint n = 0;\n\t\tint[] A;\n\t\t\n\t\tn = sc.nextInt();\n\t\tA = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tsort(A, n);\n\t\tprint(A);\n\t\tSystem.out.println(get());\n\t\t\n\t\t////////////////////////////////////\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = 0;",
"n",
"0",
"int[] A;",
"A",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"A = new int[n]",
"A",
"new int[n]",
"n",
"for (int i = 0; i < n; ++i) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"++i",
"++i",
"i",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sort(A, n)",
"sort",
"A",
"n",
"print(A)",
"print",
"A",
"System.out.println(get())",
"System.out.println",
"System.out",
"System",
"System.out",
"get()",
"get",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"public class Main {\n\n\t// define variables & initialize\n\tprivate static int cnt = 0;\t// how many bubbleSort is used\n\t\n\t// sort method :: sort given array using insertion Sort\n\tpublic static void sort(int[] _A, int _n) {\n\t\tint flg = 1;\n\t\twhile (flg != 0) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\t// print method :: print array\n\tpublic static void print(int[] _A) {\n\t\tfor (int i = 0; i < _A.length; ++i) {\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println();\n\t}\n\t\n\t// get method :: get cnt (how many bubbleSort was used)\n\tpublic static int get() {\n\t\treturn cnt;\n\t}\npublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t////////////////////////////////////\n\t\tint n = 0;\n\t\tint[] A;\n\t\t\n\t\tn = sc.nextInt();\n\t\tA = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tsort(A, n);\n\t\tprint(A);\n\t\tSystem.out.println(get());\n\t\t\n\t\t////////////////////////////////////\n\t\tsc.close();\n\t}\n\n\n\n}",
"public class Main {\n\n\t// define variables & initialize\n\tprivate static int cnt = 0;\t// how many bubbleSort is used\n\t\n\t// sort method :: sort given array using insertion Sort\n\tpublic static void sort(int[] _A, int _n) {\n\t\tint flg = 1;\n\t\twhile (flg != 0) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = _n - 1; i >= 1; --i) {\n\t\t\t\tif (_A[i] < _A[i - 1]) {\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i - 1] = _A[i] ^ _A[i - 1];\n\t\t\t\t\t_A[i] = _A[i] ^ _A[i - 1];\n\t\t\t\t\tflg = 1;\n\t\t\t\t\t++cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\t// print method :: print array\n\tpublic static void print(int[] _A) {\n\t\tfor (int i = 0; i < _A.length; ++i) {\n\t\t\tSystem.out.print(_A[i]);\n\t\t\tif (i != _A.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t}\n\t\tSystem.out.println();\n\t}\n\t\n\t// get method :: get cnt (how many bubbleSort was used)\n\tpublic static int get() {\n\t\treturn cnt;\n\t}\npublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t////////////////////////////////////\n\t\tint n = 0;\n\t\tint[] A;\n\t\t\n\t\tn = sc.nextInt();\n\t\tA = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tsort(A, n);\n\t\tprint(A);\n\t\tSystem.out.println(get());\n\t\t\n\t\t////////////////////////////////////\n\t\tsc.close();\n\t}\n\n\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
// define variables & initialize
private static int cnt = 0; // how many bubbleSort is used
// sort method :: sort given array using insertion Sort
public static void sort(int[] _A, int _n) {
int flg = 1;
while (flg != 0) {
flg = 0;
for (int i = _n - 1; i >= 1; --i) {
if (_A[i] < _A[i - 1]) {
_A[i] = _A[i] ^ _A[i - 1];
_A[i - 1] = _A[i] ^ _A[i - 1];
_A[i] = _A[i] ^ _A[i - 1];
flg = 1;
++cnt;
}
}
}
}
// print method :: print array
public static void print(int[] _A) {
for (int i = 0; i < _A.length; ++i) {
System.out.print(_A[i]);
if (i != _A.length - 1)
System.out.print(" ");
}
System.out.println();
}
// get method :: get cnt (how many bubbleSort was used)
public static int get() {
return cnt;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
////////////////////////////////////
int n = 0;
int[] A;
n = sc.nextInt();
A = new int[n];
for (int i = 0; i < n; ++i) {
A[i] = sc.nextInt();
}
sort(A, n);
print(A);
System.out.println(get());
////////////////////////////////////
sc.close();
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
4,
13,
23,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
20,
17,
41,
13,
0,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
17,
0,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
166,
5
],
[
166,
6
],
[
6,
7
],
[
6,
8
],
[
166,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
9,
14
],
[
14,
15
],
[
166,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
18,
21
],
[
21,
22
],
[
18,
23
],
[
23,
24
],
[
18,
25
],
[
25,
26
],
[
25,
27
],
[
18,
29
],
[
29,
30
],
[
18,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
18,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
36,
41
],
[
41,
42
],
[
41,
43
],
[
36,
44
],
[
44,
45
],
[
45,
46
],
[
36,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
18,
56
],
[
56,
57
],
[
56,
58
],
[
18,
59
],
[
59,
60
],
[
59,
61
],
[
18,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
68,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
68,
81
],
[
82,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
83,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
93,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
108,
114
],
[
93,
115
],
[
115,
116
],
[
115,
117
],
[
93,
118
],
[
118,
119
],
[
18,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
125,
126
],
[
125,
127
],
[
120,
128
],
[
128,
129
],
[
129,
130
],
[
120,
131
],
[
132,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
133,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
145,
147
],
[
133,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
18,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
159,
164
],
[
0,
165
],
[
165,
166
],
[
165,
167
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tstatic Scanner scan = new Scanner(System.in);\n\tpublic static void main(String args[]){\n\t\trun();\n\t}\n\tstatic void run(){\n\t\t\n\t\tint n, tmp, count;\n\t\tint[] a = new int[100];\n\t\t\n\t\tboolean flag;\n\t\t\n\t\tn = scan.nextInt();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\tflag = true;\n\t\t\n\t\tcount = 0;\n\t\t\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tstatic Scanner scan = new Scanner(System.in);\n\tpublic static void main(String args[]){\n\t\trun();\n\t}\n\tstatic void run(){\n\t\t\n\t\tint n, tmp, count;\n\t\tint[] a = new int[100];\n\t\t\n\t\tboolean flag;\n\t\t\n\t\tn = scan.nextInt();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\tflag = true;\n\t\t\n\t\tcount = 0;\n\t\t\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"static Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"public static void main(String args[]){\n\t\trun();\n\t}",
"main",
"{\n\t\trun();\n\t}",
"run()",
"run",
"String args[]",
"args",
"static void run(){\n\t\t\n\t\tint n, tmp, count;\n\t\tint[] a = new int[100];\n\t\t\n\t\tboolean flag;\n\t\t\n\t\tn = scan.nextInt();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\tflag = true;\n\t\t\n\t\tcount = 0;\n\t\t\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"run",
"{\n\t\t\n\t\tint n, tmp, count;\n\t\tint[] a = new int[100];\n\t\t\n\t\tboolean flag;\n\t\t\n\t\tn = scan.nextInt();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\tflag = true;\n\t\t\n\t\tcount = 0;\n\t\t\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"int n",
"n",
"tmp",
"tmp",
"count;",
"count",
"int[] a = new int[100];",
"a",
"new int[100]",
"100",
"boolean flag;",
"flag",
"n = scan.nextInt()",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for(int i = 0; i < n; i++){\n\t\t\ta[i] = scan.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = scan.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = scan.nextInt();\n\t\t}",
"a[i] = scan.nextInt()",
"a[i]",
"a",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"flag = true",
"flag",
"true",
"count = 0",
"count",
"0",
"while(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int i = n - 1;",
"int i = n - 1;",
"i",
"n - 1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"a[i] < a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"{\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"tmp = a[i]",
"tmp",
"a[i]",
"a",
"i",
"a[i] = a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i - 1] = tmp",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"tmp",
"flag = true",
"flag",
"true",
"count++",
"count",
"for(int i = 0; i < n; i++){\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}",
"if(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}",
"i == n - 1",
"i",
"n - 1",
"n",
"1",
"{\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}",
"System.out.println(a[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}",
"System.out.print(a[i]+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]+\" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"public class Main {\n\tstatic Scanner scan = new Scanner(System.in);\n\tpublic static void main(String args[]){\n\t\trun();\n\t}\n\tstatic void run(){\n\t\t\n\t\tint n, tmp, count;\n\t\tint[] a = new int[100];\n\t\t\n\t\tboolean flag;\n\t\t\n\t\tn = scan.nextInt();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\tflag = true;\n\t\t\n\t\tcount = 0;\n\t\t\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n\tstatic Scanner scan = new Scanner(System.in);\n\tpublic static void main(String args[]){\n\t\trun();\n\t}\n\tstatic void run(){\n\t\t\n\t\tint n, tmp, count;\n\t\tint[] a = new int[100];\n\t\t\n\t\tboolean flag;\n\t\t\n\t\tn = scan.nextInt();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\tflag = true;\n\t\t\n\t\tcount = 0;\n\t\t\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = n - 1; i > 0; i--){\n\t\t\t\tif(a[i] < a[i - 1]){\n\t\t\t\t\ttmp = a[i];\n\t\t\t\t\ta[i] = a[i - 1];\n\t\t\t\t\ta[i - 1] = tmp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tif(i == n - 1){\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}else{\n\t\t\t\tSystem.out.print(a[i]+\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
static Scanner scan = new Scanner(System.in);
public static void main(String args[]){
run();
}
static void run(){
int n, tmp, count;
int[] a = new int[100];
boolean flag;
n = scan.nextInt();
for(int i = 0; i < n; i++){
a[i] = scan.nextInt();
}
flag = true;
count = 0;
while(flag){
flag = false;
for(int i = n - 1; i > 0; i--){
if(a[i] < a[i - 1]){
tmp = a[i];
a[i] = a[i - 1];
a[i - 1] = tmp;
flag = true;
count++;
}
}
}
for(int i = 0; i < n; i++){
if(i == n - 1){
System.out.println(a[i]);
}else{
System.out.print(a[i]+" ");
}
}
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
41,
13,
17,
41,
13,
17,
41,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
18,
13,
13,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
0,
13,
13,
14,
2,
13,
18,
13,
13,
30,
11,
1,
41,
13,
13,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
195,
5
],
[
195,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
8,
26
],
[
26,
27
],
[
26,
28
],
[
8,
29
],
[
29,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
48,
49
],
[
49,
50
],
[
8,
51
],
[
51,
52
],
[
52,
53
],
[
8,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
54,
64
],
[
64,
65
],
[
65,
66
],
[
54,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
74,
81
],
[
81,
82
],
[
81,
83
],
[
74,
84
],
[
84,
85
],
[
85,
86
],
[
74,
87
],
[
88,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
101,
103
],
[
68,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
116,
117
],
[
116,
118
],
[
111,
119
],
[
119,
120
],
[
120,
121
],
[
111,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
128,
130
],
[
123,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
131,
137
],
[
137,
138
],
[
137,
139
],
[
123,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
123,
145
],
[
145,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
152,
153
],
[
152,
154
],
[
147,
155
],
[
155,
156
],
[
156,
157
],
[
147,
158
],
[
159,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
160,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
167,
172
],
[
172,
173
],
[
172,
174
],
[
166,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
175,
180
],
[
160,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
182,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
6,
192
],
[
192,
193
],
[
0,
194
],
[
194,
195
],
[
194,
196
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main (String [] args) {\n\t\tScanner scan = new Scanner (System.in);\n\t\tint n = scan.nextInt();\n\t\tint data[] = new int[n];\n\t\tint min, mini = 0, count = 0, a;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdata[i] = scan.nextInt();\n\t\t}\n\t\tscan.close();\n\t\t\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main (String [] args) {\n\t\tScanner scan = new Scanner (System.in);\n\t\tint n = scan.nextInt();\n\t\tint data[] = new int[n];\n\t\tint min, mini = 0, count = 0, a;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdata[i] = scan.nextInt();\n\t\t}\n\t\tscan.close();\n\t\t\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n}",
"Main",
"public static void main (String [] args) {\n\t\tScanner scan = new Scanner (System.in);\n\t\tint n = scan.nextInt();\n\t\tint data[] = new int[n];\n\t\tint min, mini = 0, count = 0, a;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdata[i] = scan.nextInt();\n\t\t}\n\t\tscan.close();\n\t\t\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner (System.in);\n\t\tint n = scan.nextInt();\n\t\tint data[] = new int[n];\n\t\tint min, mini = 0, count = 0, a;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdata[i] = scan.nextInt();\n\t\t}\n\t\tscan.close();\n\t\t\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}",
"Scanner scan = new Scanner (System.in);",
"scan",
"new Scanner (System.in)",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int data[] = new int[n];",
"data",
"new int[n]",
"n",
"int min",
"min",
"mini = 0",
"mini",
"0",
"count = 0",
"count",
"0",
"a;",
"a",
"for (int i = 0; i < n; i++) {\n\t\t\tdata[i] = scan.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tdata[i] = scan.nextInt();\n\t\t}",
"{\n\t\t\tdata[i] = scan.nextInt();\n\t\t}",
"data[i] = scan.nextInt()",
"data[i]",
"data",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"scan.close()",
"scan.close",
"scan",
"for (int i = 0; i < n - 1; i++) {\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}",
"{\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}",
"min = data[i]",
"min",
"data[i]",
"data",
"i",
"for (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}",
"int j = i + 1;",
"int j = i + 1;",
"j",
"i + 1",
"i",
"1",
"j < n",
"j",
"n",
"j++",
"j++",
"j",
"{\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}",
"if (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}",
"min > data[j]",
"min",
"data[j]",
"data",
"j",
"{\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}",
"min = data[j]",
"min",
"data[j]",
"data",
"j",
"mini = j",
"mini",
"j",
"if (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"min != data[i]",
"min",
"data[i]",
"data",
"i",
"{\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"for (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"int k = mini;",
"int k = mini;",
"k",
"mini",
"k > i",
"k",
"i",
"k--",
"k--",
"k",
"{\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"{\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"a = data[k - 1]",
"a",
"data[k - 1]",
"data",
"k - 1",
"k",
"1",
"data[k - 1] = data[k]",
"data[k - 1]",
"data",
"k - 1",
"k",
"1",
"data[k]",
"data",
"k",
"data[k] = a",
"data[k]",
"data",
"k",
"a",
"count++",
"count",
"for (int i = 0; i < n; i++) {\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}",
"if (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}",
"i == n - 1",
"i",
"n - 1",
"n",
"1",
"{\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t}",
"System.out.println(data[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"data[i]",
"data",
"i",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"{\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}",
"System.out.print(data[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"data[i] + \" \"",
"data[i]",
"data",
"i",
"\" \"",
"String [] args",
"args",
"public class Main {\n\tpublic static void main (String [] args) {\n\t\tScanner scan = new Scanner (System.in);\n\t\tint n = scan.nextInt();\n\t\tint data[] = new int[n];\n\t\tint min, mini = 0, count = 0, a;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdata[i] = scan.nextInt();\n\t\t}\n\t\tscan.close();\n\t\t\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n}",
"public class Main {\n\tpublic static void main (String [] args) {\n\t\tScanner scan = new Scanner (System.in);\n\t\tint n = scan.nextInt();\n\t\tint data[] = new int[n];\n\t\tint min, mini = 0, count = 0, a;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdata[i] = scan.nextInt();\n\t\t}\n\t\tscan.close();\n\t\t\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\tmin = data[i];\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tif (min > data[j]) {\n\t\t\t\t\tmin = data[j];\n\t\t\t\t\tmini = j;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (min != data[i]) {\n\t\t\t\tfor (int k = mini; k > i; k--) {\n\t\t\t\t\ta = data[k - 1];\n\t\t\t\t\tdata[k - 1] = data[k];\n\t\t\t\t\tdata[k] = a;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i == n - 1) {\n\t\t\t\tSystem.out.println(data[i]);\n\t\t\t\tSystem.out.println(count);\n\t\t\t} else {\n\t\t\t\tSystem.out.print(data[i] + \" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main (String [] args) {
Scanner scan = new Scanner (System.in);
int n = scan.nextInt();
int data[] = new int[n];
int min, mini = 0, count = 0, a;
for (int i = 0; i < n; i++) {
data[i] = scan.nextInt();
}
scan.close();
for (int i = 0; i < n - 1; i++) {
min = data[i];
for (int j = i + 1; j < n; j++) {
if (min > data[j]) {
min = data[j];
mini = j;
}
}
if (min != data[i]) {
for (int k = mini; k > i; k--) {
a = data[k - 1];
data[k - 1] = data[k];
data[k] = a;
count++;
}
}
}
for (int i = 0; i < n; i++) {
if (i == n - 1) {
System.out.println(data[i]);
System.out.println(count);
} else {
System.out.print(data[i] + " ");
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
41,
13,
17,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
3,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
2,
17,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
8,
46
],
[
46,
47
],
[
46,
48
],
[
8,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
57,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
57,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
72,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
82,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
82,
104
],
[
104,
105
],
[
82,
106
],
[
106,
107
],
[
106,
108
],
[
8,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
114,
115
],
[
114,
116
],
[
109,
117
],
[
117,
118
],
[
118,
119
],
[
109,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
127,
128
],
[
127,
129
],
[
121,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
130,
136
],
[
121,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
8,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
148,
149
],
[
148,
150
],
[
6,
151
],
[
151,
152
]
] | [
"import java.util.Scanner;\n\nclass Main{\n public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint N = sc.nextInt();\n\tint A[] = new int[N];\n\tfor(int i = 0;i < N;i++){\n\t A[i] = sc.nextInt();\n\t}\n\tint flag = 1;\n\tint tmp, time = 0;\n\twhile(flag == 1){\n\t flag = 0;\n\t for(int j = N - 1;j >= 1;j--){\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }\n\t}\n\tfor(int k = 0;k < N;k++){\n\t System.out.print(A[k]);\n\t if(k == N - 1) break;\n\t System.out.print(\" \");\n\t}\n\tSystem.out.println(\"\\n\" + time);\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint N = sc.nextInt();\n\tint A[] = new int[N];\n\tfor(int i = 0;i < N;i++){\n\t A[i] = sc.nextInt();\n\t}\n\tint flag = 1;\n\tint tmp, time = 0;\n\twhile(flag == 1){\n\t flag = 0;\n\t for(int j = N - 1;j >= 1;j--){\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }\n\t}\n\tfor(int k = 0;k < N;k++){\n\t System.out.print(A[k]);\n\t if(k == N - 1) break;\n\t System.out.print(\" \");\n\t}\n\tSystem.out.println(\"\\n\" + time);\n }\n}",
"Main",
"public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint N = sc.nextInt();\n\tint A[] = new int[N];\n\tfor(int i = 0;i < N;i++){\n\t A[i] = sc.nextInt();\n\t}\n\tint flag = 1;\n\tint tmp, time = 0;\n\twhile(flag == 1){\n\t flag = 0;\n\t for(int j = N - 1;j >= 1;j--){\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }\n\t}\n\tfor(int k = 0;k < N;k++){\n\t System.out.print(A[k]);\n\t if(k == N - 1) break;\n\t System.out.print(\" \");\n\t}\n\tSystem.out.println(\"\\n\" + time);\n }",
"main",
"{\n\tScanner sc = new Scanner(System.in);\n\tint N = sc.nextInt();\n\tint A[] = new int[N];\n\tfor(int i = 0;i < N;i++){\n\t A[i] = sc.nextInt();\n\t}\n\tint flag = 1;\n\tint tmp, time = 0;\n\twhile(flag == 1){\n\t flag = 0;\n\t for(int j = N - 1;j >= 1;j--){\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }\n\t}\n\tfor(int k = 0;k < N;k++){\n\t System.out.print(A[k]);\n\t if(k == N - 1) break;\n\t System.out.print(\" \");\n\t}\n\tSystem.out.println(\"\\n\" + time);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int A[] = new int[N];",
"A",
"new int[N]",
"N",
"for(int i = 0;i < N;i++){\n\t A[i] = sc.nextInt();\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t A[i] = sc.nextInt();\n\t}",
"{\n\t A[i] = sc.nextInt();\n\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int flag = 1;",
"flag",
"1",
"int tmp",
"tmp",
"time = 0;",
"time",
"0",
"while(flag == 1){\n\t flag = 0;\n\t for(int j = N - 1;j >= 1;j--){\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }\n\t}",
"flag == 1",
"flag",
"1",
"{\n\t flag = 0;\n\t for(int j = N - 1;j >= 1;j--){\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }\n\t}",
"flag = 0",
"flag",
"0",
"for(int j = N - 1;j >= 1;j--){\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }",
"int j = N - 1;",
"int j = N - 1;",
"j",
"N - 1",
"N",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }",
"{\n\t\tif(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }\n\t }",
"if(A[j] < A[j - 1]){\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }",
"A[j] < A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"{\n\t\t tmp = A[j];\n\t\t A[j] = A[j - 1];\n\t\t A[j - 1] = tmp;\n\t\t time++;\n\t\t flag = 1;\n\t\t }",
"tmp = A[j]",
"tmp",
"A[j]",
"A",
"j",
"A[j] = A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"A[j - 1] = tmp",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"tmp",
"time++",
"time",
"flag = 1",
"flag",
"1",
"for(int k = 0;k < N;k++){\n\t System.out.print(A[k]);\n\t if(k == N - 1) break;\n\t System.out.print(\" \");\n\t}",
"int k = 0;",
"int k = 0;",
"k",
"0",
"k < N",
"k",
"N",
"k++",
"k++",
"k",
"{\n\t System.out.print(A[k]);\n\t if(k == N - 1) break;\n\t System.out.print(\" \");\n\t}",
"{\n\t System.out.print(A[k]);\n\t if(k == N - 1) break;\n\t System.out.print(\" \");\n\t}",
"System.out.print(A[k])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[k]",
"A",
"k",
"if(k == N - 1) break;",
"k == N - 1",
"k",
"N - 1",
"N",
"1",
"break;",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(\"\\n\" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\\n\" + time",
"\"\\n\"",
"time",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int A[] = new int[N];
for(int i = 0;i < N;i++){
A[i] = sc.nextInt();
}
int flag = 1;
int tmp, time = 0;
while(flag == 1){
flag = 0;
for(int j = N - 1;j >= 1;j--){
if(A[j] < A[j - 1]){
tmp = A[j];
A[j] = A[j - 1];
A[j - 1] = tmp;
time++;
flag = 1;
}
}
}
for(int k = 0;k < N;k++){
System.out.print(A[k]);
if(k == N - 1) break;
System.out.print(" ");
}
System.out.println("\n" + time);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
2,
13,
17,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
30,
4,
18,
13,
17,
4,
18,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
180,
5
],
[
180,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
41,
44
],
[
6,
45
],
[
45,
46
],
[
180,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
57,
59
],
[
53,
60
],
[
60,
61
],
[
60,
62
],
[
53,
63
],
[
63,
64
],
[
64,
65
],
[
53,
66
],
[
67,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
68,
75
],
[
75,
76
],
[
75,
77
],
[
78,
78
],
[
78,
79
],
[
78,
80
],
[
78,
81
],
[
68,
82
],
[
82,
83
],
[
83,
84
],
[
68,
85
],
[
86,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
88,
94
],
[
94,
95
],
[
94,
96
],
[
87,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
97,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
115,
117
],
[
112,
118
],
[
97,
119
],
[
119,
120
],
[
49,
121
],
[
121,
122
],
[
121,
123
],
[
121,
124
],
[
49,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
125,
130
],
[
47,
131
],
[
131,
132
],
[
47,
133
],
[
133,
134
],
[
180,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
146,
148
],
[
141,
149
],
[
149,
150
],
[
150,
151
],
[
141,
152
],
[
153,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
159,
162
],
[
153,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
166,
167
],
[
166,
168
],
[
137,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
135,
175
],
[
175,
176
],
[
135,
177
],
[
177,
178
],
[
0,
179
],
[
179,
180
],
[
179,
181
]
] | [
"\nimport java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i]=scanner.nextInt();\n }\n bubbleSort(A,N);\n }\n \n static void bubbleSort(int[] A,int N){\n \tint count = 0;\n for(int i=N-1;i>0;i--){\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \tprintList(A,N);\n System.out.println(count);\n }\n static void printList(int[] A,int N){\n StringBuilder builder = new StringBuilder();\n for(int i=0;i<N;i++){\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }\n System.out.println(builder);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i]=scanner.nextInt();\n }\n bubbleSort(A,N);\n }\n \n static void bubbleSort(int[] A,int N){\n \tint count = 0;\n for(int i=N-1;i>0;i--){\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \tprintList(A,N);\n System.out.println(count);\n }\n static void printList(int[] A,int N){\n StringBuilder builder = new StringBuilder();\n for(int i=0;i<N;i++){\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }\n System.out.println(builder);\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i]=scanner.nextInt();\n }\n bubbleSort(A,N);\n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i]=scanner.nextInt();\n }\n bubbleSort(A,N);\n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int N = scanner.nextInt();",
"N",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int[] A = new int[N];",
"A",
"new int[N]",
"N",
"for(int i=0;i<N;i++){\n A[i]=scanner.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n A[i]=scanner.nextInt();\n }",
"{\n A[i]=scanner.nextInt();\n }",
"A[i]=scanner.nextInt()",
"A[i]",
"A",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"bubbleSort(A,N)",
"bubbleSort",
"A",
"N",
"String[] args",
"args",
"static void bubbleSort(int[] A,int N){\n \tint count = 0;\n for(int i=N-1;i>0;i--){\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \tprintList(A,N);\n System.out.println(count);\n }",
"bubbleSort",
"{\n \tint count = 0;\n for(int i=N-1;i>0;i--){\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \tprintList(A,N);\n System.out.println(count);\n }",
"int count = 0;",
"count",
"0",
"for(int i=N-1;i>0;i--){\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }",
"int i=N-1;",
"int i=N-1;",
"i",
"N-1",
"N",
"1",
"i>0",
"i",
"0",
"i--",
"i--",
"i",
"{\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }",
"{\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }",
"for(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}",
"int j=N-1;",
"int j=N-1;",
"j",
"N-1",
"N",
"1",
"j>N-1-i",
"j",
"N-1-i",
"N-1-i",
"N",
"1",
"i",
"j--",
"j--",
"j",
"{\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}",
"{\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}",
"if(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}",
"A[j-1] > A[j]",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j]",
"A",
"j",
"{\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}",
"int v = A[j];",
"v",
"A[j]",
"A",
"j",
"A[j] = A[j-1]",
"A[j]",
"A",
"j",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"A[j-1] = v",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"v",
"count++",
"count",
"printList(A,N)",
"printList",
"A",
"N",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"int[] A",
"A",
"int N",
"N",
"static void printList(int[] A,int N){\n StringBuilder builder = new StringBuilder();\n for(int i=0;i<N;i++){\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }\n System.out.println(builder);\n }",
"printList",
"{\n StringBuilder builder = new StringBuilder();\n for(int i=0;i<N;i++){\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }\n System.out.println(builder);\n }",
"StringBuilder builder = new StringBuilder();",
"builder",
"new StringBuilder()",
"for(int i=0;i<N;i++){\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }",
"{\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }",
"if(i>0){\n builder.append(\" \");\n }",
"i>0",
"i",
"0",
"{\n builder.append(\" \");\n }",
"builder.append(\" \")",
"builder.append",
"builder",
"\" \"",
"builder.append(A[i])",
"builder.append",
"builder",
"A[i]",
"A",
"i",
"System.out.println(builder)",
"System.out.println",
"System.out",
"System",
"System.out",
"builder",
"int[] A",
"A",
"int N",
"N",
"public class Main{\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i]=scanner.nextInt();\n }\n bubbleSort(A,N);\n }\n \n static void bubbleSort(int[] A,int N){\n \tint count = 0;\n for(int i=N-1;i>0;i--){\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \tprintList(A,N);\n System.out.println(count);\n }\n static void printList(int[] A,int N){\n StringBuilder builder = new StringBuilder();\n for(int i=0;i<N;i++){\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }\n System.out.println(builder);\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n for(int i=0;i<N;i++){\n A[i]=scanner.nextInt();\n }\n bubbleSort(A,N);\n }\n \n static void bubbleSort(int[] A,int N){\n \tint count = 0;\n for(int i=N-1;i>0;i--){\n \t//[N-1-i] is better than 0\n \tfor(int j=N-1;j>N-1-i;j--){\n \t\tif(A[j-1] > A[j]){\n \t\t\tint v = A[j];\n \t\t\tA[j] = A[j-1];\n \t\t\tA[j-1] = v;\n \t\t\tcount++;\n \t\t}\n \t}\n }\n \tprintList(A,N);\n System.out.println(count);\n }\n static void printList(int[] A,int N){\n StringBuilder builder = new StringBuilder();\n for(int i=0;i<N;i++){\n if(i>0){\n builder.append(\" \");\n }\n builder.append(A[i]);\n }\n System.out.println(builder);\n }\n}",
"Main"
] |
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int[] A = new int[N];
for(int i=0;i<N;i++){
A[i]=scanner.nextInt();
}
bubbleSort(A,N);
}
static void bubbleSort(int[] A,int N){
int count = 0;
for(int i=N-1;i>0;i--){
//[N-1-i] is better than 0
for(int j=N-1;j>N-1-i;j--){
if(A[j-1] > A[j]){
int v = A[j];
A[j] = A[j-1];
A[j-1] = v;
count++;
}
}
}
printList(A,N);
System.out.println(count);
}
static void printList(int[] A,int N){
StringBuilder builder = new StringBuilder();
for(int i=0;i<N;i++){
if(i>0){
builder.append(" ");
}
builder.append(A[i]);
}
System.out.println(builder);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
41,
13,
20,
13,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
173,
8
],
[
173,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
22,
25
],
[
11,
26
],
[
26,
27
],
[
26,
28
],
[
11,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
11,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
37,
40
],
[
11,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
41,
46
],
[
46,
47
],
[
46,
48
],
[
41,
49
],
[
49,
50
],
[
50,
51
],
[
41,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
60,
62
],
[
11,
63
],
[
63,
64
],
[
63,
65
],
[
11,
66
],
[
66,
67
],
[
66,
68
],
[
11,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
75,
82
],
[
82,
83
],
[
82,
84
],
[
75,
85
],
[
85,
86
],
[
86,
87
],
[
75,
88
],
[
89,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
90,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
100,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
112,
114
],
[
100,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
115,
121
],
[
100,
122
],
[
122,
123
],
[
122,
124
],
[
100,
125
],
[
125,
126
],
[
11,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
132,
133
],
[
132,
134
],
[
127,
135
],
[
135,
136
],
[
136,
137
],
[
127,
138
],
[
139,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
143,
145
],
[
140,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
140,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
11,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
9,
170
],
[
170,
171
],
[
0,
172
],
[
172,
173
],
[
172,
174
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tpublic static void main(String[] args)throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int n = Integer.parseInt(line);\n int[] a = new int[n];\n String line2 = br.readLine();\n String[] str = line2.split(\" \");\n for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);\n boolean flag=true;\n int cnt=0;\n while(flag){\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }\n \tfor(int i=0;i<n;i++){\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}\n \tSystem.out.println(cnt);\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\tpublic static void main(String[] args)throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int n = Integer.parseInt(line);\n int[] a = new int[n];\n String line2 = br.readLine();\n String[] str = line2.split(\" \");\n for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);\n boolean flag=true;\n int cnt=0;\n while(flag){\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }\n \tfor(int i=0;i<n;i++){\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}\n \tSystem.out.println(cnt);\n\t}\n}",
"Main",
"public static void main(String[] args)throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int n = Integer.parseInt(line);\n int[] a = new int[n];\n String line2 = br.readLine();\n String[] str = line2.split(\" \");\n for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);\n boolean flag=true;\n int cnt=0;\n while(flag){\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }\n \tfor(int i=0;i<n;i++){\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}\n \tSystem.out.println(cnt);\n\t}",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int n = Integer.parseInt(line);\n int[] a = new int[n];\n String line2 = br.readLine();\n String[] str = line2.split(\" \");\n for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);\n boolean flag=true;\n int cnt=0;\n while(flag){\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }\n \tfor(int i=0;i<n;i++){\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}\n \tSystem.out.println(cnt);\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String line = br.readLine();",
"line",
"br.readLine()",
"br.readLine",
"br",
"int n = Integer.parseInt(line);",
"n",
"Integer.parseInt(line)",
"Integer.parseInt",
"Integer",
"line",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"String line2 = br.readLine();",
"line2",
"br.readLine()",
"br.readLine",
"br",
"String[] str = line2.split(\" \");",
"str",
"line2.split(\" \")",
"line2.split",
"line2",
"\" \"",
"for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=Integer.parseInt(str[i]);",
"a[i]=Integer.parseInt(str[i])",
"a[i]",
"a",
"i",
"Integer.parseInt(str[i])",
"Integer.parseInt",
"Integer",
"str[i]",
"str",
"i",
"boolean flag=true;",
"flag",
"true",
"int cnt=0;",
"cnt",
"0",
"while(flag){\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }",
"flag",
"{\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }",
"flag=false",
"flag",
"false",
"for(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}",
"int j=n-1;",
"int j=n-1;",
"j",
"n-1",
"n",
"1",
"j>0",
"j",
"0",
"j--",
"j--",
"j",
"{\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}",
"{\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}",
"if(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}",
"a[j]<a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1]=tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"tmp",
"flag=true",
"flag",
"true",
"cnt++",
"cnt",
"for(int i=0;i<n;i++){\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}",
"{\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}",
"if(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);",
"i!=n-1",
"i",
"n-1",
"n",
"1",
"System.out.print(a[i]+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]+\" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(a[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args)throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int n = Integer.parseInt(line);\n int[] a = new int[n];\n String line2 = br.readLine();\n String[] str = line2.split(\" \");\n for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);\n boolean flag=true;\n int cnt=0;\n while(flag){\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }\n \tfor(int i=0;i<n;i++){\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}\n \tSystem.out.println(cnt);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args)throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int n = Integer.parseInt(line);\n int[] a = new int[n];\n String line2 = br.readLine();\n String[] str = line2.split(\" \");\n for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);\n boolean flag=true;\n int cnt=0;\n while(flag){\n \tflag=false;\n \tfor(int j=n-1;j>0;j--){\n \t\tif(a[j]<a[j-1]){\n \t\t\tint tmp = a[j];\n \t\t\ta[j] = a[j-1];\n \t\t\ta[j-1]=tmp;\n \t\t\tflag=true;\n \t\t\tcnt++;\n \t\t}\n \t}\n }\n \tfor(int i=0;i<n;i++){\n \t\tif(i!=n-1)System.out.print(a[i]+\" \");\n \t\telse System.out.println(a[i]);\n \t}\n \tSystem.out.println(cnt);\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args)throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int n = Integer.parseInt(line);
int[] a = new int[n];
String line2 = br.readLine();
String[] str = line2.split(" ");
for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);
boolean flag=true;
int cnt=0;
while(flag){
flag=false;
for(int j=n-1;j>0;j--){
if(a[j]<a[j-1]){
int tmp = a[j];
a[j] = a[j-1];
a[j-1]=tmp;
flag=true;
cnt++;
}
}
}
for(int i=0;i<n;i++){
if(i!=n-1)System.out.print(a[i]+" ");
else System.out.println(a[i]);
}
System.out.println(cnt);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
13,
13,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
13,
13,
4,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
20,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
4,
18,
18,
13,
13,
4,
18,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
215,
8
],
[
215,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
17,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
22,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
30,
32
],
[
11,
33
],
[
33,
34
],
[
33,
35
],
[
9,
36
],
[
36,
37
],
[
215,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
44,
46
],
[
40,
47
],
[
47,
48
],
[
47,
49
],
[
40,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
56,
65
],
[
65,
66
],
[
65,
67
],
[
56,
68
],
[
68,
69
],
[
69,
70
],
[
56,
71
],
[
72,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
73,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
83,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
98,
104
],
[
83,
105
],
[
105,
106
],
[
105,
107
],
[
83,
108
],
[
108,
109
],
[
40,
110
],
[
110,
111
],
[
110,
112
],
[
40,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
113,
118
],
[
38,
119
],
[
119,
120
],
[
215,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
128,
129
],
[
129,
130
],
[
121,
131
],
[
131,
132
],
[
215,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
139,
140
],
[
139,
141
],
[
135,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
142,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
149,
151
],
[
142,
152
],
[
152,
153
],
[
153,
154
],
[
142,
155
],
[
156,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
162,
163
],
[
161,
164
],
[
164,
165
],
[
164,
166
],
[
135,
167
],
[
167,
168
],
[
133,
169
],
[
169,
170
],
[
215,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
177,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
184,
186
],
[
177,
187
],
[
187,
188
],
[
188,
189
],
[
177,
190
],
[
191,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
192,
195
],
[
195,
196
],
[
195,
197
],
[
191,
198
],
[
198,
199
],
[
199,
200
],
[
198,
201
],
[
173,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
202,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
210,
211
],
[
171,
212
],
[
212,
213
],
[
0,
214
],
[
214,
215
],
[
214,
216
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = readInt(r);\n\t\tString[] numArrayStr = r.readLine().split(\" \");\n\n\t\tint[] numArrayInt = convertToInt(numArrayStr);\n\n\t\tbubbleSort(numArrayInt);\n\t}\n\n\tpublic static void bubbleSort(int[] numArrayInt){\n\t\tint temp = 0;\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintBlank(numArrayInt);\n\t\tSystem.out.println(count);\n\t}\n\n\tpublic static int readInt(BufferedReader r) throws Exception{\n return Integer.parseInt(r.readLine());\n }\n\n\tpublic static int[] convertToInt(String[] numArrayStr){\n\t\tint[] numArrayInt = new int[numArrayStr.length];\n\t\tfor(int i = 0; i < numArrayStr.length; i++){\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}\n\t\treturn numArrayInt;\n\t}\n\n\tpublic static void printBlank(int[] numArrayInt){\n\t\tStringBuilder builder = new StringBuilder();\n\t\tfor(int i = 0; i < numArrayInt.length; i++){\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(builder.toString().trim());\n\t}\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = readInt(r);\n\t\tString[] numArrayStr = r.readLine().split(\" \");\n\n\t\tint[] numArrayInt = convertToInt(numArrayStr);\n\n\t\tbubbleSort(numArrayInt);\n\t}\n\n\tpublic static void bubbleSort(int[] numArrayInt){\n\t\tint temp = 0;\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintBlank(numArrayInt);\n\t\tSystem.out.println(count);\n\t}\n\n\tpublic static int readInt(BufferedReader r) throws Exception{\n return Integer.parseInt(r.readLine());\n }\n\n\tpublic static int[] convertToInt(String[] numArrayStr){\n\t\tint[] numArrayInt = new int[numArrayStr.length];\n\t\tfor(int i = 0; i < numArrayStr.length; i++){\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}\n\t\treturn numArrayInt;\n\t}\n\n\tpublic static void printBlank(int[] numArrayInt){\n\t\tStringBuilder builder = new StringBuilder();\n\t\tfor(int i = 0; i < numArrayInt.length; i++){\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(builder.toString().trim());\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = readInt(r);\n\t\tString[] numArrayStr = r.readLine().split(\" \");\n\n\t\tint[] numArrayInt = convertToInt(numArrayStr);\n\n\t\tbubbleSort(numArrayInt);\n\t}",
"main",
"{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = readInt(r);\n\t\tString[] numArrayStr = r.readLine().split(\" \");\n\n\t\tint[] numArrayInt = convertToInt(numArrayStr);\n\n\t\tbubbleSort(numArrayInt);\n\t}",
"BufferedReader r = new BufferedReader(new InputStreamReader(System.in));",
"r",
"new BufferedReader(new InputStreamReader(System.in))",
"int n = readInt(r);",
"n",
"readInt(r)",
"readInt",
"r",
"String[] numArrayStr = r.readLine().split(\" \");",
"numArrayStr",
"r.readLine().split(\" \")",
"r.readLine().split",
"r.readLine()",
"r.readLine",
"r",
"\" \"",
"int[] numArrayInt = convertToInt(numArrayStr);",
"numArrayInt",
"convertToInt(numArrayStr)",
"convertToInt",
"numArrayStr",
"bubbleSort(numArrayInt)",
"bubbleSort",
"numArrayInt",
"String[] args",
"args",
"public static void bubbleSort(int[] numArrayInt){\n\t\tint temp = 0;\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintBlank(numArrayInt);\n\t\tSystem.out.println(count);\n\t}",
"bubbleSort",
"{\n\t\tint temp = 0;\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintBlank(numArrayInt);\n\t\tSystem.out.println(count);\n\t}",
"int temp = 0;",
"temp",
"0",
"int count = 0;",
"count",
"0",
"boolean flag = true;",
"flag",
"true",
"while(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int i = numArrayInt.length - 1;",
"int i = numArrayInt.length - 1;",
"i",
"numArrayInt.length - 1",
"numArrayInt.length",
"numArrayInt",
"numArrayInt.length",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"numArrayInt[i] < numArrayInt[i - 1]",
"numArrayInt[i]",
"numArrayInt",
"i",
"numArrayInt[i - 1]",
"numArrayInt",
"i - 1",
"i",
"1",
"{\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"temp = numArrayInt[i]",
"temp",
"numArrayInt[i]",
"numArrayInt",
"i",
"numArrayInt[i] = numArrayInt[i - 1]",
"numArrayInt[i]",
"numArrayInt",
"i",
"numArrayInt[i - 1]",
"numArrayInt",
"i - 1",
"i",
"1",
"numArrayInt[i - 1] = temp",
"numArrayInt[i - 1]",
"numArrayInt",
"i - 1",
"i",
"1",
"temp",
"flag = true",
"flag",
"true",
"count++",
"count",
"printBlank(numArrayInt)",
"printBlank",
"numArrayInt",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"int[] numArrayInt",
"numArrayInt",
"public static int readInt(BufferedReader r) throws Exception{\n return Integer.parseInt(r.readLine());\n }",
"readInt",
"{\n return Integer.parseInt(r.readLine());\n }",
"return Integer.parseInt(r.readLine());",
"Integer.parseInt(r.readLine())",
"Integer.parseInt",
"Integer",
"r.readLine()",
"r.readLine",
"r",
"BufferedReader r",
"r",
"public static int[] convertToInt(String[] numArrayStr){\n\t\tint[] numArrayInt = new int[numArrayStr.length];\n\t\tfor(int i = 0; i < numArrayStr.length; i++){\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}\n\t\treturn numArrayInt;\n\t}",
"convertToInt",
"{\n\t\tint[] numArrayInt = new int[numArrayStr.length];\n\t\tfor(int i = 0; i < numArrayStr.length; i++){\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}\n\t\treturn numArrayInt;\n\t}",
"int[] numArrayInt = new int[numArrayStr.length];",
"numArrayInt",
"new int[numArrayStr.length]",
"numArrayStr.length",
"numArrayStr",
"numArrayStr.length",
"for(int i = 0; i < numArrayStr.length; i++){\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numArrayStr.length",
"i",
"numArrayStr.length",
"numArrayStr",
"numArrayStr.length",
"i++",
"i++",
"i",
"{\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}",
"{\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}",
"numArrayInt[i] = Integer.parseInt(numArrayStr[i])",
"numArrayInt[i]",
"numArrayInt",
"i",
"Integer.parseInt(numArrayStr[i])",
"Integer.parseInt",
"Integer",
"numArrayStr[i]",
"numArrayStr",
"i",
"return numArrayInt;",
"numArrayInt",
"String[] numArrayStr",
"numArrayStr",
"public static void printBlank(int[] numArrayInt){\n\t\tStringBuilder builder = new StringBuilder();\n\t\tfor(int i = 0; i < numArrayInt.length; i++){\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(builder.toString().trim());\n\t}",
"printBlank",
"{\n\t\tStringBuilder builder = new StringBuilder();\n\t\tfor(int i = 0; i < numArrayInt.length; i++){\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(builder.toString().trim());\n\t}",
"StringBuilder builder = new StringBuilder();",
"builder",
"new StringBuilder()",
"for(int i = 0; i < numArrayInt.length; i++){\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numArrayInt.length",
"i",
"numArrayInt.length",
"numArrayInt",
"numArrayInt.length",
"i++",
"i++",
"i",
"{\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}",
"{\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}",
"builder.append(numArrayInt[i])",
"builder.append",
"builder",
"numArrayInt[i]",
"numArrayInt",
"i",
"builder.append(\" \")",
"builder.append",
"builder",
"\" \"",
"System.out.println(builder.toString().trim())",
"System.out.println",
"System.out",
"System",
"System.out",
"builder.toString().trim()",
"builder.toString().trim",
"builder.toString()",
"builder.toString",
"builder",
"int[] numArrayInt",
"numArrayInt",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = readInt(r);\n\t\tString[] numArrayStr = r.readLine().split(\" \");\n\n\t\tint[] numArrayInt = convertToInt(numArrayStr);\n\n\t\tbubbleSort(numArrayInt);\n\t}\n\n\tpublic static void bubbleSort(int[] numArrayInt){\n\t\tint temp = 0;\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintBlank(numArrayInt);\n\t\tSystem.out.println(count);\n\t}\n\n\tpublic static int readInt(BufferedReader r) throws Exception{\n return Integer.parseInt(r.readLine());\n }\n\n\tpublic static int[] convertToInt(String[] numArrayStr){\n\t\tint[] numArrayInt = new int[numArrayStr.length];\n\t\tfor(int i = 0; i < numArrayStr.length; i++){\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}\n\t\treturn numArrayInt;\n\t}\n\n\tpublic static void printBlank(int[] numArrayInt){\n\t\tStringBuilder builder = new StringBuilder();\n\t\tfor(int i = 0; i < numArrayInt.length; i++){\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(builder.toString().trim());\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = readInt(r);\n\t\tString[] numArrayStr = r.readLine().split(\" \");\n\n\t\tint[] numArrayInt = convertToInt(numArrayStr);\n\n\t\tbubbleSort(numArrayInt);\n\t}\n\n\tpublic static void bubbleSort(int[] numArrayInt){\n\t\tint temp = 0;\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile(flag){\n\t\t\tflag = false;\n\t\t\tfor(int i = numArrayInt.length - 1; i > 0; i--){\n\t\t\t\tif(numArrayInt[i] < numArrayInt[i - 1]){\n\t\t\t\t\ttemp = numArrayInt[i];\n\t\t\t\t\tnumArrayInt[i] = numArrayInt[i - 1];\n\t\t\t\t\tnumArrayInt[i - 1] = temp;\n\t\t\t\t\tflag = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintBlank(numArrayInt);\n\t\tSystem.out.println(count);\n\t}\n\n\tpublic static int readInt(BufferedReader r) throws Exception{\n return Integer.parseInt(r.readLine());\n }\n\n\tpublic static int[] convertToInt(String[] numArrayStr){\n\t\tint[] numArrayInt = new int[numArrayStr.length];\n\t\tfor(int i = 0; i < numArrayStr.length; i++){\n\t\t\tnumArrayInt[i] = Integer.parseInt(numArrayStr[i]);\n\t\t}\n\t\treturn numArrayInt;\n\t}\n\n\tpublic static void printBlank(int[] numArrayInt){\n\t\tStringBuilder builder = new StringBuilder();\n\t\tfor(int i = 0; i < numArrayInt.length; i++){\n\t\t\tbuilder.append(numArrayInt[i]);\n\t\t\tbuilder.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(builder.toString().trim());\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
int n = readInt(r);
String[] numArrayStr = r.readLine().split(" ");
int[] numArrayInt = convertToInt(numArrayStr);
bubbleSort(numArrayInt);
}
public static void bubbleSort(int[] numArrayInt){
int temp = 0;
int count = 0;
boolean flag = true;
while(flag){
flag = false;
for(int i = numArrayInt.length - 1; i > 0; i--){
if(numArrayInt[i] < numArrayInt[i - 1]){
temp = numArrayInt[i];
numArrayInt[i] = numArrayInt[i - 1];
numArrayInt[i - 1] = temp;
flag = true;
count++;
}
}
}
printBlank(numArrayInt);
System.out.println(count);
}
public static int readInt(BufferedReader r) throws Exception{
return Integer.parseInt(r.readLine());
}
public static int[] convertToInt(String[] numArrayStr){
int[] numArrayInt = new int[numArrayStr.length];
for(int i = 0; i < numArrayStr.length; i++){
numArrayInt[i] = Integer.parseInt(numArrayStr[i]);
}
return numArrayInt;
}
public static void printBlank(int[] numArrayInt){
StringBuilder builder = new StringBuilder();
for(int i = 0; i < numArrayInt.length; i++){
builder.append(numArrayInt[i]);
builder.append(" ");
}
System.out.println(builder.toString().trim());
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
41,
13,
18,
13,
13,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
169,
5
],
[
169,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
8,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
36,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
48,
50
],
[
44,
51
],
[
51,
52
],
[
51,
53
],
[
44,
54
],
[
54,
55
],
[
55,
56
],
[
44,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
59,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
59,
72
],
[
73,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
79,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
89,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
89,
106
],
[
106,
107
],
[
8,
108
],
[
108,
109
],
[
108,
110
],
[
8,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
6,
117
],
[
117,
118
],
[
169,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
129,
131
],
[
122,
132
],
[
132,
133
],
[
133,
134
],
[
122,
135
],
[
136,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
142,
143
],
[
142,
144
],
[
136,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
145,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
121,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
160,
165
],
[
119,
166
],
[
166,
167
],
[
0,
168
],
[
168,
169
],
[
168,
170
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tint count = 0;\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = n-1; i >= 0; i--) {\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint(a);\n\t\tSystem.out.println(count);\n\n\t}\n\tstatic void print(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tint count = 0;\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = n-1; i >= 0; i--) {\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint(a);\n\t\tSystem.out.println(count);\n\n\t}\n\tstatic void print(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tint count = 0;\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = n-1; i >= 0; i--) {\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint(a);\n\t\tSystem.out.println(count);\n\n\t}",
"main",
"{\n\n\t\tint count = 0;\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = n-1; i >= 0; i--) {\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint(a);\n\t\tSystem.out.println(count);\n\n\t}",
"int count = 0;",
"count",
"0",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = n-1; i >= 0; i--) {\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = n-1;",
"int i = n-1;",
"i",
"n-1",
"n",
"1",
"i >= 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"if (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"tmp",
"count++",
"count",
"print(a)",
"print",
"a",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"static void print(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}",
"print",
"{\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}",
"for (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"if (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"i != a.length-1",
"i",
"a.length-1",
"a.length",
"a",
"a.length",
"1",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"int[] a",
"a",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tint count = 0;\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = n-1; i >= 0; i--) {\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint(a);\n\t\tSystem.out.println(count);\n\n\t}\n\tstatic void print(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tint count = 0;\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = n-1; i >= 0; i--) {\n\t\t\tfor (int j = n-1; j > 0; j--) {\n\t\t\t\tint tmp = a[j];\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint(a);\n\t\tSystem.out.println(count);\n\n\t}\n\tstatic void print(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int count = 0;
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
for (int i = n-1; i >= 0; i--) {
for (int j = n-1; j > 0; j--) {
int tmp = a[j];
if (a[j] < a[j-1]) {
a[j] = a[j-1];
a[j-1] = tmp;
count++;
}
}
}
print(a);
System.out.println(count);
}
static void print(int[] a) {
for (int i = 0; i < a.length; i++) {
System.out.print(a[i]);
if (i != a.length-1) {
System.out.print(" ");
}
}
System.out.print("\n");
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
0,
13,
20,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
171,
5
],
[
171,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
8,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
26,
31
],
[
31,
32
],
[
31,
33
],
[
26,
34
],
[
34,
35
],
[
35,
36
],
[
26,
37
],
[
38,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
44,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
46,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
61,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
61,
71
],
[
71,
72
],
[
72,
73
],
[
61,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
76,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
86,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
86,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
103,
109
],
[
86,
110
],
[
110,
111
],
[
8,
112
],
[
112,
113
],
[
112,
114
],
[
112,
115
],
[
8,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
6,
122
],
[
122,
123
],
[
171,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
132,
133
],
[
132,
134
],
[
127,
135
],
[
135,
136
],
[
136,
137
],
[
127,
138
],
[
139,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
145,
147
],
[
139,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
151,
153
],
[
148,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
126,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
124,
166
],
[
166,
167
],
[
124,
168
],
[
168,
169
],
[
0,
170
],
[
170,
171
],
[
170,
172
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] A;\n A = new int[n];\n int count = 0;\n for(int i=0;i<n;++i){\n A[i] = sc.nextInt();\n }\n for(int i=0;i<n-1;++i){\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }\n print(A, n);\n System.out.println(count);\n }\n\n public static void print(int A[], int n){\n for(int i=0;i<n;++i){\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }\n System.out.println();\n }\n}\n\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] A;\n A = new int[n];\n int count = 0;\n for(int i=0;i<n;++i){\n A[i] = sc.nextInt();\n }\n for(int i=0;i<n-1;++i){\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }\n print(A, n);\n System.out.println(count);\n }\n\n public static void print(int A[], int n){\n for(int i=0;i<n;++i){\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }\n System.out.println();\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] A;\n A = new int[n];\n int count = 0;\n for(int i=0;i<n;++i){\n A[i] = sc.nextInt();\n }\n for(int i=0;i<n-1;++i){\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }\n print(A, n);\n System.out.println(count);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] A;\n A = new int[n];\n int count = 0;\n for(int i=0;i<n;++i){\n A[i] = sc.nextInt();\n }\n for(int i=0;i<n-1;++i){\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }\n print(A, n);\n System.out.println(count);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] A;",
"A",
"A = new int[n]",
"A",
"new int[n]",
"n",
"int count = 0;",
"count",
"0",
"for(int i=0;i<n;++i){\n A[i] = sc.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"++i",
"++i",
"i",
"{\n A[i] = sc.nextInt();\n }",
"{\n A[i] = sc.nextInt();\n }",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i=0;i<n-1;++i){\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n-1",
"i",
"n-1",
"n",
"1",
"++i",
"++i",
"i",
"{\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }",
"{\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }",
"for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }",
"int j=0;",
"int j=0;",
"j",
"0",
"j<n-1",
"j",
"n-1",
"n",
"1",
"++j",
"++j",
"j",
"{\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }",
"{\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }",
"if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }",
"A[j] > A[j+1]",
"A[j]",
"A",
"j",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"{\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }",
"int c;",
"c",
"c = A[j]",
"c",
"A[j]",
"A",
"j",
"A[j] = A[j+1]",
"A[j]",
"A",
"j",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"A[j+1] = c",
"A[j+1]",
"A",
"j+1",
"j",
"1",
"c",
"count++",
"count",
"print(A, n)",
"print",
"A",
"n",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public static void print(int A[], int n){\n for(int i=0;i<n;++i){\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }\n System.out.println();\n }",
"print",
"{\n for(int i=0;i<n;++i){\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }\n System.out.println();\n }",
"for(int i=0;i<n;++i){\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"++i",
"++i",
"i",
"{\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }",
"{\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }",
"System.out.print(A[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"A[i]",
"A",
"i",
"if(i<n-1){System.out.print(\" \");}",
"i<n-1",
"i",
"n-1",
"n",
"1",
"{System.out.print(\" \");}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"int A[]",
"A",
"int n",
"n",
"public class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] A;\n A = new int[n];\n int count = 0;\n for(int i=0;i<n;++i){\n A[i] = sc.nextInt();\n }\n for(int i=0;i<n-1;++i){\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }\n print(A, n);\n System.out.println(count);\n }\n\n public static void print(int A[], int n){\n for(int i=0;i<n;++i){\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }\n System.out.println();\n }\n}",
"public class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] A;\n A = new int[n];\n int count = 0;\n for(int i=0;i<n;++i){\n A[i] = sc.nextInt();\n }\n for(int i=0;i<n-1;++i){\n for(int j=0;j<n-1;++j){\n if(A[j] > A[j+1]){\n int c;\n c = A[j];\n A[j] = A[j+1];\n A[j+1] = c;\n count++;\n }\n }\n }\n print(A, n);\n System.out.println(count);\n }\n\n public static void print(int A[], int n){\n for(int i=0;i<n;++i){\n System.out.print(A[i]);\n if(i<n-1){System.out.print(\" \");}\n }\n System.out.println();\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] A;
A = new int[n];
int count = 0;
for(int i=0;i<n;++i){
A[i] = sc.nextInt();
}
for(int i=0;i<n-1;++i){
for(int j=0;j<n-1;++j){
if(A[j] > A[j+1]){
int c;
c = A[j];
A[j] = A[j+1];
A[j+1] = c;
count++;
}
}
}
print(A, n);
System.out.println(count);
}
public static void print(int A[], int n){
for(int i=0;i<n;++i){
System.out.print(A[i]);
if(i<n-1){System.out.print(" ");}
}
System.out.println();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
20,
13,
0,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
4,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
17,
2,
13,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
212,
20
],
[
212,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
29,
32
],
[
32,
33
],
[
33,
34
],
[
23,
35
],
[
35,
36
],
[
35,
37
],
[
23,
39
],
[
39,
40
],
[
39,
41
],
[
23,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
45,
50
],
[
23,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
71,
72
],
[
71,
73
],
[
23,
74
],
[
74,
75
],
[
74,
76
],
[
21,
77
],
[
77,
78
],
[
212,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
81,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
95,
96
],
[
95,
97
],
[
90,
98
],
[
98,
99
],
[
99,
100
],
[
90,
101
],
[
102,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
103,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
110,
112
],
[
103,
113
],
[
113,
114
],
[
114,
115
],
[
103,
116
],
[
117,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
125,
126
],
[
125,
127
],
[
118,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
128,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
136,
142
],
[
142,
143
],
[
142,
144
],
[
128,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
128,
150
],
[
150,
151
],
[
81,
152
],
[
152,
153
],
[
152,
154
],
[
81,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
79,
161
],
[
161,
162
],
[
212,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
166,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
173,
175
],
[
166,
176
],
[
176,
177
],
[
177,
178
],
[
166,
179
],
[
180,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
181,
186
],
[
186,
187
],
[
186,
188
],
[
180,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
189,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
197,
202
],
[
189,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
203,
208
],
[
163,
209
],
[
209,
210
],
[
0,
211
],
[
211,
212
],
[
211,
213
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\n\nimport java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tString tmp_arr[] = new String[n];\n\t\tint arr[] = new int[n];\n\t\ttmp_arr = br.readLine().split(\" \");\n\t\tfor(int i=0; i<n;i++){\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}\n\t\t\n\t\tbubblesort_swap_num(arr);\n\t}\n\tpublic static void bubblesort_swap_num(int[] arr){\n\t\tint n = arr.length;\n\t\tint ans = 0;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint_array(arr);\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static void print_array(int[] arr){\n\t\tfor(int i=0; i<arr.length; i++){\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}\n\t}\n}\n",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tString tmp_arr[] = new String[n];\n\t\tint arr[] = new int[n];\n\t\ttmp_arr = br.readLine().split(\" \");\n\t\tfor(int i=0; i<n;i++){\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}\n\t\t\n\t\tbubblesort_swap_num(arr);\n\t}\n\tpublic static void bubblesort_swap_num(int[] arr){\n\t\tint n = arr.length;\n\t\tint ans = 0;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint_array(arr);\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static void print_array(int[] arr){\n\t\tfor(int i=0; i<arr.length; i++){\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tString tmp_arr[] = new String[n];\n\t\tint arr[] = new int[n];\n\t\ttmp_arr = br.readLine().split(\" \");\n\t\tfor(int i=0; i<n;i++){\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}\n\t\t\n\t\tbubblesort_swap_num(arr);\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tString tmp_arr[] = new String[n];\n\t\tint arr[] = new int[n];\n\t\ttmp_arr = br.readLine().split(\" \");\n\t\tfor(int i=0; i<n;i++){\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}\n\t\t\n\t\tbubblesort_swap_num(arr);\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"String tmp_arr[] = new String[n];",
"tmp_arr",
"new String[n]",
"n",
"int arr[] = new int[n];",
"arr",
"new int[n]",
"n",
"tmp_arr = br.readLine().split(\" \")",
"tmp_arr",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for(int i=0; i<n;i++){\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}",
"{\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}",
"arr[i] = Integer.parseInt(tmp_arr[i])",
"arr[i]",
"arr",
"i",
"Integer.parseInt(tmp_arr[i])",
"Integer.parseInt",
"Integer",
"tmp_arr[i]",
"tmp_arr",
"i",
"bubblesort_swap_num(arr)",
"bubblesort_swap_num",
"arr",
"String[] args",
"args",
"public static void bubblesort_swap_num(int[] arr){\n\t\tint n = arr.length;\n\t\tint ans = 0;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint_array(arr);\n\t\tSystem.out.println(ans);\n\t}",
"bubblesort_swap_num",
"{\n\t\tint n = arr.length;\n\t\tint ans = 0;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint_array(arr);\n\t\tSystem.out.println(ans);\n\t}",
"int n = arr.length;",
"n",
"arr.length",
"arr",
"arr.length",
"int ans = 0;",
"ans",
"0",
"for(int i=0; i<n; i++){\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}",
"int j=1;",
"int j=1;",
"j",
"1",
"j<n-i",
"j",
"n-i",
"n",
"i",
"j++",
"j++",
"j",
"{\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}",
"if(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}",
"arr[j-1] > arr[j]",
"arr[j-1]",
"arr",
"j-1",
"j",
"1",
"arr[j]",
"arr",
"j",
"{\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}",
"int tmp = arr[j-1];",
"tmp",
"arr[j-1]",
"arr",
"j-1",
"j",
"1",
"arr[j-1] = arr[j]",
"arr[j-1]",
"arr",
"j-1",
"j",
"1",
"arr[j]",
"arr",
"j",
"arr[j] = tmp",
"arr[j]",
"arr",
"j",
"tmp",
"ans++",
"ans",
"print_array(arr)",
"print_array",
"arr",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"int[] arr",
"arr",
"public static void print_array(int[] arr){\n\t\tfor(int i=0; i<arr.length; i++){\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}\n\t}",
"print_array",
"{\n\t\tfor(int i=0; i<arr.length; i++){\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}\n\t}",
"for(int i=0; i<arr.length; i++){\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<arr.length",
"i",
"arr.length",
"arr",
"arr.length",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}",
"{\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}",
"System.out.print(arr[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"arr[i]",
"arr",
"i",
"if(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");",
"i != arr.length-1",
"i",
"arr.length-1",
"arr.length",
"arr",
"arr.length",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"int[] arr",
"arr",
"public class Main {\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tString tmp_arr[] = new String[n];\n\t\tint arr[] = new int[n];\n\t\ttmp_arr = br.readLine().split(\" \");\n\t\tfor(int i=0; i<n;i++){\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}\n\t\t\n\t\tbubblesort_swap_num(arr);\n\t}\n\tpublic static void bubblesort_swap_num(int[] arr){\n\t\tint n = arr.length;\n\t\tint ans = 0;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint_array(arr);\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static void print_array(int[] arr){\n\t\tfor(int i=0; i<arr.length; i++){\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tString tmp_arr[] = new String[n];\n\t\tint arr[] = new int[n];\n\t\ttmp_arr = br.readLine().split(\" \");\n\t\tfor(int i=0; i<n;i++){\n\t\t\tarr[i] = Integer.parseInt(tmp_arr[i]);\n\t\t}\n\t\t\n\t\tbubblesort_swap_num(arr);\n\t}\n\tpublic static void bubblesort_swap_num(int[] arr){\n\t\tint n = arr.length;\n\t\tint ans = 0;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tfor(int j=1; j<n-i; j++){\n\t\t\t\tif(arr[j-1] > arr[j]){\n\t\t\t\t\tint tmp = arr[j-1];\n\t\t\t\t\tarr[j-1] = arr[j];\n\t\t\t\t\tarr[j] = tmp;\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprint_array(arr);\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static void print_array(int[] arr){\n\t\tfor(int i=0; i<arr.length; i++){\n\t\t\tSystem.out.print(arr[i]);\n\t\t\tif(i != arr.length-1) System.out.print(\" \");\n\t\t\telse System.out.print(\"\\n\");\n\t\t}\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String tmp_arr[] = new String[n];
int arr[] = new int[n];
tmp_arr = br.readLine().split(" ");
for(int i=0; i<n;i++){
arr[i] = Integer.parseInt(tmp_arr[i]);
}
bubblesort_swap_num(arr);
}
public static void bubblesort_swap_num(int[] arr){
int n = arr.length;
int ans = 0;
for(int i=0; i<n; i++){
for(int j=1; j<n-i; j++){
if(arr[j-1] > arr[j]){
int tmp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = tmp;
ans++;
}
}
}
print_array(arr);
System.out.println(ans);
}
public static void print_array(int[] arr){
for(int i=0; i<arr.length; i++){
System.out.print(arr[i]);
if(i != arr.length-1) System.out.print(" ");
else System.out.print("\n");
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
172,
11
],
[
172,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
32,
37
],
[
14,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
58,
60
],
[
14,
61
],
[
61,
62
],
[
61,
63
],
[
14,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
69,
70
],
[
69,
71
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
77,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
77,
89
],
[
89,
90
],
[
90,
91
],
[
77,
92
],
[
93,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
94,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
116,
118
],
[
104,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
104,
126
],
[
126,
127
],
[
14,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
128,
138
],
[
138,
139
],
[
139,
140
],
[
128,
141
],
[
142,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
14,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
153,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
160,
162
],
[
14,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
163,
168
],
[
12,
169
],
[
169,
170
],
[
0,
171
],
[
171,
172
],
[
171,
173
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\n\n/**\n *\n * @author Y\n */\npublic class Main {\n public static void main(String[]args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int N = Integer.parseInt(br.readLine());\n int[] a = new int[N];\n String[] s = br.readLine().split(\" \");\n for(int i = 0;i<N;i++){\n a[i] = Integer.parseInt(s[i]);\n }\n \n int Nswap = 0;\n for(int i=0;i<N;i++){\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }\n \n for(int i=0;i<N-1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[N-1]);\n System.out.println(Nswap);\n \n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"public class Main {\n public static void main(String[]args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int N = Integer.parseInt(br.readLine());\n int[] a = new int[N];\n String[] s = br.readLine().split(\" \");\n for(int i = 0;i<N;i++){\n a[i] = Integer.parseInt(s[i]);\n }\n \n int Nswap = 0;\n for(int i=0;i<N;i++){\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }\n \n for(int i=0;i<N-1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[N-1]);\n System.out.println(Nswap);\n \n }\n}",
"Main",
"public static void main(String[]args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int N = Integer.parseInt(br.readLine());\n int[] a = new int[N];\n String[] s = br.readLine().split(\" \");\n for(int i = 0;i<N;i++){\n a[i] = Integer.parseInt(s[i]);\n }\n \n int Nswap = 0;\n for(int i=0;i<N;i++){\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }\n \n for(int i=0;i<N-1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[N-1]);\n System.out.println(Nswap);\n \n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int N = Integer.parseInt(br.readLine());\n int[] a = new int[N];\n String[] s = br.readLine().split(\" \");\n for(int i = 0;i<N;i++){\n a[i] = Integer.parseInt(s[i]);\n }\n \n int Nswap = 0;\n for(int i=0;i<N;i++){\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }\n \n for(int i=0;i<N-1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[N-1]);\n System.out.println(Nswap);\n \n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int N = Integer.parseInt(br.readLine());",
"N",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"int[] a = new int[N];",
"a",
"new int[N]",
"N",
"String[] s = br.readLine().split(\" \");",
"s",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for(int i = 0;i<N;i++){\n a[i] = Integer.parseInt(s[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n a[i] = Integer.parseInt(s[i]);\n }",
"{\n a[i] = Integer.parseInt(s[i]);\n }",
"a[i] = Integer.parseInt(s[i])",
"a[i]",
"a",
"i",
"Integer.parseInt(s[i])",
"Integer.parseInt",
"Integer",
"s[i]",
"s",
"i",
"int Nswap = 0;",
"Nswap",
"0",
"for(int i=0;i<N;i++){\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }",
"{\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }",
"for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }",
"int j = N-1;",
"int j = N-1;",
"j",
"N-1",
"N",
"1",
"j>=i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }",
"{\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }",
"if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }",
"a[j]<a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j]=a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1]=tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"tmp",
"Nswap++",
"Nswap",
"for(int i=0;i<N-1;i++){\n System.out.print(a[i] + \" \");\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n System.out.print(a[i] + \" \");\n }",
"{\n System.out.print(a[i] + \" \");\n }",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(a[N-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[N-1]",
"a",
"N-1",
"N",
"1",
"System.out.println(Nswap)",
"System.out.println",
"System.out",
"System",
"System.out",
"Nswap",
"String[]args",
"args",
"public class Main {\n public static void main(String[]args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int N = Integer.parseInt(br.readLine());\n int[] a = new int[N];\n String[] s = br.readLine().split(\" \");\n for(int i = 0;i<N;i++){\n a[i] = Integer.parseInt(s[i]);\n }\n \n int Nswap = 0;\n for(int i=0;i<N;i++){\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }\n \n for(int i=0;i<N-1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[N-1]);\n System.out.println(Nswap);\n \n }\n}",
"public class Main {\n public static void main(String[]args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int N = Integer.parseInt(br.readLine());\n int[] a = new int[N];\n String[] s = br.readLine().split(\" \");\n for(int i = 0;i<N;i++){\n a[i] = Integer.parseInt(s[i]);\n }\n \n int Nswap = 0;\n for(int i=0;i<N;i++){\n for(int j = N-1;j>=i+1;j--){\n if(a[j]<a[j-1]){\n int tmp = a[j];\n a[j]=a[j-1];\n a[j-1]=tmp;\n \n Nswap++;\n }\n }\n }\n \n for(int i=0;i<N-1;i++){\n System.out.print(a[i] + \" \");\n }\n System.out.println(a[N-1]);\n System.out.println(Nswap);\n \n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/**
*
* @author Y
*/
public class Main {
public static void main(String[]args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int[] a = new int[N];
String[] s = br.readLine().split(" ");
for(int i = 0;i<N;i++){
a[i] = Integer.parseInt(s[i]);
}
int Nswap = 0;
for(int i=0;i<N;i++){
for(int j = N-1;j>=i+1;j--){
if(a[j]<a[j-1]){
int tmp = a[j];
a[j]=a[j-1];
a[j-1]=tmp;
Nswap++;
}
}
}
for(int i=0;i<N-1;i++){
System.out.print(a[i] + " ");
}
System.out.println(a[N-1]);
System.out.println(Nswap);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
18,
13,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
4,
18,
18,
13,
13,
18,
13,
17,
14,
2,
13,
17,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
186,
11
],
[
186,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
32,
37
],
[
14,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
58,
60
],
[
14,
61
],
[
61,
62
],
[
61,
63
],
[
14,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
64,
76
],
[
76,
77
],
[
77,
78
],
[
64,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
81,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
81,
95
],
[
95,
96
],
[
96,
97
],
[
81,
98
],
[
99,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
100,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
115,
117
],
[
110,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
121,
123
],
[
118,
124
],
[
124,
125
],
[
124,
126
],
[
110,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
110,
132
],
[
132,
133
],
[
14,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
14,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
154,
156
],
[
147,
157
],
[
157,
158
],
[
158,
159
],
[
147,
160
],
[
161,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
162,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
169,
171
],
[
14,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
14,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
177,
182
],
[
12,
183
],
[
183,
184
],
[
0,
185
],
[
185,
186
],
[
185,
187
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main (String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] a = new int[n];\n\t\tString[] elements = br.readLine().split(\" \");\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}\n\t\t\n\t\tint swap = 0;\n\t\t\n\t\tfor (int i = 0; i < a.length - 1; i++){\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(a[0]);\t\n\t\tif(n > 1){\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap);\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n\tpublic static void main (String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] a = new int[n];\n\t\tString[] elements = br.readLine().split(\" \");\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}\n\t\t\n\t\tint swap = 0;\n\t\t\n\t\tfor (int i = 0; i < a.length - 1; i++){\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(a[0]);\t\n\t\tif(n > 1){\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap);\n\t}\n}",
"Main",
"public static void main (String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] a = new int[n];\n\t\tString[] elements = br.readLine().split(\" \");\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}\n\t\t\n\t\tint swap = 0;\n\t\t\n\t\tfor (int i = 0; i < a.length - 1; i++){\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(a[0]);\t\n\t\tif(n > 1){\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap);\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] a = new int[n];\n\t\tString[] elements = br.readLine().split(\" \");\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}\n\t\t\n\t\tint swap = 0;\n\t\t\n\t\tfor (int i = 0; i < a.length - 1; i++){\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(a[0]);\t\n\t\tif(n > 1){\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap);\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"String[] elements = br.readLine().split(\" \");",
"elements",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for (int i = 0; i < n; i++){\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}",
"{\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}",
"a[i] = Integer.parseInt(elements[i])",
"a[i]",
"a",
"i",
"Integer.parseInt(elements[i])",
"Integer.parseInt",
"Integer",
"elements[i]",
"elements",
"i",
"int swap = 0;",
"swap",
"0",
"for (int i = 0; i < a.length - 1; i++){\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length - 1",
"i",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}",
"int j = a.length - 1;",
"int j = a.length - 1;",
"j",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"j >= i + 1",
"j",
"i + 1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}",
"if(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}",
"int v = a[j-1];",
"v",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = a[j]",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j]",
"a",
"j",
"a[j] = v",
"a[j]",
"a",
"j",
"v",
"swap++",
"swap",
"System.out.print(a[0])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[0]",
"a",
"0",
"if(n > 1){\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}",
"n > 1",
"n",
"1",
"{\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}",
"for (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}",
"{\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}",
"System.out.print(\" \" + a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \" + a[i]",
"\" \"",
"a[i]",
"a",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(swap)",
"System.out.println",
"System.out",
"System",
"System.out",
"swap",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main (String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] a = new int[n];\n\t\tString[] elements = br.readLine().split(\" \");\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}\n\t\t\n\t\tint swap = 0;\n\t\t\n\t\tfor (int i = 0; i < a.length - 1; i++){\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(a[0]);\t\n\t\tif(n > 1){\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap);\n\t}\n}",
"public class Main {\n\n\tpublic static void main (String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tint[] a = new int[n];\n\t\tString[] elements = br.readLine().split(\" \");\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\ta[i] = Integer.parseInt(elements[i]);\n\t\t}\n\t\t\n\t\tint swap = 0;\n\t\t\n\t\tfor (int i = 0; i < a.length - 1; i++){\n\t\t\tfor(int j = a.length - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j-1]){\n\t\t\t\t\tint v = a[j-1];\n\t\t\t\t\ta[j-1] = a[j];\n\t\t\t\t\ta[j] = v;\n\t\t\t\t\tswap++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(a[0]);\t\n\t\tif(n > 1){\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap);\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main (String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] a = new int[n];
String[] elements = br.readLine().split(" ");
for (int i = 0; i < n; i++){
a[i] = Integer.parseInt(elements[i]);
}
int swap = 0;
for (int i = 0; i < a.length - 1; i++){
for(int j = a.length - 1; j >= i + 1; j--){
if(a[j] < a[j-1]){
int v = a[j-1];
a[j-1] = a[j];
a[j] = v;
swap++;
}
}
}
System.out.print(a[0]);
if(n > 1){
for (int i = 1; i < a.length; i++) {
System.out.print(" " + a[i]);
}
}
System.out.println();
System.out.println(swap);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
18,
13,
13,
41,
13,
17,
41,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
40,
13,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
175,
5
],
[
175,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
11,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
19,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
26,
28
],
[
19,
29
],
[
29,
30
],
[
30,
31
],
[
19,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
38,
40
],
[
34,
41
],
[
41,
42
],
[
41,
43
],
[
34,
44
],
[
44,
45
],
[
45,
46
],
[
34,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
56,
58
],
[
49,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
59,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
59,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
76,
82
],
[
8,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
88,
89
],
[
88,
90
],
[
83,
91
],
[
91,
92
],
[
92,
93
],
[
83,
94
],
[
95,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
96,
101
],
[
101,
102
],
[
101,
103
],
[
95,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
110,
115
],
[
8,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
8,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
6,
127
],
[
127,
128
],
[
175,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
134,
136
],
[
131,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
131,
142
],
[
142,
143
],
[
142,
144
],
[
131,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
151,
152
],
[
151,
153
],
[
146,
154
],
[
154,
155
],
[
155,
156
],
[
146,
157
],
[
158,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
163,
164
],
[
164,
165
],
[
131,
166
],
[
166,
167
],
[
166,
168
],
[
131,
169
],
[
169,
170
],
[
170,
171
],
[
129,
172
],
[
172,
173
],
[
0,
174
],
[
174,
175
],
[
174,
176
]
] | [
"import java.util.Scanner;\n\npublic class Main{\n\n\n\tpublic static void BubbleSort(int[] array){\n\t\tint len=array.length;\n\t\tint cnt=0;\n\t\tint swap;\n\t\tfor(int i=0;i<len-1;i++){\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<len;i++){\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}\n\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}\n\n\tpublic static void main(String[] args){\n\n\t\tint n;\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tn=scan.nextInt();\n\t\tint[] box=new int[n];\n\n\t\tfor(int i=0;i<n;i++){\n\t\tbox[i]=scan.nextInt();\n\t\t}\n\n\t\tBubbleSort(box);\n\n\t\tscan.close();\n\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\n\n\tpublic static void BubbleSort(int[] array){\n\t\tint len=array.length;\n\t\tint cnt=0;\n\t\tint swap;\n\t\tfor(int i=0;i<len-1;i++){\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<len;i++){\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}\n\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}\n\n\tpublic static void main(String[] args){\n\n\t\tint n;\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tn=scan.nextInt();\n\t\tint[] box=new int[n];\n\n\t\tfor(int i=0;i<n;i++){\n\t\tbox[i]=scan.nextInt();\n\t\t}\n\n\t\tBubbleSort(box);\n\n\t\tscan.close();\n\n\t}\n\n}",
"Main",
"public static void BubbleSort(int[] array){\n\t\tint len=array.length;\n\t\tint cnt=0;\n\t\tint swap;\n\t\tfor(int i=0;i<len-1;i++){\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<len;i++){\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}\n\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}",
"BubbleSort",
"{\n\t\tint len=array.length;\n\t\tint cnt=0;\n\t\tint swap;\n\t\tfor(int i=0;i<len-1;i++){\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<len;i++){\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}\n\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}",
"int len=array.length;",
"len",
"array.length",
"array",
"array.length",
"int cnt=0;",
"cnt",
"0",
"int swap;",
"swap",
"for(int i=0;i<len-1;i++){\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<len-1",
"i",
"len-1",
"len",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}",
"int j=len-1;",
"int j=len-1;",
"j",
"len-1",
"len",
"1",
"i<j",
"i",
"j",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}",
"if(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}",
"array[j]<array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}",
"cnt++",
"cnt",
"swap=array[j]",
"swap",
"array[j]",
"array",
"j",
"array[j]=array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1]=swap",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"swap",
"for(int i=0;i<len;i++){\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<len",
"i",
"len",
"i++",
"i++",
"i",
"{\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}",
"{\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}",
"System.out.print(array[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"array[i]",
"array",
"i",
"if(i!=len-1)System.out.print(\" \");",
"i!=len-1",
"i",
"len-1",
"len",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"int[] array",
"array",
"public static void main(String[] args){\n\n\t\tint n;\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tn=scan.nextInt();\n\t\tint[] box=new int[n];\n\n\t\tfor(int i=0;i<n;i++){\n\t\tbox[i]=scan.nextInt();\n\t\t}\n\n\t\tBubbleSort(box);\n\n\t\tscan.close();\n\n\t}",
"main",
"{\n\n\t\tint n;\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tn=scan.nextInt();\n\t\tint[] box=new int[n];\n\n\t\tfor(int i=0;i<n;i++){\n\t\tbox[i]=scan.nextInt();\n\t\t}\n\n\t\tBubbleSort(box);\n\n\t\tscan.close();\n\n\t}",
"int n;",
"n",
"Scanner scan=new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"n=scan.nextInt()",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int[] box=new int[n];",
"box",
"new int[n]",
"n",
"for(int i=0;i<n;i++){\n\t\tbox[i]=scan.nextInt();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\tbox[i]=scan.nextInt();\n\t\t}",
"{\n\t\tbox[i]=scan.nextInt();\n\t\t}",
"box[i]=scan.nextInt()",
"box[i]",
"box",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"BubbleSort(box)",
"BubbleSort",
"box",
"scan.close()",
"scan.close",
"scan",
"String[] args",
"args",
"public class Main{\n\n\n\tpublic static void BubbleSort(int[] array){\n\t\tint len=array.length;\n\t\tint cnt=0;\n\t\tint swap;\n\t\tfor(int i=0;i<len-1;i++){\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<len;i++){\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}\n\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}\n\n\tpublic static void main(String[] args){\n\n\t\tint n;\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tn=scan.nextInt();\n\t\tint[] box=new int[n];\n\n\t\tfor(int i=0;i<n;i++){\n\t\tbox[i]=scan.nextInt();\n\t\t}\n\n\t\tBubbleSort(box);\n\n\t\tscan.close();\n\n\t}\n\n}",
"public class Main{\n\n\n\tpublic static void BubbleSort(int[] array){\n\t\tint len=array.length;\n\t\tint cnt=0;\n\t\tint swap;\n\t\tfor(int i=0;i<len-1;i++){\n\t\t\tfor(int j=len-1;i<j;j--){\n\t\t\t\tif(array[j]<array[j-1]){\n\t\t\t\t\tcnt++;\n\t\t\t\t\tswap=array[j];array[j]=array[j-1];array[j-1]=swap;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<len;i++){\n\t\tSystem.out.print(array[i]);\n\t\tif(i!=len-1)System.out.print(\" \");}\n\n\t\tSystem.out.println();\n\t\tSystem.out.println(cnt);\n\t}\n\n\tpublic static void main(String[] args){\n\n\t\tint n;\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tn=scan.nextInt();\n\t\tint[] box=new int[n];\n\n\t\tfor(int i=0;i<n;i++){\n\t\tbox[i]=scan.nextInt();\n\t\t}\n\n\t\tBubbleSort(box);\n\n\t\tscan.close();\n\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void BubbleSort(int[] array){
int len=array.length;
int cnt=0;
int swap;
for(int i=0;i<len-1;i++){
for(int j=len-1;i<j;j--){
if(array[j]<array[j-1]){
cnt++;
swap=array[j];array[j]=array[j-1];array[j-1]=swap;
}
}
}
for(int i=0;i<len;i++){
System.out.print(array[i]);
if(i!=len-1)System.out.print(" ");}
System.out.println();
System.out.println(cnt);
}
public static void main(String[] args){
int n;
Scanner scan=new Scanner(System.in);
n=scan.nextInt();
int[] box=new int[n];
for(int i=0;i<n;i++){
box[i]=scan.nextInt();
}
BubbleSort(box);
scan.close();
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
17,
2,
13,
2,
2,
13,
13,
17,
1,
40,
13,
30,
30,
14,
2,
4,
18,
13,
18,
13,
13,
4,
18,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
18,
18,
13,
13,
4,
18,
13,
17,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
125,
8
],
[
125,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
17,
20
],
[
20,
21
],
[
21,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
25,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
11,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
34,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
41,
43
],
[
34,
44
],
[
44,
45
],
[
45,
46
],
[
34,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
57,
57
],
[
57,
58
],
[
57,
59
],
[
57,
60
],
[
49,
61
],
[
61,
62
],
[
62,
63
],
[
49,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
71,
72
],
[
71,
73
],
[
67,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
66,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
82,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
82,
104
],
[
104,
105
],
[
11,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
111,
115
],
[
11,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
9,
122
],
[
122,
123
],
[
0,
124
],
[
124,
125
],
[
124,
126
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n String[] array = br.readLine().split(\" \");\n int count = 0;\n\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }\n\n System.out.println(String.join(\" \", array));\n System.out.println(count);\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n String[] array = br.readLine().split(\" \");\n int count = 0;\n\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }\n\n System.out.println(String.join(\" \", array));\n System.out.println(count);\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n String[] array = br.readLine().split(\" \");\n int count = 0;\n\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }\n\n System.out.println(String.join(\" \", array));\n System.out.println(count);\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n String[] array = br.readLine().split(\" \");\n int count = 0;\n\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }\n\n System.out.println(String.join(\" \", array));\n System.out.println(count);\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"String[] array = br.readLine().split(\" \");",
"array",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int count = 0;",
"count",
"0",
"for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }",
"{\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }",
"for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }",
"int j = 0;",
"int j = 0;",
"j",
"0",
"j < n - i - 1",
"j",
"n - i - 1",
"n - i - 1",
"n",
"i",
"1",
"j++",
"j++",
"j",
"{\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }",
"{\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }",
"if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }",
"Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])",
"Integer.parseInt(array[j])",
"Integer.parseInt",
"Integer",
"array[j]",
"array",
"j",
"Integer.parseInt(array[j + 1])",
"Integer.parseInt",
"Integer",
"array[j + 1]",
"array",
"j + 1",
"j",
"1",
"{\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }",
"String tmp = array[j];",
"tmp",
"array[j]",
"array",
"j",
"array[j] = array[j + 1]",
"array[j]",
"array",
"j",
"array[j + 1]",
"array",
"j + 1",
"j",
"1",
"array[j + 1] = tmp",
"array[j + 1]",
"array",
"j + 1",
"j",
"1",
"tmp",
"count++",
"count",
"System.out.println(String.join(\" \", array))",
"System.out.println",
"System.out",
"System",
"System.out",
"String.join(\" \", array)",
"String.join",
"String",
"\" \"",
"array",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n String[] array = br.readLine().split(\" \");\n int count = 0;\n\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }\n\n System.out.println(String.join(\" \", array));\n System.out.println(count);\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n String[] array = br.readLine().split(\" \");\n int count = 0;\n\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {\n String tmp = array[j];\n array[j] = array[j + 1];\n array[j + 1] = tmp;\n count++;\n }\n }\n }\n\n System.out.println(String.join(\" \", array));\n System.out.println(count);\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String[] array = br.readLine().split(" ");
int count = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {
String tmp = array[j];
array[j] = array[j + 1];
array[j + 1] = tmp;
count++;
}
}
}
System.out.println(String.join(" ", array));
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
0,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
162,
5
],
[
162,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
8,
27
],
[
27,
28
],
[
8,
29
],
[
29,
30
],
[
8,
31
],
[
31,
32
],
[
31,
33
],
[
8,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
34,
39
],
[
39,
40
],
[
39,
41
],
[
34,
42
],
[
42,
43
],
[
43,
44
],
[
34,
45
],
[
46,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
52,
53
],
[
8,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
54,
64
],
[
64,
65
],
[
65,
66
],
[
54,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
69,
76
],
[
76,
77
],
[
76,
78
],
[
69,
79
],
[
79,
80
],
[
80,
81
],
[
69,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
84,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
94,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
94,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
112,
114
],
[
109,
115
],
[
94,
116
],
[
116,
117
],
[
8,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
118,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
118,
128
],
[
128,
129
],
[
129,
130
],
[
118,
131
],
[
132,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
8,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
150,
152
],
[
8,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
153,
158
],
[
6,
159
],
[
159,
160
],
[
0,
161
],
[
161,
162
],
[
161,
163
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint []A = new int [N];\n\t\tint i, j, t, k, l;\n\t\tint count = 0;\n\t\t\n\t\tfor (i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor(j = 0; j <= N-1; j++) {\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (l = 0;l < N - 1; l++) {\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}\n\t\tSystem.out.println(A[N-1]);\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint []A = new int [N];\n\t\tint i, j, t, k, l;\n\t\tint count = 0;\n\t\t\n\t\tfor (i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor(j = 0; j <= N-1; j++) {\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (l = 0;l < N - 1; l++) {\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}\n\t\tSystem.out.println(A[N-1]);\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint []A = new int [N];\n\t\tint i, j, t, k, l;\n\t\tint count = 0;\n\t\t\n\t\tfor (i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor(j = 0; j <= N-1; j++) {\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (l = 0;l < N - 1; l++) {\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}\n\t\tSystem.out.println(A[N-1]);\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint []A = new int [N];\n\t\tint i, j, t, k, l;\n\t\tint count = 0;\n\t\t\n\t\tfor (i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor(j = 0; j <= N-1; j++) {\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (l = 0;l < N - 1; l++) {\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}\n\t\tSystem.out.println(A[N-1]);\n\t\tSystem.out.println(count);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int []A = new int [N];",
"A",
"new int [N]",
"N",
"int i",
"i",
"j",
"j",
"t",
"t",
"k",
"k",
"l;",
"l",
"int count = 0;",
"count",
"0",
"for (i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"i = 0;",
"i = 0",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(j = 0; j <= N-1; j++) {\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"j = 0;",
"j = 0",
"j",
"0",
"j <= N-1",
"j",
"N-1",
"N",
"1",
"j++",
"j++",
"j",
"{\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"{\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"for(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"k = N-1;",
"k = N-1",
"k",
"N-1",
"N",
"1",
"k > j",
"k",
"j",
"k--",
"k--",
"k",
"{\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"A[k] < A[k-1]",
"A[k]",
"A",
"k",
"A[k-1]",
"A",
"k-1",
"k",
"1",
"{\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"t = A[k]",
"t",
"A[k]",
"A",
"k",
"A[k] = A[k-1]",
"A[k]",
"A",
"k",
"A[k-1]",
"A",
"k-1",
"k",
"1",
"A[k-1] = t",
"A[k-1]",
"A",
"k-1",
"k",
"1",
"t",
"count++",
"count",
"for (l = 0;l < N - 1; l++) {\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}",
"l = 0;",
"l = 0",
"l",
"0",
"l < N - 1",
"l",
"N - 1",
"N",
"1",
"l++",
"l++",
"l",
"{\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}",
"{\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}",
"System.out.print(A[l] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"A[l] + \" \"",
"A[l]",
"A",
"l",
"\" \"",
"System.out.println(A[N-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"A[N-1]",
"A",
"N-1",
"N",
"1",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint []A = new int [N];\n\t\tint i, j, t, k, l;\n\t\tint count = 0;\n\t\t\n\t\tfor (i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor(j = 0; j <= N-1; j++) {\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (l = 0;l < N - 1; l++) {\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}\n\t\tSystem.out.println(A[N-1]);\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint []A = new int [N];\n\t\tint i, j, t, k, l;\n\t\tint count = 0;\n\t\t\n\t\tfor (i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor(j = 0; j <= N-1; j++) {\n\t\t\tfor(k = N-1;k > j;k--) {\n\t\t\t\tif(A[k] < A[k-1]) {\n\t\t\t\t\tt = A[k];\n\t\t\t\t\tA[k] = A[k-1];\n\t\t\t\t\tA[k-1] = t;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (l = 0;l < N - 1; l++) {\n\t\t\tSystem.out.print(A[l] + \" \");\n\t\t}\n\t\tSystem.out.println(A[N-1]);\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int []A = new int [N];
int i, j, t, k, l;
int count = 0;
for (i = 0; i < N; i++) {
A[i] = sc.nextInt();
}
for(j = 0; j <= N-1; j++) {
for(k = N-1;k > j;k--) {
if(A[k] < A[k-1]) {
t = A[k];
A[k] = A[k-1];
A[k-1] = t;
count++;
}
}
}
for (l = 0;l < N - 1; l++) {
System.out.print(A[l] + " ");
}
System.out.println(A[N-1]);
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
18,
13,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
2,
18,
13,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
29,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
178,
5
],
[
178,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
43,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
46,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
61,
66
],
[
66,
67
],
[
66,
68
],
[
60,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
69,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
78,
83
],
[
8,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
8,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
6,
95
],
[
95,
96
],
[
178,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
103,
110
],
[
110,
111
],
[
110,
112
],
[
103,
113
],
[
113,
114
],
[
114,
115
],
[
103,
116
],
[
117,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
118,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
118,
134
],
[
134,
135
],
[
135,
136
],
[
118,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
146,
148
],
[
139,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
152,
154
],
[
149,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
149,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
167,
169
],
[
164,
170
],
[
149,
171
],
[
171,
172
],
[
99,
173
],
[
173,
174
],
[
97,
175
],
[
175,
176
],
[
0,
177
],
[
177,
178
],
[
177,
179
]
] | [
"\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n // write your code here\n Scanner scanner=new Scanner(System.in);\n int n=scanner.nextInt();\n int[] ints=new int[n];\n for(int i=0;i<n;i++){\n ints[i]=scanner.nextInt();\n }\n int result=bubbleSort(ints);\n for(int i=0;i<ints.length;i++){\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(result);\n }\n public static int bubbleSort(int[] ints){\n int result=0;\n for(int i=ints.length;i>1;i--){\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }\n return result;\n }\n\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n public static void main(String[] args) {\n // write your code here\n Scanner scanner=new Scanner(System.in);\n int n=scanner.nextInt();\n int[] ints=new int[n];\n for(int i=0;i<n;i++){\n ints[i]=scanner.nextInt();\n }\n int result=bubbleSort(ints);\n for(int i=0;i<ints.length;i++){\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(result);\n }\n public static int bubbleSort(int[] ints){\n int result=0;\n for(int i=ints.length;i>1;i--){\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }\n return result;\n }\n\n}",
"Main",
"public static void main(String[] args) {\n // write your code here\n Scanner scanner=new Scanner(System.in);\n int n=scanner.nextInt();\n int[] ints=new int[n];\n for(int i=0;i<n;i++){\n ints[i]=scanner.nextInt();\n }\n int result=bubbleSort(ints);\n for(int i=0;i<ints.length;i++){\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(result);\n }",
"main",
"{\n // write your code here\n Scanner scanner=new Scanner(System.in);\n int n=scanner.nextInt();\n int[] ints=new int[n];\n for(int i=0;i<n;i++){\n ints[i]=scanner.nextInt();\n }\n int result=bubbleSort(ints);\n for(int i=0;i<ints.length;i++){\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(result);\n }",
"Scanner scanner=new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int n=scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int[] ints=new int[n];",
"ints",
"new int[n]",
"n",
"for(int i=0;i<n;i++){\n ints[i]=scanner.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n ints[i]=scanner.nextInt();\n }",
"{\n ints[i]=scanner.nextInt();\n }",
"ints[i]=scanner.nextInt()",
"ints[i]",
"ints",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int result=bubbleSort(ints);",
"result",
"bubbleSort(ints)",
"bubbleSort",
"ints",
"for(int i=0;i<ints.length;i++){\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<ints.length",
"i",
"ints.length",
"ints",
"ints.length",
"i++",
"i++",
"i",
"{\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }",
"{\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }",
"System.out.print(ints[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"ints[i]",
"ints",
"i",
"if(i!=ints.length-1){\n System.out.print(\" \");\n }",
"i!=ints.length-1",
"i",
"ints.length-1",
"ints.length",
"ints",
"ints.length",
"1",
"{\n System.out.print(\" \");\n }",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(result)",
"System.out.println",
"System.out",
"System",
"System.out",
"result",
"String[] args",
"args",
"public static int bubbleSort(int[] ints){\n int result=0;\n for(int i=ints.length;i>1;i--){\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }\n return result;\n }",
"bubbleSort",
"{\n int result=0;\n for(int i=ints.length;i>1;i--){\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }\n return result;\n }",
"int result=0;",
"result",
"0",
"for(int i=ints.length;i>1;i--){\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }",
"int i=ints.length;",
"int i=ints.length;",
"i",
"ints.length",
"ints",
"ints.length",
"i>1",
"i",
"1",
"i--",
"i--",
"i",
"{\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }",
"{\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }",
"for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }",
"int j=ints.length-1;",
"int j=ints.length-1;",
"j",
"ints.length-1",
"ints.length",
"ints",
"ints.length",
"1",
"j>ints.length-i",
"j",
"ints.length-i",
"ints.length",
"ints",
"ints.length",
"i",
"j--",
"j--",
"j",
"{\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }",
"{\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }",
"if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }",
"ints[j]<ints[j-1]",
"ints[j]",
"ints",
"j",
"ints[j-1]",
"ints",
"j-1",
"j",
"1",
"{\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }",
"int tmp=ints[j];",
"tmp",
"ints[j]",
"ints",
"j",
"ints[j]=ints[j-1]",
"ints[j]",
"ints",
"j",
"ints[j-1]",
"ints",
"j-1",
"j",
"1",
"ints[j-1]=tmp",
"ints[j-1]",
"ints",
"j-1",
"j",
"1",
"tmp",
"result++",
"result",
"return result;",
"result",
"int[] ints",
"ints",
"public class Main {\n\n public static void main(String[] args) {\n // write your code here\n Scanner scanner=new Scanner(System.in);\n int n=scanner.nextInt();\n int[] ints=new int[n];\n for(int i=0;i<n;i++){\n ints[i]=scanner.nextInt();\n }\n int result=bubbleSort(ints);\n for(int i=0;i<ints.length;i++){\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(result);\n }\n public static int bubbleSort(int[] ints){\n int result=0;\n for(int i=ints.length;i>1;i--){\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }\n return result;\n }\n\n}",
"public class Main {\n\n public static void main(String[] args) {\n // write your code here\n Scanner scanner=new Scanner(System.in);\n int n=scanner.nextInt();\n int[] ints=new int[n];\n for(int i=0;i<n;i++){\n ints[i]=scanner.nextInt();\n }\n int result=bubbleSort(ints);\n for(int i=0;i<ints.length;i++){\n System.out.print(ints[i]);\n if(i!=ints.length-1){\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(result);\n }\n public static int bubbleSort(int[] ints){\n int result=0;\n for(int i=ints.length;i>1;i--){\n for(int j=ints.length-1;j>ints.length-i;j--){\n if(ints[j]<ints[j-1]){\n int tmp=ints[j];\n ints[j]=ints[j-1];\n ints[j-1]=tmp;\n result++;\n }\n }\n }\n return result;\n }\n\n}",
"Main"
] |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
int[] ints=new int[n];
for(int i=0;i<n;i++){
ints[i]=scanner.nextInt();
}
int result=bubbleSort(ints);
for(int i=0;i<ints.length;i++){
System.out.print(ints[i]);
if(i!=ints.length-1){
System.out.print(" ");
}
}
System.out.println();
System.out.println(result);
}
public static int bubbleSort(int[] ints){
int result=0;
for(int i=ints.length;i>1;i--){
for(int j=ints.length-1;j>ints.length-i;j--){
if(ints[j]<ints[j-1]){
int tmp=ints[j];
ints[j]=ints[j-1];
ints[j-1]=tmp;
result++;
}
}
}
return result;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
2,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
153,
5
],
[
153,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
8,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
36,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
44,
54
],
[
54,
55
],
[
55,
56
],
[
44,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
59,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
59,
72
],
[
73,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
74,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
84,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
84,
106
],
[
106,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
117,
118
],
[
108,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
126,
127
],
[
126,
128
],
[
120,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
8,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
142,
147
],
[
147,
148
],
[
147,
149
],
[
6,
150
],
[
150,
151
],
[
0,
152
],
[
152,
153
],
[
152,
154
]
] | [
"import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String [] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint numSwaps = 0;\n\t\t\n\t\tint n = in.nextInt();\n\t\tint [] arr = new int [n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tarr[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int j = 0; j < n - 1; j++) {\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int k = 0; k < n; k++) {\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"\\n\" + numSwaps);\n\t}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String [] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint numSwaps = 0;\n\t\t\n\t\tint n = in.nextInt();\n\t\tint [] arr = new int [n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tarr[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int j = 0; j < n - 1; j++) {\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int k = 0; k < n; k++) {\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"\\n\" + numSwaps);\n\t}\n}",
"Main",
"public static void main(String [] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint numSwaps = 0;\n\t\t\n\t\tint n = in.nextInt();\n\t\tint [] arr = new int [n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tarr[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int j = 0; j < n - 1; j++) {\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int k = 0; k < n; k++) {\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"\\n\" + numSwaps);\n\t}",
"main",
"{\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint numSwaps = 0;\n\t\t\n\t\tint n = in.nextInt();\n\t\tint [] arr = new int [n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tarr[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int j = 0; j < n - 1; j++) {\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int k = 0; k < n; k++) {\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"\\n\" + numSwaps);\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int numSwaps = 0;",
"numSwaps",
"0",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int [] arr = new int [n];",
"arr",
"new int [n]",
"n",
"for(int i = 0; i < n; i++) {\n\t\t\tarr[i] = in.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i] = in.nextInt();\n\t\t}",
"{\n\t\t\tarr[i] = in.nextInt();\n\t\t}",
"arr[i] = in.nextInt()",
"arr[i]",
"arr",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"for(int j = 0; j < n - 1; j++) {\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int j = 0;",
"int j = 0;",
"j",
"0",
"j < n - 1",
"j",
"n - 1",
"n",
"1",
"j++",
"j++",
"j",
"{\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}",
"int h = n - 1;",
"int h = n - 1;",
"h",
"n - 1",
"n",
"1",
"h > j",
"h",
"j",
"h--",
"h--",
"h",
"{\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}",
"if(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}",
"arr[h] < arr[h - 1]",
"arr[h]",
"arr",
"h",
"arr[h - 1]",
"arr",
"h - 1",
"h",
"1",
"{\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}",
"int temp = arr[h];",
"temp",
"arr[h]",
"arr",
"h",
"arr[h] = arr[h - 1]",
"arr[h]",
"arr",
"h",
"arr[h - 1]",
"arr",
"h - 1",
"h",
"1",
"arr[h - 1] = temp",
"arr[h - 1]",
"arr",
"h - 1",
"h",
"1",
"temp",
"numSwaps++",
"numSwaps",
"for(int k = 0; k < n; k++) {\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"int k = 0;",
"int k = 0;",
"k",
"0",
"k < n",
"k",
"n",
"k++",
"k++",
"k",
"{\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"System.out.print(arr[k])",
"System.out.print",
"System.out",
"System",
"System.out",
"arr[k]",
"arr",
"k",
"if(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"k != n - 1",
"k",
"n - 1",
"n",
"1",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(\"\\n\" + numSwaps)",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\\n\" + numSwaps",
"\"\\n\"",
"numSwaps",
"String [] args",
"args",
"public class Main {\n\n\tpublic static void main(String [] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint numSwaps = 0;\n\t\t\n\t\tint n = in.nextInt();\n\t\tint [] arr = new int [n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tarr[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int j = 0; j < n - 1; j++) {\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int k = 0; k < n; k++) {\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"\\n\" + numSwaps);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String [] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint numSwaps = 0;\n\t\t\n\t\tint n = in.nextInt();\n\t\tint [] arr = new int [n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tarr[i] = in.nextInt();\n\t\t}\n\t\t\n\t\tfor(int j = 0; j < n - 1; j++) {\n\t\t\t\n\t\t\t\n\t\t\tfor(int h = n - 1; h > j ; h--) {\n\t\t\t\t\n\t\t\t\tif(arr[h] < arr[h - 1]) {\n\t\t\t\t\tint temp = arr[h];\n\t\t\t\t\tarr[h] = arr[h - 1];\n\t\t\t\t\tarr[h - 1] = temp;\n\t\t\t\t\tnumSwaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int k = 0; k < n; k++) {\n\t\t\tSystem.out.print(arr[k]);\n\t\t\t\n\t\t\tif(k != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"\\n\" + numSwaps);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String [] args) {
Scanner in = new Scanner(System.in);
int numSwaps = 0;
int n = in.nextInt();
int [] arr = new int [n];
for(int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
for(int j = 0; j < n - 1; j++) {
for(int h = n - 1; h > j ; h--) {
if(arr[h] < arr[h - 1]) {
int temp = arr[h];
arr[h] = arr[h - 1];
arr[h - 1] = temp;
numSwaps++;
}
}
}
for(int k = 0; k < n; k++) {
System.out.print(arr[k]);
if(k != n - 1) {
System.out.print(" ");
}
}
System.out.println("\n" + numSwaps);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
12,
13,
30,
4,
18,
20,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
171,
5
],
[
171,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
27,
29
],
[
23,
30
],
[
30,
31
],
[
30,
32
],
[
23,
33
],
[
33,
34
],
[
34,
35
],
[
23,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
45,
47
],
[
38,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
48,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
48,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
63,
69
],
[
48,
70
],
[
70,
71
],
[
48,
72
],
[
72,
73
],
[
72,
74
],
[
8,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
80,
81
],
[
80,
82
],
[
75,
83
],
[
83,
84
],
[
84,
85
],
[
75,
86
],
[
87,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
88,
93
],
[
93,
94
],
[
93,
95
],
[
87,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
8,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
113,
118
],
[
6,
119
],
[
119,
120
],
[
6,
121
],
[
121,
122
],
[
171,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
125,
134
],
[
134,
135
],
[
134,
136
],
[
125,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
138,
143
],
[
143,
144
],
[
143,
145
],
[
138,
146
],
[
146,
147
],
[
147,
148
],
[
138,
149
],
[
150,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
156,
157
],
[
125,
158
],
[
158,
159
],
[
158,
160
],
[
158,
161
],
[
171,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
162,
168
],
[
168,
169
],
[
0,
170
],
[
170,
171
],
[
170,
172
]
] | [
"import java.util.Scanner;\n\n// ALDS1_2_A\npublic class Main {\n\tvoid bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tvoid bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main",
"void bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"bubbleSort",
"{\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"boolean flag = true;",
"flag",
"true",
"int tmp",
"tmp",
"count = 0;",
"count",
"0",
"while (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"if (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"array[j] < array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"{\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"tmp = array[j]",
"tmp",
"array[j]",
"array",
"j",
"array[j] = array[j-1]",
"array[j]",
"array",
"j",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"array[j-1] = tmp",
"array[j-1]",
"array",
"j-1",
"j",
"1",
"tmp",
"count++",
"count",
"flag = true",
"flag",
"true",
"for (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}",
"{\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}",
"System.out.print(array[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"array[i]",
"array",
"i",
"if (i < n - 1) System.out.print(\" \");",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"int[] array",
"array",
"int n",
"n",
"void run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}",
"run",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] array = new int[n];",
"array",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarray[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tarray[i] = sc.nextInt();\n\t\t}",
"array[i] = sc.nextInt()",
"array[i]",
"array",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"bubbleSort(array, n)",
"bubbleSort",
"array",
"n",
"public static void main(String[] args) {\n\t\tnew Main().run();\n\t}",
"main",
"{\n\t\tnew Main().run();\n\t}",
"new Main().run()",
"new Main().run",
"new Main()",
"String[] args",
"args",
"public class Main {\n\tvoid bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"public class Main {\n\tvoid bubbleSort(int[] array, int n) {\n\t\tboolean flag = true;\n\t\tint tmp, count = 0;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\t\tif (array[j] < array[j-1]) {\n\t\t\t\t\ttmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(array[i]);\n\t\t\tif (i < n - 1) System.out.print(\" \");;\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\t\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarray[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(array, n);\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main"
] | import java.util.Scanner;
// ALDS1_2_A
public class Main {
void bubbleSort(int[] array, int n) {
boolean flag = true;
int tmp, count = 0;
while (flag) {
flag = false;
for (int j = n - 1; j > 0; j--) {
if (array[j] < array[j-1]) {
tmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;
count++;
flag = true;
}
}
}
for (int i = 0; i < n; i++) {
System.out.print(array[i]);
if (i < n - 1) System.out.print(" ");;
}
System.out.println();
System.out.println(count);
}
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] array = new int[n];
for (int i = 0; i < n; i++) {
array[i] = sc.nextInt();
}
bubbleSort(array, n);
}
public static void main(String[] args) {
new Main().run();
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
4,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
162,
5
],
[
162,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
6,
11
],
[
11,
12
],
[
162,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
15,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
15,
24
],
[
24,
25
],
[
24,
26
],
[
15,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
40,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
15,
48
],
[
48,
49
],
[
49,
50
],
[
15,
51
],
[
51,
52
],
[
51,
53
],
[
15,
54
],
[
54,
55
],
[
54,
56
],
[
15,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
63,
70
],
[
70,
71
],
[
70,
72
],
[
63,
73
],
[
73,
74
],
[
74,
75
],
[
63,
76
],
[
77,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
88,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
96,
102
],
[
102,
103
],
[
102,
104
],
[
88,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
88,
110
],
[
110,
111
],
[
88,
112
],
[
112,
113
],
[
112,
114
],
[
15,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
120,
121
],
[
120,
122
],
[
115,
123
],
[
123,
124
],
[
124,
125
],
[
115,
126
],
[
127,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
127,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
136,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
15,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
15,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
0,
161
],
[
161,
162
],
[
161,
163
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tprivate static void solve() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tsc.close();\n\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tprivate static void solve() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tsc.close();\n\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t\tSystem.out.println(count);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tsolve();\n\t}",
"main",
"{\n\t\tsolve();\n\t}",
"solve()",
"solve",
"String[] args",
"args",
"private static void solve() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tsc.close();\n\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t\tSystem.out.println(count);\n\t}",
"solve",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tsc.close();\n\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t\tSystem.out.println(count);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.close()",
"sc.close",
"sc",
"int count = 0;",
"count",
"0",
"boolean flag = true;",
"flag",
"true",
"while (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"int i = n - 1;",
"int i = n - 1;",
"i",
"n - 1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}",
"if (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"a[i] < a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"{\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}",
"int tmp = a[i - 1];",
"tmp",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i - 1] = a[i]",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i]",
"a",
"i",
"a[i] = tmp",
"a[i]",
"a",
"i",
"tmp",
"count++",
"count",
"flag = true",
"flag",
"true",
"for (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"if (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"i != n - 1",
"i",
"n - 1",
"n",
"1",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tprivate static void solve() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tsc.close();\n\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tprivate static void solve() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tsc.close();\n\n\t\tint count = 0;\n\t\tboolean flag = true;\n\t\twhile (flag) {\n\t\t\tflag = false;\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\tif (a[i] < a[i - 1]) {\n\t\t\t\t\tint tmp = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[i];\n\t\t\t\t\ta[i] = tmp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != n - 1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(\"\\n\");\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
solve();
}
private static void solve() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
sc.close();
int count = 0;
boolean flag = true;
while (flag) {
flag = false;
for (int i = n - 1; i > 0; i--) {
if (a[i] < a[i - 1]) {
int tmp = a[i - 1];
a[i - 1] = a[i];
a[i] = tmp;
count++;
flag = true;
}
}
}
for (int i = 0; i < n; i++) {
System.out.print(a[i]);
if (i != n - 1) {
System.out.print(" ");
}
}
System.out.print("\n");
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
17,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
162,
5
],
[
162,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
11,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
16,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
23,
28
],
[
28,
29
],
[
28,
30
],
[
23,
31
],
[
31,
32
],
[
32,
33
],
[
23,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
46,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
61,
70
],
[
70,
71
],
[
70,
72
],
[
61,
73
],
[
73,
74
],
[
74,
75
],
[
61,
76
],
[
77,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
88,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
88,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
103,
109
],
[
88,
110
],
[
110,
111
],
[
8,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
112,
117
],
[
117,
118
],
[
117,
119
],
[
112,
120
],
[
120,
121
],
[
121,
122
],
[
112,
123
],
[
124,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
130,
135
],
[
130,
136
],
[
136,
137
],
[
136,
138
],
[
125,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
140,
146
],
[
146,
147
],
[
146,
148
],
[
8,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
155,
155
],
[
155,
156
],
[
155,
157
],
[
155,
158
],
[
6,
159
],
[
159,
160
],
[
0,
161
],
[
161,
162
],
[
161,
163
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n int total;\n\n Scanner inp = new Scanner(System.in);\n total = inp.nextInt();\n\n int[] a = new int[total];\n\n for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }\n\n int swapcount = 0;\n\n for (int i = 0; i < a.length; i++) {\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }\n\n for (int l = 0; l < total; l++) {\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }\n\n System.out.printf(\"\\n\" + swapcount+\"\\n\");\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n int total;\n\n Scanner inp = new Scanner(System.in);\n total = inp.nextInt();\n\n int[] a = new int[total];\n\n for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }\n\n int swapcount = 0;\n\n for (int i = 0; i < a.length; i++) {\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }\n\n for (int l = 0; l < total; l++) {\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }\n\n System.out.printf(\"\\n\" + swapcount+\"\\n\");\n }\n}",
"Main",
"public static void main(String[] args) {\n int total;\n\n Scanner inp = new Scanner(System.in);\n total = inp.nextInt();\n\n int[] a = new int[total];\n\n for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }\n\n int swapcount = 0;\n\n for (int i = 0; i < a.length; i++) {\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }\n\n for (int l = 0; l < total; l++) {\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }\n\n System.out.printf(\"\\n\" + swapcount+\"\\n\");\n }",
"main",
"{\n int total;\n\n Scanner inp = new Scanner(System.in);\n total = inp.nextInt();\n\n int[] a = new int[total];\n\n for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }\n\n int swapcount = 0;\n\n for (int i = 0; i < a.length; i++) {\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }\n\n for (int l = 0; l < total; l++) {\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }\n\n System.out.printf(\"\\n\" + swapcount+\"\\n\");\n }",
"int total;",
"total",
"Scanner inp = new Scanner(System.in);",
"inp",
"new Scanner(System.in)",
"total = inp.nextInt()",
"total",
"inp.nextInt()",
"inp.nextInt",
"inp",
"int[] a = new int[total];",
"a",
"new int[total]",
"total",
"for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }",
"int k = 0;",
"int k = 0;",
"k",
"0",
"k < total",
"k",
"total",
"k++",
"k++",
"k",
"{\n a[k] = inp.nextInt();\n }",
"{\n a[k] = inp.nextInt();\n }",
"a[k] = inp.nextInt()",
"a[k]",
"a",
"k",
"inp.nextInt()",
"inp.nextInt",
"inp",
"int swapcount = 0;",
"swapcount",
"0",
"for (int i = 0; i < a.length; i++) {\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }",
"{\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }",
"for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }",
"int j = a.length - 1;",
"int j = a.length - 1;",
"j",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }",
"{\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }",
"if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }",
"a[j] < a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"{\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }",
"int temp = a[j];",
"temp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = temp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"temp",
"swapcount++",
"swapcount",
"for (int l = 0; l < total; l++) {\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }",
"int l = 0;",
"int l = 0;",
"l",
"0",
"l < total",
"l",
"total",
"l++",
"l++",
"l",
"{\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }",
"{\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }",
"if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }",
"l == 0",
"l",
"0",
"{\n System.out.printf(\"%d\", a[l]);\n }",
"System.out.printf(\"%d\", a[l])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d\"",
"a[l]",
"a",
"l",
"{\n System.out.printf(\" %d\", a[l]);\n }",
"System.out.printf(\" %d\", a[l])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\" %d\"",
"a[l]",
"a",
"l",
"System.out.printf(\"\\n\" + swapcount+\"\\n\")",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"\\n\" + swapcount+\"\\n\"",
"\"\\n\" + swapcount+\"\\n\"",
"\"\\n\"",
"swapcount",
"\"\\n\"",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n int total;\n\n Scanner inp = new Scanner(System.in);\n total = inp.nextInt();\n\n int[] a = new int[total];\n\n for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }\n\n int swapcount = 0;\n\n for (int i = 0; i < a.length; i++) {\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }\n\n for (int l = 0; l < total; l++) {\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }\n\n System.out.printf(\"\\n\" + swapcount+\"\\n\");\n }\n}",
"public class Main {\n public static void main(String[] args) {\n int total;\n\n Scanner inp = new Scanner(System.in);\n total = inp.nextInt();\n\n int[] a = new int[total];\n\n for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }\n\n int swapcount = 0;\n\n for (int i = 0; i < a.length; i++) {\n for (int j = a.length - 1; j > i; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j-1];\n a[j-1] = temp;\n\n swapcount++;\n }\n }\n }\n\n for (int l = 0; l < total; l++) {\n if (l == 0) {\n System.out.printf(\"%d\", a[l]);\n } else {\n System.out.printf(\" %d\", a[l]);\n }\n }\n\n System.out.printf(\"\\n\" + swapcount+\"\\n\");\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
int total;
Scanner inp = new Scanner(System.in);
total = inp.nextInt();
int[] a = new int[total];
for (int k = 0; k < total; k++) {
a[k] = inp.nextInt();
}
int swapcount = 0;
for (int i = 0; i < a.length; i++) {
for (int j = a.length - 1; j > i; j--) {
if (a[j] < a[j - 1]) {
int temp = a[j];
a[j] = a[j-1];
a[j-1] = temp;
swapcount++;
}
}
}
for (int l = 0; l < total; l++) {
if (l == 0) {
System.out.printf("%d", a[l]);
} else {
System.out.printf(" %d", a[l]);
}
}
System.out.printf("\n" + swapcount+"\n");
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
12,
13,
30,
4,
13,
4,
13,
4,
13,
23,
13,
12,
13,
30,
0,
13,
4,
18,
13,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
12,
13,
30,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
176,
5
],
[
176,
6
],
[
6,
7
],
[
6,
8
],
[
176,
9
],
[
9,
10
],
[
176,
11
],
[
11,
12
],
[
176,
13
],
[
13,
14
],
[
13,
15
],
[
176,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
18,
21
],
[
21,
22
],
[
18,
23
],
[
23,
24
],
[
16,
25
],
[
25,
26
],
[
176,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
29,
35
],
[
35,
36
],
[
35,
37
],
[
29,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
44,
45
],
[
44,
46
],
[
39,
47
],
[
47,
48
],
[
48,
49
],
[
39,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
176,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
71,
78
],
[
78,
79
],
[
78,
80
],
[
71,
81
],
[
81,
82
],
[
82,
83
],
[
71,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
87,
93
],
[
93,
94
],
[
93,
95
],
[
86,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
96,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
111,
117
],
[
96,
118
],
[
118,
119
],
[
118,
120
],
[
96,
121
],
[
121,
122
],
[
176,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
126,
136
],
[
136,
137
],
[
137,
138
],
[
126,
139
],
[
140,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
146,
148
],
[
140,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
154,
155
],
[
154,
156
],
[
149,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
125,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
125,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
0,
175
],
[
175,
176
],
[
175,
177
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n static Scanner sc = new Scanner(System.in);\n static int n;\n static int a[];\n static int count = 0;\n\n public static void main(String[] args) {\n read();\n solve();\n output();\n }\n\n public static void read() {\n n = sc.nextInt();\n a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n }\n\n public static void solve() {\n boolean flag= true;\n while(flag) {\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }\n }\n\n public static void output() {\n for (int i = 0; i < a.length; i++) {\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(count);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n static Scanner sc = new Scanner(System.in);\n static int n;\n static int a[];\n static int count = 0;\n\n public static void main(String[] args) {\n read();\n solve();\n output();\n }\n\n public static void read() {\n n = sc.nextInt();\n a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n }\n\n public static void solve() {\n boolean flag= true;\n while(flag) {\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }\n }\n\n public static void output() {\n for (int i = 0; i < a.length; i++) {\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(count);\n }\n}",
"Main",
"static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"static int n;",
"n",
"static int a[];",
"a",
"static int count = 0;",
"count",
"0",
"public static void main(String[] args) {\n read();\n solve();\n output();\n }",
"main",
"{\n read();\n solve();\n output();\n }",
"read()",
"read",
"solve()",
"solve",
"output()",
"output",
"String[] args",
"args",
"public static void read() {\n n = sc.nextInt();\n a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n }",
"read",
"{\n n = sc.nextInt();\n a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n }",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"a = new int[n]",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = sc.nextInt();\n }",
"{\n a[i] = sc.nextInt();\n }",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"public static void solve() {\n boolean flag= true;\n while(flag) {\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }\n }",
"solve",
"{\n boolean flag= true;\n while(flag) {\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }\n }",
"boolean flag= true;",
"flag",
"true",
"while(flag) {\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }",
"flag",
"{\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }",
"int i = n-1;",
"int i = n-1;",
"i",
"n-1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }",
"{\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }",
"if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }",
"a[i - 1] > a[i]",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i]",
"a",
"i",
"{\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }",
"int tmp = a[i];",
"tmp",
"a[i]",
"a",
"i",
"a[i] = a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i - 1] = tmp",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"tmp",
"flag = true",
"flag",
"true",
"count++",
"count",
"public static void output() {\n for (int i = 0; i < a.length; i++) {\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(count);\n }",
"output",
"{\n for (int i = 0; i < a.length; i++) {\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(count);\n }",
"for (int i = 0; i < a.length; i++) {\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }",
"{\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"if (i + 1 < a.length) {\n System.out.print(\" \");\n }",
"i + 1 < a.length",
"i + 1",
"i",
"1",
"a.length",
"a",
"a.length",
"{\n System.out.print(\" \");\n }",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"public class Main {\n static Scanner sc = new Scanner(System.in);\n static int n;\n static int a[];\n static int count = 0;\n\n public static void main(String[] args) {\n read();\n solve();\n output();\n }\n\n public static void read() {\n n = sc.nextInt();\n a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n }\n\n public static void solve() {\n boolean flag= true;\n while(flag) {\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }\n }\n\n public static void output() {\n for (int i = 0; i < a.length; i++) {\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(count);\n }\n}",
"public class Main {\n static Scanner sc = new Scanner(System.in);\n static int n;\n static int a[];\n static int count = 0;\n\n public static void main(String[] args) {\n read();\n solve();\n output();\n }\n\n public static void read() {\n n = sc.nextInt();\n a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n }\n\n public static void solve() {\n boolean flag= true;\n while(flag) {\n flag = false;\n for (int i = n-1; i > 0; i--) {\n if (a[i - 1] > a[i]) {\n int tmp = a[i];\n a[i] = a[i - 1];\n a[i - 1] = tmp;\n flag = true;\n count++;\n }\n }\n }\n }\n\n public static void output() {\n for (int i = 0; i < a.length; i++) {\n System.out.print(a[i]);\n if (i + 1 < a.length) {\n System.out.print(\" \");\n }\n }\n System.out.println();\n System.out.println(count);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static int n;
static int a[];
static int count = 0;
public static void main(String[] args) {
read();
solve();
output();
}
public static void read() {
n = sc.nextInt();
a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
}
public static void solve() {
boolean flag= true;
while(flag) {
flag = false;
for (int i = n-1; i > 0; i--) {
if (a[i - 1] > a[i]) {
int tmp = a[i];
a[i] = a[i - 1];
a[i - 1] = tmp;
flag = true;
count++;
}
}
}
}
public static void output() {
for (int i = 0; i < a.length; i++) {
System.out.print(a[i]);
if (i + 1 < a.length) {
System.out.print(" ");
}
}
System.out.println();
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
2,
4,
18,
13,
17,
4,
18,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
171,
5
],
[
171,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
57,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
57,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
72,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
82,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
82,
104
],
[
104,
105
],
[
8,
106
],
[
106,
107
],
[
106,
108
],
[
8,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
8,
115
],
[
115,
116
],
[
116,
117
],
[
6,
118
],
[
118,
119
],
[
171,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
126,
136
],
[
136,
137
],
[
137,
138
],
[
126,
139
],
[
140,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
141,
144
],
[
144,
145
],
[
144,
146
],
[
140,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
122,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
154,
158
],
[
151,
159
],
[
159,
160
],
[
160,
161
],
[
122,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
162,
167
],
[
120,
168
],
[
168,
169
],
[
0,
170
],
[
170,
171
],
[
170,
172
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n \tfor (int i = 0; i < n; i++) {\n \t\tdata[i] = sc.nextInt();\n \t}\n\n \tint count = 0;\n \tfor (int i = 0; i < n; i++) {\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}\n\n \tprintData(data);\n \tSystem.out.println(count);\n\n sc.close();\n\t}\n\n\tprivate static void printData(int[] data) {\n\t\tStringBuffer printData = new StringBuffer();\n\t\tfor (int i = 0; i < data.length; i++) {\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}\n\t\tprintData.delete(printData.length() - 1, printData.length());\n\t\tSystem.out.println(printData);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n \tfor (int i = 0; i < n; i++) {\n \t\tdata[i] = sc.nextInt();\n \t}\n\n \tint count = 0;\n \tfor (int i = 0; i < n; i++) {\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}\n\n \tprintData(data);\n \tSystem.out.println(count);\n\n sc.close();\n\t}\n\n\tprivate static void printData(int[] data) {\n\t\tStringBuffer printData = new StringBuffer();\n\t\tfor (int i = 0; i < data.length; i++) {\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}\n\t\tprintData.delete(printData.length() - 1, printData.length());\n\t\tSystem.out.println(printData);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n \tfor (int i = 0; i < n; i++) {\n \t\tdata[i] = sc.nextInt();\n \t}\n\n \tint count = 0;\n \tfor (int i = 0; i < n; i++) {\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}\n\n \tprintData(data);\n \tSystem.out.println(count);\n\n sc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n \tfor (int i = 0; i < n; i++) {\n \t\tdata[i] = sc.nextInt();\n \t}\n\n \tint count = 0;\n \tfor (int i = 0; i < n; i++) {\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}\n\n \tprintData(data);\n \tSystem.out.println(count);\n\n sc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] data = new int[n];",
"data",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n \t\tdata[i] = sc.nextInt();\n \t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tdata[i] = sc.nextInt();\n \t}",
"{\n \t\tdata[i] = sc.nextInt();\n \t}",
"data[i] = sc.nextInt()",
"data[i]",
"data",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count = 0;",
"count",
"0",
"for (int i = 0; i < n; i++) {\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}",
"{\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}",
"for (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}",
"{\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}",
"if (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}",
"data[j] < data[j - 1]",
"data[j]",
"data",
"j",
"data[j - 1]",
"data",
"j - 1",
"j",
"1",
"{\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}",
"int temp = data[j];",
"temp",
"data[j]",
"data",
"j",
"data[j] = data[j - 1]",
"data[j]",
"data",
"j",
"data[j - 1]",
"data",
"j - 1",
"j",
"1",
"data[j - 1] = temp",
"data[j - 1]",
"data",
"j - 1",
"j",
"1",
"temp",
"count++",
"count",
"printData(data)",
"printData",
"data",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"private static void printData(int[] data) {\n\t\tStringBuffer printData = new StringBuffer();\n\t\tfor (int i = 0; i < data.length; i++) {\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}\n\t\tprintData.delete(printData.length() - 1, printData.length());\n\t\tSystem.out.println(printData);\n\t}",
"printData",
"{\n\t\tStringBuffer printData = new StringBuffer();\n\t\tfor (int i = 0; i < data.length; i++) {\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}\n\t\tprintData.delete(printData.length() - 1, printData.length());\n\t\tSystem.out.println(printData);\n\t}",
"StringBuffer printData = new StringBuffer();",
"printData",
"new StringBuffer()",
"for (int i = 0; i < data.length; i++) {\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < data.length",
"i",
"data.length",
"data",
"data.length",
"i++",
"i++",
"i",
"{\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}",
"{\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}",
"printData.append(data[i])",
"printData.append",
"printData",
"data[i]",
"data",
"i",
"printData.append(\" \")",
"printData.append",
"printData",
"\" \"",
"printData.delete(printData.length() - 1, printData.length())",
"printData.delete",
"printData",
"printData.length() - 1",
"printData.length()",
"printData.length",
"printData",
"1",
"printData.length()",
"printData.length",
"printData",
"System.out.println(printData)",
"System.out.println",
"System.out",
"System",
"System.out",
"printData",
"int[] data",
"data",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n \tfor (int i = 0; i < n; i++) {\n \t\tdata[i] = sc.nextInt();\n \t}\n\n \tint count = 0;\n \tfor (int i = 0; i < n; i++) {\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}\n\n \tprintData(data);\n \tSystem.out.println(count);\n\n sc.close();\n\t}\n\n\tprivate static void printData(int[] data) {\n\t\tStringBuffer printData = new StringBuffer();\n\t\tfor (int i = 0; i < data.length; i++) {\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}\n\t\tprintData.delete(printData.length() - 1, printData.length());\n\t\tSystem.out.println(printData);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n \tfor (int i = 0; i < n; i++) {\n \t\tdata[i] = sc.nextInt();\n \t}\n\n \tint count = 0;\n \tfor (int i = 0; i < n; i++) {\n \t\tfor (int j = n - 1; j > i; j--) {\n \t\t\tif (data[j] < data[j - 1]) {\n \t\t\t\tint temp = data[j];\n \t\t\t\tdata[j] = data[j - 1];\n \t\t\t\tdata[j - 1] = temp;\n \t\t\t\tcount++;\n \t\t\t}\n \t\t}\n \t}\n\n \tprintData(data);\n \tSystem.out.println(count);\n\n sc.close();\n\t}\n\n\tprivate static void printData(int[] data) {\n\t\tStringBuffer printData = new StringBuffer();\n\t\tfor (int i = 0; i < data.length; i++) {\n\t\t\tprintData.append(data[i]);\n\t\t\tprintData.append(\" \");\n\t\t}\n\t\tprintData.delete(printData.length() - 1, printData.length());\n\t\tSystem.out.println(printData);\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] data = new int[n];
for (int i = 0; i < n; i++) {
data[i] = sc.nextInt();
}
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = n - 1; j > i; j--) {
if (data[j] < data[j - 1]) {
int temp = data[j];
data[j] = data[j - 1];
data[j - 1] = temp;
count++;
}
}
}
printData(data);
System.out.println(count);
sc.close();
}
private static void printData(int[] data) {
StringBuffer printData = new StringBuffer();
for (int i = 0; i < data.length; i++) {
printData.append(data[i]);
printData.append(" ");
}
printData.delete(printData.length() - 1, printData.length());
System.out.println(printData);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
20,
41,
13,
4,
18,
13,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
13,
1,
40,
13,
30,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
29,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
186,
5
],
[
186,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
46,
50
],
[
8,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
51,
61
],
[
61,
62
],
[
62,
63
],
[
51,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
66,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
66,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
86,
91
],
[
91,
92
],
[
91,
93
],
[
8,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
94,
99
],
[
6,
100
],
[
100,
101
],
[
186,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
108,
109
],
[
108,
110
],
[
104,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
111,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
129,
131
],
[
125,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
125,
137
],
[
137,
138
],
[
138,
139
],
[
125,
140
],
[
141,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
149,
151
],
[
142,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
155,
157
],
[
152,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
164,
166
],
[
152,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
170,
172
],
[
167,
173
],
[
152,
174
],
[
174,
175
],
[
152,
176
],
[
176,
177
],
[
176,
178
],
[
104,
179
],
[
179,
180
],
[
102,
181
],
[
181,
182
],
[
102,
183
],
[
183,
184
],
[
0,
185
],
[
185,
186
],
[
185,
187
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tMain main = new Main();\n\t\tint ans = main.bubbleSort(a, n);\n\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}\n\n\tprivate int bubbleSort(int[] a, int n) {\n\t\tboolean hasSwapped = true; // 要素の入れ替えを行った\n\t\tint cnt = 0;\n\t\t// 未ソート部分の先頭を表す i を持つ外側のループ\n\t\tfor (int i = 0; hasSwapped; i++) {\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn cnt;\n\t}\n\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tMain main = new Main();\n\t\tint ans = main.bubbleSort(a, n);\n\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}\n\n\tprivate int bubbleSort(int[] a, int n) {\n\t\tboolean hasSwapped = true; // 要素の入れ替えを行った\n\t\tint cnt = 0;\n\t\t// 未ソート部分の先頭を表す i を持つ外側のループ\n\t\tfor (int i = 0; hasSwapped; i++) {\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn cnt;\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tMain main = new Main();\n\t\tint ans = main.bubbleSort(a, n);\n\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tMain main = new Main();\n\t\tint ans = main.bubbleSort(a, n);\n\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Main main = new Main();",
"main",
"new Main()",
"int ans = main.bubbleSort(a, n);",
"ans",
"main.bubbleSort(a, n)",
"main.bubbleSort",
"main",
"a",
"n",
"for (int i = 0; i < a.length; i++) {\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}",
"{\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}",
"if (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}",
"i != a.length - 1",
"i",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"{\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t}",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"{\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}",
"System.out.println(a[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"private int bubbleSort(int[] a, int n) {\n\t\tboolean hasSwapped = true; // 要素の入れ替えを行った\n\t\tint cnt = 0;\n\t\t// 未ソート部分の先頭を表す i を持つ外側のループ\n\t\tfor (int i = 0; hasSwapped; i++) {\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn cnt;\n\t}",
"bubbleSort",
"{\n\t\tboolean hasSwapped = true; // 要素の入れ替えを行った\n\t\tint cnt = 0;\n\t\t// 未ソート部分の先頭を表す i を持つ外側のループ\n\t\tfor (int i = 0; hasSwapped; i++) {\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn cnt;\n\t}",
"boolean hasSwapped = true;",
"hasSwapped",
"true",
"int cnt = 0;",
"cnt",
"0",
"for (int i = 0; hasSwapped; i++) {\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"hasSwapped",
"i++",
"i++",
"i",
"{\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"{\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"hasSwapped = false",
"hasSwapped",
"false",
"for (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j >= i + 1",
"j",
"i + 1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}",
"if (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}",
"a[j] < a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"a[j - 1] = tmp",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"tmp",
"cnt++",
"cnt",
"hasSwapped = true",
"hasSwapped",
"true",
"return cnt;",
"cnt",
"int[] a",
"a",
"int n",
"n",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tMain main = new Main();\n\t\tint ans = main.bubbleSort(a, n);\n\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}\n\n\tprivate int bubbleSort(int[] a, int n) {\n\t\tboolean hasSwapped = true; // 要素の入れ替えを行った\n\t\tint cnt = 0;\n\t\t// 未ソート部分の先頭を表す i を持つ外側のループ\n\t\tfor (int i = 0; hasSwapped; i++) {\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn cnt;\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\n\t\tMain main = new Main();\n\t\tint ans = main.bubbleSort(a, n);\n\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif (i != a.length - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}\n\n\tprivate int bubbleSort(int[] a, int n) {\n\t\tboolean hasSwapped = true; // 要素の入れ替えを行った\n\t\tint cnt = 0;\n\t\t// 未ソート部分の先頭を表す i を持つ外側のループ\n\t\tfor (int i = 0; hasSwapped; i++) {\n\t\t\thasSwapped = false;\n\t\t\t// 末尾の要素からi+1まで入れ替え処理を行う\n\t\t\tfor (int j = n - 1; j >= i + 1; j--) {\n\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\tcnt++;\n\t\t\t\t\thasSwapped = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn cnt;\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
Main main = new Main();
int ans = main.bubbleSort(a, n);
for (int i = 0; i < a.length; i++) {
if (i != a.length - 1) {
System.out.print(a[i] + " ");
} else {
System.out.println(a[i]);
}
}
System.out.println(ans);
}
private int bubbleSort(int[] a, int n) {
boolean hasSwapped = true; // 要素の入れ替えを行った
int cnt = 0;
// 未ソート部分の先頭を表す i を持つ外側のループ
for (int i = 0; hasSwapped; i++) {
hasSwapped = false;
// 末尾の要素からi+1まで入れ替え処理を行う
for (int j = n - 1; j >= i + 1; j--) {
if (a[j] < a[j - 1]) {
int tmp = a[j];
a[j] = a[j - 1];
a[j - 1] = tmp;
cnt++;
hasSwapped = true;
}
}
}
return cnt;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
41,
13,
17,
42,
2,
13,
2,
13,
17,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
40,
13,
41,
13,
20,
28,
13,
13,
30,
4,
18,
13,
2,
13,
17,
4,
18,
13,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
8,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
26,
31
],
[
8,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
41,
42
],
[
32,
43
],
[
44,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
52,
53
],
[
52,
54
],
[
8,
55
],
[
55,
56
],
[
55,
57
],
[
8,
58
],
[
58,
59
],
[
58,
60
],
[
8,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
68,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
68,
81
],
[
82,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
83,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
93,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
108,
114
],
[
93,
115
],
[
115,
116
],
[
67,
117
],
[
117,
118
],
[
8,
119
],
[
119,
120
],
[
119,
121
],
[
8,
122
],
[
122,
123
],
[
122,
124
],
[
122,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
129,
130
],
[
129,
131
],
[
8,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
135,
139
],
[
8,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
8,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
6,
152
],
[
152,
153
]
] | [
"import java.util.Scanner;\n\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = Integer.parseInt(sc.nextLine());\n int[] array = new int[n];\n String[] input = sc.nextLine().split(\" \");\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(input[i]);\n }\n\n int count = 0;\n int k = 0;\n while(k < n-1){\n for(int i = n-1; i > k; i--){\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }\n k++;\n }\n\n StringBuilder sb = new StringBuilder();\n\n for(int i : array)\n sb.append(i + \" \");\n \n sb.deleteCharAt(sb.length()-1);\n\n System.out.println(sb);\n System.out.println(count);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = Integer.parseInt(sc.nextLine());\n int[] array = new int[n];\n String[] input = sc.nextLine().split(\" \");\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(input[i]);\n }\n\n int count = 0;\n int k = 0;\n while(k < n-1){\n for(int i = n-1; i > k; i--){\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }\n k++;\n }\n\n StringBuilder sb = new StringBuilder();\n\n for(int i : array)\n sb.append(i + \" \");\n \n sb.deleteCharAt(sb.length()-1);\n\n System.out.println(sb);\n System.out.println(count);\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = Integer.parseInt(sc.nextLine());\n int[] array = new int[n];\n String[] input = sc.nextLine().split(\" \");\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(input[i]);\n }\n\n int count = 0;\n int k = 0;\n while(k < n-1){\n for(int i = n-1; i > k; i--){\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }\n k++;\n }\n\n StringBuilder sb = new StringBuilder();\n\n for(int i : array)\n sb.append(i + \" \");\n \n sb.deleteCharAt(sb.length()-1);\n\n System.out.println(sb);\n System.out.println(count);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n\n int n = Integer.parseInt(sc.nextLine());\n int[] array = new int[n];\n String[] input = sc.nextLine().split(\" \");\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(input[i]);\n }\n\n int count = 0;\n int k = 0;\n while(k < n-1){\n for(int i = n-1; i > k; i--){\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }\n k++;\n }\n\n StringBuilder sb = new StringBuilder();\n\n for(int i : array)\n sb.append(i + \" \");\n \n sb.deleteCharAt(sb.length()-1);\n\n System.out.println(sb);\n System.out.println(count);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = Integer.parseInt(sc.nextLine());",
"n",
"Integer.parseInt(sc.nextLine())",
"Integer.parseInt",
"Integer",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int[] array = new int[n];",
"array",
"new int[n]",
"n",
"String[] input = sc.nextLine().split(\" \");",
"input",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(input[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n array[i] = Integer.parseInt(input[i]);\n }",
"{\n array[i] = Integer.parseInt(input[i]);\n }",
"array[i] = Integer.parseInt(input[i])",
"array[i]",
"array",
"i",
"Integer.parseInt(input[i])",
"Integer.parseInt",
"Integer",
"input[i]",
"input",
"i",
"int count = 0;",
"count",
"0",
"int k = 0;",
"k",
"0",
"while(k < n-1){\n for(int i = n-1; i > k; i--){\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }\n k++;\n }",
"k < n-1",
"k",
"n-1",
"n",
"1",
"{\n for(int i = n-1; i > k; i--){\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }\n k++;\n }",
"for(int i = n-1; i > k; i--){\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }",
"int i = n-1;",
"int i = n-1;",
"i",
"n-1",
"n",
"1",
"i > k",
"i",
"k",
"i--",
"i--",
"i",
"{\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }",
"{\n if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }\n }",
"if(array[i] < array[i-1]){\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }",
"array[i] < array[i-1]",
"array[i]",
"array",
"i",
"array[i-1]",
"array",
"i-1",
"i",
"1",
"{\n int tmp = array[i];\n array[i] = array[i-1];\n array[i-1] = tmp;\n count++;\n }",
"int tmp = array[i];",
"tmp",
"array[i]",
"array",
"i",
"array[i] = array[i-1]",
"array[i]",
"array",
"i",
"array[i-1]",
"array",
"i-1",
"i",
"1",
"array[i-1] = tmp",
"array[i-1]",
"array",
"i-1",
"i",
"1",
"tmp",
"count++",
"count",
"k++",
"k",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"for(int i : array)\n sb.append(i + \" \");",
"int i",
"array",
"sb.append(i + \" \");",
"sb.append(i + \" \")",
"sb.append",
"sb",
"i + \" \"",
"i",
"\" \"",
"sb.deleteCharAt(sb.length()-1)",
"sb.deleteCharAt",
"sb",
"sb.length()-1",
"sb.length()",
"sb.length",
"sb",
"1",
"System.out.println(sb)",
"System.out.println",
"System.out",
"System",
"System.out",
"sb",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine());
int[] array = new int[n];
String[] input = sc.nextLine().split(" ");
for(int i = 0; i < n; i++){
array[i] = Integer.parseInt(input[i]);
}
int count = 0;
int k = 0;
while(k < n-1){
for(int i = n-1; i > k; i--){
if(array[i] < array[i-1]){
int tmp = array[i];
array[i] = array[i-1];
array[i-1] = tmp;
count++;
}
}
k++;
}
StringBuilder sb = new StringBuilder();
for(int i : array)
sb.append(i + " ");
sb.deleteCharAt(sb.length()-1);
System.out.println(sb);
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
4,
13,
13,
41,
13,
4,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
29,
20,
12,
13,
30,
41,
13,
4,
18,
13,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
20,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
4,
13,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
13,
13,
29,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
23,
13,
23,
13,
12,
13,
30,
4,
13,
13,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
2,
4,
18,
13,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
0,
13,
17,
30,
30,
14,
2,
2,
13,
13,
17,
30,
29,
17,
29,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
304,
8
],
[
304,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
11,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
18,
20
],
[
11,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
23,
25
],
[
11,
26
],
[
26,
27
],
[
26,
28
],
[
11,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
29,
34
],
[
34,
35
],
[
34,
36
],
[
29,
37
],
[
37,
38
],
[
38,
39
],
[
29,
40
],
[
41,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
46,
48
],
[
42,
49
],
[
49,
50
],
[
49,
51
],
[
42,
52
],
[
52,
53
],
[
53,
54
],
[
42,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
70,
72
],
[
67,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
67,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
67,
89
],
[
89,
90
],
[
11,
91
],
[
91,
92
],
[
91,
93
],
[
11,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
94,
99
],
[
9,
100
],
[
100,
101
],
[
304,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
105,
106
],
[
304,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
109,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
107,
120
],
[
120,
121
],
[
304,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
124,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
124,
136
],
[
136,
137
],
[
136,
138
],
[
139,
140
],
[
139,
141
],
[
124,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
142,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
149,
151
],
[
142,
152
],
[
152,
153
],
[
153,
154
],
[
142,
155
],
[
156,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
162,
163
],
[
161,
164
],
[
164,
165
],
[
164,
166
],
[
124,
167
],
[
167,
168
],
[
122,
169
],
[
169,
170
],
[
304,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
176,
178
],
[
173,
179
],
[
179,
180
],
[
179,
181
],
[
173,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
183,
188
],
[
188,
189
],
[
188,
190
],
[
183,
191
],
[
191,
192
],
[
192,
193
],
[
183,
194
],
[
195,
195
],
[
195,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
196,
200
],
[
200,
201
],
[
200,
202
],
[
173,
203
],
[
203,
204
],
[
171,
205
],
[
205,
206
],
[
304,
207
],
[
207,
208
],
[
207,
209
],
[
209,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
210,
215
],
[
215,
216
],
[
215,
217
],
[
210,
218
],
[
218,
219
],
[
219,
220
],
[
210,
221
],
[
222,
222
],
[
222,
223
],
[
223,
224
],
[
224,
225
],
[
225,
226
],
[
225,
227
],
[
223,
228
],
[
228,
229
],
[
228,
230
],
[
222,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
234,
235
],
[
234,
236
],
[
231,
237
],
[
237,
238
],
[
238,
239
],
[
239,
240
],
[
240,
241
],
[
240,
242
],
[
238,
243
],
[
209,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
244,
249
],
[
207,
250
],
[
250,
251
],
[
207,
252
],
[
252,
253
],
[
304,
254
],
[
254,
255
],
[
254,
256
],
[
256,
257
],
[
257,
258
],
[
257,
259
],
[
257,
260
],
[
260,
261
],
[
260,
262
],
[
254,
263
],
[
263,
264
],
[
304,
265
],
[
265,
266
],
[
265,
267
],
[
267,
268
],
[
268,
269
],
[
268,
270
],
[
270,
271
],
[
271,
272
],
[
272,
273
],
[
271,
274
],
[
270,
275
],
[
267,
276
],
[
276,
277
],
[
277,
278
],
[
278,
279
],
[
278,
280
],
[
276,
281
],
[
281,
282
],
[
281,
283
],
[
276,
284
],
[
284,
285
],
[
285,
286
],
[
285,
287
],
[
276,
288
],
[
289,
289
],
[
289,
290
],
[
290,
291
],
[
291,
292
],
[
292,
293
],
[
292,
294
],
[
291,
295
],
[
290,
296
],
[
296,
297
],
[
297,
298
],
[
267,
299
],
[
299,
300
],
[
265,
301
],
[
301,
302
],
[
0,
303
],
[
303,
304
],
[
303,
305
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint n = getInt(breader);\n\t\tint[] num = getAry(breader);\n\t\tint snum = 0;\n\t\tfor(int i = 0; i < n ; i++ ) {\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tputAry(num);\n\t\tSystem.out.println(snum);\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(System.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static int[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint n = getInt(breader);\n\t\tint[] num = getAry(breader);\n\t\tint snum = 0;\n\t\tfor(int i = 0; i < n ; i++ ) {\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tputAry(num);\n\t\tSystem.out.println(snum);\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(System.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static int[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint n = getInt(breader);\n\t\tint[] num = getAry(breader);\n\t\tint snum = 0;\n\t\tfor(int i = 0; i < n ; i++ ) {\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tputAry(num);\n\t\tSystem.out.println(snum);\n\t}",
"main",
"{\n\t\tBufferedReader breader = getReader();\n\t\tint n = getInt(breader);\n\t\tint[] num = getAry(breader);\n\t\tint snum = 0;\n\t\tfor(int i = 0; i < n ; i++ ) {\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tputAry(num);\n\t\tSystem.out.println(snum);\n\t}",
"BufferedReader breader = getReader();",
"breader",
"getReader()",
"getReader",
"int n = getInt(breader);",
"n",
"getInt(breader)",
"getInt",
"breader",
"int[] num = getAry(breader);",
"num",
"getAry(breader)",
"getAry",
"breader",
"int snum = 0;",
"snum",
"0",
"for(int i = 0; i < n ; i++ ) {\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}",
"int j = n-1 ;",
"int j = n-1 ;",
"j",
"n-1",
"n",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}",
"if ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}",
"num[j] < num[j-1]",
"num[j]",
"num",
"j",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}",
"int k = num[j] ;",
"k",
"num[j]",
"num",
"j",
"num[j] = num[j-1]",
"num[j]",
"num",
"j",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"num[j-1] = k",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"k",
"snum++",
"snum",
"putAry(num)",
"putAry",
"num",
"System.out.println(snum)",
"System.out.println",
"System.out",
"System",
"System.out",
"snum",
"String[] args",
"args",
"public static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(System.in)));\n\t}",
"getReader",
"{\n\t\treturn( new BufferedReader(new InputStreamReader(System.in)));\n\t}",
"return( new BufferedReader(new InputStreamReader(System.in)));",
"( new BufferedReader(new InputStreamReader(System.in)))",
"public static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}",
"getInt",
"{\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}",
"String line = br.readLine();",
"line",
"br.readLine()",
"br.readLine",
"br",
"return Integer.valueOf(line);",
"Integer.valueOf(line)",
"Integer.valueOf",
"Integer",
"line",
"BufferedReader br",
"br",
"public static int[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}",
"getAry",
"{\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}",
"String line = br.readLine();",
"line",
"br.readLine()",
"br.readLine",
"br",
"String[] nstr = line.split(\" \");",
"nstr",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"int[] n = new int[nstr.length];",
"n",
"new int[nstr.length]",
"nstr.length",
"nstr",
"nstr.length",
"for( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}",
"int i=0 ;",
"int i=0 ;",
"i",
"0",
"i < nstr.length",
"i",
"nstr.length",
"nstr",
"nstr.length",
"i++",
"i++",
"i",
"{\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}",
"{\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}",
"n[i] = Integer.valueOf(nstr[i])",
"n[i]",
"n",
"i",
"Integer.valueOf(nstr[i])",
"Integer.valueOf",
"Integer",
"nstr[i]",
"nstr",
"i",
"return n;",
"n",
"BufferedReader br",
"br",
"public static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}",
"getAryMl",
"{\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}",
"int n = getInt(br);",
"n",
"getInt(br)",
"getInt",
"br",
"int[] ary = new int[n];",
"ary",
"new int[n]",
"n",
"for( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}",
"int i=0 ;",
"int i=0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tary[i] = getInt(br);\n\t\t}",
"{\n\t\t\tary[i] = getInt(br);\n\t\t}",
"ary[i] = getInt(br)",
"ary[i]",
"ary",
"i",
"getInt(br)",
"getInt",
"br",
"return ary;",
"ary",
"BufferedReader br",
"br",
"public static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}",
"putAry",
"{\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}",
"for( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"System.out.print(ary[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"ary[i]",
"ary",
"i",
"if ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"i < num-1",
"i",
"num-1",
"num",
"1",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(\"\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\"",
"int[] ary",
"ary",
"int num",
"num",
"public static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}",
"putAry",
"{\n\t\tputAry(ary, ary.length ) ;\n\t}",
"putAry(ary, ary.length )",
"putAry",
"ary",
"ary.length",
"ary",
"ary.length",
"int[] ary",
"ary",
"public static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}",
"isPrime",
"{\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}",
"int r = (int)Math.sqrt((double)n)+1;",
"r",
"(int)Math.sqrt((double)n)+1",
"(int)Math.sqrt((double)n)",
"Math.sqrt",
"Math",
"(double)n",
"1",
"for( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}",
"int j = 2 ;",
"int j = 2 ;",
"j",
"2",
"j < r",
"j",
"r",
"j += 1",
"j += 1",
"j",
"1",
"{\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}",
"{\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}",
"if ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}",
"n%j == 0",
"n%j",
"n",
"j",
"0",
"{\n\t\t\t\treturn false;\n\t\t\t}",
"return false;",
"false",
"return true;",
"true",
"int n",
"n",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint n = getInt(breader);\n\t\tint[] num = getAry(breader);\n\t\tint snum = 0;\n\t\tfor(int i = 0; i < n ; i++ ) {\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tputAry(num);\n\t\tSystem.out.println(snum);\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(System.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static int[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint n = getInt(breader);\n\t\tint[] num = getAry(breader);\n\t\tint snum = 0;\n\t\tfor(int i = 0; i < n ; i++ ) {\n\t\t\tfor( int j = n-1 ; j > i ; j-- ) {\n\t\t\t\tif ( num[j] < num[j-1] ) {\n\t\t\t\t\tint k = num[j] ;\n\t\t\t\t\tnum[j] = num[j-1];\n\t\t\t\t\tnum[j-1] = k;\n\t\t\t\t\tsnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tputAry(num);\n\t\tSystem.out.println(snum);\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(System.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static int[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader breader = getReader();
int n = getInt(breader);
int[] num = getAry(breader);
int snum = 0;
for(int i = 0; i < n ; i++ ) {
for( int j = n-1 ; j > i ; j-- ) {
if ( num[j] < num[j-1] ) {
int k = num[j] ;
num[j] = num[j-1];
num[j-1] = k;
snum++;
}
}
}
putAry(num);
System.out.println(snum);
}
public static BufferedReader getReader() {
return( new BufferedReader(new InputStreamReader(System.in)));
}
public static int getInt(BufferedReader br)throws Exception {
String line = br.readLine();
return Integer.valueOf(line);
}
public static int[] getAry(BufferedReader br)throws Exception {
String line = br.readLine();
String[] nstr = line.split(" ");
int[] n = new int[nstr.length];
for( int i=0 ; i < nstr.length ; i++ ) {
n[i] = Integer.valueOf(nstr[i]);
}
return n;
}
public static int[] getAryMl(BufferedReader br)throws Exception {
int n = getInt(br);
int[] ary = new int[n];
for( int i=0 ; i < n ; i++ ) {
ary[i] = getInt(br);
}
return ary;
}
public static void putAry(int[] ary, int num) {
for( int i = 0; i < num ; i++ ) {
System.out.print(ary[i]);
if ( i < num-1) {
System.out.print(" ");
}
}
System.out.println("");
}
public static void putAry(int[] ary) {
putAry(ary, ary.length ) ;
}
public static boolean isPrime(int n) {
int r = (int)Math.sqrt((double)n)+1;
for( int j = 2 ; j < r ; j += 1) {
if ( n%j == 0 ) {
return false;
}
}
return true;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
11,
1,
0,
13,
17,
2,
13,
2,
18,
13,
13,
17,
1,
40,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
12,
13
],
[
13,
14
],
[
13,
15
],
[
11,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
18,
22
],
[
11,
23
],
[
23,
24
],
[
24,
25
],
[
11,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
27,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
32,
36
],
[
8,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
37,
42
],
[
42,
43
],
[
42,
44
],
[
6,
45
],
[
45,
46
],
[
4,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
49,
58
],
[
58,
59
],
[
58,
60
],
[
49,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
62,
67
],
[
67,
68
],
[
67,
69
],
[
62,
70
],
[
70,
71
],
[
71,
72
],
[
62,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
78,
79
],
[
79,
80
],
[
49,
81
],
[
81,
82
],
[
81,
83
],
[
49,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
84,
89
],
[
89,
90
],
[
89,
91
],
[
84,
92
],
[
92,
93
],
[
93,
94
],
[
84,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
96,
103
],
[
103,
104
],
[
103,
105
],
[
96,
106
],
[
106,
107
],
[
107,
108
],
[
96,
109
],
[
110,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
111,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
121,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
121,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
136,
142
],
[
121,
143
],
[
143,
144
],
[
49,
145
],
[
145,
146
],
[
145,
147
],
[
49,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
47,
154
],
[
154,
155
]
] | [
"import java.util.Scanner;\n\nclass Main{\n static void trace(int[] a){\n int i;\n for(i = 0; i < a.length - 1; i++)\n System.out.print(a[i] + \" \");\n System.out.println(a[i]);\n }\n\n public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int a[] = new int[n];\n for(int i = 0; i < n; i++)\n a[i] = stdIn.nextInt();\n\n int count = 0;\n for(int i = 0; i < n; i++)\n for(int j = n-1; j > i; j--){\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }\n\n trace(a);\n System.out.println(count);\n\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n static void trace(int[] a){\n int i;\n for(i = 0; i < a.length - 1; i++)\n System.out.print(a[i] + \" \");\n System.out.println(a[i]);\n }\n\n public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int a[] = new int[n];\n for(int i = 0; i < n; i++)\n a[i] = stdIn.nextInt();\n\n int count = 0;\n for(int i = 0; i < n; i++)\n for(int j = n-1; j > i; j--){\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }\n\n trace(a);\n System.out.println(count);\n\n }\n}",
"Main",
"static void trace(int[] a){\n int i;\n for(i = 0; i < a.length - 1; i++)\n System.out.print(a[i] + \" \");\n System.out.println(a[i]);\n }",
"trace",
"{\n int i;\n for(i = 0; i < a.length - 1; i++)\n System.out.print(a[i] + \" \");\n System.out.println(a[i]);\n }",
"int i;",
"i",
"for(i = 0; i < a.length - 1; i++)\n System.out.print(a[i] + \" \");",
"i = 0;",
"i = 0",
"i",
"0",
"i < a.length - 1",
"i",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"i++",
"i++",
"i",
"System.out.print(a[i] + \" \");",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(a[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"int[] a",
"a",
"public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int a[] = new int[n];\n for(int i = 0; i < n; i++)\n a[i] = stdIn.nextInt();\n\n int count = 0;\n for(int i = 0; i < n; i++)\n for(int j = n-1; j > i; j--){\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }\n\n trace(a);\n System.out.println(count);\n\n }",
"main",
"{\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int a[] = new int[n];\n for(int i = 0; i < n; i++)\n a[i] = stdIn.nextInt();\n\n int count = 0;\n for(int i = 0; i < n; i++)\n for(int j = n-1; j > i; j--){\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }\n\n trace(a);\n System.out.println(count);\n\n }",
"Scanner stdIn = new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"int n = stdIn.nextInt();",
"n",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int a[] = new int[n];",
"a",
"new int[n]",
"n",
"for(int i = 0; i < n; i++)\n a[i] = stdIn.nextInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = stdIn.nextInt();",
"a[i] = stdIn.nextInt()",
"a[i]",
"a",
"i",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int count = 0;",
"count",
"0",
"for(int i = 0; i < n; i++)\n for(int j = n-1; j > i; j--){\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"for(int j = n-1; j > i; j--){\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }",
"for(int j = n-1; j > i; j--){\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }",
"{\n if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }\n }",
"if(a[j] < a[j-1]){\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n int tmp = a[j];\n a[j] = a[j-1];\n a[j-1] = tmp;\n count++;\n }",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"tmp",
"count++",
"count",
"trace(a)",
"trace",
"a",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
static void trace(int[] a){
int i;
for(i = 0; i < a.length - 1; i++)
System.out.print(a[i] + " ");
System.out.println(a[i]);
}
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int n = stdIn.nextInt();
int a[] = new int[n];
for(int i = 0; i < n; i++)
a[i] = stdIn.nextInt();
int count = 0;
for(int i = 0; i < n; i++)
for(int j = n-1; j > i; j--){
if(a[j] < a[j-1]){
int tmp = a[j];
a[j] = a[j-1];
a[j-1] = tmp;
count++;
}
}
trace(a);
System.out.println(count);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
12,
13,
30,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
2,
13,
17,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
40,
13,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
198,
11
],
[
198,
12
],
[
12,
13
],
[
12,
14
],
[
198,
15
],
[
15,
16
],
[
15,
17
],
[
198,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
20,
35
],
[
35,
36
],
[
35,
37
],
[
20,
38
],
[
38,
39
],
[
38,
40
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
20,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
47,
52
],
[
20,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
53,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
53,
63
],
[
63,
64
],
[
64,
65
],
[
53,
66
],
[
67,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
20,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
78,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
78,
91
],
[
92,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
93,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
93,
107
],
[
107,
108
],
[
108,
109
],
[
93,
110
],
[
111,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
119,
121
],
[
112,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
122,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
122,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
139,
145
],
[
20,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
153,
155
],
[
146,
156
],
[
156,
157
],
[
157,
158
],
[
146,
159
],
[
160,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
164,
168
],
[
161,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
170,
175
],
[
175,
176
],
[
175,
177
],
[
169,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
178,
183
],
[
161,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
185,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
18,
195
],
[
195,
196
],
[
0,
197
],
[
197,
198
],
[
197,
199
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic void Sort(){\n\n\t}\n\n\tpublic void maain(){\n\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\t//1???????????\\????????¢\n\t StringBuilder buider = new StringBuilder();\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String n = br.readLine();\n int count = 0;\n int yard = 0;\n\n //\n int[] num = new int[Integer.parseInt(n)];\n\n String[] input2 = br.readLine().split(\" \");\n\n for(int i = 0; i < num.length; i++){\n \tnum[i] = Integer.parseInt(input2[i]);\n }\n\n //\n for(int i = 0; i < num.length ; i++){\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }\n\n //\n for(int i = 0; i < num.length; i++){\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n\tpublic void Sort(){\n\n\t}\n\n\tpublic void maain(){\n\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\t//1???????????\\????????¢\n\t StringBuilder buider = new StringBuilder();\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String n = br.readLine();\n int count = 0;\n int yard = 0;\n\n //\n int[] num = new int[Integer.parseInt(n)];\n\n String[] input2 = br.readLine().split(\" \");\n\n for(int i = 0; i < num.length; i++){\n \tnum[i] = Integer.parseInt(input2[i]);\n }\n\n //\n for(int i = 0; i < num.length ; i++){\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }\n\n //\n for(int i = 0; i < num.length; i++){\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }\n\t}\n}",
"Main",
"public void Sort(){\n\n\t}",
"Sort",
"{\n\n\t}",
"public void maain(){\n\n\t}",
"maain",
"{\n\n\t}",
"public static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\t//1???????????\\????????¢\n\t StringBuilder buider = new StringBuilder();\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String n = br.readLine();\n int count = 0;\n int yard = 0;\n\n //\n int[] num = new int[Integer.parseInt(n)];\n\n String[] input2 = br.readLine().split(\" \");\n\n for(int i = 0; i < num.length; i++){\n \tnum[i] = Integer.parseInt(input2[i]);\n }\n\n //\n for(int i = 0; i < num.length ; i++){\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }\n\n //\n for(int i = 0; i < num.length; i++){\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }\n\t}",
"main",
"{\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\t//1???????????\\????????¢\n\t StringBuilder buider = new StringBuilder();\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String n = br.readLine();\n int count = 0;\n int yard = 0;\n\n //\n int[] num = new int[Integer.parseInt(n)];\n\n String[] input2 = br.readLine().split(\" \");\n\n for(int i = 0; i < num.length; i++){\n \tnum[i] = Integer.parseInt(input2[i]);\n }\n\n //\n for(int i = 0; i < num.length ; i++){\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }\n\n //\n for(int i = 0; i < num.length; i++){\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }\n\t}",
"StringBuilder buider = new StringBuilder();",
"buider",
"new StringBuilder()",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String n = br.readLine();",
"n",
"br.readLine()",
"br.readLine",
"br",
"int count = 0;",
"count",
"0",
"int yard = 0;",
"yard",
"0",
"int[] num = new int[Integer.parseInt(n)];",
"num",
"new int[Integer.parseInt(n)]",
"Integer.parseInt(n)",
"Integer.parseInt",
"Integer",
"n",
"String[] input2 = br.readLine().split(\" \");",
"input2",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for(int i = 0; i < num.length; i++){\n \tnum[i] = Integer.parseInt(input2[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num.length",
"i",
"num.length",
"num",
"num.length",
"i++",
"i++",
"i",
"{\n \tnum[i] = Integer.parseInt(input2[i]);\n }",
"{\n \tnum[i] = Integer.parseInt(input2[i]);\n }",
"num[i] = Integer.parseInt(input2[i])",
"num[i]",
"num",
"i",
"Integer.parseInt(input2[i])",
"Integer.parseInt",
"Integer",
"input2[i]",
"input2",
"i",
"for(int i = 0; i < num.length ; i++){\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num.length",
"i",
"num.length",
"num",
"num.length",
"i++",
"i++",
"i",
"{\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }",
"{\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }",
"for(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}",
"int j = num.length - 1 ;",
"int j = num.length - 1 ;",
"j",
"num.length - 1",
"num.length",
"num",
"num.length",
"1",
"i + 1 <= j",
"i + 1",
"i",
"1",
"j",
"j--",
"j--",
"j",
"{\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}",
"{\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}",
"if(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}",
"num[j] < num[j - 1]",
"num[j]",
"num",
"j",
"num[j - 1]",
"num",
"j - 1",
"j",
"1",
"{\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}",
"count++",
"count",
"yard = num[j]",
"yard",
"num[j]",
"num",
"j",
"num[j] = num[j - 1]",
"num[j]",
"num",
"j",
"num[j - 1]",
"num",
"j - 1",
"j",
"1",
"num[j - 1] = yard",
"num[j - 1]",
"num",
"j - 1",
"j",
"1",
"yard",
"for(int i = 0; i < num.length; i++){\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num.length",
"i",
"num.length",
"num",
"num.length",
"i++",
"i++",
"i",
"{\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }",
"{\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }",
"if(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}",
"i == num.length - 1",
"i",
"num.length - 1",
"num.length",
"num",
"num.length",
"1",
"{\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}",
"System.out.println(num[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"num[i]",
"num",
"i",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"{\n \tSystem.out.print(num[i] + \" \");\n \t}",
"System.out.print(num[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"num[i] + \" \"",
"num[i]",
"num",
"i",
"\" \"",
"String[] args",
"args",
"public class Main {\n\n\tpublic void Sort(){\n\n\t}\n\n\tpublic void maain(){\n\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\t//1???????????\\????????¢\n\t StringBuilder buider = new StringBuilder();\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String n = br.readLine();\n int count = 0;\n int yard = 0;\n\n //\n int[] num = new int[Integer.parseInt(n)];\n\n String[] input2 = br.readLine().split(\" \");\n\n for(int i = 0; i < num.length; i++){\n \tnum[i] = Integer.parseInt(input2[i]);\n }\n\n //\n for(int i = 0; i < num.length ; i++){\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }\n\n //\n for(int i = 0; i < num.length; i++){\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }\n\t}\n}",
"public class Main {\n\n\tpublic void Sort(){\n\n\t}\n\n\tpublic void maain(){\n\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\t//1???????????\\????????¢\n\t StringBuilder buider = new StringBuilder();\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String n = br.readLine();\n int count = 0;\n int yard = 0;\n\n //\n int[] num = new int[Integer.parseInt(n)];\n\n String[] input2 = br.readLine().split(\" \");\n\n for(int i = 0; i < num.length; i++){\n \tnum[i] = Integer.parseInt(input2[i]);\n }\n\n //\n for(int i = 0; i < num.length ; i++){\n\n \tfor(int j = num.length - 1 ; i + 1 <= j; j--){\n \t\t\t\n \t\tif(num[j] < num[j - 1]){\n\n \t\t\tcount++;\n \t\t\tyard = num[j];\n \t\t\tnum[j] = num[j - 1];\n \t\t\tnum[j - 1] = yard;\n \t\t}\n \t}\n }\n\n //\n for(int i = 0; i < num.length; i++){\n\n \tif(i == num.length - 1){\n \t\tSystem.out.println(num[i]);\n \t\tSystem.out.println(count);\n \t}else{\n \tSystem.out.print(num[i] + \" \");\n \t}\n }\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public void Sort(){
}
public void maain(){
}
public static void main(String[] args) throws IOException {
// TODO ?????????????????????????????????????????????
//1???????????\????????¢
StringBuilder buider = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String n = br.readLine();
int count = 0;
int yard = 0;
//
int[] num = new int[Integer.parseInt(n)];
String[] input2 = br.readLine().split(" ");
for(int i = 0; i < num.length; i++){
num[i] = Integer.parseInt(input2[i]);
}
//
for(int i = 0; i < num.length ; i++){
for(int j = num.length - 1 ; i + 1 <= j; j--){
if(num[j] < num[j - 1]){
count++;
yard = num[j];
num[j] = num[j - 1];
num[j - 1] = yard;
}
}
}
//
for(int i = 0; i < num.length; i++){
if(i == num.length - 1){
System.out.println(num[i]);
System.out.println(count);
}else{
System.out.print(num[i] + " ");
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
17,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
17,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
37,
38
],
[
38,
39
],
[
8,
40
],
[
40,
41
],
[
40,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
8,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
56,
58
],
[
52,
59
],
[
59,
60
],
[
59,
61
],
[
52,
62
],
[
62,
63
],
[
63,
64
],
[
52,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
67,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
77,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
77,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
77,
102
],
[
102,
103
],
[
8,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
104,
109
],
[
109,
110
],
[
109,
111
],
[
104,
112
],
[
112,
113
],
[
113,
114
],
[
104,
115
],
[
116,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
116,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
132,
133
],
[
132,
134
],
[
8,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
140,
142
],
[
6,
143
],
[
143,
144
]
] | [
"import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\t\n\t\tint a[] = new int[n];\n\t\tfor(int i = 0; i < n; i++) a[i] = sc.nextInt();\n\t\t\n\t\tint chtimes = 0;\n\t\tboolean flag = true;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n-1; j >= 1; j--) {\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(i != 0) System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\\n\" + chtimes);\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\t\n\t\tint a[] = new int[n];\n\t\tfor(int i = 0; i < n; i++) a[i] = sc.nextInt();\n\t\t\n\t\tint chtimes = 0;\n\t\tboolean flag = true;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n-1; j >= 1; j--) {\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(i != 0) System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\\n\" + chtimes);\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\t\n\t\tint a[] = new int[n];\n\t\tfor(int i = 0; i < n; i++) a[i] = sc.nextInt();\n\t\t\n\t\tint chtimes = 0;\n\t\tboolean flag = true;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n-1; j >= 1; j--) {\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(i != 0) System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\\n\" + chtimes);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\t\n\t\tint a[] = new int[n];\n\t\tfor(int i = 0; i < n; i++) a[i] = sc.nextInt();\n\t\t\n\t\tint chtimes = 0;\n\t\tboolean flag = true;\n\t\twhile(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n-1; j >= 1; j--) {\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(i != 0) System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}\n\t\tSystem.out.println(\"\\n\" + chtimes);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int a[] = new int[n];",
"a",
"new int[n]",
"n",
"for(int i = 0; i < n; i++) a[i] = sc.nextInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = sc.nextInt();",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int chtimes = 0;",
"chtimes",
"0",
"boolean flag = true;",
"flag",
"true",
"while(flag) {\n\t\t\tflag = false;\n\t\t\tfor(int j = n-1; j >= 1; j--) {\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor(int j = n-1; j >= 1; j--) {\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for(int j = n-1; j >= 1; j--) {\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}\n\t\t\t}",
"if(a[j] < a[j-1]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tflag = true;\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tchtimes++;\n\t\t\t\t}",
"flag = true",
"flag",
"true",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"tmp",
"chtimes++",
"chtimes",
"for(int i = 0; i < n; i++) {\n\t\t\tif(i != 0) System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif(i != 0) System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}",
"{\n\t\t\tif(i != 0) System.out.print(\" \");\n\t\t\tSystem.out.print(a[i]);\n\t\t}",
"if(i != 0) System.out.print(\" \");",
"i != 0",
"i",
"0",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.println(\"\\n\" + chtimes)",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\\n\" + chtimes",
"\"\\n\"",
"chtimes",
"String args[]",
"args"
] | import java.util.Scanner;
class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a[] = new int[n];
for(int i = 0; i < n; i++) a[i] = sc.nextInt();
int chtimes = 0;
boolean flag = true;
while(flag) {
flag = false;
for(int j = n-1; j >= 1; j--) {
if(a[j] < a[j-1]) {
flag = true;
int tmp = a[j];
a[j] = a[j-1];
a[j-1] = tmp;
chtimes++;
}
}
}
for(int i = 0; i < n; i++) {
if(i != 0) System.out.print(" ");
System.out.print(a[i]);
}
System.out.println("\n" + chtimes);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
180,
5
],
[
180,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
13,
14
],
[
14,
15
],
[
14,
16
],
[
12,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
19,
21
],
[
12,
22
],
[
22,
23
],
[
23,
24
],
[
12,
25
],
[
26,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
31,
35
],
[
27,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
38,
40
],
[
27,
41
],
[
41,
42
],
[
42,
43
],
[
27,
44
],
[
45,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
56,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
71,
77
],
[
56,
78
],
[
78,
79
],
[
8,
80
],
[
80,
81
],
[
80,
82
],
[
8,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
6,
89
],
[
89,
90
],
[
180,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
94,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
94,
104
],
[
104,
105
],
[
105,
106
],
[
94,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
114,
115
],
[
114,
116
],
[
108,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
117,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
125,
130
],
[
117,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
91,
137
],
[
137,
138
],
[
180,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
141,
150
],
[
150,
151
],
[
150,
152
],
[
141,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
159,
160
],
[
159,
161
],
[
154,
162
],
[
162,
163
],
[
163,
164
],
[
154,
165
],
[
166,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
171,
172
],
[
172,
173
],
[
141,
174
],
[
174,
175
],
[
174,
176
],
[
139,
177
],
[
177,
178
],
[
0,
179
],
[
179,
180
],
[
179,
181
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\n\n\tpublic static void bubble_sort(int[] a) {\n\t\tint num_swaps = 0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdisplay(a);\n\t\tSystem.out.println(num_swaps);\n\t}\n\n\tpublic static void display(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = s.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = s.nextInt();\n\t\t}\n\t\tbubble_sort(a);\n\t}\n\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\n\n\tpublic static void bubble_sort(int[] a) {\n\t\tint num_swaps = 0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdisplay(a);\n\t\tSystem.out.println(num_swaps);\n\t}\n\n\tpublic static void display(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = s.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = s.nextInt();\n\t\t}\n\t\tbubble_sort(a);\n\t}\n\n}",
"Main",
"public static void bubble_sort(int[] a) {\n\t\tint num_swaps = 0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdisplay(a);\n\t\tSystem.out.println(num_swaps);\n\t}",
"bubble_sort",
"{\n\t\tint num_swaps = 0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdisplay(a);\n\t\tSystem.out.println(num_swaps);\n\t}",
"int num_swaps = 0;",
"num_swaps",
"0",
"for (int i = 0; i < a.length; i++) {\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}",
"int j = a.length - 1;",
"int j = a.length - 1;",
"j",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"j >= i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}",
"if (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}",
"a[j] < a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = tmp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"tmp",
"num_swaps++",
"num_swaps",
"display(a)",
"display",
"a",
"System.out.println(num_swaps)",
"System.out.println",
"System.out",
"System",
"System.out",
"num_swaps",
"int[] a",
"a",
"public static void display(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}\n\t}",
"display",
"{\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}\n\t}",
"for (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}",
"{\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}",
"System.out.print(a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"if (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");",
"i != a.length - 1",
"i",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.print(\"\\n\")",
"System.out.print",
"System.out",
"System",
"System.out",
"\"\\n\"",
"int[] a",
"a",
"public static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = s.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = s.nextInt();\n\t\t}\n\t\tbubble_sort(a);\n\t}",
"main",
"{\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = s.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = s.nextInt();\n\t\t}\n\t\tbubble_sort(a);\n\t}",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int n = s.nextInt();",
"n",
"s.nextInt()",
"s.nextInt",
"s",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\ta[i] = s.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = s.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = s.nextInt();\n\t\t}",
"a[i] = s.nextInt()",
"a[i]",
"a",
"i",
"s.nextInt()",
"s.nextInt",
"s",
"bubble_sort(a)",
"bubble_sort",
"a",
"String[] args",
"args",
"public class Main {\n\n\n\n\tpublic static void bubble_sort(int[] a) {\n\t\tint num_swaps = 0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdisplay(a);\n\t\tSystem.out.println(num_swaps);\n\t}\n\n\tpublic static void display(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = s.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = s.nextInt();\n\t\t}\n\t\tbubble_sort(a);\n\t}\n\n}",
"public class Main {\n\n\n\n\tpublic static void bubble_sort(int[] a) {\n\t\tint num_swaps = 0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tfor (int j = a.length - 1; j >= i+1; j--) {\n\t\t\t\tif (a[j] < a[j-1]) {\n\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j-1] = tmp;\n\t\t\t\t\tnum_swaps++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdisplay(a);\n\t\tSystem.out.println(num_swaps);\n\t}\n\n\tpublic static void display(int[] a) {\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tSystem.out.print(a[i]);\n\t\t\tif (i != a.length - 1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\telse\n\t\t\t\tSystem.out.print(\"\\n\");\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = s.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = s.nextInt();\n\t\t}\n\t\tbubble_sort(a);\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void bubble_sort(int[] a) {
int num_swaps = 0;
for (int i = 0; i < a.length; i++) {
for (int j = a.length - 1; j >= i+1; j--) {
if (a[j] < a[j-1]) {
int tmp = a[j];
a[j] = a[j-1];
a[j-1] = tmp;
num_swaps++;
}
}
}
display(a);
System.out.println(num_swaps);
}
public static void display(int[] a) {
for (int i = 0; i < a.length; i++) {
System.out.print(a[i]);
if (i != a.length - 1)
System.out.print(" ");
else
System.out.print("\n");
}
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = s.nextInt();
}
bubble_sort(a);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
38,
30,
41,
13,
20,
41,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
11,
1,
41,
13,
17,
41,
13,
17,
41,
13,
2,
2,
13,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
41,
13,
20,
28,
13,
13,
30,
30,
4,
18,
4,
18,
13,
13,
17,
4,
18,
13,
2,
4,
18,
13,
17,
4,
18,
4,
18,
13,
17,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
182,
11
],
[
182,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
20,
22
],
[
16,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
29,
30
],
[
16,
31
],
[
31,
32
],
[
31,
33
],
[
16,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
37,
42
],
[
16,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
43,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
55,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
63,
65
],
[
16,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
71,
73
],
[
67,
74
],
[
74,
75
],
[
66,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
80,
82
],
[
66,
83
],
[
83,
84
],
[
84,
85
],
[
66,
86
],
[
87,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
91,
98
],
[
98,
99
],
[
98,
100
],
[
91,
101
],
[
101,
102
],
[
102,
103
],
[
91,
104
],
[
105,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
106,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
119,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
128,
130
],
[
116,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
131,
137
],
[
116,
138
],
[
138,
139
],
[
116,
140
],
[
140,
141
],
[
140,
142
],
[
16,
143
],
[
143,
144
],
[
143,
145
],
[
16,
146
],
[
146,
147
],
[
146,
148
],
[
146,
149
],
[
150,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
153,
156
],
[
151,
157
],
[
16,
158
],
[
158,
159
],
[
159,
160
],
[
158,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
161,
165
],
[
16,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
168,
171
],
[
166,
172
],
[
16,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
173,
178
],
[
12,
179
],
[
179,
180
],
[
0,
181
],
[
181,
182
],
[
181,
183
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }\n }",
"main",
"{\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }\n }",
"try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }",
"{\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"new BufferedReader(new InputStreamReader(System.in))",
"int count=0;",
"count",
"0",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"int[] seq = new int[n];",
"seq",
"new int[n]",
"n",
"String[] line = br.readLine().split(\" \");",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n seq[i] = Integer.parseInt(line[i]);\n }",
"{\n seq[i] = Integer.parseInt(line[i]);\n }",
"seq[i] = Integer.parseInt(line[i])",
"seq[i]",
"seq",
"i",
"Integer.parseInt(line[i])",
"Integer.parseInt",
"Integer",
"line[i]",
"line",
"i",
"for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }",
"int i=0,f=1,t;",
"int i=0",
"i",
"0",
"f=1",
"f",
"1",
"t;",
"t",
"i<n || f==1",
"i<n",
"i",
"n",
"f==1",
"f",
"1",
"i++",
"i++",
"i",
"{\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }",
"{\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }",
"f=0",
"f",
"0",
"for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }",
"int j=n-1;",
"int j=n-1;",
"j",
"n-1",
"n",
"1",
"j>0",
"j",
"0",
"j--",
"j--",
"j",
"{\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }",
"{\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }",
"if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }",
"seq[j] < seq[j-1]",
"seq[j]",
"seq",
"j",
"seq[j-1]",
"seq",
"j-1",
"j",
"1",
"{\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }",
"t = seq[j]",
"t",
"seq[j]",
"seq",
"j",
"seq[j] = seq[j-1]",
"seq[j]",
"seq",
"j",
"seq[j-1]",
"seq",
"j-1",
"j",
"1",
"seq[j-1] = t",
"seq[j-1]",
"seq",
"j-1",
"j",
"1",
"t",
"count++",
"count",
"f=1",
"f",
"1",
"StringBuilder s = new StringBuilder();",
"s",
"new StringBuilder()",
"for (int i : seq) { s.append(i).append(\" \"); }",
"int i",
"seq",
"{ s.append(i).append(\" \"); }",
"{ s.append(i).append(\" \"); }",
"s.append(i).append(\" \")",
"s.append(i).append",
"s.append(i)",
"s.append",
"s",
"i",
"\" \"",
"s.setLength(s.length()-1)",
"s.setLength",
"s",
"s.length()-1",
"s.length()",
"s.length",
"s",
"1",
"s.append(\"\\n\").append(count)",
"s.append(\"\\n\").append",
"s.append(\"\\n\")",
"s.append",
"s",
"\"\\n\"",
"count",
"System.out.println(s)",
"System.out.println",
"System.out",
"System",
"System.out",
"s",
"String[] args",
"args",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int count=0;\n int n = Integer.parseInt(br.readLine());\n int[] seq = new int[n];\n String[] line = br.readLine().split(\" \");\n for (int i=0; i < n; i++) {\n seq[i] = Integer.parseInt(line[i]);\n }\n\n for(int i=0,f=1,t; i<n || f==1; i++ ) {\n f=0;\n for(int j=n-1; j>0; j-- ) {\n if( seq[j] < seq[j-1]) {\n t = seq[j];\n seq[j] = seq[j-1];\n seq[j-1] = t;\n count++;\n f=1;\n }\n }\n }\n\n StringBuilder s = new StringBuilder();\n for (int i : seq) { s.append(i).append(\" \"); }\n s.setLength(s.length()-1);\n s.append(\"\\n\").append(count);\n System.out.println(s);\n }\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int count=0;
int n = Integer.parseInt(br.readLine());
int[] seq = new int[n];
String[] line = br.readLine().split(" ");
for (int i=0; i < n; i++) {
seq[i] = Integer.parseInt(line[i]);
}
for(int i=0,f=1,t; i<n || f==1; i++ ) {
f=0;
for(int j=n-1; j>0; j-- ) {
if( seq[j] < seq[j-1]) {
t = seq[j];
seq[j] = seq[j-1];
seq[j-1] = t;
count++;
f=1;
}
}
}
StringBuilder s = new StringBuilder();
for (int i : seq) { s.append(i).append(" "); }
s.setLength(s.length()-1);
s.append("\n").append(count);
System.out.println(s);
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
41,
13,
18,
13,
13,
41,
13,
18,
13,
2,
13,
17,
14,
2,
13,
13,
30,
0,
18,
13,
13,
13,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
4,
18,
18,
13,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
156,
5
],
[
156,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
8,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
24,
29
],
[
29,
30
],
[
29,
31
],
[
24,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
36,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
44,
45
],
[
45,
46
],
[
8,
47
],
[
47,
48
],
[
48,
49
],
[
8,
50
],
[
50,
51
],
[
50,
52
],
[
8,
53
],
[
53,
54
],
[
53,
55
],
[
8,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
62,
69
],
[
69,
70
],
[
69,
71
],
[
62,
72
],
[
72,
73
],
[
73,
74
],
[
62,
75
],
[
76,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
76,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
76,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
93,
106
],
[
106,
107
],
[
93,
108
],
[
108,
109
],
[
108,
110
],
[
8,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
116,
117
],
[
116,
118
],
[
8,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
124,
125
],
[
124,
126
],
[
119,
127
],
[
127,
128
],
[
128,
129
],
[
119,
130
],
[
131,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
8,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
6,
153
],
[
153,
154
],
[
0,
155
],
[
155,
156
],
[
155,
157
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=Integer.valueOf(sc.next());\n\t\tint[] arr= new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tint count=0;\n\t\tboolean f=true;\n\t\twhile(f){\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(arr[0]);\n\t\tfor(int i=1;i<n;i++){\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=Integer.valueOf(sc.next());\n\t\tint[] arr= new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tint count=0;\n\t\tboolean f=true;\n\t\twhile(f){\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(arr[0]);\n\t\tfor(int i=1;i<n;i++){\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=Integer.valueOf(sc.next());\n\t\tint[] arr= new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tint count=0;\n\t\tboolean f=true;\n\t\twhile(f){\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(arr[0]);\n\t\tfor(int i=1;i<n;i++){\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=Integer.valueOf(sc.next());\n\t\tint[] arr= new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tint count=0;\n\t\tboolean f=true;\n\t\twhile(f){\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(arr[0]);\n\t\tfor(int i=1;i<n;i++){\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}",
"Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n=Integer.valueOf(sc.next());",
"n",
"Integer.valueOf(sc.next())",
"Integer.valueOf",
"Integer",
"sc.next()",
"sc.next",
"sc",
"int[] arr= new int[n];",
"arr",
"new int[n]",
"n",
"for(int i=0;i<n;i++){\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}",
"{\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}",
"arr[i]=Integer.valueOf(sc.next())",
"arr[i]",
"arr",
"i",
"Integer.valueOf(sc.next())",
"Integer.valueOf",
"Integer",
"sc.next()",
"sc.next",
"sc",
"sc.close()",
"sc.close",
"sc",
"int count=0;",
"count",
"0",
"boolean f=true;",
"f",
"true",
"while(f){\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"f",
"{\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}",
"f=false",
"f",
"false",
"for(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}",
"int i=n-1;",
"int i=n-1;",
"i",
"n-1",
"n",
"1",
"i>0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}",
"int a=arr[i];",
"a",
"arr[i]",
"arr",
"i",
"int b=arr[i-1];",
"b",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"if(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}",
"a<b",
"a",
"b",
"{\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}",
"arr[i]=b",
"arr[i]",
"arr",
"i",
"b",
"arr[i-1]=a",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"a",
"count++",
"count",
"f=true",
"f",
"true",
"System.out.print(arr[0])",
"System.out.print",
"System.out",
"System",
"System.out",
"arr[0]",
"arr",
"0",
"for(int i=1;i<n;i++){\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}",
"{\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}",
"System.out.print(\" \"+arr[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"+arr[i]",
"\" \"",
"arr[i]",
"arr",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=Integer.valueOf(sc.next());\n\t\tint[] arr= new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tint count=0;\n\t\tboolean f=true;\n\t\twhile(f){\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(arr[0]);\n\t\tfor(int i=1;i<n;i++){\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=Integer.valueOf(sc.next());\n\t\tint[] arr= new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tarr[i]=Integer.valueOf(sc.next());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tint count=0;\n\t\tboolean f=true;\n\t\twhile(f){\n\t\t\tf=false;\n\t\t\tfor(int i=n-1;i>0;i--){\n\t\t\t\tint a=arr[i];\n\t\t\t\tint b=arr[i-1];\n\t\t\t\tif(a<b){\n\t\t\t\t\tarr[i]=b;\n\t\t\t\t\tarr[i-1]=a;\n\t\t\t\t\tcount++;\n\t\t\t\t\tf=true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(arr[0]);\n\t\tfor(int i=1;i<n;i++){\n\t\t\tSystem.out.print(\" \"+arr[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=Integer.valueOf(sc.next());
int[] arr= new int[n];
for(int i=0;i<n;i++){
arr[i]=Integer.valueOf(sc.next());
}
sc.close();
int count=0;
boolean f=true;
while(f){
f=false;
for(int i=n-1;i>0;i--){
int a=arr[i];
int b=arr[i-1];
if(a<b){
arr[i]=b;
arr[i-1]=a;
count++;
f=true;
}
}
}
System.out.print(arr[0]);
for(int i=1;i<n;i++){
System.out.print(" "+arr[i]);
}
System.out.println();
System.out.println(count);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
38,
5,
13,
30,
4,
18,
13,
5,
13,
30,
4,
18,
13,
30,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
18,
18,
13,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
195,
11
],
[
195,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
18,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
18,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
37,
38
],
[
38,
39
],
[
31,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
42,
47
],
[
31,
48
],
[
48,
49
],
[
48,
50
],
[
51,
52
],
[
51,
53
],
[
31,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
54,
64
],
[
64,
65
],
[
65,
66
],
[
54,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
76,
77
],
[
76,
78
],
[
31,
79
],
[
79,
80
],
[
79,
81
],
[
31,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
82,
92
],
[
92,
93
],
[
93,
94
],
[
82,
95
],
[
96,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
97,
106
],
[
106,
107
],
[
106,
108
],
[
97,
109
],
[
109,
110
],
[
110,
111
],
[
97,
112
],
[
113,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
121,
123
],
[
114,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
124,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
124,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
139,
145
],
[
124,
146
],
[
146,
147
],
[
31,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
153,
154
],
[
153,
155
],
[
31,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
156,
166
],
[
166,
167
],
[
167,
168
],
[
156,
169
],
[
170,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
171,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
178,
180
],
[
31,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
31,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
186,
191
],
[
12,
192
],
[
192,
193
],
[
0,
194
],
[
194,
195
],
[
194,
196
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t \n\t\ttry {\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t \n\t\ttry {\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t \n\t\ttry {\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t \n\t\ttry {\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"BufferedReader in = new BufferedReader(new InputStreamReader(System.in));",
"in",
"new BufferedReader(new InputStreamReader(System.in))",
"try {\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"NumberFormatException e",
"{\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"IOException e",
"{\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t}",
"int lim = Integer.parseInt(in.readLine());",
"lim",
"Integer.parseInt(in.readLine())",
"Integer.parseInt",
"Integer",
"in.readLine()",
"in.readLine",
"in",
"String[] nums = in.readLine().split(\" \");",
"nums",
"in.readLine().split(\" \")",
"in.readLine().split",
"in.readLine()",
"in.readLine",
"in",
"\" \"",
"int[] a = new int[nums.length];",
"a",
"new int[nums.length]",
"nums.length",
"nums",
"nums.length",
"for (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}",
"{\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}",
"a[i] = Integer.parseInt(nums[i])",
"a[i]",
"a",
"i",
"Integer.parseInt(nums[i])",
"Integer.parseInt",
"Integer",
"nums[i]",
"nums",
"i",
"int cnt = 0;",
"cnt",
"0",
"for (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"for (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}",
"int j = (a.length - 1);",
"int j = (a.length - 1);",
"j",
"(a.length - 1)",
"a.length",
"a",
"a.length",
"1",
"j > i",
"j",
"i",
"j--",
"j--",
"j",
"{\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}",
"{\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}",
"if (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}",
"a[j] < a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}",
"int tmp = a[j];",
"tmp",
"a[j]",
"a",
"j",
"a[j] = a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"a[j - 1] = tmp",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"tmp",
"cnt++",
"cnt",
"System.out.print(a[0])",
"System.out.print",
"System.out",
"System",
"System.out",
"a[0]",
"a",
"0",
"for (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}",
"{\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}",
"System.out.print(\" \" + a[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \" + a[i]",
"\" \"",
"a[i]",
"a",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t \n\t\ttry {\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t \n\t\ttry {\n\t\t\tint lim = Integer.parseInt(in.readLine());\n\n\t\t\tString[] nums = in.readLine().split(\" \");\n\t\t\tint[] a = new int[nums.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = Integer.parseInt(nums[i]);\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\tfor (int j = (a.length - 1); j > i; j--) {\n\t\t\t\t\tif (a[j] < a[j - 1]) {\n\t\t\t\t\t\tint tmp = a[j];\n\t\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\t\ta[j - 1] = tmp;\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.print(a[0]);\n\t\t\tfor (int i = 1; i < a.length; i++) {\n\t\t\t\tSystem.out.print(\" \" + a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t\t\n\t\t\tSystem.out.println(cnt);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
int lim = Integer.parseInt(in.readLine());
String[] nums = in.readLine().split(" ");
int[] a = new int[nums.length];
for (int i = 0; i < a.length; i++) {
a[i] = Integer.parseInt(nums[i]);
}
int cnt = 0;
for (int i = 0; i < a.length; i++) {
for (int j = (a.length - 1); j > i; j--) {
if (a[j] < a[j - 1]) {
int tmp = a[j];
a[j] = a[j - 1];
a[j - 1] = tmp;
cnt++;
}
}
}
System.out.print(a[0]);
for (int i = 1; i < a.length; i++) {
System.out.print(" " + a[i]);
}
System.out.println();
System.out.println(cnt);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
4,
18,
13,
41,
13,
4,
13,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
4,
13,
13,
13,
2,
13,
17,
0,
13,
17,
40,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
205,
5
],
[
205,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
22,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
31,
32
],
[
31,
33
],
[
8,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
34,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
41,
43
],
[
34,
44
],
[
44,
45
],
[
45,
46
],
[
34,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
56,
57
],
[
56,
58
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
8,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
64,
67
],
[
8,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
68,
81
],
[
82,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
83,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
83,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
103,
108
],
[
108,
109
],
[
108,
110
],
[
8,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
6,
117
],
[
117,
118
],
[
205,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
125,
126
],
[
125,
127
],
[
121,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
138,
140
],
[
134,
141
],
[
141,
142
],
[
141,
143
],
[
134,
144
],
[
144,
145
],
[
145,
146
],
[
134,
147
],
[
148,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
156,
158
],
[
149,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
160,
163
],
[
160,
164
],
[
164,
165
],
[
164,
166
],
[
159,
167
],
[
167,
168
],
[
167,
169
],
[
159,
170
],
[
170,
171
],
[
121,
172
],
[
172,
173
],
[
119,
174
],
[
174,
175
],
[
119,
176
],
[
176,
177
],
[
205,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
183,
184
],
[
183,
185
],
[
180,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
190,
191
],
[
190,
192
],
[
180,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
178,
198
],
[
198,
199
],
[
178,
200
],
[
200,
201
],
[
178,
202
],
[
202,
203
],
[
0,
204
],
[
204,
205
],
[
204,
206
]
] | [
"import java.util.Scanner;\n\n/**\n * ZAKIREN第5章\n *\n * @author K.Yamauchi\n *\n */\npublic class Main {\n\n\t/**\n\t *\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\tScanner scan = new Scanner(System.in); // 入力\n\t\tint n = Integer.parseInt(scan.nextLine()); // 要素数\n\n\t\t// ソート対象配列の読み込み\n\t\tString[] targetArrayStr = scan.nextLine().split(\" \");\n\t\tint[] targetArray = new int[targetArrayStr.length];\n\t\tfor (int i = 0; i < targetArrayStr.length; i++) {\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\n\t\t// ソート\n\t\tint exchangingCount = bubbleSort(n, targetArray);\n\n\t\t// 結果出力\n\t\tfor (int i = 0; i < targetArray.length; i++) {\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(exchangingCount);;\n\n\t}\n\n\t/**\n\t * 指定された整数配列をバブルソートする。\n\t *\n\t * @param n 配列の要素数\n\t * @param targetArray バブルソートしたい整数配列\n\t */\n\tprivate static int bubbleSort(int n, int[] targetArray) {\n\t\tboolean isNotSorted = true; // ソート未完了フラグ\n\t\tint exchangingCount = 0; // 入れ替え回数\n\n\t\t// ソートが完了するまで\n\t\twhile (isNotSorted) {\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exchangingCount;\n\t}\n\n\t/**\n\t * 配列内の2つの要素を入れ替える。\n\t *\n\t * @param array 入れ替えたい要素を含む配列\n\t * @param a 入れ替えたい要素のindex\n\t * @param b 入れ替えたい要素のindex\n\t */\n\tprivate static void exchangeArrayValue(int[] array, int a, int b) {\n\t\tint temp = array[a];\n\t\tarray[a] = array[b];\n\t\tarray[b] = temp;\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\t/**\n\t *\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\tScanner scan = new Scanner(System.in); // 入力\n\t\tint n = Integer.parseInt(scan.nextLine()); // 要素数\n\n\t\t// ソート対象配列の読み込み\n\t\tString[] targetArrayStr = scan.nextLine().split(\" \");\n\t\tint[] targetArray = new int[targetArrayStr.length];\n\t\tfor (int i = 0; i < targetArrayStr.length; i++) {\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\n\t\t// ソート\n\t\tint exchangingCount = bubbleSort(n, targetArray);\n\n\t\t// 結果出力\n\t\tfor (int i = 0; i < targetArray.length; i++) {\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(exchangingCount);;\n\n\t}\n\n\t/**\n\t * 指定された整数配列をバブルソートする。\n\t *\n\t * @param n 配列の要素数\n\t * @param targetArray バブルソートしたい整数配列\n\t */\n\tprivate static int bubbleSort(int n, int[] targetArray) {\n\t\tboolean isNotSorted = true; // ソート未完了フラグ\n\t\tint exchangingCount = 0; // 入れ替え回数\n\n\t\t// ソートが完了するまで\n\t\twhile (isNotSorted) {\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exchangingCount;\n\t}\n\n\t/**\n\t * 配列内の2つの要素を入れ替える。\n\t *\n\t * @param array 入れ替えたい要素を含む配列\n\t * @param a 入れ替えたい要素のindex\n\t * @param b 入れ替えたい要素のindex\n\t */\n\tprivate static void exchangeArrayValue(int[] array, int a, int b) {\n\t\tint temp = array[a];\n\t\tarray[a] = array[b];\n\t\tarray[b] = temp;\n\t}\n\n}",
"Main",
"/**\n\t *\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\tScanner scan = new Scanner(System.in); // 入力\n\t\tint n = Integer.parseInt(scan.nextLine()); // 要素数\n\n\t\t// ソート対象配列の読み込み\n\t\tString[] targetArrayStr = scan.nextLine().split(\" \");\n\t\tint[] targetArray = new int[targetArrayStr.length];\n\t\tfor (int i = 0; i < targetArrayStr.length; i++) {\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\n\t\t// ソート\n\t\tint exchangingCount = bubbleSort(n, targetArray);\n\n\t\t// 結果出力\n\t\tfor (int i = 0; i < targetArray.length; i++) {\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(exchangingCount);;\n\n\t}",
"main",
"{\n\n\t\tScanner scan = new Scanner(System.in); // 入力\n\t\tint n = Integer.parseInt(scan.nextLine()); // 要素数\n\n\t\t// ソート対象配列の読み込み\n\t\tString[] targetArrayStr = scan.nextLine().split(\" \");\n\t\tint[] targetArray = new int[targetArrayStr.length];\n\t\tfor (int i = 0; i < targetArrayStr.length; i++) {\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\n\t\t// ソート\n\t\tint exchangingCount = bubbleSort(n, targetArray);\n\n\t\t// 結果出力\n\t\tfor (int i = 0; i < targetArray.length; i++) {\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(exchangingCount);;\n\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n = Integer.parseInt(scan.nextLine());",
"n",
"Integer.parseInt(scan.nextLine())",
"Integer.parseInt",
"Integer",
"scan.nextLine()",
"scan.nextLine",
"scan",
"String[] targetArrayStr = scan.nextLine().split(\" \");",
"targetArrayStr",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"int[] targetArray = new int[targetArrayStr.length];",
"targetArray",
"new int[targetArrayStr.length]",
"targetArrayStr.length",
"targetArrayStr",
"targetArrayStr.length",
"for (int i = 0; i < targetArrayStr.length; i++) {\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < targetArrayStr.length",
"i",
"targetArrayStr.length",
"targetArrayStr",
"targetArrayStr.length",
"i++",
"i++",
"i",
"{\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}",
"{\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}",
"targetArray[i] = Integer.parseInt(targetArrayStr[i])",
"targetArray[i]",
"targetArray",
"i",
"Integer.parseInt(targetArrayStr[i])",
"Integer.parseInt",
"Integer",
"targetArrayStr[i]",
"targetArrayStr",
"i",
"scan.close()",
"scan.close",
"scan",
"int exchangingCount = bubbleSort(n, targetArray);",
"exchangingCount",
"bubbleSort(n, targetArray)",
"bubbleSort",
"n",
"targetArray",
"for (int i = 0; i < targetArray.length; i++) {\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < targetArray.length",
"i",
"targetArray.length",
"targetArray",
"targetArray.length",
"i++",
"i++",
"i",
"{\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}",
"{\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}",
"if (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}",
"i < targetArray.length - 1",
"i",
"targetArray.length - 1",
"targetArray.length",
"targetArray",
"targetArray.length",
"1",
"{\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t}",
"System.out.print(targetArray[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"targetArray[i] + \" \"",
"targetArray[i]",
"targetArray",
"i",
"\" \"",
"{\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}",
"System.out.println(targetArray[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"targetArray[i]",
"targetArray",
"i",
"System.out.println(exchangingCount)",
"System.out.println",
"System.out",
"System",
"System.out",
"exchangingCount",
"String[] args",
"args",
"/**\n\t * 指定された整数配列をバブルソートする。\n\t *\n\t * @param n 配列の要素数\n\t * @param targetArray バブルソートしたい整数配列\n\t */\n\tprivate static int bubbleSort(int n, int[] targetArray) {\n\t\tboolean isNotSorted = true; // ソート未完了フラグ\n\t\tint exchangingCount = 0; // 入れ替え回数\n\n\t\t// ソートが完了するまで\n\t\twhile (isNotSorted) {\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exchangingCount;\n\t}",
"bubbleSort",
"{\n\t\tboolean isNotSorted = true; // ソート未完了フラグ\n\t\tint exchangingCount = 0; // 入れ替え回数\n\n\t\t// ソートが完了するまで\n\t\twhile (isNotSorted) {\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exchangingCount;\n\t}",
"boolean isNotSorted = true;",
"isNotSorted",
"true",
"int exchangingCount = 0;",
"exchangingCount",
"0",
"while (isNotSorted) {\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"isNotSorted",
"{\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"isNotSorted = false",
"isNotSorted",
"false",
"for (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}",
"int i = n - 1;",
"int i = n - 1;",
"i",
"n - 1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}",
"if (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}",
"targetArray[i] < targetArray[i - 1]",
"targetArray[i]",
"targetArray",
"i",
"targetArray[i - 1]",
"targetArray",
"i - 1",
"i",
"1",
"{\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}",
"exchangeArrayValue(targetArray, i, i - 1)",
"exchangeArrayValue",
"targetArray",
"i",
"i - 1",
"i",
"1",
"isNotSorted = true",
"isNotSorted",
"true",
"exchangingCount++",
"exchangingCount",
"return exchangingCount;",
"exchangingCount",
"int n",
"n",
"int[] targetArray",
"targetArray",
"/**\n\t * 配列内の2つの要素を入れ替える。\n\t *\n\t * @param array 入れ替えたい要素を含む配列\n\t * @param a 入れ替えたい要素のindex\n\t * @param b 入れ替えたい要素のindex\n\t */\n\tprivate static void exchangeArrayValue(int[] array, int a, int b) {\n\t\tint temp = array[a];\n\t\tarray[a] = array[b];\n\t\tarray[b] = temp;\n\t}",
"exchangeArrayValue",
"{\n\t\tint temp = array[a];\n\t\tarray[a] = array[b];\n\t\tarray[b] = temp;\n\t}",
"int temp = array[a];",
"temp",
"array[a]",
"array",
"a",
"array[a] = array[b]",
"array[a]",
"array",
"a",
"array[b]",
"array",
"b",
"array[b] = temp",
"array[b]",
"array",
"b",
"temp",
"int[] array",
"array",
"int a",
"a",
"int b",
"b",
"public class Main {\n\n\t/**\n\t *\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\tScanner scan = new Scanner(System.in); // 入力\n\t\tint n = Integer.parseInt(scan.nextLine()); // 要素数\n\n\t\t// ソート対象配列の読み込み\n\t\tString[] targetArrayStr = scan.nextLine().split(\" \");\n\t\tint[] targetArray = new int[targetArrayStr.length];\n\t\tfor (int i = 0; i < targetArrayStr.length; i++) {\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\n\t\t// ソート\n\t\tint exchangingCount = bubbleSort(n, targetArray);\n\n\t\t// 結果出力\n\t\tfor (int i = 0; i < targetArray.length; i++) {\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(exchangingCount);;\n\n\t}\n\n\t/**\n\t * 指定された整数配列をバブルソートする。\n\t *\n\t * @param n 配列の要素数\n\t * @param targetArray バブルソートしたい整数配列\n\t */\n\tprivate static int bubbleSort(int n, int[] targetArray) {\n\t\tboolean isNotSorted = true; // ソート未完了フラグ\n\t\tint exchangingCount = 0; // 入れ替え回数\n\n\t\t// ソートが完了するまで\n\t\twhile (isNotSorted) {\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exchangingCount;\n\t}\n\n\t/**\n\t * 配列内の2つの要素を入れ替える。\n\t *\n\t * @param array 入れ替えたい要素を含む配列\n\t * @param a 入れ替えたい要素のindex\n\t * @param b 入れ替えたい要素のindex\n\t */\n\tprivate static void exchangeArrayValue(int[] array, int a, int b) {\n\t\tint temp = array[a];\n\t\tarray[a] = array[b];\n\t\tarray[b] = temp;\n\t}\n\n}",
"public class Main {\n\n\t/**\n\t *\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\tScanner scan = new Scanner(System.in); // 入力\n\t\tint n = Integer.parseInt(scan.nextLine()); // 要素数\n\n\t\t// ソート対象配列の読み込み\n\t\tString[] targetArrayStr = scan.nextLine().split(\" \");\n\t\tint[] targetArray = new int[targetArrayStr.length];\n\t\tfor (int i = 0; i < targetArrayStr.length; i++) {\n\t\t\ttargetArray[i] = Integer.parseInt(targetArrayStr[i]);\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\n\t\t// ソート\n\t\tint exchangingCount = bubbleSort(n, targetArray);\n\n\t\t// 結果出力\n\t\tfor (int i = 0; i < targetArray.length; i++) {\n\t\t\tif (i < targetArray.length - 1) {\n\t\t\t\tSystem.out.print(targetArray[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(targetArray[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(exchangingCount);;\n\n\t}\n\n\t/**\n\t * 指定された整数配列をバブルソートする。\n\t *\n\t * @param n 配列の要素数\n\t * @param targetArray バブルソートしたい整数配列\n\t */\n\tprivate static int bubbleSort(int n, int[] targetArray) {\n\t\tboolean isNotSorted = true; // ソート未完了フラグ\n\t\tint exchangingCount = 0; // 入れ替え回数\n\n\t\t// ソートが完了するまで\n\t\twhile (isNotSorted) {\n\t\t\tisNotSorted = false;\n\n\t\t\t// 天秤を右端から移動していく\n\t\t\tfor (int i = n - 1; i > 0; i--) {\n\t\t\t\t// 自分より小さい値が左側に居たら\n\t\t\t\tif (targetArray[i] < targetArray[i - 1]) {\n\t\t\t\t\t// 2つの要素を入れ替える\n\t\t\t\t\texchangeArrayValue(targetArray, i, i - 1);\n\t\t\t\t\tisNotSorted = true;\n\t\t\t\t\texchangingCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exchangingCount;\n\t}\n\n\t/**\n\t * 配列内の2つの要素を入れ替える。\n\t *\n\t * @param array 入れ替えたい要素を含む配列\n\t * @param a 入れ替えたい要素のindex\n\t * @param b 入れ替えたい要素のindex\n\t */\n\tprivate static void exchangeArrayValue(int[] array, int a, int b) {\n\t\tint temp = array[a];\n\t\tarray[a] = array[b];\n\t\tarray[b] = temp;\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
/**
* ZAKIREN第5章
*
* @author K.Yamauchi
*
*/
public class Main {
/**
*
* @param args
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in); // 入力
int n = Integer.parseInt(scan.nextLine()); // 要素数
// ソート対象配列の読み込み
String[] targetArrayStr = scan.nextLine().split(" ");
int[] targetArray = new int[targetArrayStr.length];
for (int i = 0; i < targetArrayStr.length; i++) {
targetArray[i] = Integer.parseInt(targetArrayStr[i]);
}
// 読み込み終了
scan.close();
// ソート
int exchangingCount = bubbleSort(n, targetArray);
// 結果出力
for (int i = 0; i < targetArray.length; i++) {
if (i < targetArray.length - 1) {
System.out.print(targetArray[i] + " ");
} else {
System.out.println(targetArray[i]);
}
}
System.out.println(exchangingCount);;
}
/**
* 指定された整数配列をバブルソートする。
*
* @param n 配列の要素数
* @param targetArray バブルソートしたい整数配列
*/
private static int bubbleSort(int n, int[] targetArray) {
boolean isNotSorted = true; // ソート未完了フラグ
int exchangingCount = 0; // 入れ替え回数
// ソートが完了するまで
while (isNotSorted) {
isNotSorted = false;
// 天秤を右端から移動していく
for (int i = n - 1; i > 0; i--) {
// 自分より小さい値が左側に居たら
if (targetArray[i] < targetArray[i - 1]) {
// 2つの要素を入れ替える
exchangeArrayValue(targetArray, i, i - 1);
isNotSorted = true;
exchangingCount++;
}
}
}
return exchangingCount;
}
/**
* 配列内の2つの要素を入れ替える。
*
* @param array 入れ替えたい要素を含む配列
* @param a 入れ替えたい要素のindex
* @param b 入れ替えたい要素のindex
*/
private static void exchangeArrayValue(int[] array, int a, int b) {
int temp = array[a];
array[a] = array[b];
array[b] = temp;
}
}
|
[
7,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
4,
13,
13,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
29,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
3,
4
],
[
3,
5
],
[
1,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
37,
38
],
[
38,
39
],
[
8,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
42,
44
],
[
42,
45
],
[
8,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
46,
56
],
[
56,
57
],
[
57,
58
],
[
46,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
60,
65
],
[
60,
66
],
[
66,
67
],
[
66,
68
],
[
8,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
69,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
8,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
6,
85
],
[
85,
86
],
[
1,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
89,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
101,
108
],
[
108,
109
],
[
108,
110
],
[
101,
111
],
[
111,
112
],
[
112,
113
],
[
101,
114
],
[
115,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
123,
125
],
[
116,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
129,
131
],
[
126,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
138,
140
],
[
126,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
141,
147
],
[
126,
148
],
[
148,
149
],
[
148,
150
],
[
126,
151
],
[
151,
152
],
[
89,
153
],
[
153,
154
],
[
87,
155
],
[
155,
156
],
[
87,
157
],
[
157,
158
]
] | [
"class Main\n{\n\tstatic int count = 0;\n\tpublic static void main( String[] args )\n\t{\n\t\tjava.util.Scanner sc = new java.util.Scanner( System.in );\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n\t\tfor( int i = 0 ; i < n ; i++ )\n\t\t\tdata[i] = sc.nextInt();\n\t\tdata = bubbleSort( data, n );\n\t\tfor( int i = 0 ; i < n-1 ; i++ )\n\t\t\tSystem.out.printf( \"%d \" ,data[i] );\n\t\tSystem.out.println( data[n-1] );\n\t\tSystem.out.println( count );\n\t}\n\tstatic int[] bubbleSort( int[] data, int n )\n\t{\n\t\tboolean flag = true;\n\t\tint work;\n\t\twhile( flag )\n\t\t{\n\t\t\tflag = false;\n\t\t\tfor( int j = n-1 ; j > 0 ; j-- )\n\t\t\t{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}\n}",
"class Main\n{\n\tstatic int count = 0;\n\tpublic static void main( String[] args )\n\t{\n\t\tjava.util.Scanner sc = new java.util.Scanner( System.in );\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n\t\tfor( int i = 0 ; i < n ; i++ )\n\t\t\tdata[i] = sc.nextInt();\n\t\tdata = bubbleSort( data, n );\n\t\tfor( int i = 0 ; i < n-1 ; i++ )\n\t\t\tSystem.out.printf( \"%d \" ,data[i] );\n\t\tSystem.out.println( data[n-1] );\n\t\tSystem.out.println( count );\n\t}\n\tstatic int[] bubbleSort( int[] data, int n )\n\t{\n\t\tboolean flag = true;\n\t\tint work;\n\t\twhile( flag )\n\t\t{\n\t\t\tflag = false;\n\t\t\tfor( int j = n-1 ; j > 0 ; j-- )\n\t\t\t{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}\n}",
"Main",
"static int count = 0;",
"count",
"0",
"public static void main( String[] args )\n\t{\n\t\tjava.util.Scanner sc = new java.util.Scanner( System.in );\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n\t\tfor( int i = 0 ; i < n ; i++ )\n\t\t\tdata[i] = sc.nextInt();\n\t\tdata = bubbleSort( data, n );\n\t\tfor( int i = 0 ; i < n-1 ; i++ )\n\t\t\tSystem.out.printf( \"%d \" ,data[i] );\n\t\tSystem.out.println( data[n-1] );\n\t\tSystem.out.println( count );\n\t}",
"main",
"{\n\t\tjava.util.Scanner sc = new java.util.Scanner( System.in );\n\t\tint n = sc.nextInt();\n\t\tint[] data = new int[n];\n\t\tfor( int i = 0 ; i < n ; i++ )\n\t\t\tdata[i] = sc.nextInt();\n\t\tdata = bubbleSort( data, n );\n\t\tfor( int i = 0 ; i < n-1 ; i++ )\n\t\t\tSystem.out.printf( \"%d \" ,data[i] );\n\t\tSystem.out.println( data[n-1] );\n\t\tSystem.out.println( count );\n\t}",
"java.util.Scanner sc = new java.util.Scanner( System.in );",
"sc",
"new java.util.Scanner( System.in )",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] data = new int[n];",
"data",
"new int[n]",
"n",
"for( int i = 0 ; i < n ; i++ )\n\t\t\tdata[i] = sc.nextInt();",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"data[i] = sc.nextInt();",
"data[i] = sc.nextInt()",
"data[i]",
"data",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"data = bubbleSort( data, n )",
"data",
"bubbleSort( data, n )",
"bubbleSort",
"data",
"n",
"for( int i = 0 ; i < n-1 ; i++ )\n\t\t\tSystem.out.printf( \"%d \" ,data[i] );",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"System.out.printf( \"%d \" ,data[i] );",
"System.out.printf( \"%d \" ,data[i] )",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d \"",
"data[i]",
"data",
"i",
"System.out.println( data[n-1] )",
"System.out.println",
"System.out",
"System",
"System.out",
"data[n-1]",
"data",
"n-1",
"n",
"1",
"System.out.println( count )",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"static int[] bubbleSort( int[] data, int n )\n\t{\n\t\tboolean flag = true;\n\t\tint work;\n\t\twhile( flag )\n\t\t{\n\t\t\tflag = false;\n\t\t\tfor( int j = n-1 ; j > 0 ; j-- )\n\t\t\t{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}",
"bubbleSort",
"{\n\t\tboolean flag = true;\n\t\tint work;\n\t\twhile( flag )\n\t\t{\n\t\t\tflag = false;\n\t\t\tfor( int j = n-1 ; j > 0 ; j-- )\n\t\t\t{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}",
"boolean flag = true;",
"flag",
"true",
"int work;",
"work",
"while( flag )\n\t\t{\n\t\t\tflag = false;\n\t\t\tfor( int j = n-1 ; j > 0 ; j-- )\n\t\t\t{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag",
"{\n\t\t\tflag = false;\n\t\t\tfor( int j = n-1 ; j > 0 ; j-- )\n\t\t\t{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flag = false",
"flag",
"false",
"for( int j = n-1 ; j > 0 ; j-- )\n\t\t\t{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"int j = n-1 ;",
"int j = n-1 ;",
"j",
"n-1",
"n",
"1",
"j > 0",
"j",
"0",
"j--",
"j--",
"j",
"{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}",
"if( data[j] < data[j-1] ){\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"data[j] < data[j-1]",
"data[j]",
"data",
"j",
"data[j-1]",
"data",
"j-1",
"j",
"1",
"{\n\t\t\t\t\twork = data[j];\n\t\t\t\t\tdata[j] = data[j-1];\n\t\t\t\t\tdata[j-1] = work;\n\t\t\t\t\tflag = true;//????????£??\\????´?????????¨????????´???\n\t\t\t\t\tcount++;\n\t\t\t\t}",
"work = data[j]",
"work",
"data[j]",
"data",
"j",
"data[j] = data[j-1]",
"data[j]",
"data",
"j",
"data[j-1]",
"data",
"j-1",
"j",
"1",
"data[j-1] = work",
"data[j-1]",
"data",
"j-1",
"j",
"1",
"work",
"flag = true",
"flag",
"true",
"count++",
"count",
"return data;",
"data",
"int[] data",
"data",
"int n",
"n"
] | class Main
{
static int count = 0;
public static void main( String[] args )
{
java.util.Scanner sc = new java.util.Scanner( System.in );
int n = sc.nextInt();
int[] data = new int[n];
for( int i = 0 ; i < n ; i++ )
data[i] = sc.nextInt();
data = bubbleSort( data, n );
for( int i = 0 ; i < n-1 ; i++ )
System.out.printf( "%d " ,data[i] );
System.out.println( data[n-1] );
System.out.println( count );
}
static int[] bubbleSort( int[] data, int n )
{
boolean flag = true;
int work;
while( flag )
{
flag = false;
for( int j = n-1 ; j > 0 ; j-- )
{
if( data[j] < data[j-1] ){
work = data[j];
data[j] = data[j-1];
data[j-1] = work;
flag = true;//????????£??\????´?????????¨????????´???
count++;
}
}
}
return data;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
20,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
4,
18,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
2,
17,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
166,
8
],
[
166,
9
],
[
9,
10
],
[
9,
11
],
[
166,
12
],
[
12,
13
],
[
12,
14
],
[
166,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
17,
26
],
[
26,
27
],
[
26,
28
],
[
17,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
30,
35
],
[
35,
36
],
[
35,
37
],
[
30,
38
],
[
38,
39
],
[
39,
40
],
[
30,
41
],
[
42,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
17,
50
],
[
50,
51
],
[
50,
52
],
[
17,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
56,
57
],
[
56,
58
],
[
17,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
64,
65
],
[
64,
66
],
[
59,
67
],
[
67,
68
],
[
68,
69
],
[
59,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
17,
80
],
[
80,
81
],
[
81,
82
],
[
17,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
17,
87
],
[
87,
88
],
[
88,
89
],
[
15,
90
],
[
90,
91
],
[
166,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
95,
105
],
[
105,
106
],
[
106,
107
],
[
95,
108
],
[
109,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
110,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
121,
123
],
[
110,
124
],
[
124,
125
],
[
125,
126
],
[
110,
127
],
[
128,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
129,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
139,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
151,
153
],
[
139,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
157,
159
],
[
154,
160
],
[
139,
161
],
[
161,
162
],
[
92,
163
],
[
163,
164
],
[
0,
165
],
[
165,
166
],
[
165,
167
]
] | [
"\nimport java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main {\n\tstatic int cnt = 0;\n\tstatic PrintWriter out =new PrintWriter(System.out);\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \t\n \tint n = sc.nextInt();\n \tint array[] = new int[n];\n \tfor(int i=0;i<n;i++) {\n \t\tarray[i] = sc.nextInt();\n \t}\n \tbubble(array);\n \tout.print(array[0]);\n \tfor(int i=1;i<n;i++) {\n \t\tout.print(\" \"+array[i]);\n \t}\n \tout.println();\n \tout.println(cnt);\n \tout.flush();\n }\n \n static void bubble(int[] a) {\n \tfor(int i=0;i<a.length;i++) {\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}\n }\n \t\n}",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tstatic int cnt = 0;\n\tstatic PrintWriter out =new PrintWriter(System.out);\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \t\n \tint n = sc.nextInt();\n \tint array[] = new int[n];\n \tfor(int i=0;i<n;i++) {\n \t\tarray[i] = sc.nextInt();\n \t}\n \tbubble(array);\n \tout.print(array[0]);\n \tfor(int i=1;i<n;i++) {\n \t\tout.print(\" \"+array[i]);\n \t}\n \tout.println();\n \tout.println(cnt);\n \tout.flush();\n }\n \n static void bubble(int[] a) {\n \tfor(int i=0;i<a.length;i++) {\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}\n }\n \t\n}",
"Main",
"static int cnt = 0;",
"cnt",
"0",
"static PrintWriter out =new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \t\n \tint n = sc.nextInt();\n \tint array[] = new int[n];\n \tfor(int i=0;i<n;i++) {\n \t\tarray[i] = sc.nextInt();\n \t}\n \tbubble(array);\n \tout.print(array[0]);\n \tfor(int i=1;i<n;i++) {\n \t\tout.print(\" \"+array[i]);\n \t}\n \tout.println();\n \tout.println(cnt);\n \tout.flush();\n }",
"main",
"{\n \tScanner sc = new Scanner(System.in);\n \t\n \tint n = sc.nextInt();\n \tint array[] = new int[n];\n \tfor(int i=0;i<n;i++) {\n \t\tarray[i] = sc.nextInt();\n \t}\n \tbubble(array);\n \tout.print(array[0]);\n \tfor(int i=1;i<n;i++) {\n \t\tout.print(\" \"+array[i]);\n \t}\n \tout.println();\n \tout.println(cnt);\n \tout.flush();\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int array[] = new int[n];",
"array",
"new int[n]",
"n",
"for(int i=0;i<n;i++) {\n \t\tarray[i] = sc.nextInt();\n \t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tarray[i] = sc.nextInt();\n \t}",
"{\n \t\tarray[i] = sc.nextInt();\n \t}",
"array[i] = sc.nextInt()",
"array[i]",
"array",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"bubble(array)",
"bubble",
"array",
"out.print(array[0])",
"out.print",
"out",
"array[0]",
"array",
"0",
"for(int i=1;i<n;i++) {\n \t\tout.print(\" \"+array[i]);\n \t}",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tout.print(\" \"+array[i]);\n \t}",
"{\n \t\tout.print(\" \"+array[i]);\n \t}",
"out.print(\" \"+array[i])",
"out.print",
"out",
"\" \"+array[i]",
"\" \"",
"array[i]",
"array",
"i",
"out.println()",
"out.println",
"out",
"out.println(cnt)",
"out.println",
"out",
"cnt",
"out.flush()",
"out.flush",
"out",
"String[] args",
"args",
"static void bubble(int[] a) {\n \tfor(int i=0;i<a.length;i++) {\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}\n }",
"bubble",
"{\n \tfor(int i=0;i<a.length;i++) {\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}\n }",
"for(int i=0;i<a.length;i++) {\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}",
"{\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}",
"for(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}",
"int j=a.length-1;",
"int j=a.length-1;",
"j",
"a.length-1",
"a.length",
"a",
"a.length",
"1",
"j>=i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}",
"{\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}",
"if(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}",
"a[j]<a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}",
"int temp = a[j];",
"temp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] =temp",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"temp",
"cnt++",
"cnt",
"int[] a",
"a",
"public class Main {\n\tstatic int cnt = 0;\n\tstatic PrintWriter out =new PrintWriter(System.out);\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \t\n \tint n = sc.nextInt();\n \tint array[] = new int[n];\n \tfor(int i=0;i<n;i++) {\n \t\tarray[i] = sc.nextInt();\n \t}\n \tbubble(array);\n \tout.print(array[0]);\n \tfor(int i=1;i<n;i++) {\n \t\tout.print(\" \"+array[i]);\n \t}\n \tout.println();\n \tout.println(cnt);\n \tout.flush();\n }\n \n static void bubble(int[] a) {\n \tfor(int i=0;i<a.length;i++) {\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}\n }\n \t\n}",
"public class Main {\n\tstatic int cnt = 0;\n\tstatic PrintWriter out =new PrintWriter(System.out);\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \t\n \tint n = sc.nextInt();\n \tint array[] = new int[n];\n \tfor(int i=0;i<n;i++) {\n \t\tarray[i] = sc.nextInt();\n \t}\n \tbubble(array);\n \tout.print(array[0]);\n \tfor(int i=1;i<n;i++) {\n \t\tout.print(\" \"+array[i]);\n \t}\n \tout.println();\n \tout.println(cnt);\n \tout.flush();\n }\n \n static void bubble(int[] a) {\n \tfor(int i=0;i<a.length;i++) {\n \t\tfor(int j=a.length-1;j>=i+1;j--) {\n \t\t\tif(a[j]<a[j-1]) {\n \t\t\t\tint temp = a[j];\n \t\t\t\ta[j] = a[j-1];\n \t\t\t\ta[j-1] =temp;\n \t\t\t\tcnt++;\n \t\t\t}\n \t\t\t\t\n \t\t}\n \t}\n }\n \t\n}",
"Main"
] |
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
static int cnt = 0;
static PrintWriter out =new PrintWriter(System.out);
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int array[] = new int[n];
for(int i=0;i<n;i++) {
array[i] = sc.nextInt();
}
bubble(array);
out.print(array[0]);
for(int i=1;i<n;i++) {
out.print(" "+array[i]);
}
out.println();
out.println(cnt);
out.flush();
}
static void bubble(int[] a) {
for(int i=0;i<a.length;i++) {
for(int j=a.length-1;j>=i+1;j--) {
if(a[j]<a[j-1]) {
int temp = a[j];
a[j] = a[j-1];
a[j-1] =temp;
cnt++;
}
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
14,
2,
2,
13,
17,
2,
17,
13,
30,
29,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
30,
29,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
198,
5
],
[
198,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
8,
13
],
[
13,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
8,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
8,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
30,
34
],
[
34,
35
],
[
34,
36
],
[
29,
37
],
[
37,
38
],
[
8,
39
],
[
39,
40
],
[
39,
41
],
[
8,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
43,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
55,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
64,
65
],
[
55,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
67,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
66,
78
],
[
78,
79
],
[
8,
80
],
[
80,
81
],
[
80,
82
],
[
8,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
83,
93
],
[
93,
94
],
[
94,
95
],
[
83,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
98,
105
],
[
105,
106
],
[
105,
107
],
[
98,
108
],
[
108,
109
],
[
109,
110
],
[
98,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
113,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
123,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
123,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
138,
144
],
[
123,
145
],
[
145,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
152,
153
],
[
152,
154
],
[
147,
155
],
[
155,
156
],
[
156,
157
],
[
147,
158
],
[
159,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
160,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
166,
171
],
[
171,
172
],
[
171,
173
],
[
160,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
174,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
8,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
8,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
189,
194
],
[
6,
195
],
[
195,
196
],
[
0,
197
],
[
197,
198
],
[
197,
199
]
] | [
"import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n int N;\n int num[];\n String line;\n\n Scanner scan=new Scanner(System.in);\n\n line=scan.next();\n N=Integer.parseInt(line);\n\n if(N<1||100<N){\n return;\n }\n \n num=new int[N];\n\n for(int i=0;i<N;i++){\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }\n\n for(int i=0;i<N;i++){\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }\n System.out.println();\n System.out.println(swap_num);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n public static void main(String[] args){\n int N;\n int num[];\n String line;\n\n Scanner scan=new Scanner(System.in);\n\n line=scan.next();\n N=Integer.parseInt(line);\n\n if(N<1||100<N){\n return;\n }\n \n num=new int[N];\n\n for(int i=0;i<N;i++){\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }\n\n for(int i=0;i<N;i++){\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }\n System.out.println();\n System.out.println(swap_num);\n }\n}",
"Main",
"public static void main(String[] args){\n int N;\n int num[];\n String line;\n\n Scanner scan=new Scanner(System.in);\n\n line=scan.next();\n N=Integer.parseInt(line);\n\n if(N<1||100<N){\n return;\n }\n \n num=new int[N];\n\n for(int i=0;i<N;i++){\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }\n\n for(int i=0;i<N;i++){\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }\n System.out.println();\n System.out.println(swap_num);\n }",
"main",
"{\n int N;\n int num[];\n String line;\n\n Scanner scan=new Scanner(System.in);\n\n line=scan.next();\n N=Integer.parseInt(line);\n\n if(N<1||100<N){\n return;\n }\n \n num=new int[N];\n\n for(int i=0;i<N;i++){\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }\n\n for(int i=0;i<N;i++){\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }\n System.out.println();\n System.out.println(swap_num);\n }",
"int N;",
"N",
"int num[];",
"num",
"String line;",
"line",
"Scanner scan=new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"line=scan.next()",
"line",
"scan.next()",
"scan.next",
"scan",
"N=Integer.parseInt(line)",
"N",
"Integer.parseInt(line)",
"Integer.parseInt",
"Integer",
"line",
"if(N<1||100<N){\n return;\n }",
"N<1||100<N",
"N<1",
"N",
"1",
"100<N",
"100",
"N",
"{\n return;\n }",
"return;",
"num=new int[N]",
"num",
"new int[N]",
"N",
"for(int i=0;i<N;i++){\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }",
"{\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }",
"num[i]=Integer.parseInt(scan.next())",
"num[i]",
"num",
"i",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"if(num[i]<0||num[i]>100){\n return;\n }",
"num[i]<0||num[i]>100",
"num[i]<0",
"num[i]",
"num",
"i",
"0",
"num[i]>100",
"num[i]",
"num",
"i",
"100",
"{\n return;\n }",
"return;",
"int swap_num=0;",
"swap_num",
"0",
"for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N-1",
"i",
"N-1",
"N",
"1",
"i++",
"i++",
"i",
"{\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }",
"{\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }",
"for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }",
"int j=N-1;",
"int j=N-1;",
"j",
"N-1",
"N",
"1",
"j>i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }",
"{\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }",
"if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }",
"num[j]<num[j-1]",
"num[j]",
"num",
"j",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"{\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }",
"int temp=num[j];",
"temp",
"num[j]",
"num",
"j",
"num[j]=num[j-1]",
"num[j]",
"num",
"j",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"num[j-1]=temp",
"num[j-1]",
"num",
"j-1",
"j",
"1",
"temp",
"swap_num++",
"swap_num",
"for(int i=0;i<N;i++){\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }",
"{\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }",
"if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");",
"i==N-1",
"i",
"N-1",
"N",
"1",
"System.out.print(num[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"num[i]",
"num",
"i",
"System.out.print(num[i]+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"num[i]+\" \"",
"num[i]",
"num",
"i",
"\" \"",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(swap_num)",
"System.out.println",
"System.out",
"System",
"System.out",
"swap_num",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n int N;\n int num[];\n String line;\n\n Scanner scan=new Scanner(System.in);\n\n line=scan.next();\n N=Integer.parseInt(line);\n\n if(N<1||100<N){\n return;\n }\n \n num=new int[N];\n\n for(int i=0;i<N;i++){\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }\n\n for(int i=0;i<N;i++){\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }\n System.out.println();\n System.out.println(swap_num);\n }\n}",
"public class Main{\n public static void main(String[] args){\n int N;\n int num[];\n String line;\n\n Scanner scan=new Scanner(System.in);\n\n line=scan.next();\n N=Integer.parseInt(line);\n\n if(N<1||100<N){\n return;\n }\n \n num=new int[N];\n\n for(int i=0;i<N;i++){\n num[i]=Integer.parseInt(scan.next());\n if(num[i]<0||num[i]>100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;i<N-1;i++){\n for(int j=N-1;j>i;j--){\n if(num[j]<num[j-1]){\n int temp=num[j];\n num[j]=num[j-1];\n num[j-1]=temp;\n\n swap_num++;\n }\n }\n }\n\n for(int i=0;i<N;i++){\n if(i==N-1)System.out.print(num[i]);\n else System.out.print(num[i]+\" \");\n\n }\n System.out.println();\n System.out.println(swap_num);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args){
int N;
int num[];
String line;
Scanner scan=new Scanner(System.in);
line=scan.next();
N=Integer.parseInt(line);
if(N<1||100<N){
return;
}
num=new int[N];
for(int i=0;i<N;i++){
num[i]=Integer.parseInt(scan.next());
if(num[i]<0||num[i]>100){
return;
}
}
//バブルソート
int swap_num=0;
for(int i=0;i<N-1;i++){
for(int j=N-1;j>i;j--){
if(num[j]<num[j-1]){
int temp=num[j];
num[j]=num[j-1];
num[j-1]=temp;
swap_num++;
}
}
}
for(int i=0;i<N;i++){
if(i==N-1)System.out.print(num[i]);
else System.out.print(num[i]+" ");
}
System.out.println();
System.out.println(swap_num);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
4,
18,
13,
17,
17,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
4,
13,
13,
13,
2,
13,
17,
40,
13,
0,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
13,
17,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
4,
13,
13,
13,
2,
13,
17,
40,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
4,
18,
13,
17,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
300,
11
],
[
300,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
28,
33
],
[
28,
34
],
[
14,
35
],
[
35,
36
],
[
35,
37
],
[
14,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
44,
45
],
[
44,
46
],
[
39,
47
],
[
47,
48
],
[
48,
49
],
[
39,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
59,
61
],
[
14,
62
],
[
62,
63
],
[
62,
64
],
[
62,
65
],
[
12,
66
],
[
66,
67
],
[
300,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
74,
75
],
[
74,
76
],
[
70,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
83,
90
],
[
90,
91
],
[
90,
92
],
[
83,
93
],
[
93,
94
],
[
94,
95
],
[
83,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
98,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
109,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
108,
118
],
[
118,
119
],
[
118,
120
],
[
70,
121
],
[
121,
122
],
[
121,
123
],
[
70,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
124,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
124,
134
],
[
134,
135
],
[
135,
136
],
[
124,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
70,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
151,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
155,
159
],
[
70,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
160,
165
],
[
68,
166
],
[
166,
167
],
[
68,
168
],
[
168,
169
],
[
300,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
176,
181
],
[
181,
182
],
[
181,
183
],
[
176,
184
],
[
184,
185
],
[
185,
186
],
[
176,
187
],
[
188,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
193,
194
],
[
193,
195
],
[
189,
196
],
[
196,
197
],
[
196,
198
],
[
189,
199
],
[
199,
200
],
[
200,
201
],
[
189,
202
],
[
203,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
206,
208
],
[
205,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
211,
213
],
[
204,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
215,
218
],
[
215,
219
],
[
219,
220
],
[
219,
221
],
[
214,
222
],
[
222,
223
],
[
172,
224
],
[
224,
225
],
[
224,
226
],
[
172,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
227,
232
],
[
232,
233
],
[
232,
234
],
[
234,
235
],
[
234,
236
],
[
227,
237
],
[
237,
238
],
[
238,
239
],
[
227,
240
],
[
241,
241
],
[
241,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
245,
247
],
[
244,
248
],
[
172,
249
],
[
249,
250
],
[
250,
251
],
[
251,
252
],
[
251,
253
],
[
249,
254
],
[
254,
255
],
[
255,
256
],
[
254,
257
],
[
254,
258
],
[
258,
259
],
[
259,
260
],
[
260,
261
],
[
258,
262
],
[
172,
263
],
[
263,
264
],
[
264,
265
],
[
265,
266
],
[
265,
267
],
[
263,
268
],
[
170,
269
],
[
269,
270
],
[
170,
271
],
[
271,
272
],
[
300,
273
],
[
273,
274
],
[
273,
275
],
[
275,
276
],
[
276,
277
],
[
276,
278
],
[
278,
279
],
[
278,
280
],
[
275,
281
],
[
281,
282
],
[
282,
283
],
[
282,
284
],
[
281,
285
],
[
285,
286
],
[
285,
287
],
[
275,
288
],
[
288,
289
],
[
289,
290
],
[
289,
291
],
[
288,
292
],
[
273,
293
],
[
293,
294
],
[
273,
295
],
[
295,
296
],
[
273,
297
],
[
297,
298
],
[
0,
299
],
[
299,
300
],
[
299,
301
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\n/**\n * Created by hwzheng on 2017/3/27.\n */\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));\n int N = Integer.parseInt(Reader.readLine());\n String A[] = Reader.readLine().split(\" \",0);\n int[] arr = new int[N];\n for (int i=0; i < N; i++){\n arr[i] = Integer.parseInt(A[i]);\n }\n bubbleSort2(arr,N);\n }\n\n private static void bubbleSort(int[] arr, int n) {\n boolean flag = true;\n int exCount = 0;\n while (flag){\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n \n private static void bubbleSort2(int[] arr, int n){\n int exCount = 0;\n for (int i = 0; i < n; i++){\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n\n private static void exch(int[] arr, int i, int j){\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));\n int N = Integer.parseInt(Reader.readLine());\n String A[] = Reader.readLine().split(\" \",0);\n int[] arr = new int[N];\n for (int i=0; i < N; i++){\n arr[i] = Integer.parseInt(A[i]);\n }\n bubbleSort2(arr,N);\n }\n\n private static void bubbleSort(int[] arr, int n) {\n boolean flag = true;\n int exCount = 0;\n while (flag){\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n \n private static void bubbleSort2(int[] arr, int n){\n int exCount = 0;\n for (int i = 0; i < n; i++){\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n\n private static void exch(int[] arr, int i, int j){\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));\n int N = Integer.parseInt(Reader.readLine());\n String A[] = Reader.readLine().split(\" \",0);\n int[] arr = new int[N];\n for (int i=0; i < N; i++){\n arr[i] = Integer.parseInt(A[i]);\n }\n bubbleSort2(arr,N);\n }",
"main",
"{\n BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));\n int N = Integer.parseInt(Reader.readLine());\n String A[] = Reader.readLine().split(\" \",0);\n int[] arr = new int[N];\n for (int i=0; i < N; i++){\n arr[i] = Integer.parseInt(A[i]);\n }\n bubbleSort2(arr,N);\n }",
"BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));",
"Reader",
"new BufferedReader (new InputStreamReader(System.in))",
"int N = Integer.parseInt(Reader.readLine());",
"N",
"Integer.parseInt(Reader.readLine())",
"Integer.parseInt",
"Integer",
"Reader.readLine()",
"Reader.readLine",
"Reader",
"String A[] = Reader.readLine().split(\" \",0);",
"A",
"Reader.readLine().split(\" \",0)",
"Reader.readLine().split",
"Reader.readLine()",
"Reader.readLine",
"Reader",
"\" \"",
"0",
"int[] arr = new int[N];",
"arr",
"new int[N]",
"N",
"for (int i=0; i < N; i++){\n arr[i] = Integer.parseInt(A[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n arr[i] = Integer.parseInt(A[i]);\n }",
"{\n arr[i] = Integer.parseInt(A[i]);\n }",
"arr[i] = Integer.parseInt(A[i])",
"arr[i]",
"arr",
"i",
"Integer.parseInt(A[i])",
"Integer.parseInt",
"Integer",
"A[i]",
"A",
"i",
"bubbleSort2(arr,N)",
"bubbleSort2",
"arr",
"N",
"String[] args",
"args",
"private static void bubbleSort(int[] arr, int n) {\n boolean flag = true;\n int exCount = 0;\n while (flag){\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }",
"bubbleSort",
"{\n boolean flag = true;\n int exCount = 0;\n while (flag){\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }",
"boolean flag = true;",
"flag",
"true",
"int exCount = 0;",
"exCount",
"0",
"while (flag){\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }",
"flag",
"{\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }",
"int i = n - 1;",
"int i = n - 1;",
"i",
"n - 1",
"n",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }",
"{\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }",
"if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }",
"arr[i] < arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"{\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }",
"exch(arr,i,i-1)",
"exch",
"arr",
"i",
"i-1",
"i",
"1",
"exCount++",
"exCount",
"flag = true",
"flag",
"true",
"String str = \"\";",
"str",
"\"\"",
"for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < arr.length",
"i",
"arr.length",
"arr",
"arr.length",
"i++",
"i++",
"i",
"{\n str += arr[i] + \" \";\n }",
"{\n str += arr[i] + \" \";\n }",
"str += arr[i] + \" \"",
"str",
"arr[i] + \" \"",
"arr[i]",
"arr",
"i",
"\" \"",
"System.out.println(str.substring(0,str.length()-1))",
"System.out.println",
"System.out",
"System",
"System.out",
"str.substring(0,str.length()-1)",
"str.substring",
"str",
"0",
"str.length()-1",
"str.length()",
"str.length",
"str",
"1",
"System.out.println(exCount)",
"System.out.println",
"System.out",
"System",
"System.out",
"exCount",
"int[] arr",
"arr",
"int n",
"n",
"private static void bubbleSort2(int[] arr, int n){\n int exCount = 0;\n for (int i = 0; i < n; i++){\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }",
"bubbleSort2",
"{\n int exCount = 0;\n for (int i = 0; i < n; i++){\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }",
"int exCount = 0;",
"exCount",
"0",
"for (int i = 0; i < n; i++){\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }",
"{\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }",
"for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j>i",
"j",
"i",
"j--",
"j--",
"j",
"{\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }",
"{\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }",
"if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }",
"arr[j] < arr[j-1]",
"arr[j]",
"arr",
"j",
"arr[j-1]",
"arr",
"j-1",
"j",
"1",
"{\n exch(arr,j,j-1);\n exCount++;\n }",
"exch(arr,j,j-1)",
"exch",
"arr",
"j",
"j-1",
"j",
"1",
"exCount++",
"exCount",
"String str = \"\";",
"str",
"\"\"",
"for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < arr.length",
"i",
"arr.length",
"arr",
"arr.length",
"i++",
"i++",
"i",
"{\n str += arr[i] + \" \";\n }",
"{\n str += arr[i] + \" \";\n }",
"str += arr[i] + \" \"",
"str",
"arr[i] + \" \"",
"arr[i]",
"arr",
"i",
"\" \"",
"System.out.println(str.substring(0,str.length()-1))",
"System.out.println",
"System.out",
"System",
"System.out",
"str.substring(0,str.length()-1)",
"str.substring",
"str",
"0",
"str.length()-1",
"str.length()",
"str.length",
"str",
"1",
"System.out.println(exCount)",
"System.out.println",
"System.out",
"System",
"System.out",
"exCount",
"int[] arr",
"arr",
"int n",
"n",
"private static void exch(int[] arr, int i, int j){\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }",
"exch",
"{\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }",
"int tmp = arr[i];",
"tmp",
"arr[i]",
"arr",
"i",
"arr[i] = arr[j]",
"arr[i]",
"arr",
"i",
"arr[j]",
"arr",
"j",
"arr[j] = tmp",
"arr[j]",
"arr",
"j",
"tmp",
"int[] arr",
"arr",
"int i",
"i",
"int j",
"j",
"public class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));\n int N = Integer.parseInt(Reader.readLine());\n String A[] = Reader.readLine().split(\" \",0);\n int[] arr = new int[N];\n for (int i=0; i < N; i++){\n arr[i] = Integer.parseInt(A[i]);\n }\n bubbleSort2(arr,N);\n }\n\n private static void bubbleSort(int[] arr, int n) {\n boolean flag = true;\n int exCount = 0;\n while (flag){\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n \n private static void bubbleSort2(int[] arr, int n){\n int exCount = 0;\n for (int i = 0; i < n; i++){\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n\n private static void exch(int[] arr, int i, int j){\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n}",
"public class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));\n int N = Integer.parseInt(Reader.readLine());\n String A[] = Reader.readLine().split(\" \",0);\n int[] arr = new int[N];\n for (int i=0; i < N; i++){\n arr[i] = Integer.parseInt(A[i]);\n }\n bubbleSort2(arr,N);\n }\n\n private static void bubbleSort(int[] arr, int n) {\n boolean flag = true;\n int exCount = 0;\n while (flag){\n flag = false;\n for (int i = n - 1; i > 0; i--){\n if (arr[i] < arr[i-1]){\n exch(arr,i,i-1);\n exCount++;\n flag = true;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n \n private static void bubbleSort2(int[] arr, int n){\n int exCount = 0;\n for (int i = 0; i < n; i++){\n for (int j = n-1; j>i; j--){\n if (arr[j] < arr[j-1]){\n exch(arr,j,j-1);\n exCount++;\n }\n }\n }\n String str = \"\";\n for (int i = 0; i < arr.length; i++){\n str += arr[i] + \" \";\n }\n System.out.println(str.substring(0,str.length()-1));\n System.out.println(exCount);\n }\n\n private static void exch(int[] arr, int i, int j){\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by hwzheng on 2017/3/27.
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));
int N = Integer.parseInt(Reader.readLine());
String A[] = Reader.readLine().split(" ",0);
int[] arr = new int[N];
for (int i=0; i < N; i++){
arr[i] = Integer.parseInt(A[i]);
}
bubbleSort2(arr,N);
}
private static void bubbleSort(int[] arr, int n) {
boolean flag = true;
int exCount = 0;
while (flag){
flag = false;
for (int i = n - 1; i > 0; i--){
if (arr[i] < arr[i-1]){
exch(arr,i,i-1);
exCount++;
flag = true;
}
}
}
String str = "";
for (int i = 0; i < arr.length; i++){
str += arr[i] + " ";
}
System.out.println(str.substring(0,str.length()-1));
System.out.println(exCount);
}
private static void bubbleSort2(int[] arr, int n){
int exCount = 0;
for (int i = 0; i < n; i++){
for (int j = n-1; j>i; j--){
if (arr[j] < arr[j-1]){
exch(arr,j,j-1);
exCount++;
}
}
}
String str = "";
for (int i = 0; i < arr.length; i++){
str += arr[i] + " ";
}
System.out.println(str.substring(0,str.length()-1));
System.out.println(exCount);
}
private static void exch(int[] arr, int i, int j){
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
17,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
18,
13,
2,
13,
17,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
17,
0,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
30,
4,
18,
13,
17,
4,
18,
13,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
6,
47
],
[
47,
48
],
[
4,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
51,
57
],
[
57,
58
],
[
57,
59
],
[
51,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
68,
77
],
[
77,
78
],
[
77,
79
],
[
68,
80
],
[
80,
81
],
[
81,
82
],
[
68,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
84,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
92,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
103,
109
],
[
109,
110
],
[
109,
111
],
[
102,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
102,
117
],
[
117,
118
],
[
117,
119
],
[
102,
120
],
[
120,
121
],
[
120,
122
],
[
51,
123
],
[
123,
124
],
[
123,
125
],
[
51,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
126,
136
],
[
136,
137
],
[
137,
138
],
[
126,
139
],
[
140,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
146,
149
],
[
140,
150
],
[
150,
151
],
[
151,
152
],
[
150,
153
],
[
153,
154
],
[
153,
155
],
[
51,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
162,
163
],
[
51,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
49,
170
],
[
170,
171
]
] | [
"import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint[] c = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tc[i] = in.nextInt();\n\t\t}\n\t\tbubbleSort(c);\n\t\tin.close();\n\t}\n\n\tprivate static void bubbleSort(int[] A) {\n\t\tint flg = 1;\n\t\tint wk;\n\t\tint count=0;\n\t\twhile (flg == 1) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = A.length - 1; i > 0; i--) {\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tStringBuilder sb=new StringBuilder();\n\t\tfor(int i=0;i<A.length;i++) {\n\t\t\tif(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\t\t\tsb.append(A[i]);\n\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t\tSystem.out.println(count);\n\t}\n\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint[] c = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tc[i] = in.nextInt();\n\t\t}\n\t\tbubbleSort(c);\n\t\tin.close();\n\t}\n\n\tprivate static void bubbleSort(int[] A) {\n\t\tint flg = 1;\n\t\tint wk;\n\t\tint count=0;\n\t\twhile (flg == 1) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = A.length - 1; i > 0; i--) {\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tStringBuilder sb=new StringBuilder();\n\t\tfor(int i=0;i<A.length;i++) {\n\t\t\tif(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\t\t\tsb.append(A[i]);\n\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main",
"public static void main(String args[]) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint[] c = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tc[i] = in.nextInt();\n\t\t}\n\t\tbubbleSort(c);\n\t\tin.close();\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint[] c = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tc[i] = in.nextInt();\n\t\t}\n\t\tbubbleSort(c);\n\t\tin.close();\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int[] c = new int[n];",
"c",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\tc[i] = in.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tc[i] = in.nextInt();\n\t\t}",
"{\n\t\t\tc[i] = in.nextInt();\n\t\t}",
"c[i] = in.nextInt()",
"c[i]",
"c",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"bubbleSort(c)",
"bubbleSort",
"c",
"in.close()",
"in.close",
"in",
"String args[]",
"args",
"private static void bubbleSort(int[] A) {\n\t\tint flg = 1;\n\t\tint wk;\n\t\tint count=0;\n\t\twhile (flg == 1) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = A.length - 1; i > 0; i--) {\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tStringBuilder sb=new StringBuilder();\n\t\tfor(int i=0;i<A.length;i++) {\n\t\t\tif(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\t\t\tsb.append(A[i]);\n\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t\tSystem.out.println(count);\n\t}",
"bubbleSort",
"{\n\t\tint flg = 1;\n\t\tint wk;\n\t\tint count=0;\n\t\twhile (flg == 1) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = A.length - 1; i > 0; i--) {\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tStringBuilder sb=new StringBuilder();\n\t\tfor(int i=0;i<A.length;i++) {\n\t\t\tif(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\t\t\tsb.append(A[i]);\n\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t\tSystem.out.println(count);\n\t}",
"int flg = 1;",
"flg",
"1",
"int wk;",
"wk",
"int count=0;",
"count",
"0",
"while (flg == 1) {\n\t\t\tflg = 0;\n\t\t\tfor (int i = A.length - 1; i > 0; i--) {\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"flg == 1",
"flg",
"1",
"{\n\t\t\tflg = 0;\n\t\t\tfor (int i = A.length - 1; i > 0; i--) {\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"flg = 0",
"flg",
"0",
"for (int i = A.length - 1; i > 0; i--) {\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}",
"int i = A.length - 1;",
"int i = A.length - 1;",
"i",
"A.length - 1",
"A.length",
"A",
"A.length",
"1",
"i > 0",
"i",
"0",
"i--",
"i--",
"i",
"{\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\twk = A[i - 1];\n\n\t\t\t\tif (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}\n\t\t\t}",
"wk = A[i - 1]",
"wk",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"if (A[i] < A[i - 1]) {\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}",
"A[i] < A[i - 1]",
"A[i]",
"A",
"i",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"{\n\t\t\t\t\tA[i - 1] = A[i];\n\t\t\t\t\tA[i] = wk;\n\t\t\t\t\tcount+=1;\n\t\t\t\t\tflg=1;\n\t\t\t\t}",
"A[i - 1] = A[i]",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"A[i]",
"A",
"i",
"A[i] = wk",
"A[i]",
"A",
"i",
"wk",
"count+=1",
"count",
"1",
"flg=1",
"flg",
"1",
"StringBuilder sb=new StringBuilder();",
"sb",
"new StringBuilder()",
"for(int i=0;i<A.length;i++) {\n\t\t\tif(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\t\t\tsb.append(A[i]);\n\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<A.length",
"i",
"A.length",
"A",
"A.length",
"i++",
"i++",
"i",
"{\n\t\t\tif(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\t\t\tsb.append(A[i]);\n\n\t\t}",
"{\n\t\t\tif(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\t\t\tsb.append(A[i]);\n\n\t\t}",
"if(i>0) {\n\t\t\t\tsb.append(\" \");\n\t\t\t}",
"i>0",
"i",
"0",
"{\n\t\t\t\tsb.append(\" \");\n\t\t\t}",
"sb.append(\" \")",
"sb.append",
"sb",
"\" \"",
"sb.append(A[i])",
"sb.append",
"sb",
"A[i]",
"A",
"i",
"System.out.println(sb.toString())",
"System.out.println",
"System.out",
"System",
"System.out",
"sb.toString()",
"sb.toString",
"sb",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"int[] A",
"A"
] | import java.util.Scanner;
class Main {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] c = new int[n];
for (int i = 0; i < n; i++) {
c[i] = in.nextInt();
}
bubbleSort(c);
in.close();
}
private static void bubbleSort(int[] A) {
int flg = 1;
int wk;
int count=0;
while (flg == 1) {
flg = 0;
for (int i = A.length - 1; i > 0; i--) {
wk = A[i - 1];
if (A[i] < A[i - 1]) {
A[i - 1] = A[i];
A[i] = wk;
count+=1;
flg=1;
}
}
}
StringBuilder sb=new StringBuilder();
for(int i=0;i<A.length;i++) {
if(i>0) {
sb.append(" ");
}
sb.append(A[i]);
}
System.out.println(sb.toString());
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
29,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
168,
5
],
[
168,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
41,
44
],
[
6,
45
],
[
45,
46
],
[
168,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
53,
55
],
[
49,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
64,
71
],
[
71,
72
],
[
71,
73
],
[
64,
74
],
[
74,
75
],
[
75,
76
],
[
64,
77
],
[
78,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
79,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
89,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
89,
111
],
[
111,
112
],
[
111,
113
],
[
89,
114
],
[
114,
115
],
[
49,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
121,
122
],
[
121,
123
],
[
116,
124
],
[
124,
125
],
[
125,
126
],
[
116,
127
],
[
128,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
129,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
152,
153
],
[
152,
154
],
[
49,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
49,
161
],
[
161,
162
],
[
47,
163
],
[
163,
164
],
[
47,
165
],
[
165,
166
],
[
0,
167
],
[
167,
168
],
[
167,
169
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic int[] bubbleSort(int[] a, int n) {\n\t\tint flg = 1;\n\t\tint cnt = 0;\n\t\twhile(flg == 1){\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t\treturn a;\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic int[] bubbleSort(int[] a, int n) {\n\t\tint flg = 1;\n\t\tint cnt = 0;\n\t\twhile(flg == 1){\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t\treturn a;\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"bubbleSort(a, n)",
"bubbleSort",
"a",
"n",
"String[] args",
"args",
"static int[] bubbleSort(int[] a, int n) {\n\t\tint flg = 1;\n\t\tint cnt = 0;\n\t\twhile(flg == 1){\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t\treturn a;\n\t}",
"bubbleSort",
"{\n\t\tint flg = 1;\n\t\tint cnt = 0;\n\t\twhile(flg == 1){\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t\treturn a;\n\t}",
"int flg = 1;",
"flg",
"1",
"int cnt = 0;",
"cnt",
"0",
"while(flg == 1){\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg == 1",
"flg",
"1",
"{\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"flg = 0",
"flg",
"0",
"for(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1 ;",
"int j = n - 1 ;",
"j",
"n - 1",
"n",
"1",
"j >= 1",
"j",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}",
"if(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}",
"a[j] < a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}",
"int v = a[j];",
"v",
"a[j]",
"a",
"j",
"a[j] = a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"a[j - 1] = v",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"v",
"flg = 1",
"flg",
"1",
"cnt++",
"cnt",
"for(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}",
"if(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}",
"i != n - 1",
"i",
"n - 1",
"n",
"1",
"{\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t}",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"{\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}",
"System.out.println(a[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"return a;",
"a",
"int[] a",
"a",
"int n",
"n",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic int[] bubbleSort(int[] a, int n) {\n\t\tint flg = 1;\n\t\tint cnt = 0;\n\t\twhile(flg == 1){\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t\treturn a;\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tbubbleSort(a, n);\n\t}\n\n\tstatic int[] bubbleSort(int[] a, int n) {\n\t\tint flg = 1;\n\t\tint cnt = 0;\n\t\twhile(flg == 1){\n\t\t\tflg = 0;\n\t\t\tfor(int j = n - 1 ; j >= 1 ; j--) {\n\t\t\t\tif(a[j] < a[j - 1]) {\n\t\t\t\t\tint v = a[j];\n\t\t\t\t\ta[j] = a[j - 1];\n\t\t\t\t\ta[j - 1] = v;\n\t\t\t\t\tflg = 1;\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\tif(i != n - 1) {\n\t\t\t\tSystem.out.print(a[i] + \" \");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(a[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t\treturn a;\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for(int i = 0 ; i < n ; i++) {
a[i] = sc.nextInt();
}
bubbleSort(a, n);
}
static int[] bubbleSort(int[] a, int n) {
int flg = 1;
int cnt = 0;
while(flg == 1){
flg = 0;
for(int j = n - 1 ; j >= 1 ; j--) {
if(a[j] < a[j - 1]) {
int v = a[j];
a[j] = a[j - 1];
a[j - 1] = v;
flg = 1;
cnt++;
}
}
}
for(int i = 0 ; i < n ; i++) {
if(i != n - 1) {
System.out.print(a[i] + " ");
} else {
System.out.println(a[i]);
}
}
System.out.println(cnt);
return a;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
18,
13,
13,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
4,
13,
13,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
4,
13,
13,
13,
4,
18,
18,
13,
13,
4,
18,
13,
13,
23,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
30,
4,
18,
13,
17,
4,
18,
18,
13,
13,
4,
18,
13,
4,
18,
13,
17,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
13,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
13,
18
],
[
9,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
29,
30
],
[
19,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
33,
38
],
[
19,
39
],
[
39,
40
],
[
39,
41
],
[
19,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
43,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
55,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
63,
65
],
[
19,
66
],
[
66,
67
],
[
66,
68
],
[
66,
69
],
[
69,
70
],
[
69,
71
],
[
6,
72
],
[
72,
73
],
[
4,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
80,
82
],
[
76,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
83,
93
],
[
93,
94
],
[
94,
95
],
[
83,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
98,
105
],
[
105,
106
],
[
105,
107
],
[
98,
108
],
[
108,
109
],
[
109,
110
],
[
98,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
113,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
123,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
123,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
138,
144
],
[
123,
145
],
[
145,
146
],
[
76,
147
],
[
147,
148
],
[
147,
149
],
[
147,
150
],
[
76,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
156,
157
],
[
157,
158
],
[
156,
159
],
[
74,
160
],
[
160,
161
],
[
74,
162
],
[
162,
163
],
[
4,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
167,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
174,
176
],
[
167,
177
],
[
177,
178
],
[
178,
179
],
[
167,
180
],
[
181,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
182,
185
],
[
185,
186
],
[
185,
187
],
[
181,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
189,
193
],
[
193,
194
],
[
193,
195
],
[
188,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
197,
200
],
[
166,
201
],
[
201,
202
],
[
202,
203
],
[
203,
204
],
[
203,
205
],
[
201,
206
],
[
206,
207
],
[
207,
208
],
[
166,
209
],
[
209,
210
],
[
210,
211
],
[
209,
212
],
[
164,
213
],
[
213,
214
],
[
164,
215
],
[
215,
216
]
] | [
"\n\nimport java.io.*;\n\nclass Main\n{\n \n public static void main(String[] args)\n {\n try{\n \t// ??\\???????????????\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n // ????????°???????????????\n int n = Integer.parseInt(br.readLine());\n String[] str = br.readLine().split(\" \");\n int[] array = new int[n];\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(str[i]);\n }\n bubbleSort(array, array.length);\n \n }catch(Exception e){\n System.out.println(e);\n }\n }\n \n public static void bubbleSort(int[] A, int N)\n {\n\t int swapNum = 0;\n StringBuilder sb = new StringBuilder(); \n for(int i = 0; i < N - 1; ++i){\n \tfor(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}\n }\n show(A,sb);\n System.out.println(Integer.toString(swapNum));\n \n }\n \n public static void show(int[] A,StringBuilder sb){\n\t for(int i = 0;i < A.length;++i){\n\t \tsb.append(A[i]);\n\t \tif(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}\n\t }\n\t System.out.println(sb.toString());\n\t sb.setLength(0);\n }\n}",
"import java.io.*;",
"io.*",
"java",
"class Main\n{\n \n public static void main(String[] args)\n {\n try{\n \t// ??\\???????????????\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n // ????????°???????????????\n int n = Integer.parseInt(br.readLine());\n String[] str = br.readLine().split(\" \");\n int[] array = new int[n];\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(str[i]);\n }\n bubbleSort(array, array.length);\n \n }catch(Exception e){\n System.out.println(e);\n }\n }\n \n public static void bubbleSort(int[] A, int N)\n {\n\t int swapNum = 0;\n StringBuilder sb = new StringBuilder(); \n for(int i = 0; i < N - 1; ++i){\n \tfor(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}\n }\n show(A,sb);\n System.out.println(Integer.toString(swapNum));\n \n }\n \n public static void show(int[] A,StringBuilder sb){\n\t for(int i = 0;i < A.length;++i){\n\t \tsb.append(A[i]);\n\t \tif(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}\n\t }\n\t System.out.println(sb.toString());\n\t sb.setLength(0);\n }\n}",
"Main",
"public static void main(String[] args)\n {\n try{\n \t// ??\\???????????????\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n // ????????°???????????????\n int n = Integer.parseInt(br.readLine());\n String[] str = br.readLine().split(\" \");\n int[] array = new int[n];\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(str[i]);\n }\n bubbleSort(array, array.length);\n \n }catch(Exception e){\n System.out.println(e);\n }\n }",
"main",
"{\n try{\n \t// ??\\???????????????\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n // ????????°???????????????\n int n = Integer.parseInt(br.readLine());\n String[] str = br.readLine().split(\" \");\n int[] array = new int[n];\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(str[i]);\n }\n bubbleSort(array, array.length);\n \n }catch(Exception e){\n System.out.println(e);\n }\n }",
"try{\n \t// ??\\???????????????\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n // ????????°???????????????\n int n = Integer.parseInt(br.readLine());\n String[] str = br.readLine().split(\" \");\n int[] array = new int[n];\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(str[i]);\n }\n bubbleSort(array, array.length);\n \n }catch(Exception e){\n System.out.println(e);\n }",
"catch(Exception e){\n System.out.println(e);\n }",
"Exception e",
"{\n System.out.println(e);\n }",
"System.out.println(e)",
"System.out.println",
"System.out",
"System",
"System.out",
"e",
"{\n \t// ??\\???????????????\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n // ????????°???????????????\n int n = Integer.parseInt(br.readLine());\n String[] str = br.readLine().split(\" \");\n int[] array = new int[n];\n \n for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(str[i]);\n }\n bubbleSort(array, array.length);\n \n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int n = Integer.parseInt(br.readLine());",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"String[] str = br.readLine().split(\" \");",
"str",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int[] array = new int[n];",
"array",
"new int[n]",
"n",
"for(int i = 0; i < n; i++){\n array[i] = Integer.parseInt(str[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n array[i] = Integer.parseInt(str[i]);\n }",
"{\n array[i] = Integer.parseInt(str[i]);\n }",
"array[i] = Integer.parseInt(str[i])",
"array[i]",
"array",
"i",
"Integer.parseInt(str[i])",
"Integer.parseInt",
"Integer",
"str[i]",
"str",
"i",
"bubbleSort(array, array.length)",
"bubbleSort",
"array",
"array.length",
"array",
"array.length",
"String[] args",
"args",
"public static void bubbleSort(int[] A, int N)\n {\n\t int swapNum = 0;\n StringBuilder sb = new StringBuilder(); \n for(int i = 0; i < N - 1; ++i){\n \tfor(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}\n }\n show(A,sb);\n System.out.println(Integer.toString(swapNum));\n \n }",
"bubbleSort",
"{\n\t int swapNum = 0;\n StringBuilder sb = new StringBuilder(); \n for(int i = 0; i < N - 1; ++i){\n \tfor(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}\n }\n show(A,sb);\n System.out.println(Integer.toString(swapNum));\n \n }",
"int swapNum = 0;",
"swapNum",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"for(int i = 0; i < N - 1; ++i){\n \tfor(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N - 1",
"i",
"N - 1",
"N",
"1",
"++i",
"++i",
"i",
"{\n \tfor(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}\n }",
"{\n \tfor(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}\n }",
"for(int j = N - 1;j > i;--j){\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}",
"int j = N - 1;",
"int j = N - 1;",
"j",
"N - 1",
"N",
"1",
"j > i",
"j",
"i",
"--j",
"--j",
"j",
"{\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}",
"{\n \t\tif(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}\n \t}",
"if(A[j] < A[j - 1]){\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}",
"A[j] < A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"{\n \t\t\tfinal int tmp = A[j];\n \t\t\tA[j] = A[j - 1];\n \t\t\tA[j - 1] = tmp;\n \t\t\tswapNum++;\n \t\t}",
"final int tmp = A[j];",
"tmp",
"A[j]",
"A",
"j",
"A[j] = A[j - 1]",
"A[j]",
"A",
"j",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"A[j - 1] = tmp",
"A[j - 1]",
"A",
"j - 1",
"j",
"1",
"tmp",
"swapNum++",
"swapNum",
"show(A,sb)",
"show",
"A",
"sb",
"System.out.println(Integer.toString(swapNum))",
"System.out.println",
"System.out",
"System",
"System.out",
"Integer.toString(swapNum)",
"Integer.toString",
"Integer",
"swapNum",
"int[] A",
"A",
"int N",
"N",
"public static void show(int[] A,StringBuilder sb){\n\t for(int i = 0;i < A.length;++i){\n\t \tsb.append(A[i]);\n\t \tif(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}\n\t }\n\t System.out.println(sb.toString());\n\t sb.setLength(0);\n }",
"show",
"{\n\t for(int i = 0;i < A.length;++i){\n\t \tsb.append(A[i]);\n\t \tif(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}\n\t }\n\t System.out.println(sb.toString());\n\t sb.setLength(0);\n }",
"for(int i = 0;i < A.length;++i){\n\t \tsb.append(A[i]);\n\t \tif(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}\n\t }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < A.length",
"i",
"A.length",
"A",
"A.length",
"++i",
"++i",
"i",
"{\n\t \tsb.append(A[i]);\n\t \tif(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}\n\t }",
"{\n\t \tsb.append(A[i]);\n\t \tif(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}\n\t }",
"sb.append(A[i])",
"sb.append",
"sb",
"A[i]",
"A",
"i",
"if(i + 1 < A.length){\n\t \t\tsb.append(\" \");\n\t \t}",
"i + 1 < A.length",
"i + 1",
"i",
"1",
"A.length",
"A",
"A.length",
"{\n\t \t\tsb.append(\" \");\n\t \t}",
"sb.append(\" \")",
"sb.append",
"sb",
"\" \"",
"System.out.println(sb.toString())",
"System.out.println",
"System.out",
"System",
"System.out",
"sb.toString()",
"sb.toString",
"sb",
"sb.setLength(0)",
"sb.setLength",
"sb",
"0",
"int[] A",
"A",
"StringBuilder sb",
"sb"
] |
import java.io.*;
class Main
{
public static void main(String[] args)
{
try{
// ??\???????????????
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// ????????°???????????????
int n = Integer.parseInt(br.readLine());
String[] str = br.readLine().split(" ");
int[] array = new int[n];
for(int i = 0; i < n; i++){
array[i] = Integer.parseInt(str[i]);
}
bubbleSort(array, array.length);
}catch(Exception e){
System.out.println(e);
}
}
public static void bubbleSort(int[] A, int N)
{
int swapNum = 0;
StringBuilder sb = new StringBuilder();
for(int i = 0; i < N - 1; ++i){
for(int j = N - 1;j > i;--j){
if(A[j] < A[j - 1]){
final int tmp = A[j];
A[j] = A[j - 1];
A[j - 1] = tmp;
swapNum++;
}
}
}
show(A,sb);
System.out.println(Integer.toString(swapNum));
}
public static void show(int[] A,StringBuilder sb){
for(int i = 0;i < A.length;++i){
sb.append(A[i]);
if(i + 1 < A.length){
sb.append(" ");
}
}
System.out.println(sb.toString());
sb.setLength(0);
}
} |
[
7,
6,
13,
41,
13,
12,
13,
30,
41,
13,
41,
13,
11,
1,
0,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
0,
13,
17,
2,
13,
2,
18,
13,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
4,
13,
13,
2,
13,
17,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
11,
1,
0,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
0,
13,
20,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
17,
4,
13,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
4,
18,
20,
20,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
203,
2
],
[
203,
3
],
[
3,
4
],
[
203,
5
],
[
5,
6
],
[
5,
7
],
[
7,
8
],
[
8,
9
],
[
7,
10
],
[
10,
11
],
[
7,
12
],
[
12,
13
],
[
13,
14
],
[
14,
15
],
[
14,
16
],
[
12,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
19,
21
],
[
12,
22
],
[
22,
23
],
[
23,
24
],
[
12,
25
],
[
26,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
27,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
27,
39
],
[
39,
40
],
[
40,
41
],
[
27,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
44,
54
],
[
54,
55
],
[
54,
56
],
[
54,
57
],
[
57,
58
],
[
57,
59
],
[
54,
60
],
[
5,
61
],
[
61,
62
],
[
203,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
75,
77
],
[
65,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
65,
83
],
[
83,
84
],
[
63,
85
],
[
85,
86
],
[
63,
87
],
[
87,
88
],
[
63,
89
],
[
89,
90
],
[
203,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
96,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
96,
106
],
[
106,
107
],
[
107,
108
],
[
96,
109
],
[
110,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
116,
117
],
[
116,
118
],
[
110,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
124,
126
],
[
119,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
119,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
91,
138
],
[
138,
139
],
[
203,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
145,
146
],
[
142,
147
],
[
147,
148
],
[
142,
149
],
[
149,
150
],
[
149,
151
],
[
152,
153
],
[
153,
154
],
[
142,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
162,
164
],
[
155,
165
],
[
165,
166
],
[
166,
167
],
[
155,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
173,
174
],
[
174,
175
],
[
142,
176
],
[
176,
177
],
[
176,
178
],
[
142,
179
],
[
179,
180
],
[
179,
181
],
[
142,
182
],
[
182,
183
],
[
182,
184
],
[
142,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
185,
190
],
[
140,
191
],
[
191,
192
],
[
203,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
196,
197
],
[
197,
198
],
[
196,
199
],
[
193,
200
],
[
200,
201
],
[
0,
202
],
[
202,
203
],
[
202,
204
]
] | [
"public class\nMain\n{\n private int swc;\n\n private void\n sort (\n int[ ] a\n )\n {\n int i, j;\n\n for ( i = 0; i < a.length; ++i )\n {\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }\n }\n \n private void\n swap (\n int[ ] a,\n int i,\n int j\n )\n {\n final int t = a[ i ];\n a[ i ] = a[ j ];\n a[ j ] = t;\n ++swc;\n }\n\n private void\n printArray (\n int[ ] a\n )\n {\n int i;\n\n for ( i = 0; i < a.length; ++i )\n {\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }\n }\n\n public void\n run (\n java.util.Scanner sc\n )\n {\n int[ ] a;\n int i, j;\n\n a = new int[ sc.nextInt ( ) ];\n for ( i = 0; i < a.length; ++i )\n a[ i ] = sc.nextInt ( );\n\n swc = 0;\n sort ( a );\n printArray ( a );\n System.out.println ( swc );\n }\n\n public static void\n main (\n String[ ] args\n )\n {\n ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );\n }\n}",
"Main\n{\n private int swc;\n\n private void\n sort (\n int[ ] a\n )\n {\n int i, j;\n\n for ( i = 0; i < a.length; ++i )\n {\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }\n }\n \n private void\n swap (\n int[ ] a,\n int i,\n int j\n )\n {\n final int t = a[ i ];\n a[ i ] = a[ j ];\n a[ j ] = t;\n ++swc;\n }\n\n private void\n printArray (\n int[ ] a\n )\n {\n int i;\n\n for ( i = 0; i < a.length; ++i )\n {\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }\n }\n\n public void\n run (\n java.util.Scanner sc\n )\n {\n int[ ] a;\n int i, j;\n\n a = new int[ sc.nextInt ( ) ];\n for ( i = 0; i < a.length; ++i )\n a[ i ] = sc.nextInt ( );\n\n swc = 0;\n sort ( a );\n printArray ( a );\n System.out.println ( swc );\n }\n\n public static void\n main (\n String[ ] args\n )\n {\n ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );\n }\n}",
"Main",
"private int swc;",
"swc",
"private void\n sort (\n int[ ] a\n )\n {\n int i, j;\n\n for ( i = 0; i < a.length; ++i )\n {\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }\n }",
"sort",
"{\n int i, j;\n\n for ( i = 0; i < a.length; ++i )\n {\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }\n }",
"int i",
"i",
"j;",
"j",
"for ( i = 0; i < a.length; ++i )\n {\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"++i",
"++i",
"i",
"{\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }",
"{\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }",
"for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }",
"j = 1;",
"j = 1",
"j",
"1",
"j < a.length - i",
"j",
"a.length - i",
"a.length",
"a",
"a.length",
"i",
"++j",
"++j",
"j",
"{\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }",
"{\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }",
"if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );",
"a[ j ] < a[ j - 1 ]",
"a[ j ]",
"a",
"j",
"a[ j - 1 ]",
"a",
"j - 1",
"j",
"1",
"swap ( a, j - 1, j )",
"swap",
"a",
"j - 1",
"j",
"1",
"j",
"int[ ] a",
"a",
"private void\n swap (\n int[ ] a,\n int i,\n int j\n )\n {\n final int t = a[ i ];\n a[ i ] = a[ j ];\n a[ j ] = t;\n ++swc;\n }",
"swap",
"{\n final int t = a[ i ];\n a[ i ] = a[ j ];\n a[ j ] = t;\n ++swc;\n }",
"final int t = a[ i ];",
"t",
"a[ i ]",
"a",
"i",
"a[ i ] = a[ j ]",
"a[ i ]",
"a",
"i",
"a[ j ]",
"a",
"j",
"a[ j ] = t",
"a[ j ]",
"a",
"j",
"t",
"++swc",
"swc",
"int[ ] a",
"a",
"int i",
"i",
"int j",
"j",
"private void\n printArray (\n int[ ] a\n )\n {\n int i;\n\n for ( i = 0; i < a.length; ++i )\n {\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }\n }",
"printArray",
"{\n int i;\n\n for ( i = 0; i < a.length; ++i )\n {\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }\n }",
"int i;",
"i",
"for ( i = 0; i < a.length; ++i )\n {\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"++i",
"++i",
"i",
"{\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }",
"{\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }",
"System.out.print ( a[ i ] )",
"System.out.print",
"System.out",
"System",
"System.out",
"a[ i ]",
"a",
"i",
"if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );",
"i + 1 < a.length",
"i + 1",
"i",
"1",
"a.length",
"a",
"a.length",
"System.out.print ( \" \" )",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println ( )",
"System.out.println",
"System.out",
"System",
"System.out",
"int[ ] a",
"a",
"public void\n run (\n java.util.Scanner sc\n )\n {\n int[ ] a;\n int i, j;\n\n a = new int[ sc.nextInt ( ) ];\n for ( i = 0; i < a.length; ++i )\n a[ i ] = sc.nextInt ( );\n\n swc = 0;\n sort ( a );\n printArray ( a );\n System.out.println ( swc );\n }",
"run",
"{\n int[ ] a;\n int i, j;\n\n a = new int[ sc.nextInt ( ) ];\n for ( i = 0; i < a.length; ++i )\n a[ i ] = sc.nextInt ( );\n\n swc = 0;\n sort ( a );\n printArray ( a );\n System.out.println ( swc );\n }",
"int[ ] a;",
"a",
"int i",
"i",
"j;",
"j",
"a = new int[ sc.nextInt ( ) ]",
"a",
"new int[ sc.nextInt ( ) ]",
"sc.nextInt ( )",
"sc.nextInt",
"sc",
"for ( i = 0; i < a.length; ++i )\n a[ i ] = sc.nextInt ( );",
"i = 0;",
"i = 0",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"++i",
"++i",
"i",
"a[ i ] = sc.nextInt ( );",
"a[ i ] = sc.nextInt ( )",
"a[ i ]",
"a",
"i",
"sc.nextInt ( )",
"sc.nextInt",
"sc",
"swc = 0",
"swc",
"0",
"sort ( a )",
"sort",
"a",
"printArray ( a )",
"printArray",
"a",
"System.out.println ( swc )",
"System.out.println",
"System.out",
"System",
"System.out",
"swc",
"java.util.Scanner sc",
"sc",
"public static void\n main (\n String[ ] args\n )\n {\n ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );\n }",
"main",
"{\n ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );\n }",
"( new Main ( ) ).run ( new java.util.Scanner ( System.in ) )",
"( new Main ( ) ).run",
"( new Main ( ) )",
"new java.util.Scanner ( System.in )",
"String[ ] args",
"args",
"Main\n{\n private int swc;\n\n private void\n sort (\n int[ ] a\n )\n {\n int i, j;\n\n for ( i = 0; i < a.length; ++i )\n {\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }\n }\n \n private void\n swap (\n int[ ] a,\n int i,\n int j\n )\n {\n final int t = a[ i ];\n a[ i ] = a[ j ];\n a[ j ] = t;\n ++swc;\n }\n\n private void\n printArray (\n int[ ] a\n )\n {\n int i;\n\n for ( i = 0; i < a.length; ++i )\n {\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }\n }\n\n public void\n run (\n java.util.Scanner sc\n )\n {\n int[ ] a;\n int i, j;\n\n a = new int[ sc.nextInt ( ) ];\n for ( i = 0; i < a.length; ++i )\n a[ i ] = sc.nextInt ( );\n\n swc = 0;\n sort ( a );\n printArray ( a );\n System.out.println ( swc );\n }\n\n public static void\n main (\n String[ ] args\n )\n {\n ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );\n }\n}",
"Main\n{\n private int swc;\n\n private void\n sort (\n int[ ] a\n )\n {\n int i, j;\n\n for ( i = 0; i < a.length; ++i )\n {\n for ( j = 1; j < a.length - i; ++j )\n {\n if ( a[ j ] < a[ j - 1 ] )\n swap ( a, j - 1, j );\n }\n }\n }\n \n private void\n swap (\n int[ ] a,\n int i,\n int j\n )\n {\n final int t = a[ i ];\n a[ i ] = a[ j ];\n a[ j ] = t;\n ++swc;\n }\n\n private void\n printArray (\n int[ ] a\n )\n {\n int i;\n\n for ( i = 0; i < a.length; ++i )\n {\n System.out.print ( a[ i ] );\n if ( i + 1 < a.length )\n System.out.print ( \" \" );\n else\n System.out.println ( );\n }\n }\n\n public void\n run (\n java.util.Scanner sc\n )\n {\n int[ ] a;\n int i, j;\n\n a = new int[ sc.nextInt ( ) ];\n for ( i = 0; i < a.length; ++i )\n a[ i ] = sc.nextInt ( );\n\n swc = 0;\n sort ( a );\n printArray ( a );\n System.out.println ( swc );\n }\n\n public static void\n main (\n String[ ] args\n )\n {\n ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );\n }\n}",
"Main"
] | public class
Main
{
private int swc;
private void
sort (
int[ ] a
)
{
int i, j;
for ( i = 0; i < a.length; ++i )
{
for ( j = 1; j < a.length - i; ++j )
{
if ( a[ j ] < a[ j - 1 ] )
swap ( a, j - 1, j );
}
}
}
private void
swap (
int[ ] a,
int i,
int j
)
{
final int t = a[ i ];
a[ i ] = a[ j ];
a[ j ] = t;
++swc;
}
private void
printArray (
int[ ] a
)
{
int i;
for ( i = 0; i < a.length; ++i )
{
System.out.print ( a[ i ] );
if ( i + 1 < a.length )
System.out.print ( " " );
else
System.out.println ( );
}
}
public void
run (
java.util.Scanner sc
)
{
int[ ] a;
int i, j;
a = new int[ sc.nextInt ( ) ];
for ( i = 0; i < a.length; ++i )
a[ i ] = sc.nextInt ( );
swc = 0;
sort ( a );
printArray ( a );
System.out.println ( swc );
}
public static void
main (
String[ ] args
)
{
( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
41,
13,
20,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
18,
13,
13,
13,
1,
40,
13,
30,
30,
11,
1,
0,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
0,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
169,
5
],
[
169,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
8,
27
],
[
27,
28
],
[
8,
29
],
[
29,
30
],
[
8,
31
],
[
31,
32
],
[
31,
33
],
[
8,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
34,
39
],
[
39,
40
],
[
39,
41
],
[
34,
42
],
[
42,
43
],
[
43,
44
],
[
34,
45
],
[
46,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
52,
53
],
[
8,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
54,
64
],
[
64,
65
],
[
65,
66
],
[
54,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
69,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
69,
81
],
[
81,
82
],
[
82,
83
],
[
69,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
86,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
96,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
110,
111
],
[
110,
112
],
[
96,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
96,
118
],
[
118,
119
],
[
8,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
120,
130
],
[
130,
131
],
[
131,
132
],
[
120,
133
],
[
134,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
8,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
148,
150
],
[
145,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
152,
157
],
[
157,
158
],
[
157,
159
],
[
8,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
160,
165
],
[
6,
166
],
[
166,
167
],
[
0,
168
],
[
168,
169
],
[
168,
170
]
] | [
"\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int bigger ;\n int a[] = new int[N];\n int i,j,k,x ;\n int count =0;\n for (x =0 ; x < N ; x++){\n a[x] = sc.nextInt();\n }\n for (i = 0; a.length > i;i++ ){\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }\n for(k=0; k<N-1;k++){\n System.out.print(a[k]+ \" \");\n }\n if(k == N-1){\n System.out.println(a[k]);\n }\n System.out.println(count);\n }\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int bigger ;\n int a[] = new int[N];\n int i,j,k,x ;\n int count =0;\n for (x =0 ; x < N ; x++){\n a[x] = sc.nextInt();\n }\n for (i = 0; a.length > i;i++ ){\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }\n for(k=0; k<N-1;k++){\n System.out.print(a[k]+ \" \");\n }\n if(k == N-1){\n System.out.println(a[k]);\n }\n System.out.println(count);\n }\n\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int bigger ;\n int a[] = new int[N];\n int i,j,k,x ;\n int count =0;\n for (x =0 ; x < N ; x++){\n a[x] = sc.nextInt();\n }\n for (i = 0; a.length > i;i++ ){\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }\n for(k=0; k<N-1;k++){\n System.out.print(a[k]+ \" \");\n }\n if(k == N-1){\n System.out.println(a[k]);\n }\n System.out.println(count);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int bigger ;\n int a[] = new int[N];\n int i,j,k,x ;\n int count =0;\n for (x =0 ; x < N ; x++){\n a[x] = sc.nextInt();\n }\n for (i = 0; a.length > i;i++ ){\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }\n for(k=0; k<N-1;k++){\n System.out.print(a[k]+ \" \");\n }\n if(k == N-1){\n System.out.println(a[k]);\n }\n System.out.println(count);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int bigger ;",
"bigger",
"int a[] = new int[N];",
"a",
"new int[N]",
"N",
"int i",
"i",
"j",
"j",
"k",
"k",
"x ;",
"x",
"int count =0;",
"count",
"0",
"for (x =0 ; x < N ; x++){\n a[x] = sc.nextInt();\n }",
"x =0 ;",
"x =0",
"x",
"0",
"x < N",
"x",
"N",
"x++",
"x++",
"x",
"{\n a[x] = sc.nextInt();\n }",
"{\n a[x] = sc.nextInt();\n }",
"a[x] = sc.nextInt()",
"a[x]",
"a",
"x",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (i = 0; a.length > i;i++ ){\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }",
"i = 0;",
"i = 0",
"i",
"0",
"a.length > i",
"a.length",
"a",
"a.length",
"i",
"i++",
"i++",
"i",
"{\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }",
"{\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }",
"for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }",
"j=N-1;",
"j=N-1",
"j",
"N-1",
"N",
"1",
"j>=i+1",
"j",
"i+1",
"i",
"1",
"j--",
"j--",
"j",
"{\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }",
"{\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }",
"if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }",
"a[j] <a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"{\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }",
"bigger = a[j-1]",
"bigger",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j-1] = a[j]",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j]",
"a",
"j",
"a[j] = bigger",
"a[j]",
"a",
"j",
"bigger",
"count++",
"count",
"for(k=0; k<N-1;k++){\n System.out.print(a[k]+ \" \");\n }",
"k=0;",
"k=0",
"k",
"0",
"k<N-1",
"k",
"N-1",
"N",
"1",
"k++",
"k++",
"k",
"{\n System.out.print(a[k]+ \" \");\n }",
"{\n System.out.print(a[k]+ \" \");\n }",
"System.out.print(a[k]+ \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[k]+ \" \"",
"a[k]",
"a",
"k",
"\" \"",
"if(k == N-1){\n System.out.println(a[k]);\n }",
"k == N-1",
"k",
"N-1",
"N",
"1",
"{\n System.out.println(a[k]);\n }",
"System.out.println(a[k])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[k]",
"a",
"k",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int bigger ;\n int a[] = new int[N];\n int i,j,k,x ;\n int count =0;\n for (x =0 ; x < N ; x++){\n a[x] = sc.nextInt();\n }\n for (i = 0; a.length > i;i++ ){\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }\n for(k=0; k<N-1;k++){\n System.out.print(a[k]+ \" \");\n }\n if(k == N-1){\n System.out.println(a[k]);\n }\n System.out.println(count);\n }\n\n}",
"public class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int bigger ;\n int a[] = new int[N];\n int i,j,k,x ;\n int count =0;\n for (x =0 ; x < N ; x++){\n a[x] = sc.nextInt();\n }\n for (i = 0; a.length > i;i++ ){\n for(j=N-1;j>=i+1;j--){\n if(a[j] <a[j-1]){\n bigger = a[j-1];\n a[j-1] = a[j];\n a[j] = bigger;\n count++;\n }\n }\n }\n for(k=0; k<N-1;k++){\n System.out.print(a[k]+ \" \");\n }\n if(k == N-1){\n System.out.println(a[k]);\n }\n System.out.println(count);\n }\n\n}",
"Main"
] |
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int bigger ;
int a[] = new int[N];
int i,j,k,x ;
int count =0;
for (x =0 ; x < N ; x++){
a[x] = sc.nextInt();
}
for (i = 0; a.length > i;i++ ){
for(j=N-1;j>=i+1;j--){
if(a[j] <a[j-1]){
bigger = a[j-1];
a[j-1] = a[j];
a[j] = bigger;
count++;
}
}
}
for(k=0; k<N-1;k++){
System.out.print(a[k]+ " ");
}
if(k == N-1){
System.out.println(a[k]);
}
System.out.println(count);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
18,
13,
13,
41,
13,
18,
13,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
4,
18,
13,
17,
13,
13,
4,
18,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
18,
13,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
4,
18,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
0,
13,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
0,
13,
17,
23,
13,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
37,
20,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
271,
23
],
[
271,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
29,
31
],
[
26,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
34,
36
],
[
26,
37
],
[
37,
38
],
[
37,
39
],
[
26,
40
],
[
40,
41
],
[
40,
42
],
[
26,
43
],
[
43,
44
],
[
43,
45
],
[
26,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
46,
50
],
[
46,
51
],
[
26,
52
],
[
52,
53
],
[
53,
54
],
[
24,
55
],
[
55,
56
],
[
271,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
61,
67
],
[
67,
68
],
[
67,
69
],
[
61,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
71,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
71,
81
],
[
81,
82
],
[
82,
83
],
[
71,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
61,
93
],
[
93,
94
],
[
93,
95
],
[
61,
96
],
[
96,
97
],
[
96,
98
],
[
61,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
105,
114
],
[
114,
115
],
[
114,
116
],
[
105,
117
],
[
117,
118
],
[
118,
119
],
[
105,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
129,
131
],
[
122,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
132,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
132,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
150,
152
],
[
147,
153
],
[
132,
154
],
[
154,
155
],
[
154,
156
],
[
132,
157
],
[
157,
158
],
[
157,
159
],
[
61,
160
],
[
160,
161
],
[
160,
162
],
[
61,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
163,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
170,
172
],
[
163,
173
],
[
173,
174
],
[
174,
175
],
[
163,
176
],
[
177,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
180,
183
],
[
183,
184
],
[
184,
185
],
[
183,
186
],
[
186,
187
],
[
186,
188
],
[
177,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
194,
195
],
[
194,
196
],
[
189,
197
],
[
197,
198
],
[
197,
199
],
[
199,
200
],
[
200,
201
],
[
199,
202
],
[
61,
203
],
[
203,
204
],
[
204,
205
],
[
203,
206
],
[
61,
207
],
[
207,
208
],
[
208,
209
],
[
207,
210
],
[
59,
211
],
[
211,
212
],
[
59,
213
],
[
213,
214
],
[
59,
215
],
[
215,
216
],
[
271,
217
],
[
217,
218
],
[
217,
219
],
[
219,
220
],
[
217,
221
],
[
221,
222
],
[
217,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
],
[
225,
229
],
[
229,
230
],
[
229,
231
],
[
223,
232
],
[
232,
233
],
[
217,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
237,
238
],
[
238,
239
],
[
239,
240
],
[
239,
241
],
[
238,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
237,
246
],
[
246,
247
],
[
247,
248
],
[
248,
249
],
[
248,
250
],
[
250,
251
],
[
251,
252
],
[
247,
253
],
[
253,
254
],
[
254,
255
],
[
254,
256
],
[
236,
257
],
[
257,
258
],
[
258,
259
],
[
259,
260
],
[
217,
261
],
[
261,
262
],
[
261,
263
],
[
263,
264
],
[
264,
265
],
[
265,
266
],
[
266,
267
],
[
265,
268
],
[
268,
269
],
[
0,
270
],
[
270,
271
],
[
270,
272
]
] | [
"import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskB solver = new TaskB();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskB {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n \tint n = in.nextInt();\n \tint a[] = new int [n];\n \tfor (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}\n \t\n \tint num = 0;\n \tboolean flag = true;\n \twhile (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}\n \t\n \tString s = new String();\n \tfor (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}\n \t\n \tout.println(s);\n \tout.println(num);\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n }\n}",
"import java.io.OutputStream;",
"OutputStream",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskB solver = new TaskB();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskB {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n \tint n = in.nextInt();\n \tint a[] = new int [n];\n \tfor (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}\n \t\n \tint num = 0;\n \tboolean flag = true;\n \twhile (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}\n \t\n \tString s = new String();\n \tfor (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}\n \t\n \tout.println(s);\n \tout.println(num);\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskB solver = new TaskB();\n solver.solve(1, in, out);\n out.close();\n }",
"main",
"{\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskB solver = new TaskB();\n solver.solve(1, in, out);\n out.close();\n }",
"InputStream inputStream = System.in;",
"inputStream",
"System.in",
"System",
"System.in",
"OutputStream outputStream = System.out;",
"outputStream",
"System.out",
"System",
"System.out",
"InputReader in = new InputReader(inputStream);",
"in",
"new InputReader(inputStream)",
"PrintWriter out = new PrintWriter(outputStream);",
"out",
"new PrintWriter(outputStream)",
"TaskB solver = new TaskB();",
"solver",
"new TaskB()",
"solver.solve(1, in, out)",
"solver.solve",
"solver",
"1",
"in",
"out",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"static class TaskB {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n \tint n = in.nextInt();\n \tint a[] = new int [n];\n \tfor (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}\n \t\n \tint num = 0;\n \tboolean flag = true;\n \twhile (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}\n \t\n \tString s = new String();\n \tfor (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}\n \t\n \tout.println(s);\n \tout.println(num);\n }\n }",
"TaskB",
"public void solve(int testNumber, InputReader in, PrintWriter out) {\n \tint n = in.nextInt();\n \tint a[] = new int [n];\n \tfor (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}\n \t\n \tint num = 0;\n \tboolean flag = true;\n \twhile (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}\n \t\n \tString s = new String();\n \tfor (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}\n \t\n \tout.println(s);\n \tout.println(num);\n }",
"solve",
"{\n \tint n = in.nextInt();\n \tint a[] = new int [n];\n \tfor (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}\n \t\n \tint num = 0;\n \tboolean flag = true;\n \twhile (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}\n \t\n \tString s = new String();\n \tfor (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}\n \t\n \tout.println(s);\n \tout.println(num);\n }",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int a[] = new int [n];",
"a",
"new int [n]",
"n",
"for (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n \t\ta[i] = in.nextInt();\n \t}",
"{\n \t\ta[i] = in.nextInt();\n \t}",
"a[i] = in.nextInt()",
"a[i]",
"a",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"int num = 0;",
"num",
"0",
"boolean flag = true;",
"flag",
"true",
"while (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}",
"flag",
"{\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}",
"flag = false",
"flag",
"false",
"for (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}",
"int i = a.length - 1;",
"int i = a.length - 1;",
"i",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"i > 0",
"i",
"0",
"i --",
"i --",
"i",
"{\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}",
"{\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}",
"if (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}",
"a[i] < a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"{\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}",
"int t = a[i];",
"t",
"a[i]",
"a",
"i",
"a[i] = a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i-1] = t",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"t",
"flag = true",
"flag",
"true",
"num += 1",
"num",
"1",
"String s = new String();",
"s",
"new String()",
"for (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}",
"{\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}",
"s = s.concat(Integer.toString(a[i]))",
"s",
"s.concat(Integer.toString(a[i]))",
"s.concat",
"s",
"Integer.toString(a[i])",
"Integer.toString",
"Integer",
"a[i]",
"a",
"i",
"if (i + 1 != a.length) s = s.concat(\" \");",
"i + 1 != a.length",
"i + 1",
"i",
"1",
"a.length",
"a",
"a.length",
"s = s.concat(\" \")",
"s",
"s.concat(\" \")",
"s.concat",
"s",
"\" \"",
"out.println(s)",
"out.println",
"out",
"s",
"out.println(num)",
"out.println",
"out",
"num",
"int testNumber",
"testNumber",
"InputReader in",
"in",
"PrintWriter out",
"out",
"static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n }",
"InputReader",
"public BufferedReader reader;",
"reader",
"public StringTokenizer tokenizer;",
"tokenizer",
"public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }",
"InputReader",
"{\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }",
"reader = new BufferedReader(new InputStreamReader(stream), 32768)",
"reader",
"new BufferedReader(new InputStreamReader(stream), 32768)",
"tokenizer = null",
"tokenizer",
"null",
"InputStream stream",
"stream",
"public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }",
"next",
"{\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }",
"while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }",
"tokenizer == null || !tokenizer.hasMoreTokens()",
"tokenizer == null",
"tokenizer",
"null",
"!tokenizer.hasMoreTokens()",
"tokenizer.hasMoreTokens()",
"tokenizer.hasMoreTokens",
"tokenizer",
"{\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }",
"try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }",
"catch (IOException e) {\n throw new RuntimeException(e);\n }",
"IOException e",
"{\n throw new RuntimeException(e);\n }",
"throw new RuntimeException(e);",
"new RuntimeException(e)",
"{\n tokenizer = new StringTokenizer(reader.readLine());\n }",
"tokenizer = new StringTokenizer(reader.readLine())",
"tokenizer",
"new StringTokenizer(reader.readLine())",
"return tokenizer.nextToken();",
"tokenizer.nextToken()",
"tokenizer.nextToken",
"tokenizer",
"public int nextInt() {\n return Integer.parseInt(next());\n }",
"nextInt",
"{\n return Integer.parseInt(next());\n }",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskB solver = new TaskB();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskB {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n \tint n = in.nextInt();\n \tint a[] = new int [n];\n \tfor (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}\n \t\n \tint num = 0;\n \tboolean flag = true;\n \twhile (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}\n \t\n \tString s = new String();\n \tfor (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}\n \t\n \tout.println(s);\n \tout.println(num);\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskB solver = new TaskB();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskB {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n \tint n = in.nextInt();\n \tint a[] = new int [n];\n \tfor (int i = 0; i < a.length; i++) {\n \t\ta[i] = in.nextInt();\n \t}\n \t\n \tint num = 0;\n \tboolean flag = true;\n \twhile (flag) {\n \t\tflag = false;\n \t\tfor (int i = a.length - 1; i > 0; i --) {\n \t\t\tif (a[i] < a[i-1]) {\n \t\t\t\tint t = a[i];\n \t\t\t\ta[i] = a[i-1];\n \t\t\t\ta[i-1] = t;\n \t\t\t\tflag = true;\n \t\t\t\tnum += 1;\n \t\t\t}\n \t\t}\n \t}\n \t\n \tString s = new String();\n \tfor (int i = 0; i < a.length; i++) {\n \t\ts = s.concat(Integer.toString(a[i]));\n \t\tif (i + 1 != a.length) s = s.concat(\" \");\n \t}\n \t\n \tout.println(s);\n \tout.println(num);\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n }\n}",
"Main"
] | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskB solver = new TaskB();
solver.solve(1, in, out);
out.close();
}
static class TaskB {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
int a[] = new int [n];
for (int i = 0; i < a.length; i++) {
a[i] = in.nextInt();
}
int num = 0;
boolean flag = true;
while (flag) {
flag = false;
for (int i = a.length - 1; i > 0; i --) {
if (a[i] < a[i-1]) {
int t = a[i];
a[i] = a[i-1];
a[i-1] = t;
flag = true;
num += 1;
}
}
}
String s = new String();
for (int i = 0; i < a.length; i++) {
s = s.concat(Integer.toString(a[i]));
if (i + 1 != a.length) s = s.concat(" ");
}
out.println(s);
out.println(num);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
11,
1,
41,
13,
17,
2,
13,
2,
18,
13,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
4,
13,
13,
13,
2,
13,
17,
40,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
181,
5
],
[
181,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
6,
44
],
[
44,
45
],
[
181,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
52,
62
],
[
62,
63
],
[
63,
64
],
[
52,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
67,
79
],
[
79,
80
],
[
80,
81
],
[
67,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
84,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
95,
98
],
[
95,
99
],
[
99,
100
],
[
99,
101
],
[
94,
102
],
[
102,
103
],
[
48,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
104,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
104,
114
],
[
114,
115
],
[
115,
116
],
[
104,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
123,
128
],
[
128,
129
],
[
128,
130
],
[
119,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
138,
140
],
[
48,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
48,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
46,
152
],
[
152,
153
],
[
181,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
159,
161
],
[
156,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
166,
167
],
[
166,
168
],
[
156,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
154,
174
],
[
174,
175
],
[
154,
176
],
[
176,
177
],
[
154,
178
],
[
178,
179
],
[
0,
180
],
[
180,
181
],
[
180,
182
]
] | [
"import java.util.*;\npublic class Main {\n\tpublic static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tnums[i] = sc.nextInt();\n\t\t}\n\t\tBubbleSort(nums);\n\t\t\n\t\t\n\t}\n\tpublic static void BubbleSort(int[] nums){\n\t\tint swap_count =0;\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap_count);\n\t}\n\tpublic static void swap(int[] nums,int i,int j){\n\t\tint temp = nums[i];\n\t\tnums[i] = nums[j];\n\t\tnums[j] = temp; \n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tnums[i] = sc.nextInt();\n\t\t}\n\t\tBubbleSort(nums);\n\t\t\n\t\t\n\t}\n\tpublic static void BubbleSort(int[] nums){\n\t\tint swap_count =0;\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap_count);\n\t}\n\tpublic static void swap(int[] nums,int i,int j){\n\t\tint temp = nums[i];\n\t\tnums[i] = nums[j];\n\t\tnums[j] = temp; \n\t}\n}",
"Main",
"public static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tnums[i] = sc.nextInt();\n\t\t}\n\t\tBubbleSort(nums);\n\t\t\n\t\t\n\t}",
"main",
"{\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tnums[i] = sc.nextInt();\n\t\t}\n\t\tBubbleSort(nums);\n\t\t\n\t\t\n\t}",
"Scanner sc =new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] nums = new int[n];",
"nums",
"new int[n]",
"n",
"for(int i=0;i<n;i++){\n\t\t\tnums[i] = sc.nextInt();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tnums[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tnums[i] = sc.nextInt();\n\t\t}",
"nums[i] = sc.nextInt()",
"nums[i]",
"nums",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"BubbleSort(nums)",
"BubbleSort",
"nums",
"String args[]",
"args",
"public static void BubbleSort(int[] nums){\n\t\tint swap_count =0;\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap_count);\n\t}",
"BubbleSort",
"{\n\t\tint swap_count =0;\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap_count);\n\t}",
"int swap_count =0;",
"swap_count",
"0",
"for(int i=0;i<nums.length;i++){\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<nums.length",
"i",
"nums.length",
"nums",
"nums.length",
"i++",
"i++",
"i",
"{\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}",
"int j=1;",
"int j=1;",
"j",
"1",
"j<nums.length-i",
"j",
"nums.length-i",
"nums.length",
"nums",
"nums.length",
"i",
"j++",
"j++",
"j",
"{\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}",
"if(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}",
"nums[j]<nums[j-1]",
"nums[j]",
"nums",
"j",
"nums[j-1]",
"nums",
"j-1",
"j",
"1",
"{\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}",
"swap(nums,j,j-1)",
"swap",
"nums",
"j",
"j-1",
"j",
"1",
"swap_count++",
"swap_count",
"for(int i=0;i<nums.length;i++){\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<nums.length",
"i",
"nums.length",
"nums",
"nums.length",
"i++",
"i++",
"i",
"{\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}",
"{\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}",
"if(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);",
"i==0",
"i",
"0",
"System.out.print(nums[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"nums[i]",
"nums",
"i",
"System.out.print(\" \"+nums[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"+nums[i]",
"\" \"",
"nums[i]",
"nums",
"i",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"System.out.println(swap_count)",
"System.out.println",
"System.out",
"System",
"System.out",
"swap_count",
"int[] nums",
"nums",
"public static void swap(int[] nums,int i,int j){\n\t\tint temp = nums[i];\n\t\tnums[i] = nums[j];\n\t\tnums[j] = temp; \n\t}",
"swap",
"{\n\t\tint temp = nums[i];\n\t\tnums[i] = nums[j];\n\t\tnums[j] = temp; \n\t}",
"int temp = nums[i];",
"temp",
"nums[i]",
"nums",
"i",
"nums[i] = nums[j]",
"nums[i]",
"nums",
"i",
"nums[j]",
"nums",
"j",
"nums[j] = temp",
"nums[j]",
"nums",
"j",
"temp",
"int[] nums",
"nums",
"int i",
"i",
"int j",
"j",
"public class Main {\n\tpublic static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tnums[i] = sc.nextInt();\n\t\t}\n\t\tBubbleSort(nums);\n\t\t\n\t\t\n\t}\n\tpublic static void BubbleSort(int[] nums){\n\t\tint swap_count =0;\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap_count);\n\t}\n\tpublic static void swap(int[] nums,int i,int j){\n\t\tint temp = nums[i];\n\t\tnums[i] = nums[j];\n\t\tnums[j] = temp; \n\t}\n}",
"public class Main {\n\tpublic static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] nums = new int[n];\n\t\tfor(int i=0;i<n;i++){\n\t\t\tnums[i] = sc.nextInt();\n\t\t}\n\t\tBubbleSort(nums);\n\t\t\n\t\t\n\t}\n\tpublic static void BubbleSort(int[] nums){\n\t\tint swap_count =0;\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tfor(int j=1;j<nums.length-i;j++){\n\t\t\t\tif(nums[j]<nums[j-1]){\n\t\t\t\t\tswap(nums,j,j-1);\n\t\t\t\t\tswap_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<nums.length;i++){\n\t\t\tif(i==0)System.out.print(nums[i]);\n\t\t\telse System.out.print(\" \"+nums[i]);\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(swap_count);\n\t}\n\tpublic static void swap(int[] nums,int i,int j){\n\t\tint temp = nums[i];\n\t\tnums[i] = nums[j];\n\t\tnums[j] = temp; \n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String args[]){
Scanner sc =new Scanner(System.in);
int n = sc.nextInt();
int[] nums = new int[n];
for(int i=0;i<n;i++){
nums[i] = sc.nextInt();
}
BubbleSort(nums);
}
public static void BubbleSort(int[] nums){
int swap_count =0;
for(int i=0;i<nums.length;i++){
for(int j=1;j<nums.length-i;j++){
if(nums[j]<nums[j-1]){
swap(nums,j,j-1);
swap_count++;
}
}
}
for(int i=0;i<nums.length;i++){
if(i==0)System.out.print(nums[i]);
else System.out.print(" "+nums[i]);
}
System.out.println();
System.out.println(swap_count);
}
public static void swap(int[] nums,int i,int j){
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
17,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
42,
13,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
14,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
29,
34
],
[
34,
35
],
[
34,
36
],
[
29,
37
],
[
37,
38
],
[
38,
39
],
[
29,
40
],
[
41,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
42,
46
],
[
46,
47
],
[
47,
48
],
[
8,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
55,
62
],
[
62,
63
],
[
62,
64
],
[
55,
65
],
[
65,
66
],
[
66,
67
],
[
55,
68
],
[
69,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
70,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
80,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
80,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
80,
102
],
[
102,
103
],
[
80,
104
],
[
104,
105
],
[
104,
106
],
[
8,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
107,
117
],
[
117,
118
],
[
118,
119
],
[
107,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
121,
127
],
[
127,
128
],
[
127,
129
],
[
8,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
130,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
137,
139
],
[
8,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
6,
146
],
[
146,
147
]
] | [
"import java.util.*;\nclass Main{\n public static void main(String args[]){\n boolean flag = true;\n int tmp;\n int count = 0;\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int Array [] = new int[n];\n //input\n for(int i = 0; i<n; i++){\n Array[i] = sc.nextInt();\n }\n //bubblesort\n while(flag){\n flag = false;\n for(int j = n-1; j>0; j--){\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0; i<n-1; i++)System.out.printf(\"%d \",Array[i]);\n System.out.println(Array[n-1]);\n System.out.println(count);\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class Main{\n public static void main(String args[]){\n boolean flag = true;\n int tmp;\n int count = 0;\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int Array [] = new int[n];\n //input\n for(int i = 0; i<n; i++){\n Array[i] = sc.nextInt();\n }\n //bubblesort\n while(flag){\n flag = false;\n for(int j = n-1; j>0; j--){\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0; i<n-1; i++)System.out.printf(\"%d \",Array[i]);\n System.out.println(Array[n-1]);\n System.out.println(count);\n }\n}",
"Main",
"public static void main(String args[]){\n boolean flag = true;\n int tmp;\n int count = 0;\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int Array [] = new int[n];\n //input\n for(int i = 0; i<n; i++){\n Array[i] = sc.nextInt();\n }\n //bubblesort\n while(flag){\n flag = false;\n for(int j = n-1; j>0; j--){\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0; i<n-1; i++)System.out.printf(\"%d \",Array[i]);\n System.out.println(Array[n-1]);\n System.out.println(count);\n }",
"main",
"{\n boolean flag = true;\n int tmp;\n int count = 0;\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int Array [] = new int[n];\n //input\n for(int i = 0; i<n; i++){\n Array[i] = sc.nextInt();\n }\n //bubblesort\n while(flag){\n flag = false;\n for(int j = n-1; j>0; j--){\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }\n }\n for(int i = 0; i<n-1; i++)System.out.printf(\"%d \",Array[i]);\n System.out.println(Array[n-1]);\n System.out.println(count);\n }",
"boolean flag = true;",
"flag",
"true",
"int tmp;",
"tmp",
"int count = 0;",
"count",
"0",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int Array [] = new int[n];",
"Array",
"new int[n]",
"n",
"for(int i = 0; i<n; i++){\n Array[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Array[i] = sc.nextInt();\n }",
"{\n Array[i] = sc.nextInt();\n }",
"Array[i] = sc.nextInt()",
"Array[i]",
"Array",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(flag){\n flag = false;\n for(int j = n-1; j>0; j--){\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }\n }",
"flag",
"{\n flag = false;\n for(int j = n-1; j>0; j--){\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }\n }",
"flag = false",
"flag",
"false",
"for(int j = n-1; j>0; j--){\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }",
"int j = n-1;",
"int j = n-1;",
"j",
"n-1",
"n",
"1",
"j>0",
"j",
"0",
"j--",
"j--",
"j",
"{\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }",
"{\n if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }\n }",
"if(Array[j]<Array[j-1]){\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }",
"Array[j]<Array[j-1]",
"Array[j]",
"Array",
"j",
"Array[j-1]",
"Array",
"j-1",
"j",
"1",
"{\n tmp = Array[j];\n Array[j] = Array[j-1];\n Array[j-1] = tmp;\n count++;\n flag = true;\n }",
"tmp = Array[j]",
"tmp",
"Array[j]",
"Array",
"j",
"Array[j] = Array[j-1]",
"Array[j]",
"Array",
"j",
"Array[j-1]",
"Array",
"j-1",
"j",
"1",
"Array[j-1] = tmp",
"Array[j-1]",
"Array",
"j-1",
"j",
"1",
"tmp",
"count++",
"count",
"flag = true",
"flag",
"true",
"for(int i = 0; i<n-1; i++)System.out.printf(\"%d \",Array[i]);",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"System.out.printf(\"%d \",Array[i]);",
"System.out.printf(\"%d \",Array[i])",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d \"",
"Array[i]",
"Array",
"i",
"System.out.println(Array[n-1])",
"System.out.println",
"System.out",
"System",
"System.out",
"Array[n-1]",
"Array",
"n-1",
"n",
"1",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String args[]",
"args"
] | import java.util.*;
class Main{
public static void main(String args[]){
boolean flag = true;
int tmp;
int count = 0;
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int Array [] = new int[n];
//input
for(int i = 0; i<n; i++){
Array[i] = sc.nextInt();
}
//bubblesort
while(flag){
flag = false;
for(int j = n-1; j>0; j--){
if(Array[j]<Array[j-1]){
tmp = Array[j];
Array[j] = Array[j-1];
Array[j-1] = tmp;
count++;
flag = true;
}
}
}
for(int i = 0; i<n-1; i++)System.out.printf("%d ",Array[i]);
System.out.println(Array[n-1]);
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
41,
13,
41,
13,
17,
42,
2,
13,
17,
30,
0,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
13,
40,
13,
0,
13,
17,
40,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
13,
17,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
179,
5
],
[
179,
6
],
[
6,
7
],
[
6,
8
],
[
179,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
11,
14
],
[
14,
15
],
[
11,
16
],
[
16,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
11,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
27,
32
],
[
32,
33
],
[
32,
34
],
[
27,
35
],
[
35,
36
],
[
36,
37
],
[
27,
38
],
[
39,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
45,
46
],
[
11,
47
],
[
47,
48
],
[
47,
49
],
[
47,
50
],
[
9,
51
],
[
51,
52
],
[
179,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
59,
61
],
[
55,
62
],
[
62,
63
],
[
55,
64
],
[
64,
65
],
[
64,
66
],
[
55,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
75,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
75,
87
],
[
87,
88
],
[
88,
89
],
[
75,
90
],
[
91,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
92,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
102,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
117,
123
],
[
102,
124
],
[
124,
125
],
[
102,
126
],
[
126,
127
],
[
126,
128
],
[
71,
129
],
[
129,
130
],
[
55,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
136,
137
],
[
136,
138
],
[
131,
139
],
[
139,
140
],
[
140,
141
],
[
131,
142
],
[
143,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
147,
149
],
[
144,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
150,
155
],
[
155,
156
],
[
155,
157
],
[
144,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
55,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
168,
173
],
[
53,
174
],
[
174,
175
],
[
53,
176
],
[
176,
177
],
[
0,
178
],
[
178,
179
],
[
178,
180
]
] | [
"import java.util.Scanner;\npublic class Main {\n\tpublic static Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint i, j, k;\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tbubblesort(n, a);\n\t}\n\tpublic static void bubblesort(int n, int a[]){\n\t\tint flag = 1;\n\t\tint i = 0;\n\t\tint temp;\n\t\tint count = 0;\n\t\twhile(flag == 1){\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tfor(i = 0; i < n; i++){\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint i, j, k;\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tbubblesort(n, a);\n\t}\n\tpublic static void bubblesort(int n, int a[]){\n\t\tint flag = 1;\n\t\tint i = 0;\n\t\tint temp;\n\t\tint count = 0;\n\t\twhile(flag == 1){\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tfor(i = 0; i < n; i++){\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main",
"public static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args) {\n\t\tint i, j, k;\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tbubblesort(n, a);\n\t}",
"main",
"{\n\t\tint i, j, k;\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tbubblesort(n, a);\n\t}",
"int i",
"i",
"j",
"j",
"k;",
"k",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int a[] = new int[n];",
"a",
"new int[n]",
"n",
"for(i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\ta[i] = sc.nextInt();\n\t\t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"bubblesort(n, a)",
"bubblesort",
"n",
"a",
"String[] args",
"args",
"public static void bubblesort(int n, int a[]){\n\t\tint flag = 1;\n\t\tint i = 0;\n\t\tint temp;\n\t\tint count = 0;\n\t\twhile(flag == 1){\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tfor(i = 0; i < n; i++){\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"bubblesort",
"{\n\t\tint flag = 1;\n\t\tint i = 0;\n\t\tint temp;\n\t\tint count = 0;\n\t\twhile(flag == 1){\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tfor(i = 0; i < n; i++){\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"int flag = 1;",
"flag",
"1",
"int i = 0;",
"i",
"0",
"int temp;",
"temp",
"int count = 0;",
"count",
"0",
"while(flag == 1){\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}",
"flag == 1",
"flag",
"1",
"{\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}",
"flag = 0",
"flag",
"0",
"for(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}",
"int j = n - 1;",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"j >= i + 1",
"j",
"i + 1",
"i",
"1",
"j--",
"j--",
"j",
"{\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}",
"if(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}",
"a[j] < a[j - 1]",
"a[j]",
"a",
"j",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"{\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}",
"temp = a[j]",
"temp",
"a[j]",
"a",
"j",
"a[j] = a[j-1]",
"a[j]",
"a",
"j",
"a[j-1]",
"a",
"j-1",
"j",
"1",
"a[j - 1] = temp",
"a[j - 1]",
"a",
"j - 1",
"j",
"1",
"temp",
"count++",
"count",
"flag = 1",
"flag",
"1",
"i++",
"i",
"for(i = 0; i < n; i++){\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}",
"{\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}",
"if(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");",
"i == n - 1",
"i",
"n - 1",
"n",
"1",
"System.out.println(a[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"a[i]",
"a",
"i",
"System.out.print(a[i] + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"a[i] + \" \"",
"a[i]",
"a",
"i",
"\" \"",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"int n",
"n",
"int a[]",
"a",
"public class Main {\n\tpublic static Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint i, j, k;\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tbubblesort(n, a);\n\t}\n\tpublic static void bubblesort(int n, int a[]){\n\t\tint flag = 1;\n\t\tint i = 0;\n\t\tint temp;\n\t\tint count = 0;\n\t\twhile(flag == 1){\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tfor(i = 0; i < n; i++){\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"public class Main {\n\tpublic static Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint i, j, k;\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tbubblesort(n, a);\n\t}\n\tpublic static void bubblesort(int n, int a[]){\n\t\tint flag = 1;\n\t\tint i = 0;\n\t\tint temp;\n\t\tint count = 0;\n\t\twhile(flag == 1){\n\t\t\tflag = 0;\n\t\t\tfor(int j = n - 1; j >= i + 1; j--){\n\t\t\t\tif(a[j] < a[j - 1]){\n\t\t\t\t\ttemp = a[j];\n\t\t\t\t\ta[j] = a[j-1];\n\t\t\t\t\ta[j - 1] = temp;\n\t\t\t\t\tcount++;\n\t\t\t\t\tflag = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tfor(i = 0; i < n; i++){\n\t\t\tif(i == n - 1) System.out.println(a[i]);\n\t\t\telse System.out.print(a[i] + \" \");\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int i, j, k;
int n = sc.nextInt();
int a[] = new int[n];
for(i = 0; i < n; i++){
a[i] = sc.nextInt();
}
bubblesort(n, a);
}
public static void bubblesort(int n, int a[]){
int flag = 1;
int i = 0;
int temp;
int count = 0;
while(flag == 1){
flag = 0;
for(int j = n - 1; j >= i + 1; j--){
if(a[j] < a[j - 1]){
temp = a[j];
a[j] = a[j-1];
a[j - 1] = temp;
count++;
flag = 1;
}
}
i++;
}
for(i = 0; i < n; i++){
if(i == n - 1) System.out.println(a[i]);
else System.out.print(a[i] + " ");
}
System.out.println(count);
}
}
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.