node_ids
listlengths 4
1.4k
| edge_index
listlengths 1
2.22k
| text
listlengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
14,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
98,
5
],
[
98,
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
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
59,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
60,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
74,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
8,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
86,
91
],
[
8,
92
],
[
92,
93
],
[
93,
94
],
[
6,
95
],
[
95,
96
],
[
0,
97
],
[
97,
98
],
[
97,
99
]
]
| [
"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[] height = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\theight[i] = sc.nextInt();\n\t\t}\n\n\t\tint temp = 0;\n\t\tlong totalStandHeight = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(totalStandHeight);\n\n\t\tsc.close();\n\n\t}\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[] height = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\theight[i] = sc.nextInt();\n\t\t}\n\n\t\tint temp = 0;\n\t\tlong totalStandHeight = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(totalStandHeight);\n\n\t\tsc.close();\n\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[] height = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\theight[i] = sc.nextInt();\n\t\t}\n\n\t\tint temp = 0;\n\t\tlong totalStandHeight = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(totalStandHeight);\n\n\t\tsc.close();\n\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint[] height = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\theight[i] = sc.nextInt();\n\t\t}\n\n\t\tint temp = 0;\n\t\tlong totalStandHeight = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(totalStandHeight);\n\n\t\tsc.close();\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[] height = new int[n];",
"height",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\theight[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\theight[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\theight[i] = sc.nextInt();\n\t\t}",
"height[i] = sc.nextInt()",
"height[i]",
"height",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int temp = 0;",
"temp",
"0",
"long totalStandHeight = 0;",
"totalStandHeight",
"0",
"for (int i = 0; i < n; i++) {\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}",
"{\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}",
"if (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}",
"temp > height[i]",
"temp",
"height[i]",
"height",
"i",
"{\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t}",
"totalStandHeight += temp - height[i]",
"totalStandHeight",
"temp - height[i]",
"temp",
"height[i]",
"height",
"i",
"if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}",
"temp < height[i]",
"temp",
"height[i]",
"height",
"i",
"{\n\t\t\t\ttemp = height[i];\n\t\t\t}",
"temp = height[i]",
"temp",
"height[i]",
"height",
"i",
"System.out.println(totalStandHeight)",
"System.out.println",
"System.out",
"System",
"System.out",
"totalStandHeight",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"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[] height = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\theight[i] = sc.nextInt();\n\t\t}\n\n\t\tint temp = 0;\n\t\tlong totalStandHeight = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(totalStandHeight);\n\n\t\tsc.close();\n\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[] height = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\theight[i] = sc.nextInt();\n\t\t}\n\n\t\tint temp = 0;\n\t\tlong totalStandHeight = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\n\t\t\tif (temp > height[i]) {\n\t\t\t\ttotalStandHeight += temp - height[i];\n\t\t\t} else if (temp < height[i]) {\n\t\t\t\ttemp = height[i];\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(totalStandHeight);\n\n\t\tsc.close();\n\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[] height = new int[n];
for (int i = 0; i < n; i++) {
height[i] = sc.nextInt();
}
int temp = 0;
long totalStandHeight = 0;
for (int i = 0; i < n; i++) {
if (temp > height[i]) {
totalStandHeight += temp - height[i];
} else if (temp < height[i]) {
temp = height[i];
}
}
System.out.println(totalStandHeight);
sc.close();
}
}
|
[
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,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
18,
13,
2,
13,
17,
41,
13,
2,
13,
18,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
2,
13,
13,
18,
13,
13,
0,
18,
13,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
106,
5
],
[
106,
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
],
[
42,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
59,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
59,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
59,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
8,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
6,
103
],
[
103,
104
],
[
0,
105
],
[
105,
106
],
[
105,
107
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] array = new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tarray[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\n\t\tlong ans = 0L;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\n\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] array = new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tarray[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\n\t\tlong ans = 0L;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] array = new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tarray[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\n\t\tlong ans = 0L;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\n\n\t}",
"main",
"{\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] array = new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tarray[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\n\t\tlong ans = 0L;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] array = new long[n];",
"array",
"new long[n]",
"n",
"for(int i=0;i<n;i++) {\n\t\t\tarray[i] = sc.nextLong();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarray[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\tarray[i] = sc.nextLong();\n\t\t}",
"array[i] = sc.nextLong()",
"array[i]",
"array",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"sc.close()",
"sc.close",
"sc",
"long ans = 0L;",
"ans",
"0L",
"for(int i=1;i<n;i++) {\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\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\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}",
"{\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}",
"long tmp = array[i-1];",
"tmp",
"array[i-1]",
"array",
"i-1",
"i",
"1",
"long sa = tmp-array[i];",
"sa",
"tmp-array[i]",
"tmp",
"array[i]",
"array",
"i",
"if(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}",
"sa>0",
"sa",
"0",
"{\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}",
"ans = ans + tmp-array[i]",
"ans",
"ans + tmp-array[i]",
"ans + tmp",
"ans",
"tmp",
"array[i]",
"array",
"i",
"array[i] = sa + array[i]",
"array[i]",
"array",
"i",
"sa + array[i]",
"sa",
"array[i]",
"array",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] array = new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tarray[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\n\t\tlong ans = 0L;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\n\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] array = new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tarray[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\n\t\tlong ans = 0L;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tlong tmp = array[i-1];\n\t\t\tlong sa = tmp-array[i];\n\t\t\tif(sa>0) {\n\t\t\t\tans = ans + tmp-array[i];\n\t\t\t\tarray[i] = sa + array[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\n\n\t}\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] array = new long[n];
for(int i=0;i<n;i++) {
array[i] = sc.nextLong();
}
sc.close();
long ans = 0L;
for(int i=1;i<n;i++) {
long tmp = array[i-1];
long sa = tmp-array[i];
if(sa>0) {
ans = ans + tmp-array[i];
array[i] = sa + array[i];
}
}
System.out.println(ans);
}
}
|
[
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,
20,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
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
],
[
108,
8
],
[
108,
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
],
[
11,
27
],
[
27,
28
],
[
27,
29
],
[
11,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
30,
35
],
[
35,
36
],
[
35,
37
],
[
30,
38
],
[
38,
39
],
[
39,
40
],
[
30,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
42,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
50,
51
],
[
11,
52
],
[
52,
53
],
[
52,
54
],
[
11,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
55,
60
],
[
60,
61
],
[
60,
62
],
[
55,
63
],
[
63,
64
],
[
64,
65
],
[
55,
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
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
78,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
11,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
9,
105
],
[
105,
106
],
[
0,
107
],
[
107,
108
],
[
107,
109
]
]
| [
"import java.util.*;\nimport java.io.*;\npublic class Main {\n\n\tpublic static void main(String[] args) throws java.lang.Exception\n {\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n =Integer.parseInt(br.readLine()),a[]=new int[n];\n\t\tStringTokenizer st=new StringTokenizer(br.readLine());\n\t\tfor(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());\n\t\tlong sum=0;\n\t\tfor(int i=1; i<n; i++) {\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) throws java.lang.Exception\n {\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n =Integer.parseInt(br.readLine()),a[]=new int[n];\n\t\tStringTokenizer st=new StringTokenizer(br.readLine());\n\t\tfor(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());\n\t\tlong sum=0;\n\t\tfor(int i=1; i<n; i++) {\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws java.lang.Exception\n {\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n =Integer.parseInt(br.readLine()),a[]=new int[n];\n\t\tStringTokenizer st=new StringTokenizer(br.readLine());\n\t\tfor(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());\n\t\tlong sum=0;\n\t\tfor(int i=1; i<n; i++) {\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}",
"main",
"{\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n =Integer.parseInt(br.readLine()),a[]=new int[n];\n\t\tStringTokenizer st=new StringTokenizer(br.readLine());\n\t\tfor(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());\n\t\tlong sum=0;\n\t\tfor(int i=1; i<n; i++) {\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\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",
"a[]=new int[n];",
"a",
"new int[n]",
"n",
"StringTokenizer st=new StringTokenizer(br.readLine());",
"st",
"new StringTokenizer(br.readLine())",
"for(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=Integer.parseInt(st.nextToken());",
"a[i]=Integer.parseInt(st.nextToken())",
"a[i]",
"a",
"i",
"Integer.parseInt(st.nextToken())",
"Integer.parseInt",
"Integer",
"st.nextToken()",
"st.nextToken",
"st",
"long sum=0;",
"sum",
"0",
"for(int i=1; i<n; i++) {\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\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\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}",
"if(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-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\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}",
"sum+=(a[i-1]-a[i])",
"sum",
"(a[i-1]-a[i])",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i]",
"a",
"i",
"a[i]=a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) throws java.lang.Exception\n {\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n =Integer.parseInt(br.readLine()),a[]=new int[n];\n\t\tStringTokenizer st=new StringTokenizer(br.readLine());\n\t\tfor(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());\n\t\tlong sum=0;\n\t\tfor(int i=1; i<n; i++) {\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws java.lang.Exception\n {\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n =Integer.parseInt(br.readLine()),a[]=new int[n];\n\t\tStringTokenizer st=new StringTokenizer(br.readLine());\n\t\tfor(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());\n\t\tlong sum=0;\n\t\tfor(int i=1; i<n; i++) {\n\t\t\tif(a[i]<a[i-1]) {\n\t\t\t\tsum+=(a[i-1]-a[i]);\n\t\t\t\ta[i]=a[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n}",
"Main"
]
| import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws java.lang.Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine()),a[]=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0; i<n; i++) a[i]=Integer.parseInt(st.nextToken());
long sum=0;
for(int i=1; i<n; i++) {
if(a[i]<a[i-1]) {
sum+=(a[i-1]-a[i]);
a[i]=a[i-1];
}
}
System.out.println(sum);
}
}
|
[
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,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
0,
13,
2,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
9,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
92,
5
],
[
92,
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
],
[
8,
45
],
[
45,
46
],
[
45,
47
],
[
8,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
48,
53
],
[
53,
54
],
[
53,
55
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
48,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
61,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
61,
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
],
[
6,
89
],
[
89,
90
],
[
0,
91
],
[
91,
92
],
[
91,
93
]
]
| [
"import java.util.*;\n\npublic class Main{\n\tpublic static void main(String arg[]){\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\tint t=a[0];\n\t\tlong sum=0;\n\t\tfor(int i=1;i<n;i++){\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\tpublic static void main(String arg[]){\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\tint t=a[0];\n\t\tlong sum=0;\n\t\tfor(int i=1;i<n;i++){\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n}",
"Main",
"public static void main(String arg[]){\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\tint t=a[0];\n\t\tlong sum=0;\n\t\tfor(int i=1;i<n;i++){\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\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\tint t=a[0];\n\t\tlong sum=0;\n\t\tfor(int i=1;i<n;i++){\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\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();",
"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 t=a[0];",
"t",
"a[0]",
"a",
"0",
"long sum=0;",
"sum",
"0",
"for(int i=1;i<n;i++){\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\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\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}",
"if(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}",
"t>a[i]",
"t",
"a[i]",
"a",
"i",
"sum=sum+(t-a[i])",
"sum",
"sum+(t-a[i])",
"sum",
"(t-a[i])",
"t",
"a[i]",
"a",
"i",
"{\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}",
"t=a[i]",
"t",
"a[i]",
"a",
"i",
"continue;",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String arg[]",
"arg",
"public class Main{\n\tpublic static void main(String arg[]){\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\tint t=a[0];\n\t\tlong sum=0;\n\t\tfor(int i=1;i<n;i++){\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n}",
"public class Main{\n\tpublic static void main(String arg[]){\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\tint t=a[0];\n\t\tlong sum=0;\n\t\tfor(int i=1;i<n;i++){\n\t\t\tif(t>a[i])\n\t\t\t\tsum=sum+(t-a[i]);\n\t\t\telse {\n\t\t\t\tt=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n}",
"Main"
]
| import java.util.*;
public class Main{
public static void main(String arg[]){
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 t=a[0];
long sum=0;
for(int i=1;i<n;i++){
if(t>a[i])
sum=sum+(t-a[i]);
else {
t=a[i];
continue;
}
}
System.out.println(sum);
}
} |
[
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,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
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
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
203,
23
],
[
203,
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
],
[
64,
65
],
[
64,
66
],
[
26,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
72,
73
],
[
72,
74
],
[
67,
75
],
[
75,
76
],
[
76,
77
],
[
67,
78
],
[
79,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
80,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
80,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
94,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
26,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
24,
112
],
[
112,
113
],
[
203,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
114,
118
],
[
118,
119
],
[
114,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
114,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
129,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
139,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
128,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
114,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
158,
161
],
[
161,
162
],
[
114,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
167,
170
],
[
170,
171
],
[
114,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
179,
180
],
[
114,
181
],
[
181,
182
],
[
181,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
187,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
183,
200
],
[
200,
201
],
[
0,
202
],
[
202,
203
],
[
202,
204
]
]
| [
"\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.math.BigInteger;\nimport java.util.*;\nimport java.util.stream.Collectors;\nimport java.util.stream.Stream;\n\npublic class Main {\n static class FastReader {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n\n public static void main(String[] args) throws Exception {\n FastReader fr = new FastReader();\n int n = fr.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = fr.nextInt();\n }\n long ans = 0;\n long maxTillNow = arr[0];\n for (int i = 1; i < n; i++) {\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }\n System.out.println(ans);\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.math.BigInteger;",
"BigInteger",
"java.math",
"import java.util.*;",
"util.*",
"java",
"import java.util.stream.Collectors;",
"Collectors",
"java.util.stream",
"import java.util.stream.Stream;",
"Stream",
"java.util.stream",
"public class Main {\n static class FastReader {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n\n public static void main(String[] args) throws Exception {\n FastReader fr = new FastReader();\n int n = fr.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = fr.nextInt();\n }\n long ans = 0;\n long maxTillNow = arr[0];\n for (int i = 1; i < n; i++) {\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }\n System.out.println(ans);\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n FastReader fr = new FastReader();\n int n = fr.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = fr.nextInt();\n }\n long ans = 0;\n long maxTillNow = arr[0];\n for (int i = 1; i < n; i++) {\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }\n System.out.println(ans);\n }",
"main",
"{\n FastReader fr = new FastReader();\n int n = fr.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = fr.nextInt();\n }\n long ans = 0;\n long maxTillNow = arr[0];\n for (int i = 1; i < n; i++) {\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }\n System.out.println(ans);\n }",
"FastReader fr = new FastReader();",
"fr",
"new FastReader()",
"int n = fr.nextInt();",
"n",
"fr.nextInt()",
"fr.nextInt",
"fr",
"long[] arr = new long[n];",
"arr",
"new long[n]",
"n",
"for (int i = 0; i < n; i++) {\n arr[i] = fr.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n arr[i] = fr.nextInt();\n }",
"{\n arr[i] = fr.nextInt();\n }",
"arr[i] = fr.nextInt()",
"arr[i]",
"arr",
"i",
"fr.nextInt()",
"fr.nextInt",
"fr",
"long ans = 0;",
"ans",
"0",
"long maxTillNow = arr[0];",
"maxTillNow",
"arr[0]",
"arr",
"0",
"for (int i = 1; i < n; i++) {\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }",
"{\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }",
"if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }",
"arr[i]<maxTillNow",
"arr[i]",
"arr",
"i",
"maxTillNow",
"{\n ans+=(maxTillNow-arr[i]);\n }",
"ans+=(maxTillNow-arr[i])",
"ans",
"(maxTillNow-arr[i])",
"maxTillNow",
"arr[i]",
"arr",
"i",
"if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }",
"arr[i]>maxTillNow",
"arr[i]",
"arr",
"i",
"maxTillNow",
"{\n maxTillNow = arr[i];\n }",
"maxTillNow = arr[i]",
"maxTillNow",
"arr[i]",
"arr",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"static class FastReader {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }",
"FastReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }",
"FastReader",
"{\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }",
"br = new BufferedReader(new\n InputStreamReader(System.in))",
"br",
"new BufferedReader(new\n InputStreamReader(System.in))",
"String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"next",
"{\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"try {\n st = new StringTokenizer(br.readLine());\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 st = new StringTokenizer(br.readLine());\n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }",
"nextLine",
"{\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }",
"String str = \"\";",
"str",
"\"\"",
"try {\n str = br.readLine();\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 str = br.readLine();\n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main {\n static class FastReader {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n\n public static void main(String[] args) throws Exception {\n FastReader fr = new FastReader();\n int n = fr.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = fr.nextInt();\n }\n long ans = 0;\n long maxTillNow = arr[0];\n for (int i = 1; i < n; i++) {\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }\n System.out.println(ans);\n }\n}",
"public class Main {\n static class FastReader {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n\n public static void main(String[] args) throws Exception {\n FastReader fr = new FastReader();\n int n = fr.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = fr.nextInt();\n }\n long ans = 0;\n long maxTillNow = arr[0];\n for (int i = 1; i < n; i++) {\n if(arr[i]<maxTillNow){\n ans+=(maxTillNow-arr[i]);\n }\n else if(arr[i]>maxTillNow){\n maxTillNow = arr[i];\n }\n }\n System.out.println(ans);\n }\n}",
"Main"
]
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) throws Exception {
FastReader fr = new FastReader();
int n = fr.nextInt();
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = fr.nextInt();
}
long ans = 0;
long maxTillNow = arr[0];
for (int i = 1; i < n; i++) {
if(arr[i]<maxTillNow){
ans+=(maxTillNow-arr[i]);
}
else if(arr[i]>maxTillNow){
maxTillNow = arr[i];
}
}
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,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
20,
13,
0,
18,
13,
17,
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,
2,
13,
17,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
2,
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
],
[
114,
5
],
[
114,
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,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
49,
50
],
[
49,
51
],
[
8,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
52,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
69,
77
],
[
77,
78
],
[
77,
79
],
[
8,
80
],
[
80,
81
],
[
80,
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
],
[
96,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
102,
104
],
[
8,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
6,
111
],
[
111,
112
],
[
0,
113
],
[
113,
114
],
[
113,
115
]
]
| [
"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[] arr = new int[n];\n for(int i=0;i<n;i++){\n arr[i]=sc.nextInt();\n }\n int[] max = new int[n];\n max[0]=arr[0];\n for(int i=1;i<n;i++){\n max[i]=Math.max(max[i-1],arr[i]);\n }\n long sum =0;\n for(int i=0;i<n;i++){\n sum+=max[i]-arr[i];\n }\n System.out.println(sum);\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[] max = new int[n];\n max[0]=arr[0];\n for(int i=1;i<n;i++){\n max[i]=Math.max(max[i-1],arr[i]);\n }\n long sum =0;\n for(int i=0;i<n;i++){\n sum+=max[i]-arr[i];\n }\n System.out.println(sum);\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[] max = new int[n];\n max[0]=arr[0];\n for(int i=1;i<n;i++){\n max[i]=Math.max(max[i-1],arr[i]);\n }\n long sum =0;\n for(int i=0;i<n;i++){\n sum+=max[i]-arr[i];\n }\n System.out.println(sum);\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[] max = new int[n];\n max[0]=arr[0];\n for(int i=1;i<n;i++){\n max[i]=Math.max(max[i-1],arr[i]);\n }\n long sum =0;\n for(int i=0;i<n;i++){\n sum+=max[i]-arr[i];\n }\n System.out.println(sum);\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[] max = new int[n];",
"max",
"new int[n]",
"n",
"max[0]=arr[0]",
"max[0]",
"max",
"0",
"arr[0]",
"arr",
"0",
"for(int i=1;i<n;i++){\n max[i]=Math.max(max[i-1],arr[i]);\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n max[i]=Math.max(max[i-1],arr[i]);\n }",
"{\n max[i]=Math.max(max[i-1],arr[i]);\n }",
"max[i]=Math.max(max[i-1],arr[i])",
"max[i]",
"max",
"i",
"Math.max(max[i-1],arr[i])",
"Math.max",
"Math",
"max[i-1]",
"max",
"i-1",
"i",
"1",
"arr[i]",
"arr",
"i",
"long sum =0;",
"sum",
"0",
"for(int i=0;i<n;i++){\n sum+=max[i]-arr[i];\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n sum+=max[i]-arr[i];\n }",
"{\n sum+=max[i]-arr[i];\n }",
"sum+=max[i]-arr[i]",
"sum",
"max[i]-arr[i]",
"max[i]",
"max",
"i",
"arr[i]",
"arr",
"i",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"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[] max = new int[n];\n max[0]=arr[0];\n for(int i=1;i<n;i++){\n max[i]=Math.max(max[i-1],arr[i]);\n }\n long sum =0;\n for(int i=0;i<n;i++){\n sum+=max[i]-arr[i];\n }\n System.out.println(sum);\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[] max = new int[n];\n max[0]=arr[0];\n for(int i=1;i<n;i++){\n max[i]=Math.max(max[i-1],arr[i]);\n }\n long sum =0;\n for(int i=0;i<n;i++){\n sum+=max[i]-arr[i];\n }\n System.out.println(sum);\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[] max = new int[n];
max[0]=arr[0];
for(int i=1;i<n;i++){
max[i]=Math.max(max[i-1],arr[i]);
}
long sum =0;
for(int i=0;i<n;i++){
sum+=max[i]-arr[i];
}
System.out.println(sum);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
17,
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,
14,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
89,
5
],
[
89,
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
],
[
24,
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
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
45,
46
],
[
8,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
59,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
60,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
8,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
80,
85
],
[
6,
86
],
[
86,
87
],
[
0,
88
],
[
88,
89
],
[
88,
90
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tlong[] list = new long[n];\n\t\tlong max = 0;\n\t\tlong sum = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist[i] = scan.nextLong();\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sum);\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 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tlong[] list = new long[n];\n\t\tlong max = 0;\n\t\tlong sum = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist[i] = scan.nextLong();\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sum);\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tlong[] list = new long[n];\n\t\tlong max = 0;\n\t\tlong sum = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist[i] = scan.nextLong();\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sum);\n\t}",
"main",
"{\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tlong[] list = new long[n];\n\t\tlong max = 0;\n\t\tlong sum = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist[i] = scan.nextLong();\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sum);\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"long[] list = new long[n];",
"list",
"new long[n]",
"n",
"long max = 0;",
"max",
"0",
"long sum = 0;",
"sum",
"0",
"for(int i = 0; i < n; i++) {\n\t\t\tlist[i] = scan.nextLong();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tlist[i] = scan.nextLong();\n\t\t}",
"{\n\t\t\tlist[i] = scan.nextLong();\n\t\t}",
"list[i] = scan.nextLong()",
"list[i]",
"list",
"i",
"scan.nextLong()",
"scan.nextLong",
"scan",
"for(int i = 0; i < n; i++) {\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[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(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}",
"if(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}",
"max < list[i]",
"max",
"list[i]",
"list",
"i",
"{\n\t\t\t\tmax = list[i];\n\t\t\t}",
"max = list[i]",
"max",
"list[i]",
"list",
"i",
"{\n\t\t\t\tsum += max - list[i];\n\t\t\t}",
"sum += max - list[i]",
"sum",
"max - list[i]",
"max",
"list[i]",
"list",
"i",
"System.out.print(sum)",
"System.out.print",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tlong[] list = new long[n];\n\t\tlong max = 0;\n\t\tlong sum = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist[i] = scan.nextLong();\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sum);\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tlong[] list = new long[n];\n\t\tlong max = 0;\n\t\tlong sum = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist[i] = scan.nextLong();\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif(max < list[i]) {\n\t\t\t\tmax = list[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += max - list[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sum);\n\t}\n\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
long[] list = new long[n];
long max = 0;
long sum = 0;
for(int i = 0; i < n; i++) {
list[i] = scan.nextLong();
}
for(int i = 0; i < n; i++) {
if(max < list[i]) {
max = list[i];
}
else {
sum += max - list[i];
}
}
System.out.print(sum);
}
}
|
[
7,
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,
28,
13,
13,
30,
30,
0,
13,
4,
18,
13,
13,
13,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
28,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
28,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
42,
40,
4,
18,
13,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
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
],
[
250,
17
],
[
250,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
20,
29
],
[
29,
30
],
[
29,
31
],
[
20,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
33,
38
],
[
38,
39
],
[
38,
40
],
[
33,
41
],
[
41,
42
],
[
42,
43
],
[
33,
44
],
[
45,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
50,
51
],
[
51,
52
],
[
20,
53
],
[
53,
54
],
[
53,
55
],
[
20,
56
],
[
56,
57
],
[
56,
58
],
[
20,
59
],
[
59,
60
],
[
59,
61
],
[
59,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
66,
70
],
[
63,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
20,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
76,
81
],
[
18,
82
],
[
82,
83
],
[
250,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
90,
92
],
[
90,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
86,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
86,
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
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
84,
124
],
[
124,
125
],
[
250,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
132,
134
],
[
132,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
128,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
140,
144
],
[
144,
145
],
[
145,
146
],
[
128,
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
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
165,
166
],
[
166,
167
],
[
165,
168
],
[
126,
169
],
[
169,
170
],
[
250,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
173,
175
],
[
171,
176
],
[
176,
177
],
[
176,
178
],
[
171,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
182,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
187,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
181,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
171,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
207,
208
],
[
206,
209
],
[
209,
210
],
[
171,
211
],
[
211,
212
],
[
211,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
213,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
218,
223
],
[
223,
224
],
[
223,
225
],
[
218,
226
],
[
226,
227
],
[
227,
228
],
[
218,
229
],
[
229,
230
],
[
230,
231
],
[
231,
232
],
[
231,
233
],
[
230,
234
],
[
234,
235
],
[
213,
236
],
[
236,
237
],
[
211,
238
],
[
238,
239
],
[
171,
240
],
[
240,
241
],
[
240,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
245,
246
],
[
244,
247
],
[
247,
248
],
[
0,
249
],
[
249,
250
],
[
249,
251
]
]
| [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.LineNumberReader;\nimport java.util.*;\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[]=new int[n];\n for (int i=0;i<n;i++){\n a[i]=sc.nextInt();\n }\n long ans=0;\n int max=0;\n for (int i:a){\n max=Math.max(max,i);\n ans+=max-i;\n }\n System.out.println(ans);\n\n\n }\n\n\n\n\n static void sort(int[] a) {\n ArrayList<Integer> l=new ArrayList<>();\n for (int i:a) l.add(i);\n Collections.sort(l);\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n static void sortReverse(long[] a) {\n ArrayList<Long> l=new ArrayList<>();\n for (long i:a) l.add(i);\n// Collections.sort.(l);\n Collections.sort(l,Collections.reverseOrder());\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n\n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.LineNumberReader;",
"LineNumberReader",
"java.io",
"import java.util.*;",
"util.*",
"java",
"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[]=new int[n];\n for (int i=0;i<n;i++){\n a[i]=sc.nextInt();\n }\n long ans=0;\n int max=0;\n for (int i:a){\n max=Math.max(max,i);\n ans+=max-i;\n }\n System.out.println(ans);\n\n\n }\n\n\n\n\n static void sort(int[] a) {\n ArrayList<Integer> l=new ArrayList<>();\n for (int i:a) l.add(i);\n Collections.sort(l);\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n static void sortReverse(long[] a) {\n ArrayList<Long> l=new ArrayList<>();\n for (long i:a) l.add(i);\n// Collections.sort.(l);\n Collections.sort(l,Collections.reverseOrder());\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n\n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\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 long ans=0;\n int max=0;\n for (int i:a){\n max=Math.max(max,i);\n ans+=max-i;\n }\n System.out.println(ans);\n\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<n;i++){\n a[i]=sc.nextInt();\n }\n long ans=0;\n int max=0;\n for (int i:a){\n max=Math.max(max,i);\n ans+=max-i;\n }\n System.out.println(ans);\n\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<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",
"long ans=0;",
"ans",
"0",
"int max=0;",
"max",
"0",
"for (int i:a){\n max=Math.max(max,i);\n ans+=max-i;\n }",
"int i",
"a",
"{\n max=Math.max(max,i);\n ans+=max-i;\n }",
"{\n max=Math.max(max,i);\n ans+=max-i;\n }",
"max=Math.max(max,i)",
"max",
"Math.max(max,i)",
"Math.max",
"Math",
"max",
"i",
"ans+=max-i",
"ans",
"max-i",
"max",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"static void sort(int[] a) {\n ArrayList<Integer> l=new ArrayList<>();\n for (int i:a) l.add(i);\n Collections.sort(l);\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }",
"sort",
"{\n ArrayList<Integer> l=new ArrayList<>();\n for (int i:a) l.add(i);\n Collections.sort(l);\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }",
"ArrayList<Integer> l=new ArrayList<>();",
"l",
"new ArrayList<>()",
"for (int i:a) l.add(i);",
"int i",
"a",
"l.add(i);",
"l.add(i)",
"l.add",
"l",
"i",
"Collections.sort(l)",
"Collections.sort",
"Collections",
"l",
"for (int i=0; i<a.length; i++) a[i]=l.get(i);",
"int i=0;",
"int i=0;",
"i",
"0",
"i<a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"a[i]=l.get(i);",
"a[i]=l.get(i)",
"a[i]",
"a",
"i",
"l.get(i)",
"l.get",
"l",
"i",
"int[] a",
"a",
"static void sortReverse(long[] a) {\n ArrayList<Long> l=new ArrayList<>();\n for (long i:a) l.add(i);\n// Collections.sort.(l);\n Collections.sort(l,Collections.reverseOrder());\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }",
"sortReverse",
"{\n ArrayList<Long> l=new ArrayList<>();\n for (long i:a) l.add(i);\n// Collections.sort.(l);\n Collections.sort(l,Collections.reverseOrder());\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }",
"ArrayList<Long> l=new ArrayList<>();",
"l",
"new ArrayList<>()",
"for (long i:a) l.add(i);",
"long i",
"a",
"l.add(i);",
"l.add(i)",
"l.add",
"l",
"i",
"Collections.sort(l,Collections.reverseOrder())",
"Collections.sort",
"Collections",
"l",
"Collections.reverseOrder()",
"Collections.reverseOrder",
"Collections",
"for (int i=0; i<a.length; i++) a[i]=l.get(i);",
"int i=0;",
"int i=0;",
"i",
"0",
"i<a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"a[i]=l.get(i);",
"a[i]=l.get(i)",
"a[i]",
"a",
"i",
"l.get(i)",
"l.get",
"l",
"i",
"long[] a",
"a",
"static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }",
"FastScanner",
"BufferedReader br=new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"StringTokenizer st=new StringTokenizer(\"\");",
"st",
"new StringTokenizer(\"\")",
"String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }",
"next",
"{\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }",
"while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"try {\n st=new StringTokenizer(br.readLine());\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 st=new StringTokenizer(br.readLine());\n }",
"st=new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }",
"readArray",
"{\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }",
"int[] a=new int[n];",
"a",
"new int[n]",
"n",
"for (int i=0; i<n; i++) a[i]=nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=nextInt();",
"a[i]=nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int n",
"n",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"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[]=new int[n];\n for (int i=0;i<n;i++){\n a[i]=sc.nextInt();\n }\n long ans=0;\n int max=0;\n for (int i:a){\n max=Math.max(max,i);\n ans+=max-i;\n }\n System.out.println(ans);\n\n\n }\n\n\n\n\n static void sort(int[] a) {\n ArrayList<Integer> l=new ArrayList<>();\n for (int i:a) l.add(i);\n Collections.sort(l);\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n static void sortReverse(long[] a) {\n ArrayList<Long> l=new ArrayList<>();\n for (long i:a) l.add(i);\n// Collections.sort.(l);\n Collections.sort(l,Collections.reverseOrder());\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n\n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\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[]=new int[n];\n for (int i=0;i<n;i++){\n a[i]=sc.nextInt();\n }\n long ans=0;\n int max=0;\n for (int i:a){\n max=Math.max(max,i);\n ans+=max-i;\n }\n System.out.println(ans);\n\n\n }\n\n\n\n\n static void sort(int[] a) {\n ArrayList<Integer> l=new ArrayList<>();\n for (int i:a) l.add(i);\n Collections.sort(l);\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n static void sortReverse(long[] a) {\n ArrayList<Long> l=new ArrayList<>();\n for (long i:a) l.add(i);\n// Collections.sort.(l);\n Collections.sort(l,Collections.reverseOrder());\n for (int i=0; i<a.length; i++) a[i]=l.get(i);\n }\n\n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n\n}",
"Main"
]
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
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();
}
long ans=0;
int max=0;
for (int i:a){
max=Math.max(max,i);
ans+=max-i;
}
System.out.println(ans);
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static void sortReverse(long[] a) {
ArrayList<Long> l=new ArrayList<>();
for (long i:a) l.add(i);
// Collections.sort.(l);
Collections.sort(l,Collections.reverseOrder());
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
2,
13,
13,
17,
30,
0,
13,
2,
13,
13,
0,
13,
13,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
70,
5
],
[
70,
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
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
37,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
43,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
52,
54
],
[
49,
55
],
[
55,
56
],
[
55,
57
],
[
37,
58
],
[
58,
59
],
[
58,
60
],
[
8,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
61,
66
],
[
6,
67
],
[
67,
68
],
[
0,
69
],
[
69,
70
],
[
69,
71
]
]
| [
"import java.util.*;\n\npublic class Main\n{\n public static void main(String[] args)\n { \t\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // int[] arr = new int[n];\n\n long total = 0;\n\n int p = sc.nextInt();\n for (int i = 1; i<n; i++)\n {\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }\n\n System.out.println(total);\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main\n{\n public static void main(String[] args)\n { \t\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // int[] arr = new int[n];\n\n long total = 0;\n\n int p = sc.nextInt();\n for (int i = 1; i<n; i++)\n {\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }\n\n System.out.println(total);\n }\n}",
"Main",
"public static void main(String[] args)\n { \t\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // int[] arr = new int[n];\n\n long total = 0;\n\n int p = sc.nextInt();\n for (int i = 1; i<n; i++)\n {\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }\n\n System.out.println(total);\n }",
"main",
"{ \t\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // int[] arr = new int[n];\n\n long total = 0;\n\n int p = sc.nextInt();\n for (int i = 1; i<n; i++)\n {\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }\n\n System.out.println(total);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long total = 0;",
"total",
"0",
"int p = sc.nextInt();",
"p",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 1; i<n; i++)\n {\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }",
"{\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }",
"int c = sc.nextInt();",
"c",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if (p - c > 0)\n {\n total += p - c;\n c = p;\n }",
"p - c > 0",
"p - c",
"p",
"c",
"0",
"{\n total += p - c;\n c = p;\n }",
"total += p - c",
"total",
"p - c",
"p",
"c",
"c = p",
"c",
"p",
"p = c",
"p",
"c",
"System.out.println(total)",
"System.out.println",
"System.out",
"System",
"System.out",
"total",
"String[] args",
"args",
"public class Main\n{\n public static void main(String[] args)\n { \t\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // int[] arr = new int[n];\n\n long total = 0;\n\n int p = sc.nextInt();\n for (int i = 1; i<n; i++)\n {\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }\n\n System.out.println(total);\n }\n}",
"public class Main\n{\n public static void main(String[] args)\n { \t\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // int[] arr = new int[n];\n\n long total = 0;\n\n int p = sc.nextInt();\n for (int i = 1; i<n; i++)\n {\n int c = sc.nextInt();\n if (p - c > 0)\n {\n total += p - c;\n c = p;\n }\n p = c;\n }\n\n System.out.println(total);\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];
long total = 0;
int p = sc.nextInt();
for (int i = 1; i<n; i++)
{
int c = sc.nextInt();
if (p - c > 0)
{
total += p - c;
c = p;
}
p = c;
}
System.out.println(total);
}
} |
[
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,
17,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
75,
5
],
[
75,
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,
26
],
[
26,
27
],
[
26,
28
],
[
28,
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
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
43,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
56,
58
],
[
49,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
8,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
63,
68
],
[
8,
69
],
[
69,
70
],
[
70,
71
],
[
6,
72
],
[
72,
73
],
[
0,
74
],
[
74,
75
],
[
74,
76
]
]
| [
"import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String str = sc.nextLine();\n int N = Integer.parseInt(str);\n\n long count=0;\n int prev_person = sc.nextInt();\n\n for(int i = 1; i < N; i++){\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }\n\n\n System.out.println(count);\n sc.close();\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 String str = sc.nextLine();\n int N = Integer.parseInt(str);\n\n long count=0;\n int prev_person = sc.nextInt();\n\n for(int i = 1; i < N; i++){\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }\n\n\n System.out.println(count);\n sc.close();\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String str = sc.nextLine();\n int N = Integer.parseInt(str);\n\n long count=0;\n int prev_person = sc.nextInt();\n\n for(int i = 1; i < N; i++){\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }\n\n\n System.out.println(count);\n sc.close();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n String str = sc.nextLine();\n int N = Integer.parseInt(str);\n\n long count=0;\n int prev_person = sc.nextInt();\n\n for(int i = 1; i < N; i++){\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }\n\n\n System.out.println(count);\n sc.close();\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String str = sc.nextLine();",
"str",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int N = Integer.parseInt(str);",
"N",
"Integer.parseInt(str)",
"Integer.parseInt",
"Integer",
"str",
"long count=0;",
"count",
"0",
"int prev_person = sc.nextInt();",
"prev_person",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i = 1; i < N; i++){\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }",
"{\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }",
"int now_person = sc.nextInt();",
"now_person",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }",
"now_person < prev_person",
"now_person",
"prev_person",
"{\n count += prev_person - now_person;\n }",
"count += prev_person - now_person",
"count",
"prev_person - now_person",
"prev_person",
"now_person",
"{\n prev_person = now_person;\n }",
"prev_person = now_person",
"prev_person",
"now_person",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String str = sc.nextLine();\n int N = Integer.parseInt(str);\n\n long count=0;\n int prev_person = sc.nextInt();\n\n for(int i = 1; i < N; i++){\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }\n\n\n System.out.println(count);\n sc.close();\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String str = sc.nextLine();\n int N = Integer.parseInt(str);\n\n long count=0;\n int prev_person = sc.nextInt();\n\n for(int i = 1; i < N; i++){\n int now_person = sc.nextInt();\n if(now_person < prev_person){\n count += prev_person - now_person;\n }\n else{\n prev_person = now_person;\n }\n }\n\n\n System.out.println(count);\n sc.close();\n }\n}",
"Main"
]
| import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int N = Integer.parseInt(str);
long count=0;
int prev_person = sc.nextInt();
for(int i = 1; i < N; i++){
int now_person = sc.nextInt();
if(now_person < prev_person){
count += prev_person - now_person;
}
else{
prev_person = now_person;
}
}
System.out.println(count);
sc.close();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
20,
12,
13,
30,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
41,
13,
17,
41,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
0,
13,
4,
18,
13,
13,
18,
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,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
13,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
42,
40,
4,
18,
13,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
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
],
[
224,
17
],
[
224,
18
],
[
18,
19
],
[
224,
20
],
[
20,
21
],
[
224,
22
],
[
22,
23
],
[
224,
24
],
[
24,
25
],
[
24,
26
],
[
224,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
29,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
29,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
29,
44
],
[
44,
45
],
[
44,
46
],
[
29,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
29,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
52,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
65,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
64,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
29,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
87,
92
],
[
27,
93
],
[
93,
94
],
[
224,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
103,
108
],
[
108,
109
],
[
108,
110
],
[
103,
111
],
[
111,
112
],
[
112,
113
],
[
103,
114
],
[
115,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
115,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
115,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
131,
133
],
[
115,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
97,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
95,
143
],
[
143,
144
],
[
224,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
150,
151
],
[
150,
152
],
[
145,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
156,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
161,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
155,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
145,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
180,
183
],
[
183,
184
],
[
145,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
192,
197
],
[
197,
198
],
[
197,
199
],
[
192,
200
],
[
200,
201
],
[
201,
202
],
[
192,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
204,
208
],
[
208,
209
],
[
187,
210
],
[
210,
211
],
[
185,
212
],
[
212,
213
],
[
145,
214
],
[
214,
215
],
[
214,
216
],
[
216,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
218,
221
],
[
221,
222
],
[
0,
223
],
[
223,
224
],
[
223,
225
]
]
| [
"//Coded By Visnunathan\n\nimport java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.lang.*;\n\npublic class Main {\n static int[] arr;\n static int n,k;\n public static void main(String[] args) {\n FastScanner sc=new FastScanner();\n // int T=sc.nextInt();\n // for (int tt=0; tt<T; tt++) {\n n = sc.nextInt();\n arr = sc.readArray(n);\n long ans = 0;\n int max = arr[0];\n for(int i=1; i<n; i++) {\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }\n System.out.println(ans);\n //}\n }\n\n static final Random random=new Random();\n \n static void ruffleSort(int[] a) {\n int n=a.length;//shuffle, then sort \n for (int i=0; i<n; i++) {\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }\n Arrays.sort(a);\n }\n \n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n \n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"import java.text.*;",
"text.*",
"java",
"import java.math.*;",
"math.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"public class Main {\n static int[] arr;\n static int n,k;\n public static void main(String[] args) {\n FastScanner sc=new FastScanner();\n // int T=sc.nextInt();\n // for (int tt=0; tt<T; tt++) {\n n = sc.nextInt();\n arr = sc.readArray(n);\n long ans = 0;\n int max = arr[0];\n for(int i=1; i<n; i++) {\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }\n System.out.println(ans);\n //}\n }\n\n static final Random random=new Random();\n \n static void ruffleSort(int[] a) {\n int n=a.length;//shuffle, then sort \n for (int i=0; i<n; i++) {\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }\n Arrays.sort(a);\n }\n \n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n \n}",
"Main",
"static int[] arr;",
"arr",
"static int n",
"n",
"k;",
"k",
"static final Random random=new Random();",
"random",
"new Random()",
"public static void main(String[] args) {\n FastScanner sc=new FastScanner();\n // int T=sc.nextInt();\n // for (int tt=0; tt<T; tt++) {\n n = sc.nextInt();\n arr = sc.readArray(n);\n long ans = 0;\n int max = arr[0];\n for(int i=1; i<n; i++) {\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }\n System.out.println(ans);\n //}\n }",
"main",
"{\n FastScanner sc=new FastScanner();\n // int T=sc.nextInt();\n // for (int tt=0; tt<T; tt++) {\n n = sc.nextInt();\n arr = sc.readArray(n);\n long ans = 0;\n int max = arr[0];\n for(int i=1; i<n; i++) {\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }\n System.out.println(ans);\n //}\n }",
"FastScanner sc=new FastScanner();",
"sc",
"new FastScanner()",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"arr = sc.readArray(n)",
"arr",
"sc.readArray(n)",
"sc.readArray",
"sc",
"n",
"long ans = 0;",
"ans",
"0",
"int max = arr[0];",
"max",
"arr[0]",
"arr",
"0",
"for(int i=1; i<n; i++) {\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }",
"{\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }",
"if(max > arr[i]) ans+=(max-arr[i]);",
"max > arr[i]",
"max",
"arr[i]",
"arr",
"i",
"ans+=(max-arr[i])",
"ans",
"(max-arr[i])",
"max",
"arr[i]",
"arr",
"i",
"max = Math.max(max,arr[i])",
"max",
"Math.max(max,arr[i])",
"Math.max",
"Math",
"max",
"arr[i]",
"arr",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"static void ruffleSort(int[] a) {\n int n=a.length;//shuffle, then sort \n for (int i=0; i<n; i++) {\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }\n Arrays.sort(a);\n }",
"ruffleSort",
"{\n int n=a.length;//shuffle, then sort \n for (int i=0; i<n; i++) {\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }\n Arrays.sort(a);\n }",
"int n=a.length;",
"n",
"a.length",
"a",
"a.length",
"for (int i=0; i<n; i++) {\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }",
"{\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }",
"int oi=random.nextInt(n)",
"oi",
"random.nextInt(n)",
"random.nextInt",
"random",
"n",
"temp=a[oi];",
"temp",
"a[oi]",
"a",
"oi",
"a[oi]=a[i]",
"a[oi]",
"a",
"oi",
"a[i]",
"a",
"i",
"a[i]=temp",
"a[i]",
"a",
"i",
"temp",
"Arrays.sort(a)",
"Arrays.sort",
"Arrays",
"a",
"int[] a",
"a",
"static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }",
"FastScanner",
"BufferedReader br=new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"StringTokenizer st=new StringTokenizer(\"\");",
"st",
"new StringTokenizer(\"\")",
"String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }",
"next",
"{\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }",
"while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"try {\n st=new StringTokenizer(br.readLine());\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 st=new StringTokenizer(br.readLine());\n }",
"st=new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }",
"readArray",
"{\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }",
"int[] a=new int[n];",
"a",
"new int[n]",
"n",
"for (int i=0; i<n; i++) a[i]=nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=nextInt();",
"a[i]=nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int n",
"n",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"public class Main {\n static int[] arr;\n static int n,k;\n public static void main(String[] args) {\n FastScanner sc=new FastScanner();\n // int T=sc.nextInt();\n // for (int tt=0; tt<T; tt++) {\n n = sc.nextInt();\n arr = sc.readArray(n);\n long ans = 0;\n int max = arr[0];\n for(int i=1; i<n; i++) {\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }\n System.out.println(ans);\n //}\n }\n\n static final Random random=new Random();\n \n static void ruffleSort(int[] a) {\n int n=a.length;//shuffle, then sort \n for (int i=0; i<n; i++) {\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }\n Arrays.sort(a);\n }\n \n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n \n}",
"public class Main {\n static int[] arr;\n static int n,k;\n public static void main(String[] args) {\n FastScanner sc=new FastScanner();\n // int T=sc.nextInt();\n // for (int tt=0; tt<T; tt++) {\n n = sc.nextInt();\n arr = sc.readArray(n);\n long ans = 0;\n int max = arr[0];\n for(int i=1; i<n; i++) {\n if(max > arr[i]) ans+=(max-arr[i]);\n max = Math.max(max,arr[i]);\n }\n System.out.println(ans);\n //}\n }\n\n static final Random random=new Random();\n \n static void ruffleSort(int[] a) {\n int n=a.length;//shuffle, then sort \n for (int i=0; i<n; i++) {\n int oi=random.nextInt(n), temp=a[oi];\n a[oi]=a[i]; a[i]=temp;\n }\n Arrays.sort(a);\n }\n \n static class FastScanner {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st=new StringTokenizer(\"\");\n String next() {\n while (!st.hasMoreTokens())\n try {\n st=new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n int[] readArray(int n) {\n int[] a=new int[n];\n for (int i=0; i<n; i++) a[i]=nextInt();\n return a;\n }\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n \n}",
"Main"
]
| //Coded By Visnunathan
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.lang.*;
public class Main {
static int[] arr;
static int n,k;
public static void main(String[] args) {
FastScanner sc=new FastScanner();
// int T=sc.nextInt();
// for (int tt=0; tt<T; tt++) {
n = sc.nextInt();
arr = sc.readArray(n);
long ans = 0;
int max = arr[0];
for(int i=1; i<n; i++) {
if(max > arr[i]) ans+=(max-arr[i]);
max = Math.max(max,arr[i]);
}
System.out.println(ans);
//}
}
static final Random random=new Random();
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
0,
18,
13,
17,
4,
18,
13,
41,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
88,
5
],
[
88,
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
],
[
22,
24
],
[
21,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
30,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
8,
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
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
56,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
8,
76
],
[
76,
77
],
[
77,
78
],
[
8,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
6,
85
],
[
85,
86
],
[
0,
87
],
[
87,
88
],
[
87,
89
]
]
| [
"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\tA[0] = sc.nextInt();\n\t\tint a = A[0];\n\t\tlong s = 0;\n\t\tfor(int i=1; i<N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(s);\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 = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tA[0] = sc.nextInt();\n\t\tint a = A[0];\n\t\tlong s = 0;\n\t\tfor(int i=1; i<N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(s);\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\tA[0] = sc.nextInt();\n\t\tint a = A[0];\n\t\tlong s = 0;\n\t\tfor(int i=1; i<N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(s);\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\tA[0] = sc.nextInt();\n\t\tint a = A[0];\n\t\tlong s = 0;\n\t\tfor(int i=1; i<N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(s);\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",
"A[0] = sc.nextInt()",
"A[0]",
"A",
"0",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int a = A[0];",
"a",
"A[0]",
"A",
"0",
"long s = 0;",
"s",
"0",
"for(int i=1; i<N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\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\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}",
"{\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}",
"A[i]<=a",
"A[i]",
"A",
"i",
"a",
"{\n\t\t\t\ts+=a-A[i];\n\t\t\t}",
"s+=a-A[i]",
"s",
"a-A[i]",
"a",
"A[i]",
"A",
"i",
"{\n\t\t\t\ta = A[i];\n\t\t\t}",
"a = A[i]",
"a",
"A[i]",
"A",
"i",
"sc.close()",
"sc.close",
"sc",
"System.out.println(s)",
"System.out.println",
"System.out",
"System",
"System.out",
"s",
"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\tA[0] = sc.nextInt();\n\t\tint a = A[0];\n\t\tlong s = 0;\n\t\tfor(int i=1; i<N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(s);\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 = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tA[0] = sc.nextInt();\n\t\tint a = A[0];\n\t\tlong s = 0;\n\t\tfor(int i=1; i<N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t\tif(A[i]<=a) {\n\t\t\t\ts+=a-A[i];\n\t\t\t}else{\n\t\t\t\ta = A[i];\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(s);\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];
A[0] = sc.nextInt();
int a = A[0];
long s = 0;
for(int i=1; i<N; i++) {
A[i] = sc.nextInt();
if(A[i]<=a) {
s+=a-A[i];
}else{
a = A[i];
}
}
sc.close();
System.out.println(s);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
17,
0,
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,
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,
4,
18,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
13,
4,
18,
13,
2,
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
],
[
127,
8
],
[
127,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
11,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
28,
33
],
[
11,
34
],
[
34,
35
],
[
34,
36
],
[
11,
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
],
[
11,
61
],
[
61,
62
],
[
61,
63
],
[
11,
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
],
[
78,
84
],
[
84,
85
],
[
84,
86
],
[
77,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
87,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
115,
117
],
[
11,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
118,
123
],
[
9,
124
],
[
124,
125
],
[
0,
126
],
[
126,
127
],
[
126,
128
]
]
| [
"import java.util.*;\nimport java.io.*;\npublic class Main\n{\n\tpublic static void main(String args[]) throws IOException\n\t{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tint n=0;\n\t\tn=Integer.parseInt(br.readLine());\n\t\tString brr[]=br.readLine().split(\" \");\n\t\tlong arr[]=new long[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}\n\t\tlong ans=0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\t\t",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main\n{\n\tpublic static void main(String args[]) throws IOException\n\t{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tint n=0;\n\t\tn=Integer.parseInt(br.readLine());\n\t\tString brr[]=br.readLine().split(\" \");\n\t\tlong arr[]=new long[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}\n\t\tlong ans=0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}",
"Main",
"public static void main(String args[]) throws IOException\n\t{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tint n=0;\n\t\tn=Integer.parseInt(br.readLine());\n\t\tString brr[]=br.readLine().split(\" \");\n\t\tlong arr[]=new long[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}\n\t\tlong ans=0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}",
"main",
"{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tint n=0;\n\t\tn=Integer.parseInt(br.readLine());\n\t\tString brr[]=br.readLine().split(\" \");\n\t\tlong arr[]=new long[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}\n\t\tlong ans=0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}",
"BufferedReader br=new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int n=0;",
"n",
"0",
"n=Integer.parseInt(br.readLine())",
"n",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"String brr[]=br.readLine().split(\" \");",
"brr",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"long arr[]=new long[n];",
"arr",
"new long[n]",
"n",
"for(int i=0;i<n;i++)\n\t\t{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}",
"{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}",
"arr[i]=Long.parseLong(brr[i])",
"arr[i]",
"arr",
"i",
"Long.parseLong(brr[i])",
"Long.parseLong",
"Long",
"brr[i]",
"brr",
"i",
"long ans=0;",
"ans",
"0",
"for(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\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\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}",
"if(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}",
"arr[i-1]>arr[i]",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]",
"arr",
"i",
"{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}",
"ans+=Math.abs(arr[i]-arr[i-1])",
"ans",
"Math.abs(arr[i]-arr[i-1])",
"Math.abs",
"Math",
"arr[i]-arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]+=Math.abs(arr[i]-arr[i-1])",
"arr[i]",
"arr",
"i",
"Math.abs(arr[i]-arr[i-1])",
"Math.abs",
"Math",
"arr[i]-arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String args[]",
"args",
"public class Main\n{\n\tpublic static void main(String args[]) throws IOException\n\t{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tint n=0;\n\t\tn=Integer.parseInt(br.readLine());\n\t\tString brr[]=br.readLine().split(\" \");\n\t\tlong arr[]=new long[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}\n\t\tlong ans=0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}",
"public class Main\n{\n\tpublic static void main(String args[]) throws IOException\n\t{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tint n=0;\n\t\tn=Integer.parseInt(br.readLine());\n\t\tString brr[]=br.readLine().split(\" \");\n\t\tlong arr[]=new long[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t{\n\t\t\tarr[i]=Long.parseLong(brr[i]);\n\t\t}\n\t\tlong ans=0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i-1]>arr[i])\n\t\t\t{\n\t\t\t\tans+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t\tarr[i]+=Math.abs(arr[i]-arr[i-1]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}",
"Main"
]
| import java.util.*;
import java.io.*;
public class Main
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=0;
n=Integer.parseInt(br.readLine());
String brr[]=br.readLine().split(" ");
long arr[]=new long[n];
for(int i=0;i<n;i++)
{
arr[i]=Long.parseLong(brr[i]);
}
long ans=0;
for(int i=1;i<n;i++)
{
if(arr[i-1]>arr[i])
{
ans+=Math.abs(arr[i]-arr[i-1]);
arr[i]+=Math.abs(arr[i]-arr[i-1]);
}
}
System.out.println(ans);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
0,
13,
13,
14,
2,
13,
13,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
66,
5
],
[
66,
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,
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
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
35,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
45,
47
],
[
41,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
54,
56
],
[
8,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
6,
63
],
[
63,
64
],
[
0,
65
],
[
65,
66
],
[
65,
67
]
]
| [
"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\tlong size = sc.nextInt();\n\t\tlong max = 0;\n\t\tlong total = 0;\n\n\t\tfor(long i=0; i<size; i++) {\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\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\tlong size = sc.nextInt();\n\t\tlong max = 0;\n\t\tlong total = 0;\n\n\t\tfor(long i=0; i<size; i++) {\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong size = sc.nextInt();\n\t\tlong max = 0;\n\t\tlong total = 0;\n\n\t\tfor(long i=0; i<size; i++) {\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong size = sc.nextInt();\n\t\tlong max = 0;\n\t\tlong total = 0;\n\n\t\tfor(long i=0; i<size; i++) {\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"long size = sc.nextInt();",
"size",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long max = 0;",
"max",
"0",
"long total = 0;",
"total",
"0",
"for(long i=0; i<size; i++) {\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}",
"long i=0;",
"long i=0;",
"i",
"0",
"i<size",
"i",
"size",
"i++",
"i++",
"i",
"{\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}",
"{\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}",
"long sci = sc.nextInt();",
"sci",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;",
"max < sci",
"max",
"sci",
"max = sci",
"max",
"sci",
"if(max > sci) total += max - sci;",
"max > sci",
"max",
"sci",
"total += max - sci",
"total",
"max - sci",
"max",
"sci",
"System.out.println(total)",
"System.out.println",
"System.out",
"System",
"System.out",
"total",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong size = sc.nextInt();\n\t\tlong max = 0;\n\t\tlong total = 0;\n\n\t\tfor(long i=0; i<size; i++) {\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong size = sc.nextInt();\n\t\tlong max = 0;\n\t\tlong total = 0;\n\n\t\tfor(long i=0; i<size; i++) {\n\t\t\tlong sci = sc.nextInt();\n\t\t\tif(max < sci) max = sci;\n\t\t\telse if(max > sci) total += max - sci;\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t}\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long size = sc.nextInt();
long max = 0;
long total = 0;
for(long i=0; i<size; i++) {
long sci = sc.nextInt();
if(max < sci) max = sci;
else if(max > sci) total += max - sci;
}
System.out.println(total);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
66,
5
],
[
66,
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
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
37,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
50,
52
],
[
43,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
8,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
6,
63
],
[
63,
64
],
[
0,
65
],
[
65,
66
],
[
65,
67
]
]
| [
"import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n \tScanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n long sum = 0l;\n long high = sc.nextLong();\n for(int i = 1; i < n; i++){\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }\n \n System.out.println(sum);\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 \n int n = sc.nextInt();\n long sum = 0l;\n long high = sc.nextLong();\n for(int i = 1; i < n; i++){\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }\n \n System.out.println(sum);\n }\n}",
"Main",
"public static void main(String[] args){\n \tScanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n long sum = 0l;\n long high = sc.nextLong();\n for(int i = 1; i < n; i++){\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }\n \n System.out.println(sum);\n }",
"main",
"{\n \tScanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n long sum = 0l;\n long high = sc.nextLong();\n for(int i = 1; i < n; i++){\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }\n \n System.out.println(sum);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long sum = 0l;",
"sum",
"0l",
"long high = sc.nextLong();",
"high",
"sc.nextLong()",
"sc.nextLong",
"sc",
"for(int i = 1; i < n; i++){\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }",
"{\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }",
"long next = sc.nextLong();",
"next",
"sc.nextLong()",
"sc.nextLong",
"sc",
"if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }",
"high > next",
"high",
"next",
"{\n \tsum += (high - next);\n }",
"sum += (high - next)",
"sum",
"(high - next)",
"high",
"next",
"{\n high = next;\n }",
"high = next",
"high",
"next",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n \tScanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n long sum = 0l;\n long high = sc.nextLong();\n for(int i = 1; i < n; i++){\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }\n \n System.out.println(sum);\n }\n}",
"public class Main{\n public static void main(String[] args){\n \tScanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n long sum = 0l;\n long high = sc.nextLong();\n for(int i = 1; i < n; i++){\n long next = sc.nextLong();\n if(high > next){\n \tsum += (high - next);\n } else {\n high = next;\n }\n }\n \n System.out.println(sum);\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();
long sum = 0l;
long high = sc.nextLong();
for(int i = 1; i < n; i++){
long next = sc.nextLong();
if(high > next){
sum += (high - next);
} else {
high = next;
}
}
System.out.println(sum);
}
}
|
[
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,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
0,
13,
18,
13,
13,
30,
0,
13,
2,
2,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
91,
5
],
[
91,
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
],
[
8,
45
],
[
45,
46
],
[
45,
47
],
[
8,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
48,
53
],
[
53,
54
],
[
53,
55
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
48,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
61,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
61,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
8,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
6,
88
],
[
88,
89
],
[
0,
90
],
[
90,
91
],
[
90,
92
]
]
| [
"import java.util.*;\n\npublic 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++) a[i] = sc.nextInt();\n\tint low = a[0];\n\tlong sum = 0;\n\tfor (int i=1; i<n; i++) {\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}\n\tSystem.out.print(sum);\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\tint n = sc.nextInt();\n\tint[] a = new int[n];\n\tfor (int i=0; i<n; i++) a[i] = sc.nextInt();\n\tint low = a[0];\n\tlong sum = 0;\n\tfor (int i=1; i<n; i++) {\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}\n\tSystem.out.print(sum);\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++) a[i] = sc.nextInt();\n\tint low = a[0];\n\tlong sum = 0;\n\tfor (int i=1; i<n; i++) {\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}\n\tSystem.out.print(sum);\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++) a[i] = sc.nextInt();\n\tint low = a[0];\n\tlong sum = 0;\n\tfor (int i=1; i<n; i++) {\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}\n\tSystem.out.print(sum);\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++) 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 low = a[0];",
"low",
"a[0]",
"a",
"0",
"long sum = 0;",
"sum",
"0",
"for (int i=1; i<n; i++) {\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}",
"{\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}",
"if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }",
"low <= a[i]",
"low",
"a[i]",
"a",
"i",
"low = a[i]",
"low",
"a[i]",
"a",
"i",
"{\n\t\tsum = sum + low - a[i];\n\t }",
"sum = sum + low - a[i]",
"sum",
"sum + low - a[i]",
"sum + low",
"sum",
"low",
"a[i]",
"a",
"i",
"System.out.print(sum)",
"System.out.print",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public 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++) a[i] = sc.nextInt();\n\tint low = a[0];\n\tlong sum = 0;\n\tfor (int i=1; i<n; i++) {\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}\n\tSystem.out.print(sum);\n }\n}",
"public 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++) a[i] = sc.nextInt();\n\tint low = a[0];\n\tlong sum = 0;\n\tfor (int i=1; i<n; i++) {\n\t if (low <= a[i]) low = a[i];\n\t else {\n\t\tsum = sum + low - a[i];\n\t }\n\t}\n\tSystem.out.print(sum);\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();
int low = a[0];
long sum = 0;
for (int i=1; i<n; i++) {
if (low <= a[i]) low = a[i];
else {
sum = sum + low - a[i];
}
}
System.out.print(sum);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
4,
13,
23,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
18,
13,
13,
2,
17,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
4,
18,
13,
2,
13,
13,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
18,
13,
13,
2,
17,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
4,
18,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
13,
4,
18,
13,
2,
13,
17,
13,
41,
13,
17,
28,
13,
13,
30,
30,
0,
13,
13,
14,
2,
2,
13,
17,
17,
30,
4,
18,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
17,
12,
13,
30,
38,
5,
13,
30,
4,
18,
18,
13,
13,
2,
17,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
2,
17,
17,
41,
13,
17,
41,
13,
17,
0,
18,
13,
17,
4,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
13,
4,
18,
13,
14,
2,
17,
2,
18,
13,
2,
13,
17,
13,
30,
0,
13,
2,
18,
13,
2,
13,
17,
13,
0,
13,
18,
13,
2,
13,
17,
0,
18,
13,
13,
13,
4,
18,
18,
13,
13,
13,
12,
13,
30,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
29,
20,
23,
13,
12,
13,
30,
29,
20,
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
],
[
315,
17
],
[
315,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
18,
23
],
[
23,
24
],
[
315,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
28,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
40,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
40,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
40,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
65,
68
],
[
68,
69
],
[
68,
70
],
[
64,
71
],
[
315,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
84,
85
],
[
84,
86
],
[
75,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
87,
96
],
[
96,
97
],
[
96,
98
],
[
87,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
99,
109
],
[
109,
110
],
[
110,
111
],
[
99,
112
],
[
113,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
87,
126
],
[
126,
127
],
[
126,
128
],
[
87,
129
],
[
129,
130
],
[
129,
131
],
[
129,
132
],
[
133,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
87,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
137,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
144,
149
],
[
137,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
315,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
169,
170
],
[
169,
171
],
[
160,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
172,
181
],
[
181,
182
],
[
181,
183
],
[
184,
185
],
[
184,
186
],
[
172,
187
],
[
187,
188
],
[
187,
189
],
[
172,
190
],
[
190,
191
],
[
190,
192
],
[
172,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
197,
198
],
[
197,
199
],
[
199,
200
],
[
200,
201
],
[
172,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
202,
207
],
[
207,
208
],
[
207,
209
],
[
202,
210
],
[
210,
211
],
[
211,
212
],
[
202,
213
],
[
214,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
217,
218
],
[
217,
219
],
[
219,
220
],
[
220,
221
],
[
214,
222
],
[
222,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
228,
230
],
[
225,
231
],
[
222,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
235,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
238,
240
],
[
235,
241
],
[
232,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
244,
246
],
[
246,
247
],
[
246,
248
],
[
214,
249
],
[
249,
250
],
[
250,
251
],
[
250,
252
],
[
249,
253
],
[
172,
254
],
[
254,
255
],
[
255,
256
],
[
256,
257
],
[
256,
258
],
[
254,
259
],
[
315,
260
],
[
260,
261
],
[
260,
262
],
[
262,
263
],
[
263,
264
],
[
264,
265
],
[
265,
266
],
[
264,
267
],
[
260,
268
],
[
268,
269
],
[
315,
270
],
[
270,
271
],
[
270,
272
],
[
272,
273
],
[
273,
274
],
[
274,
275
],
[
275,
276
],
[
274,
277
],
[
270,
278
],
[
278,
279
],
[
315,
280
],
[
280,
281
],
[
280,
282
],
[
282,
283
],
[
283,
284
],
[
284,
285
],
[
285,
286
],
[
284,
287
],
[
280,
288
],
[
288,
289
],
[
315,
290
],
[
290,
291
],
[
290,
292
],
[
292,
293
],
[
293,
294
],
[
294,
295
],
[
295,
296
],
[
294,
297
],
[
290,
298
],
[
298,
299
],
[
315,
300
],
[
300,
301
],
[
300,
302
],
[
302,
303
],
[
303,
304
],
[
300,
305
],
[
305,
306
],
[
315,
307
],
[
307,
308
],
[
307,
309
],
[
309,
310
],
[
310,
311
],
[
307,
312
],
[
312,
313
],
[
0,
314
],
[
314,
315
],
[
314,
316
]
]
| [
"import java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n // abc176_a();\n // abc176_b();\n abc176_c();\n }\n\n private static void abc176_a() {\n try (Scanner sc = new Scanner(System.in)) {\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_b() {\n try (Scanner sc = new Scanner(System.in)) {\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n // int 2147483648 [ 2 * 10(9)]\n // long 9223372036854775808 [ 9 * 10(18)]\n\n public static int parseI(String value) {\n return Integer.parseInt(value);\n }\n\n public static long parseL(String value) {\n return Long.parseLong(value);\n }\n\n public static double parseD(String value) {\n return Double.parseDouble(value);\n }\n\n public static <T> String parseS(T value) {\n return String.valueOf(value);\n }\n\n public static BigDecimal parseBigD(String value) {\n return new BigDecimal(value);\n }\n\n public static BigInteger parseBigI(String value) {\n return new BigInteger(value);\n }\n\n}",
"import java.math.BigDecimal;",
"BigDecimal",
"java.math",
"import java.math.BigInteger;",
"BigInteger",
"java.math",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n public static void main(String[] args) {\n // abc176_a();\n // abc176_b();\n abc176_c();\n }\n\n private static void abc176_a() {\n try (Scanner sc = new Scanner(System.in)) {\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_b() {\n try (Scanner sc = new Scanner(System.in)) {\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n // int 2147483648 [ 2 * 10(9)]\n // long 9223372036854775808 [ 9 * 10(18)]\n\n public static int parseI(String value) {\n return Integer.parseInt(value);\n }\n\n public static long parseL(String value) {\n return Long.parseLong(value);\n }\n\n public static double parseD(String value) {\n return Double.parseDouble(value);\n }\n\n public static <T> String parseS(T value) {\n return String.valueOf(value);\n }\n\n public static BigDecimal parseBigD(String value) {\n return new BigDecimal(value);\n }\n\n public static BigInteger parseBigI(String value) {\n return new BigInteger(value);\n }\n\n}",
"Main",
"public static void main(String[] args) {\n // abc176_a();\n // abc176_b();\n abc176_c();\n }",
"main",
"{\n // abc176_a();\n // abc176_b();\n abc176_c();\n }",
"abc176_c()",
"abc176_c",
"String[] args",
"args",
"private static void abc176_a() {\n try (Scanner sc = new Scanner(System.in)) {\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }",
"abc176_a",
"{\n try (Scanner sc = new Scanner(System.in)) {\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }",
"try (Scanner sc = new Scanner(System.in)) {\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\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",
"\"エラー\"",
"e",
"{\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\n\n }",
"Scanner sc = new Scanner(System.in)",
"Scanner sc = new Scanner(System.in)",
"new Scanner(System.in)",
"double nAll = sc.nextInt();",
"nAll",
"sc.nextInt()",
"sc.nextInt",
"sc",
"double xOneTime = sc.nextInt();",
"xOneTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int tMinute = sc.nextInt();",
"tMinute",
"sc.nextInt()",
"sc.nextInt",
"sc",
"System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute)",
"System.out.println",
"System.out",
"System",
"System.out",
"(int) Math.ceil(nAll / xOneTime) * tMinute",
"(int) Math.ceil(nAll / xOneTime)",
"Math.ceil",
"Math",
"nAll / xOneTime",
"nAll",
"xOneTime",
"tMinute",
"private static void abc176_b() {\n try (Scanner sc = new Scanner(System.in)) {\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }",
"abc176_b",
"{\n try (Scanner sc = new Scanner(System.in)) {\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }",
"try (Scanner sc = new Scanner(System.in)) {\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\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",
"\"エラー\"",
"e",
"{\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n\n }",
"Scanner sc = new Scanner(System.in)",
"Scanner sc = new Scanner(System.in)",
"new Scanner(System.in)",
"String nValue = sc.next();",
"nValue",
"sc.next()",
"sc.next",
"sc",
"List<Integer> numList = new ArrayList<Integer>();",
"numList",
"new ArrayList<Integer>()",
"for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i <= nValue.length()",
"i",
"nValue.length()",
"nValue.length",
"nValue",
"i++",
"i++",
"i",
"{\n numList.add(parseI(nValue.substring(i - 1, i)));\n }",
"{\n numList.add(parseI(nValue.substring(i - 1, i)));\n }",
"numList.add(parseI(nValue.substring(i - 1, i)))",
"numList.add",
"numList",
"parseI(nValue.substring(i - 1, i))",
"parseI",
"nValue.substring(i - 1, i)",
"nValue.substring",
"nValue",
"i - 1",
"i",
"1",
"i",
"int sum = 0;",
"sum",
"0",
"for (int num : numList) {\n sum += num;\n }",
"int num",
"numList",
"{\n sum += num;\n }",
"{\n sum += num;\n }",
"sum += num",
"sum",
"num",
"if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }",
"sum % 9 == 0",
"sum % 9",
"sum",
"9",
"0",
"{\n System.out.println(\"Yes\");\n }",
"System.out.println(\"Yes\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"Yes\"",
"{\n System.out.println(\"No\");\n }",
"System.out.println(\"No\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"No\"",
"private static void abc176_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }",
"abc176_c",
"{\n try (Scanner sc = new Scanner(System.in)) {\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }",
"try (Scanner sc = new Scanner(System.in)) {\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\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",
"\"エラー\"",
"e",
"{\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\n\n }",
"Scanner sc = new Scanner(System.in)",
"Scanner sc = new Scanner(System.in)",
"new Scanner(System.in)",
"int nPeopleCount = sc.nextInt();",
"nPeopleCount",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] aTallList = new int[2 * 100000];",
"aTallList",
"new int[2 * 100000]",
"2 * 100000",
"2",
"100000",
"long totalAdd = 0;",
"totalAdd",
"0",
"int tall = 0;",
"tall",
"0",
"aTallList[0] = parseI(sc.next())",
"aTallList[0]",
"aTallList",
"0",
"parseI(sc.next())",
"parseI",
"sc.next()",
"sc.next",
"sc",
"for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < nPeopleCount",
"i",
"nPeopleCount",
"i++",
"i++",
"i",
"{\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }",
"{\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }",
"tall = parseI(sc.next())",
"tall",
"parseI(sc.next())",
"parseI",
"sc.next()",
"sc.next",
"sc",
"if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }",
"0 < aTallList[i - 1] - tall",
"0",
"aTallList[i - 1] - tall",
"aTallList[i - 1]",
"aTallList",
"i - 1",
"i",
"1",
"tall",
"{\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }",
"totalAdd += aTallList[i - 1] - tall",
"totalAdd",
"aTallList[i - 1] - tall",
"aTallList[i - 1]",
"aTallList",
"i - 1",
"i",
"1",
"tall",
"tall = aTallList[i - 1]",
"tall",
"aTallList[i - 1]",
"aTallList",
"i - 1",
"i",
"1",
"aTallList[i] = tall",
"aTallList[i]",
"aTallList",
"i",
"tall",
"System.out.println(totalAdd)",
"System.out.println",
"System.out",
"System",
"System.out",
"totalAdd",
"public static int parseI(String value) {\n return Integer.parseInt(value);\n }",
"parseI",
"{\n return Integer.parseInt(value);\n }",
"return Integer.parseInt(value);",
"Integer.parseInt(value)",
"Integer.parseInt",
"Integer",
"value",
"String value",
"value",
"public static long parseL(String value) {\n return Long.parseLong(value);\n }",
"parseL",
"{\n return Long.parseLong(value);\n }",
"return Long.parseLong(value);",
"Long.parseLong(value)",
"Long.parseLong",
"Long",
"value",
"String value",
"value",
"public static double parseD(String value) {\n return Double.parseDouble(value);\n }",
"parseD",
"{\n return Double.parseDouble(value);\n }",
"return Double.parseDouble(value);",
"Double.parseDouble(value)",
"Double.parseDouble",
"Double",
"value",
"String value",
"value",
"public static <T> String parseS(T value) {\n return String.valueOf(value);\n }",
"parseS",
"{\n return String.valueOf(value);\n }",
"return String.valueOf(value);",
"String.valueOf(value)",
"String.valueOf",
"String",
"value",
"T value",
"value",
"public static BigDecimal parseBigD(String value) {\n return new BigDecimal(value);\n }",
"parseBigD",
"{\n return new BigDecimal(value);\n }",
"return new BigDecimal(value);",
"new BigDecimal(value)",
"String value",
"value",
"public static BigInteger parseBigI(String value) {\n return new BigInteger(value);\n }",
"parseBigI",
"{\n return new BigInteger(value);\n }",
"return new BigInteger(value);",
"new BigInteger(value)",
"String value",
"value",
"public class Main {\n\n public static void main(String[] args) {\n // abc176_a();\n // abc176_b();\n abc176_c();\n }\n\n private static void abc176_a() {\n try (Scanner sc = new Scanner(System.in)) {\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_b() {\n try (Scanner sc = new Scanner(System.in)) {\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n // int 2147483648 [ 2 * 10(9)]\n // long 9223372036854775808 [ 9 * 10(18)]\n\n public static int parseI(String value) {\n return Integer.parseInt(value);\n }\n\n public static long parseL(String value) {\n return Long.parseLong(value);\n }\n\n public static double parseD(String value) {\n return Double.parseDouble(value);\n }\n\n public static <T> String parseS(T value) {\n return String.valueOf(value);\n }\n\n public static BigDecimal parseBigD(String value) {\n return new BigDecimal(value);\n }\n\n public static BigInteger parseBigI(String value) {\n return new BigInteger(value);\n }\n\n}",
"public class Main {\n\n public static void main(String[] args) {\n // abc176_a();\n // abc176_b();\n abc176_c();\n }\n\n private static void abc176_a() {\n try (Scanner sc = new Scanner(System.in)) {\n double nAll = sc.nextInt();\n double xOneTime = sc.nextInt();\n int tMinute = sc.nextInt();\n\n System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_b() {\n try (Scanner sc = new Scanner(System.in)) {\n String nValue = sc.next();\n List<Integer> numList = new ArrayList<Integer>();\n\n for (int i = 1; i <= nValue.length(); i++) {\n numList.add(parseI(nValue.substring(i - 1, i)));\n }\n\n int sum = 0;\n\n for (int num : numList) {\n sum += num;\n }\n\n if (sum % 9 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n private static void abc176_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int nPeopleCount = sc.nextInt();\n int[] aTallList = new int[2 * 100000];\n\n long totalAdd = 0;\n int tall = 0;\n\n aTallList[0] = parseI(sc.next());\n for (int i = 1; i < nPeopleCount; i++) {\n tall = parseI(sc.next());\n if (0 < aTallList[i - 1] - tall) {\n totalAdd += aTallList[i - 1] - tall;\n tall = aTallList[i - 1];\n }\n aTallList[i] = tall;\n }\n System.out.println(totalAdd);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n // int 2147483648 [ 2 * 10(9)]\n // long 9223372036854775808 [ 9 * 10(18)]\n\n public static int parseI(String value) {\n return Integer.parseInt(value);\n }\n\n public static long parseL(String value) {\n return Long.parseLong(value);\n }\n\n public static double parseD(String value) {\n return Double.parseDouble(value);\n }\n\n public static <T> String parseS(T value) {\n return String.valueOf(value);\n }\n\n public static BigDecimal parseBigD(String value) {\n return new BigDecimal(value);\n }\n\n public static BigInteger parseBigI(String value) {\n return new BigInteger(value);\n }\n\n}",
"Main"
]
| import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// abc176_a();
// abc176_b();
abc176_c();
}
private static void abc176_a() {
try (Scanner sc = new Scanner(System.in)) {
double nAll = sc.nextInt();
double xOneTime = sc.nextInt();
int tMinute = sc.nextInt();
System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);
} catch (Exception e) {
System.out.println("エラー" + e);
}
}
private static void abc176_b() {
try (Scanner sc = new Scanner(System.in)) {
String nValue = sc.next();
List<Integer> numList = new ArrayList<Integer>();
for (int i = 1; i <= nValue.length(); i++) {
numList.add(parseI(nValue.substring(i - 1, i)));
}
int sum = 0;
for (int num : numList) {
sum += num;
}
if (sum % 9 == 0) {
System.out.println("Yes");
} else {
System.out.println("No");
}
} catch (Exception e) {
System.out.println("エラー" + e);
}
}
private static void abc176_c() {
try (Scanner sc = new Scanner(System.in)) {
int nPeopleCount = sc.nextInt();
int[] aTallList = new int[2 * 100000];
long totalAdd = 0;
int tall = 0;
aTallList[0] = parseI(sc.next());
for (int i = 1; i < nPeopleCount; i++) {
tall = parseI(sc.next());
if (0 < aTallList[i - 1] - tall) {
totalAdd += aTallList[i - 1] - tall;
tall = aTallList[i - 1];
}
aTallList[i] = tall;
}
System.out.println(totalAdd);
} catch (Exception e) {
System.out.println("エラー" + e);
}
}
// int 2147483648 [ 2 * 10(9)]
// long 9223372036854775808 [ 9 * 10(18)]
public static int parseI(String value) {
return Integer.parseInt(value);
}
public static long parseL(String value) {
return Long.parseLong(value);
}
public static double parseD(String value) {
return Double.parseDouble(value);
}
public static <T> String parseS(T value) {
return String.valueOf(value);
}
public static BigDecimal parseBigD(String value) {
return new BigDecimal(value);
}
public static BigInteger parseBigI(String value) {
return new BigInteger(value);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
41,
13,
17,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
88,
8
],
[
88,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
11,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
23,
26
],
[
26,
27
],
[
27,
28
],
[
11,
29
],
[
29,
30
],
[
29,
31
],
[
11,
32
],
[
32,
33
],
[
32,
34
],
[
11,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
37,
39
],
[
11,
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
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
59,
60
],
[
52,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
63,
67
],
[
52,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
11,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
11,
82
],
[
82,
83
],
[
83,
84
],
[
9,
85
],
[
85,
86
],
[
0,
87
],
[
87,
88
],
[
87,
89
]
]
| [
"// package Contest#176;\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter out = new PrintWriter(System.out);\n\n StringTokenizer st = new StringTokenizer(br.readLine());\n int n = Integer.parseInt(st.nextToken());\n StringTokenizer st1 = new StringTokenizer(br.readLine());\n\n long sum = 0;\n int max = Integer.MIN_VALUE;\n\n for(int i=1; i<=n; i++){\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }\n\n out.println(sum);\n out.close();\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n public static void main(String[] args) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter out = new PrintWriter(System.out);\n\n StringTokenizer st = new StringTokenizer(br.readLine());\n int n = Integer.parseInt(st.nextToken());\n StringTokenizer st1 = new StringTokenizer(br.readLine());\n\n long sum = 0;\n int max = Integer.MIN_VALUE;\n\n for(int i=1; i<=n; i++){\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }\n\n out.println(sum);\n out.close();\n }\n}",
"Main",
"public static void main(String[] args) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter out = new PrintWriter(System.out);\n\n StringTokenizer st = new StringTokenizer(br.readLine());\n int n = Integer.parseInt(st.nextToken());\n StringTokenizer st1 = new StringTokenizer(br.readLine());\n\n long sum = 0;\n int max = Integer.MIN_VALUE;\n\n for(int i=1; i<=n; i++){\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }\n\n out.println(sum);\n out.close();\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter out = new PrintWriter(System.out);\n\n StringTokenizer st = new StringTokenizer(br.readLine());\n int n = Integer.parseInt(st.nextToken());\n StringTokenizer st1 = new StringTokenizer(br.readLine());\n\n long sum = 0;\n int max = Integer.MIN_VALUE;\n\n for(int i=1; i<=n; i++){\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }\n\n out.println(sum);\n out.close();\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"StringTokenizer st = new StringTokenizer(br.readLine());",
"st",
"new StringTokenizer(br.readLine())",
"int n = Integer.parseInt(st.nextToken());",
"n",
"Integer.parseInt(st.nextToken())",
"Integer.parseInt",
"Integer",
"st.nextToken()",
"st.nextToken",
"st",
"StringTokenizer st1 = new StringTokenizer(br.readLine());",
"st1",
"new StringTokenizer(br.readLine())",
"long sum = 0;",
"sum",
"0",
"int max = Integer.MIN_VALUE;",
"max",
"Integer.MIN_VALUE",
"Integer",
"Integer.MIN_VALUE",
"for(int i=1; i<=n; i++){\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<=n",
"i",
"n",
"i++",
"i++",
"i",
"{\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }",
"{\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }",
"int ht = Integer.parseInt(st1.nextToken());",
"ht",
"Integer.parseInt(st1.nextToken())",
"Integer.parseInt",
"Integer",
"st1.nextToken()",
"st1.nextToken",
"st1",
"max = Math.max(max, ht)",
"max",
"Math.max(max, ht)",
"Math.max",
"Math",
"max",
"ht",
"if(ht < max){\n sum += (max-ht);\n }",
"ht < max",
"ht",
"max",
"{\n sum += (max-ht);\n }",
"sum += (max-ht)",
"sum",
"(max-ht)",
"max",
"ht",
"out.println(sum)",
"out.println",
"out",
"sum",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter out = new PrintWriter(System.out);\n\n StringTokenizer st = new StringTokenizer(br.readLine());\n int n = Integer.parseInt(st.nextToken());\n StringTokenizer st1 = new StringTokenizer(br.readLine());\n\n long sum = 0;\n int max = Integer.MIN_VALUE;\n\n for(int i=1; i<=n; i++){\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }\n\n out.println(sum);\n out.close();\n }\n}",
"public class Main {\n public static void main(String[] args) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter out = new PrintWriter(System.out);\n\n StringTokenizer st = new StringTokenizer(br.readLine());\n int n = Integer.parseInt(st.nextToken());\n StringTokenizer st1 = new StringTokenizer(br.readLine());\n\n long sum = 0;\n int max = Integer.MIN_VALUE;\n\n for(int i=1; i<=n; i++){\n int ht = Integer.parseInt(st1.nextToken());\n max = Math.max(max, ht);\n if(ht < max){\n sum += (max-ht);\n }\n }\n\n out.println(sum);\n out.close();\n }\n}",
"Main"
]
| // package Contest#176;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
StringTokenizer st1 = new StringTokenizer(br.readLine());
long sum = 0;
int max = Integer.MIN_VALUE;
for(int i=1; i<=n; i++){
int ht = Integer.parseInt(st1.nextToken());
max = Math.max(max, ht);
if(ht < max){
sum += (max-ht);
}
}
out.println(sum);
out.close();
}
} |
[
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,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
2,
18,
13,
13,
17,
3,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
2,
18,
13,
2,
13,
17,
2,
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
],
[
120,
5
],
[
120,
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
],
[
51,
52
],
[
51,
53
],
[
44,
54
],
[
54,
55
],
[
55,
56
],
[
44,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
59,
67
],
[
58,
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
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
78,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
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
],
[
8,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
6,
117
],
[
117,
118
],
[
0,
119
],
[
119,
120
],
[
119,
121
]
]
| [
"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[] a = new int[n];\n for(int i=0; i<n; i++) {\n a[i] = sc.nextInt();\n }\n\n long sum = 0;\n for(int i=0; i<a.length; i++) {\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }\n System.out.println(sum);\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\n long sum = 0;\n for(int i=0; i<a.length; i++) {\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }\n System.out.println(sum);\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\n long sum = 0;\n for(int i=0; i<a.length; i++) {\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }\n System.out.println(sum);\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\n long sum = 0;\n for(int i=0; i<a.length; i++) {\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }\n System.out.println(sum);\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",
"long sum = 0;",
"sum",
"0",
"for(int i=0; i<a.length; i++) {\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }",
"{\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }",
"if(i == a.length-1) break;",
"i == a.length-1",
"i",
"a.length-1",
"a.length",
"a",
"a.length",
"1",
"break;",
"if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }",
"a[i] > a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"{\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }",
"sum += a[i] - a[i+1]",
"sum",
"a[i] - a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"a[i+1] = a[i+1] + (a[i] - a[i+1])",
"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",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"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\n long sum = 0;\n for(int i=0; i<a.length; i++) {\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }\n System.out.println(sum);\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\n long sum = 0;\n for(int i=0; i<a.length; i++) {\n if(i == a.length-1) break;\n if(a[i] > a[i+1]) {\n sum += a[i] - a[i+1];\n a[i+1] = a[i+1] + (a[i] - a[i+1]);\n }\n }\n System.out.println(sum);\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();
}
long sum = 0;
for(int i=0; i<a.length; i++) {
if(i == a.length-1) break;
if(a[i] > a[i+1]) {
sum += a[i] - a[i+1];
a[i+1] = a[i+1] + (a[i] - a[i+1]);
}
}
System.out.println(sum);
}
}
|
[
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,
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,
41,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
4,
18,
13,
2,
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
],
[
107,
8
],
[
107,
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,
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
],
[
52,
55
],
[
55,
56
],
[
55,
57
],
[
11,
58
],
[
58,
59
],
[
58,
60
],
[
11,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
11,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
66,
71
],
[
71,
72
],
[
71,
73
],
[
66,
74
],
[
74,
75
],
[
75,
76
],
[
66,
77
],
[
78,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
11,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
9,
104
],
[
104,
105
],
[
0,
106
],
[
106,
107
],
[
106,
108
]
]
| [
"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[] data = br.readLine().split(\" \");\n long[] a = new long[n];\n for(int i = 0; i < n; i++){\n a[i] = Long.parseLong(data[i]);\n }\n long answer = 0;\n long max = a[0];\n for(int i = 1; i < n; i++){\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }\n System.out.println(answer);\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[] data = br.readLine().split(\" \");\n long[] a = new long[n];\n for(int i = 0; i < n; i++){\n a[i] = Long.parseLong(data[i]);\n }\n long answer = 0;\n long max = a[0];\n for(int i = 1; i < n; i++){\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }\n System.out.println(answer);\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[] data = br.readLine().split(\" \");\n long[] a = new long[n];\n for(int i = 0; i < n; i++){\n a[i] = Long.parseLong(data[i]);\n }\n long answer = 0;\n long max = a[0];\n for(int i = 1; i < n; i++){\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }\n System.out.println(answer);\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n String[] data = br.readLine().split(\" \");\n long[] a = new long[n];\n for(int i = 0; i < n; i++){\n a[i] = Long.parseLong(data[i]);\n }\n long answer = 0;\n long max = a[0];\n for(int i = 1; i < n; i++){\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }\n System.out.println(answer);\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[] data = br.readLine().split(\" \");",
"data",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"long[] a = new long[n];",
"a",
"new long[n]",
"n",
"for(int i = 0; i < n; i++){\n a[i] = Long.parseLong(data[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = Long.parseLong(data[i]);\n }",
"{\n a[i] = Long.parseLong(data[i]);\n }",
"a[i] = Long.parseLong(data[i])",
"a[i]",
"a",
"i",
"Long.parseLong(data[i])",
"Long.parseLong",
"Long",
"data[i]",
"data",
"i",
"long answer = 0;",
"answer",
"0",
"long max = a[0];",
"max",
"a[0]",
"a",
"0",
"for(int i = 1; i < n; i++){\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }",
"{\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }",
"max = Math.max(max, a[i])",
"max",
"Math.max(max, a[i])",
"Math.max",
"Math",
"max",
"a[i]",
"a",
"i",
"answer += Math.abs(max - a[i])",
"answer",
"Math.abs(max - a[i])",
"Math.abs",
"Math",
"max - a[i]",
"max",
"a[i]",
"a",
"i",
"System.out.println(answer)",
"System.out.println",
"System.out",
"System",
"System.out",
"answer",
"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[] data = br.readLine().split(\" \");\n long[] a = new long[n];\n for(int i = 0; i < n; i++){\n a[i] = Long.parseLong(data[i]);\n }\n long answer = 0;\n long max = a[0];\n for(int i = 1; i < n; i++){\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }\n System.out.println(answer);\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[] data = br.readLine().split(\" \");\n long[] a = new long[n];\n for(int i = 0; i < n; i++){\n a[i] = Long.parseLong(data[i]);\n }\n long answer = 0;\n long max = a[0];\n for(int i = 1; i < n; i++){\n max = Math.max(max, a[i]);\n answer += Math.abs(max - a[i]);\n }\n System.out.println(answer);\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[] data = br.readLine().split(" ");
long[] a = new long[n];
for(int i = 0; i < n; i++){
a[i] = Long.parseLong(data[i]);
}
long answer = 0;
long max = a[0];
for(int i = 1; i < n; i++){
max = Math.max(max, a[i]);
answer += Math.abs(max - a[i]);
}
System.out.println(answer);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
12,
13,
30,
41,
13,
20,
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,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
198,
8
],
[
198,
9
],
[
9,
10
],
[
198,
11
],
[
11,
12
],
[
11,
13
],
[
13,
14
],
[
14,
15
],
[
14,
16
],
[
13,
17
],
[
17,
18
],
[
17,
19
],
[
13,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
13,
25
],
[
25,
26
],
[
25,
27
],
[
13,
29
],
[
29,
30
],
[
29,
31
],
[
13,
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
],
[
13,
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
],
[
68,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
67,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
80,
86
],
[
86,
87
],
[
86,
88
],
[
77,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
13,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
13,
104
],
[
104,
105
],
[
105,
106
],
[
11,
107
],
[
107,
108
],
[
198,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
109,
113
],
[
113,
114
],
[
109,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
109,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
124,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
134,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
123,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
109,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
153,
156
],
[
156,
157
],
[
109,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
162,
165
],
[
165,
166
],
[
109,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
171,
174
],
[
174,
175
],
[
109,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
182,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
178,
195
],
[
195,
196
],
[
0,
197
],
[
197,
198
],
[
197,
199
]
]
| [
"import java.io.*;\nimport java.util.*;\n\n\npublic class Main{\n\t\n\tpublic static void main(String[] args){\n\t\n\tMyScanner sc = new MyScanner();\n\tout = new PrintWriter(new BufferedOutputStream(System.out));\n\t\n\t/**/\n\n\tint numberOfPersons = sc.nextInt();\n\tlong[] persons = new long[numberOfPersons];\n\tlong counter = 0;\n\t\n\tfor(int i = 0; i < numberOfPersons; i++){\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}\n\t\n\tfor(int i = 1; i < persons.length; i++){\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}\n\t\n\tSystem.out.println(counter);\n\t\n\t\n\t\n\t/**/\n\t \n\t out.close();\t\n\t}\n\t\n\t\n\t\n\tpublic static PrintWriter out;\n\t\n\tpublic static class MyScanner{\n\t\t\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic MyScanner(){\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\t\n\t\tString next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n\t\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\t\n\tpublic static void main(String[] args){\n\t\n\tMyScanner sc = new MyScanner();\n\tout = new PrintWriter(new BufferedOutputStream(System.out));\n\t\n\t/**/\n\n\tint numberOfPersons = sc.nextInt();\n\tlong[] persons = new long[numberOfPersons];\n\tlong counter = 0;\n\t\n\tfor(int i = 0; i < numberOfPersons; i++){\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}\n\t\n\tfor(int i = 1; i < persons.length; i++){\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}\n\t\n\tSystem.out.println(counter);\n\t\n\t\n\t\n\t/**/\n\t \n\t out.close();\t\n\t}\n\t\n\t\n\t\n\tpublic static PrintWriter out;\n\t\n\tpublic static class MyScanner{\n\t\t\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic MyScanner(){\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\t\n\t\tString next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n\t\n}",
"Main",
"public static PrintWriter out;",
"out",
"public static void main(String[] args){\n\t\n\tMyScanner sc = new MyScanner();\n\tout = new PrintWriter(new BufferedOutputStream(System.out));\n\t\n\t/**/\n\n\tint numberOfPersons = sc.nextInt();\n\tlong[] persons = new long[numberOfPersons];\n\tlong counter = 0;\n\t\n\tfor(int i = 0; i < numberOfPersons; i++){\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}\n\t\n\tfor(int i = 1; i < persons.length; i++){\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}\n\t\n\tSystem.out.println(counter);\n\t\n\t\n\t\n\t/**/\n\t \n\t out.close();\t\n\t}",
"main",
"{\n\t\n\tMyScanner sc = new MyScanner();\n\tout = new PrintWriter(new BufferedOutputStream(System.out));\n\t\n\t/**/\n\n\tint numberOfPersons = sc.nextInt();\n\tlong[] persons = new long[numberOfPersons];\n\tlong counter = 0;\n\t\n\tfor(int i = 0; i < numberOfPersons; i++){\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}\n\t\n\tfor(int i = 1; i < persons.length; i++){\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}\n\t\n\tSystem.out.println(counter);\n\t\n\t\n\t\n\t/**/\n\t \n\t out.close();\t\n\t}",
"MyScanner sc = new MyScanner();",
"sc",
"new MyScanner()",
"out = new PrintWriter(new BufferedOutputStream(System.out))",
"out",
"new PrintWriter(new BufferedOutputStream(System.out))",
"int numberOfPersons = sc.nextInt();",
"numberOfPersons",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] persons = new long[numberOfPersons];",
"persons",
"new long[numberOfPersons]",
"numberOfPersons",
"long counter = 0;",
"counter",
"0",
"for(int i = 0; i < numberOfPersons; i++){\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numberOfPersons",
"i",
"numberOfPersons",
"i++",
"i++",
"i",
"{\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}",
"{\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}",
"persons[i] = sc.nextLong()",
"persons[i]",
"persons",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"for(int i = 1; i < persons.length; i++){\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < persons.length",
"i",
"persons.length",
"persons",
"persons.length",
"i++",
"i++",
"i",
"{\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}",
"{\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}",
"if(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}",
"persons[i] < persons[i - 1]",
"persons[i]",
"persons",
"i",
"persons[i - 1]",
"persons",
"i - 1",
"i",
"1",
"{\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}",
"counter += persons[i - 1] - persons[i]",
"counter",
"persons[i - 1] - persons[i]",
"persons[i - 1]",
"persons",
"i - 1",
"i",
"1",
"persons[i]",
"persons",
"i",
"persons[i] = persons[i - 1]",
"persons[i]",
"persons",
"i",
"persons[i - 1]",
"persons",
"i - 1",
"i",
"1",
"System.out.println(counter)",
"System.out.println",
"System.out",
"System",
"System.out",
"counter",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"public static class MyScanner{\n\t\t\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic MyScanner(){\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\t\n\t\tString next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }",
"MyScanner",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public MyScanner(){\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}",
"MyScanner",
"{\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"next",
"{\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"try {\n st = new StringTokenizer(br.readLine());\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 st = new StringTokenizer(br.readLine());\n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }",
"nextLine",
"{\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }",
"String str = \"\";",
"str",
"\"\"",
"try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"IOException e",
"{\n\t e.printStackTrace();\n\t }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t str = br.readLine();\n\t }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main{\n\t\n\tpublic static void main(String[] args){\n\t\n\tMyScanner sc = new MyScanner();\n\tout = new PrintWriter(new BufferedOutputStream(System.out));\n\t\n\t/**/\n\n\tint numberOfPersons = sc.nextInt();\n\tlong[] persons = new long[numberOfPersons];\n\tlong counter = 0;\n\t\n\tfor(int i = 0; i < numberOfPersons; i++){\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}\n\t\n\tfor(int i = 1; i < persons.length; i++){\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}\n\t\n\tSystem.out.println(counter);\n\t\n\t\n\t\n\t/**/\n\t \n\t out.close();\t\n\t}\n\t\n\t\n\t\n\tpublic static PrintWriter out;\n\t\n\tpublic static class MyScanner{\n\t\t\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic MyScanner(){\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\t\n\t\tString next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n\t\n}",
"public class Main{\n\t\n\tpublic static void main(String[] args){\n\t\n\tMyScanner sc = new MyScanner();\n\tout = new PrintWriter(new BufferedOutputStream(System.out));\n\t\n\t/**/\n\n\tint numberOfPersons = sc.nextInt();\n\tlong[] persons = new long[numberOfPersons];\n\tlong counter = 0;\n\t\n\tfor(int i = 0; i < numberOfPersons; i++){\n\t\t\n\t\tpersons[i] = sc.nextLong();\n\t\t\n\t}\n\t\n\tfor(int i = 1; i < persons.length; i++){\n\t\t\n\t\tif(persons[i] < persons[i - 1]){\n\t\t\n\t\t\tcounter += persons[i - 1] - persons[i];\n\t\t\tpersons[i] = persons[i - 1];\n\t\t\n\t\t}\n\t\t\n\t}\n\t\n\tSystem.out.println(counter);\n\t\n\t\n\t\n\t/**/\n\t \n\t out.close();\t\n\t}\n\t\n\t\n\t\n\tpublic static PrintWriter out;\n\t\n\tpublic static class MyScanner{\n\t\t\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic MyScanner(){\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\t\n\t\tString next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n\t\n}",
"Main"
]
| import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args){
MyScanner sc = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
/**/
int numberOfPersons = sc.nextInt();
long[] persons = new long[numberOfPersons];
long counter = 0;
for(int i = 0; i < numberOfPersons; i++){
persons[i] = sc.nextLong();
}
for(int i = 1; i < persons.length; i++){
if(persons[i] < persons[i - 1]){
counter += persons[i - 1] - persons[i];
persons[i] = persons[i - 1];
}
}
System.out.println(counter);
/**/
out.close();
}
public static PrintWriter out;
public static class MyScanner{
BufferedReader br;
StringTokenizer st;
public MyScanner(){
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
|
[
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,
2,
13,
17,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
9,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
99,
5
],
[
99,
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
],
[
51,
52
],
[
51,
53
],
[
44,
54
],
[
54,
55
],
[
55,
56
],
[
44,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
58,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
58,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
8,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
6,
96
],
[
96,
97
],
[
0,
98
],
[
98,
99
],
[
98,
100
]
]
| [
"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 long[] heights = new long[n];\n for (int i = 0; i < n; i++) {\n heights[i] = sc.nextLong();\n }\n long ans = 0;\n for (int j = 0; j < n - 1; j++) {\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }\n System.out.println(ans);\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 long[] heights = new long[n];\n for (int i = 0; i < n; i++) {\n heights[i] = sc.nextLong();\n }\n long ans = 0;\n for (int j = 0; j < n - 1; j++) {\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }\n System.out.println(ans);\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long[] heights = new long[n];\n for (int i = 0; i < n; i++) {\n heights[i] = sc.nextLong();\n }\n long ans = 0;\n for (int j = 0; j < n - 1; j++) {\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }\n System.out.println(ans);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long[] heights = new long[n];\n for (int i = 0; i < n; i++) {\n heights[i] = sc.nextLong();\n }\n long ans = 0;\n for (int j = 0; j < n - 1; j++) {\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\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",
"long[] heights = new long[n];",
"heights",
"new long[n]",
"n",
"for (int i = 0; i < n; i++) {\n heights[i] = sc.nextLong();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n heights[i] = sc.nextLong();\n }",
"{\n heights[i] = sc.nextLong();\n }",
"heights[i] = sc.nextLong()",
"heights[i]",
"heights",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"long ans = 0;",
"ans",
"0",
"for (int j = 0; j < n - 1; j++) {\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }",
"int j = 0;",
"int j = 0;",
"j",
"0",
"j < n - 1",
"j",
"n - 1",
"n",
"1",
"j++",
"j++",
"j",
"{\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }",
"{\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }",
"if (heights[j] <= heights[j + 1]) continue;",
"heights[j] <= heights[j + 1]",
"heights[j]",
"heights",
"j",
"heights[j + 1]",
"heights",
"j + 1",
"j",
"1",
"continue;",
"ans += heights[j] - heights[j + 1]",
"ans",
"heights[j] - heights[j + 1]",
"heights[j]",
"heights",
"j",
"heights[j + 1]",
"heights",
"j + 1",
"j",
"1",
"heights[j + 1] = heights[j]",
"heights[j + 1]",
"heights",
"j + 1",
"j",
"1",
"heights[j]",
"heights",
"j",
"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 long[] heights = new long[n];\n for (int i = 0; i < n; i++) {\n heights[i] = sc.nextLong();\n }\n long ans = 0;\n for (int j = 0; j < n - 1; j++) {\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }\n System.out.println(ans);\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 long[] heights = new long[n];\n for (int i = 0; i < n; i++) {\n heights[i] = sc.nextLong();\n }\n long ans = 0;\n for (int j = 0; j < n - 1; j++) {\n if (heights[j] <= heights[j + 1]) continue;\n ans += heights[j] - heights[j + 1];\n heights[j + 1] = heights[j];\n }\n System.out.println(ans);\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();
long[] heights = new long[n];
for (int i = 0; i < n; i++) {
heights[i] = sc.nextLong();
}
long ans = 0;
for (int j = 0; j < n - 1; j++) {
if (heights[j] <= heights[j + 1]) continue;
ans += heights[j] - heights[j + 1];
heights[j + 1] = heights[j];
}
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,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
41,
13,
0,
13,
40,
17,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
94,
5
],
[
94,
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
],
[
8,
43
],
[
43,
44
],
[
8,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
8,
49
],
[
49,
50
],
[
49,
51
],
[
8,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
52,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
65,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
8,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
85,
90
],
[
6,
91
],
[
91,
92
],
[
0,
93
],
[
93,
94
],
[
93,
95
]
]
| [
"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 n[] = new int[N];\n for(int i = 0; i < N; i++){\n n[i] = sc.nextInt();\n }\n long last, sum;\n last = -1;\n sum = 0;\n for(int i = 0; i < N; i++){\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }\n System.out.println(sum);\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 n[] = new int[N];\n for(int i = 0; i < N; i++){\n n[i] = sc.nextInt();\n }\n long last, sum;\n last = -1;\n sum = 0;\n for(int i = 0; i < N; i++){\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }\n System.out.println(sum);\n }\n}",
"Main",
"public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int n[] = new int[N];\n for(int i = 0; i < N; i++){\n n[i] = sc.nextInt();\n }\n long last, sum;\n last = -1;\n sum = 0;\n for(int i = 0; i < N; i++){\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }\n System.out.println(sum);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int n[] = new int[N];\n for(int i = 0; i < N; i++){\n n[i] = sc.nextInt();\n }\n long last, sum;\n last = -1;\n sum = 0;\n for(int i = 0; i < N; i++){\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }\n System.out.println(sum);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int n[] = new int[N];",
"n",
"new int[N]",
"N",
"for(int i = 0; i < N; i++){\n n[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n n[i] = sc.nextInt();\n }",
"{\n n[i] = sc.nextInt();\n }",
"n[i] = sc.nextInt()",
"n[i]",
"n",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long last",
"last",
"sum;",
"sum",
"last = -1",
"last",
"-1",
"1",
"sum = 0",
"sum",
"0",
"for(int i = 0; i < N; i++){\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }",
"{\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }",
"if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }",
"last > n[i]",
"last",
"n[i]",
"n",
"i",
"{\n sum += (last - n[i]);\n }",
"sum += (last - n[i])",
"sum",
"(last - n[i])",
"last",
"n[i]",
"n",
"i",
"{\n last = n[i];\n }",
"last = n[i]",
"last",
"n[i]",
"n",
"i",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"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 n[] = new int[N];\n for(int i = 0; i < N; i++){\n n[i] = sc.nextInt();\n }\n long last, sum;\n last = -1;\n sum = 0;\n for(int i = 0; i < N; i++){\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }\n System.out.println(sum);\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 n[] = new int[N];\n for(int i = 0; i < N; i++){\n n[i] = sc.nextInt();\n }\n long last, sum;\n last = -1;\n sum = 0;\n for(int i = 0; i < N; i++){\n\t if(last > n[i]){\n sum += (last - n[i]);\n } else {\n last = n[i];\n }\n }\n System.out.println(sum);\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 n[] = new int[N];
for(int i = 0; i < N; i++){
n[i] = sc.nextInt();
}
long last, sum;
last = -1;
sum = 0;
for(int i = 0; i < N; i++){
if(last > n[i]){
sum += (last - n[i]);
} else {
last = n[i];
}
}
System.out.println(sum);
}
} |
[
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,
4,
18,
13,
4,
18,
13,
41,
13,
17,
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,
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,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
30,
9,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
124,
5
],
[
124,
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
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
29,
30
],
[
8,
31
],
[
31,
32
],
[
31,
33
],
[
8,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
8,
40
],
[
40,
41
],
[
40,
42
],
[
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
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
62,
63
],
[
61,
64
],
[
64,
65
],
[
64,
66
],
[
8,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
67,
77
],
[
77,
78
],
[
78,
79
],
[
67,
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
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
92,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
110,
111
],
[
110,
112
],
[
82,
113
],
[
113,
114
],
[
8,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
6,
121
],
[
121,
122
],
[
0,
123
],
[
123,
124
],
[
123,
125
]
]
| [
"import java.util.*;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString N = sc.nextLine();\n\t\tint N_int = Integer.parseInt(N);\n\t\tString A = sc.nextLine();\n\t\t// System.out.println(A);\n\t\tsc.close();\n\n\t\tlong result=0;\n\n\t\tString[] num_str = A.split(\" \");\n\t\tint[] num_int = new int[N_int];\n\n\t\tfor(int i=0; i < N_int; i++){\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}\n\n\n\t\tfor(int j=0; j < N_int-1; j++){\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(result);\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\tString N = sc.nextLine();\n\t\tint N_int = Integer.parseInt(N);\n\t\tString A = sc.nextLine();\n\t\t// System.out.println(A);\n\t\tsc.close();\n\n\t\tlong result=0;\n\n\t\tString[] num_str = A.split(\" \");\n\t\tint[] num_int = new int[N_int];\n\n\t\tfor(int i=0; i < N_int; i++){\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}\n\n\n\t\tfor(int j=0; j < N_int-1; j++){\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(result);\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString N = sc.nextLine();\n\t\tint N_int = Integer.parseInt(N);\n\t\tString A = sc.nextLine();\n\t\t// System.out.println(A);\n\t\tsc.close();\n\n\t\tlong result=0;\n\n\t\tString[] num_str = A.split(\" \");\n\t\tint[] num_int = new int[N_int];\n\n\t\tfor(int i=0; i < N_int; i++){\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}\n\n\n\t\tfor(int j=0; j < N_int-1; j++){\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(result);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tString N = sc.nextLine();\n\t\tint N_int = Integer.parseInt(N);\n\t\tString A = sc.nextLine();\n\t\t// System.out.println(A);\n\t\tsc.close();\n\n\t\tlong result=0;\n\n\t\tString[] num_str = A.split(\" \");\n\t\tint[] num_int = new int[N_int];\n\n\t\tfor(int i=0; i < N_int; i++){\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}\n\n\n\t\tfor(int j=0; j < N_int-1; j++){\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(result);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String N = sc.nextLine();",
"N",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int N_int = Integer.parseInt(N);",
"N_int",
"Integer.parseInt(N)",
"Integer.parseInt",
"Integer",
"N",
"String A = sc.nextLine();",
"A",
"sc.nextLine()",
"sc.nextLine",
"sc",
"sc.close()",
"sc.close",
"sc",
"long result=0;",
"result",
"0",
"String[] num_str = A.split(\" \");",
"num_str",
"A.split(\" \")",
"A.split",
"A",
"\" \"",
"int[] num_int = new int[N_int];",
"num_int",
"new int[N_int]",
"N_int",
"for(int i=0; i < N_int; i++){\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i < N_int",
"i",
"N_int",
"i++",
"i++",
"i",
"{\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}",
"{\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}",
"num_int[i] = Integer.parseInt(num_str[i])",
"num_int[i]",
"num_int",
"i",
"Integer.parseInt(num_str[i])",
"Integer.parseInt",
"Integer",
"num_str[i]",
"num_str",
"i",
"for(int j=0; j < N_int-1; j++){\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}",
"int j=0;",
"int j=0;",
"j",
"0",
"j < N_int-1",
"j",
"N_int-1",
"N_int",
"1",
"j++",
"j++",
"j",
"{\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}",
"if (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"num_int[j] > num_int[j+1]",
"num_int[j]",
"num_int",
"j",
"num_int[j+1]",
"num_int",
"j+1",
"j",
"1",
"{\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}",
"result += num_int[j]- num_int[j+1]",
"result",
"num_int[j]- num_int[j+1]",
"num_int[j]",
"num_int",
"j",
"num_int[j+1]",
"num_int",
"j+1",
"j",
"1",
"num_int[j+1] = num_int[j]",
"num_int[j+1]",
"num_int",
"j+1",
"j",
"1",
"num_int[j]",
"num_int",
"j",
"{\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"continue;",
"System.out.println(result)",
"System.out.println",
"System.out",
"System",
"System.out",
"result",
"String[] args",
"args",
"public class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString N = sc.nextLine();\n\t\tint N_int = Integer.parseInt(N);\n\t\tString A = sc.nextLine();\n\t\t// System.out.println(A);\n\t\tsc.close();\n\n\t\tlong result=0;\n\n\t\tString[] num_str = A.split(\" \");\n\t\tint[] num_int = new int[N_int];\n\n\t\tfor(int i=0; i < N_int; i++){\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}\n\n\n\t\tfor(int j=0; j < N_int-1; j++){\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(result);\n\t}\n}",
"public class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString N = sc.nextLine();\n\t\tint N_int = Integer.parseInt(N);\n\t\tString A = sc.nextLine();\n\t\t// System.out.println(A);\n\t\tsc.close();\n\n\t\tlong result=0;\n\n\t\tString[] num_str = A.split(\" \");\n\t\tint[] num_int = new int[N_int];\n\n\t\tfor(int i=0; i < N_int; i++){\n\t\t\tnum_int[i] = Integer.parseInt(num_str[i]);\n\t\t\t}\n\n\n\t\tfor(int j=0; j < N_int-1; j++){\n\t\t\t\tif (num_int[j] > num_int[j+1]){\n\t\t\t\t\tresult += num_int[j]- num_int[j+1];\n\t\t\t\t\tnum_int[j+1] = num_int[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(result);\n\t}\n}",
"Main"
]
| import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String N = sc.nextLine();
int N_int = Integer.parseInt(N);
String A = sc.nextLine();
// System.out.println(A);
sc.close();
long result=0;
String[] num_str = A.split(" ");
int[] num_int = new int[N_int];
for(int i=0; i < N_int; i++){
num_int[i] = Integer.parseInt(num_str[i]);
}
for(int j=0; j < N_int-1; j++){
if (num_int[j] > num_int[j+1]){
result += num_int[j]- num_int[j+1];
num_int[j+1] = num_int[j];
}
else{
continue;
}
}
System.out.println(result);
}
}
|
[
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,
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,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
99,
5
],
[
99,
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
],
[
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
],
[
60,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
69,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
8,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
6,
96
],
[
96,
97
],
[
0,
98
],
[
98,
99
],
[
98,
100
]
]
| [
"import java.util.Scanner;\n\npublic class Main{\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc=new Scanner(System.in);\n\n\t\tint n= sc.nextInt();\n\n\t\tlong cnt =0;\n\n\t\tint[] arr= new int[n];\n\n\t\tfor(int i =0;i<n;i++) {\n\t\t\tarr[i]=sc.nextInt();\n\t\t}\n\n\t\tfor(int j=0;j<n-1;j++) {\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\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\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc=new Scanner(System.in);\n\n\t\tint n= sc.nextInt();\n\n\t\tlong cnt =0;\n\n\t\tint[] arr= new int[n];\n\n\t\tfor(int i =0;i<n;i++) {\n\t\t\tarr[i]=sc.nextInt();\n\t\t}\n\n\t\tfor(int j=0;j<n-1;j++) {\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\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\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc=new Scanner(System.in);\n\n\t\tint n= sc.nextInt();\n\n\t\tlong cnt =0;\n\n\t\tint[] arr= new int[n];\n\n\t\tfor(int i =0;i<n;i++) {\n\t\t\tarr[i]=sc.nextInt();\n\t\t}\n\n\t\tfor(int j=0;j<n-1;j++) {\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}",
"main",
"{\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc=new Scanner(System.in);\n\n\t\tint n= sc.nextInt();\n\n\t\tlong cnt =0;\n\n\t\tint[] arr= new int[n];\n\n\t\tfor(int i =0;i<n;i++) {\n\t\t\tarr[i]=sc.nextInt();\n\t\t}\n\n\t\tfor(int j=0;j<n-1;j++) {\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\n\t\t\t}\n\t\t}\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",
"long cnt =0;",
"cnt",
"0",
"int[] arr= new int[n];",
"arr",
"new int[n]",
"n",
"for(int i =0;i<n;i++) {\n\t\t\tarr[i]=sc.nextInt();\n\t\t}",
"int i =0;",
"int i =0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i]=sc.nextInt();\n\t\t}",
"{\n\t\t\tarr[i]=sc.nextInt();\n\t\t}",
"arr[i]=sc.nextInt()",
"arr[i]",
"arr",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int j=0;j<n-1;j++) {\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\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\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\n\t\t\t}\n\t\t}",
"if(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\n\t\t\t}",
"arr[j+1]<arr[j]",
"arr[j+1]",
"arr",
"j+1",
"j",
"1",
"arr[j]",
"arr",
"j",
"{\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\n\t\t\t}",
"cnt+=arr[j]-arr[j+1]",
"cnt",
"arr[j]-arr[j+1]",
"arr[j]",
"arr",
"j",
"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",
"System.out.println(cnt)",
"System.out.println",
"System.out",
"System",
"System.out",
"cnt",
"String[] args",
"args",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc=new Scanner(System.in);\n\n\t\tint n= sc.nextInt();\n\n\t\tlong cnt =0;\n\n\t\tint[] arr= new int[n];\n\n\t\tfor(int i =0;i<n;i++) {\n\t\t\tarr[i]=sc.nextInt();\n\t\t}\n\n\t\tfor(int j=0;j<n-1;j++) {\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}\n\n}",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner sc=new Scanner(System.in);\n\n\t\tint n= sc.nextInt();\n\n\t\tlong cnt =0;\n\n\t\tint[] arr= new int[n];\n\n\t\tfor(int i =0;i<n;i++) {\n\t\t\tarr[i]=sc.nextInt();\n\t\t}\n\n\t\tfor(int j=0;j<n-1;j++) {\n\t\t\tif(arr[j+1]<arr[j]) {\n\t\t\t\tcnt+=arr[j]-arr[j+1];\n\t\t\t\tarr[j+1]=arr[j];\n\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) {
// TODO 自動生成されたメソッド・スタブ
Scanner sc=new Scanner(System.in);
int n= sc.nextInt();
long cnt =0;
int[] arr= new int[n];
for(int i =0;i<n;i++) {
arr[i]=sc.nextInt();
}
for(int j=0;j<n-1;j++) {
if(arr[j+1]<arr[j]) {
cnt+=arr[j]-arr[j+1];
arr[j+1]=arr[j];
}
}
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,
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,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
41,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
96,
5
],
[
96,
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
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
58,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
70,
76
],
[
76,
77
],
[
76,
78
],
[
67,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
67,
84
],
[
84,
85
],
[
84,
86
],
[
8,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
87,
92
],
[
6,
93
],
[
93,
94
],
[
0,
95
],
[
95,
96
],
[
95,
97
]
]
| [
"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\tlong[] height =new long[N];\n\t\tlong con = 0;\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(con);\n\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\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tlong[] height =new long[N];\n\t\tlong con = 0;\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(con);\n\n\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\tlong[] height =new long[N];\n\t\tlong con = 0;\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(con);\n\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tlong[] height =new long[N];\n\t\tlong con = 0;\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(con);\n\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] height =new long[N];",
"height",
"new long[N]",
"N",
"long con = 0;",
"con",
"0",
"for (int i = 0; i < N; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\theight[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\theight[i] = sc.nextLong();\n\t\t}",
"height[i] = sc.nextLong()",
"height[i]",
"height",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"for (int i = 1; i < N; i++) {\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\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\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}",
"{\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}",
"if (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}",
"height[i-1] > height[i]",
"height[i-1]",
"height",
"i-1",
"i",
"1",
"height[i]",
"height",
"i",
"{\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}",
"long let =height[i-1] - height[i];",
"let",
"height[i-1] - height[i]",
"height[i-1]",
"height",
"i-1",
"i",
"1",
"height[i]",
"height",
"i",
"height[i] += let",
"height[i]",
"height",
"i",
"let",
"con += let",
"con",
"let",
"System.out.println(con)",
"System.out.println",
"System.out",
"System",
"System.out",
"con",
"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\tlong[] height =new long[N];\n\t\tlong con = 0;\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(con);\n\n\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 = sc.nextInt();\n\t\tlong[] height =new long[N];\n\t\tlong con = 0;\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (height[i-1] > height[i]) {\n\t\t\t\tlong let =height[i-1] - height[i];\n\t\t\t\theight[i] += let;\n\t\t\t\tcon += let;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(con);\n\n\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();
long[] height =new long[N];
long con = 0;
for (int i = 0; i < N; i++) {
height[i] = sc.nextLong();
}
for (int i = 1; i < N; i++) {
if (height[i-1] > height[i]) {
long let =height[i-1] - height[i];
height[i] += let;
con += let;
}
}
System.out.println(con);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
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,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
4,
18,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
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
],
[
202,
11
],
[
202,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
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
],
[
14,
50
],
[
50,
51
],
[
50,
52
],
[
14,
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
],
[
69,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
81,
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
],
[
93,
97
],
[
78,
98
],
[
98,
99
],
[
98,
100
],
[
14,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
14,
105
],
[
105,
106
],
[
106,
107
],
[
14,
108
],
[
108,
109
],
[
109,
110
],
[
12,
111
],
[
111,
112
],
[
202,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
113,
117
],
[
117,
118
],
[
113,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
113,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
128,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
138,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
127,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
113,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
157,
160
],
[
160,
161
],
[
113,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
166,
169
],
[
169,
170
],
[
113,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
175,
178
],
[
178,
179
],
[
113,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
186,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
182,
199
],
[
199,
200
],
[
0,
201
],
[
201,
202
],
[
201,
203
]
]
| [
"import java.util.*;\nimport java.io.*;\nimport java.lang.*;\n \npublic class Main {\n\n static class FastReader {\n\n BufferedReader br; \n StringTokenizer st; \n\n public FastReader() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n\n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n\n int nextInt() { \n return Integer.parseInt(next()); \n } \n\n long nextLong() { \n return Long.parseLong(next()); \n } \n\n double nextDouble() { \n return Double.parseDouble(next()); \n } \n\n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n public static void main(String args[]) throws IOException {\n // try {\n // FileOutputStream output = new FileOutputStream(\"temp.out\");\n // PrintStream out = new PrintStream(output);\n // //Diverting the output stream into file \"temp.out\".Comment the below line to use console\n // System.setOut(out);\n \n // InputStream input = new FileInputStream(\"temp.in\");\n // //Diverting the input stream into file \"temp.in\".Comment the below line to use console\n // System.setIn(input);\n \n // } catch (FileNotFoundException e) {\n // e.printStackTrace();\n // }\n \n FastReader sc = new FastReader();\n PrintWriter wr = new PrintWriter(System.out);\n \n // int t = 1;\n // t = sc.nextInt(); //Comment this line if there is single test case\n\n // while((t--) != 0) {\n\n\n // } \n\n\n int n = sc.nextInt();\n\n int[] arr = new int[n];\n\n for(int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n long ans = 0;\n\n for(int i = 1; i < arr.length; i++) {\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n } \n\n wr.println(ans);\n \n wr.flush();\n wr.close();\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"public class Main {\n\n static class FastReader {\n\n BufferedReader br; \n StringTokenizer st; \n\n public FastReader() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n\n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n\n int nextInt() { \n return Integer.parseInt(next()); \n } \n\n long nextLong() { \n return Long.parseLong(next()); \n } \n\n double nextDouble() { \n return Double.parseDouble(next()); \n } \n\n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n public static void main(String args[]) throws IOException {\n // try {\n // FileOutputStream output = new FileOutputStream(\"temp.out\");\n // PrintStream out = new PrintStream(output);\n // //Diverting the output stream into file \"temp.out\".Comment the below line to use console\n // System.setOut(out);\n \n // InputStream input = new FileInputStream(\"temp.in\");\n // //Diverting the input stream into file \"temp.in\".Comment the below line to use console\n // System.setIn(input);\n \n // } catch (FileNotFoundException e) {\n // e.printStackTrace();\n // }\n \n FastReader sc = new FastReader();\n PrintWriter wr = new PrintWriter(System.out);\n \n // int t = 1;\n // t = sc.nextInt(); //Comment this line if there is single test case\n\n // while((t--) != 0) {\n\n\n // } \n\n\n int n = sc.nextInt();\n\n int[] arr = new int[n];\n\n for(int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n long ans = 0;\n\n for(int i = 1; i < arr.length; i++) {\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n } \n\n wr.println(ans);\n \n wr.flush();\n wr.close();\n }\n}",
"Main",
"public static void main(String args[]) throws IOException {\n // try {\n // FileOutputStream output = new FileOutputStream(\"temp.out\");\n // PrintStream out = new PrintStream(output);\n // //Diverting the output stream into file \"temp.out\".Comment the below line to use console\n // System.setOut(out);\n \n // InputStream input = new FileInputStream(\"temp.in\");\n // //Diverting the input stream into file \"temp.in\".Comment the below line to use console\n // System.setIn(input);\n \n // } catch (FileNotFoundException e) {\n // e.printStackTrace();\n // }\n \n FastReader sc = new FastReader();\n PrintWriter wr = new PrintWriter(System.out);\n \n // int t = 1;\n // t = sc.nextInt(); //Comment this line if there is single test case\n\n // while((t--) != 0) {\n\n\n // } \n\n\n int n = sc.nextInt();\n\n int[] arr = new int[n];\n\n for(int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n long ans = 0;\n\n for(int i = 1; i < arr.length; i++) {\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n } \n\n wr.println(ans);\n \n wr.flush();\n wr.close();\n }",
"main",
"{\n // try {\n // FileOutputStream output = new FileOutputStream(\"temp.out\");\n // PrintStream out = new PrintStream(output);\n // //Diverting the output stream into file \"temp.out\".Comment the below line to use console\n // System.setOut(out);\n \n // InputStream input = new FileInputStream(\"temp.in\");\n // //Diverting the input stream into file \"temp.in\".Comment the below line to use console\n // System.setIn(input);\n \n // } catch (FileNotFoundException e) {\n // e.printStackTrace();\n // }\n \n FastReader sc = new FastReader();\n PrintWriter wr = new PrintWriter(System.out);\n \n // int t = 1;\n // t = sc.nextInt(); //Comment this line if there is single test case\n\n // while((t--) != 0) {\n\n\n // } \n\n\n int n = sc.nextInt();\n\n int[] arr = new int[n];\n\n for(int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n long ans = 0;\n\n for(int i = 1; i < arr.length; i++) {\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n } \n\n wr.println(ans);\n \n wr.flush();\n wr.close();\n }",
"FastReader sc = new FastReader();",
"sc",
"new FastReader()",
"PrintWriter wr = new PrintWriter(System.out);",
"wr",
"new PrintWriter(System.out)",
"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",
"long ans = 0;",
"ans",
"0",
"for(int i = 1; i < arr.length; i++) {\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < arr.length",
"i",
"arr.length",
"arr",
"arr.length",
"i++",
"i++",
"i",
"{\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n }",
"{\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n }",
"if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }",
"arr[i] < arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"{\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }",
"int temp = Math.abs(arr[i] - arr[i-1]);",
"temp",
"Math.abs(arr[i] - arr[i-1])",
"Math.abs",
"Math",
"arr[i] - arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i] += temp",
"arr[i]",
"arr",
"i",
"temp",
"ans += temp",
"ans",
"temp",
"wr.println(ans)",
"wr.println",
"wr",
"ans",
"wr.flush()",
"wr.flush",
"wr",
"wr.close()",
"wr.close",
"wr",
"String args[]",
"args",
"static class FastReader {\n\n BufferedReader br; \n StringTokenizer st; \n\n public FastReader() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n\n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n\n int nextInt() { \n return Integer.parseInt(next()); \n } \n\n long nextLong() { \n return Long.parseLong(next()); \n } \n\n double nextDouble() { \n return Double.parseDouble(next()); \n } \n\n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }",
"FastReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n }",
"FastReader",
"{ \n br = new BufferedReader(new InputStreamReader(System.in)); \n }",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }",
"next",
"{ \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }",
"while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{ \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n }",
"try { \n st = new StringTokenizer(br.readLine()); \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 st = new StringTokenizer(br.readLine()); \n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"long nextLong() { \n return Long.parseLong(next()); \n }",
"nextLong",
"{ \n return Long.parseLong(next()); \n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() { \n return Double.parseDouble(next()); \n }",
"nextDouble",
"{ \n return Double.parseDouble(next()); \n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n }",
"nextLine",
"{ \n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n }",
"String str = \"\";",
"str",
"\"\"",
"try { \n str = br.readLine(); \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 str = br.readLine(); \n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main {\n\n static class FastReader {\n\n BufferedReader br; \n StringTokenizer st; \n\n public FastReader() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n\n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n\n int nextInt() { \n return Integer.parseInt(next()); \n } \n\n long nextLong() { \n return Long.parseLong(next()); \n } \n\n double nextDouble() { \n return Double.parseDouble(next()); \n } \n\n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n public static void main(String args[]) throws IOException {\n // try {\n // FileOutputStream output = new FileOutputStream(\"temp.out\");\n // PrintStream out = new PrintStream(output);\n // //Diverting the output stream into file \"temp.out\".Comment the below line to use console\n // System.setOut(out);\n \n // InputStream input = new FileInputStream(\"temp.in\");\n // //Diverting the input stream into file \"temp.in\".Comment the below line to use console\n // System.setIn(input);\n \n // } catch (FileNotFoundException e) {\n // e.printStackTrace();\n // }\n \n FastReader sc = new FastReader();\n PrintWriter wr = new PrintWriter(System.out);\n \n // int t = 1;\n // t = sc.nextInt(); //Comment this line if there is single test case\n\n // while((t--) != 0) {\n\n\n // } \n\n\n int n = sc.nextInt();\n\n int[] arr = new int[n];\n\n for(int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n long ans = 0;\n\n for(int i = 1; i < arr.length; i++) {\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n } \n\n wr.println(ans);\n \n wr.flush();\n wr.close();\n }\n}",
"public class Main {\n\n static class FastReader {\n\n BufferedReader br; \n StringTokenizer st; \n\n public FastReader() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n\n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n\n int nextInt() { \n return Integer.parseInt(next()); \n } \n\n long nextLong() { \n return Long.parseLong(next()); \n } \n\n double nextDouble() { \n return Double.parseDouble(next()); \n } \n\n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n public static void main(String args[]) throws IOException {\n // try {\n // FileOutputStream output = new FileOutputStream(\"temp.out\");\n // PrintStream out = new PrintStream(output);\n // //Diverting the output stream into file \"temp.out\".Comment the below line to use console\n // System.setOut(out);\n \n // InputStream input = new FileInputStream(\"temp.in\");\n // //Diverting the input stream into file \"temp.in\".Comment the below line to use console\n // System.setIn(input);\n \n // } catch (FileNotFoundException e) {\n // e.printStackTrace();\n // }\n \n FastReader sc = new FastReader();\n PrintWriter wr = new PrintWriter(System.out);\n \n // int t = 1;\n // t = sc.nextInt(); //Comment this line if there is single test case\n\n // while((t--) != 0) {\n\n\n // } \n\n\n int n = sc.nextInt();\n\n int[] arr = new int[n];\n\n for(int i = 0; i < n; i++) {\n arr[i] = sc.nextInt();\n }\n long ans = 0;\n\n for(int i = 1; i < arr.length; i++) {\n \n if(arr[i] < arr[i-1]){\n int temp = Math.abs(arr[i] - arr[i-1]);\n arr[i] += temp;\n ans += temp;\n }\n } \n\n wr.println(ans);\n \n wr.flush();\n wr.close();\n }\n}",
"Main"
]
| import java.util.*;
import java.io.*;
import java.lang.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String args[]) throws IOException {
// try {
// FileOutputStream output = new FileOutputStream("temp.out");
// PrintStream out = new PrintStream(output);
// //Diverting the output stream into file "temp.out".Comment the below line to use console
// System.setOut(out);
// InputStream input = new FileInputStream("temp.in");
// //Diverting the input stream into file "temp.in".Comment the below line to use console
// System.setIn(input);
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
FastReader sc = new FastReader();
PrintWriter wr = new PrintWriter(System.out);
// int t = 1;
// t = sc.nextInt(); //Comment this line if there is single test case
// while((t--) != 0) {
// }
int n = sc.nextInt();
int[] arr = new int[n];
for(int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
long ans = 0;
for(int i = 1; i < arr.length; i++) {
if(arr[i] < arr[i-1]){
int temp = Math.abs(arr[i] - arr[i-1]);
arr[i] += temp;
ans += temp;
}
}
wr.println(ans);
wr.flush();
wr.close();
}
} |
[
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
9,
0,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
89,
5
],
[
89,
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
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
59,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
66,
72
],
[
59,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
8,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
80,
85
],
[
6,
86
],
[
86,
87
],
[
0,
88
],
[
88,
89
],
[
88,
90
]
]
| [
"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 num = sc.nextInt();\n\t\tint[] intArray = new int[num];\n\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tlong humidai = 0;\n\t\tint targetNum = 0;\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}\n\n\t\tSystem.out.print(humidai);\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 num = sc.nextInt();\n\t\tint[] intArray = new int[num];\n\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tlong humidai = 0;\n\t\tint targetNum = 0;\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}\n\n\t\tSystem.out.print(humidai);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint num = sc.nextInt();\n\t\tint[] intArray = new int[num];\n\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tlong humidai = 0;\n\t\tint targetNum = 0;\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}\n\n\t\tSystem.out.print(humidai);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint num = sc.nextInt();\n\t\tint[] intArray = new int[num];\n\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tlong humidai = 0;\n\t\tint targetNum = 0;\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}\n\n\t\tSystem.out.print(humidai);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int num = sc.nextInt();",
"num",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int[] intArray = new int[num];",
"intArray",
"new int[num]",
"num",
"for(int i = 0; i < num; i++)\n\t\t{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}",
"intArray[i] = sc.nextInt()",
"intArray[i]",
"intArray",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long humidai = 0;",
"humidai",
"0",
"int targetNum = 0;",
"targetNum",
"0",
"for(int i = 0; i < num; i++)\n\t\t{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}",
"{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}",
"if(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}",
"targetNum < intArray[i]",
"targetNum",
"intArray[i]",
"intArray",
"i",
"{\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}",
"targetNum = intArray[i]",
"targetNum",
"intArray[i]",
"intArray",
"i",
"continue;",
"humidai += targetNum - intArray[i]",
"humidai",
"targetNum - intArray[i]",
"targetNum",
"intArray[i]",
"intArray",
"i",
"System.out.print(humidai)",
"System.out.print",
"System.out",
"System",
"System.out",
"humidai",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint num = sc.nextInt();\n\t\tint[] intArray = new int[num];\n\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tlong humidai = 0;\n\t\tint targetNum = 0;\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}\n\n\t\tSystem.out.print(humidai);\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 num = sc.nextInt();\n\t\tint[] intArray = new int[num];\n\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tlong humidai = 0;\n\t\tint targetNum = 0;\n\t\tfor(int i = 0; i < num; i++)\n\t\t{\n\t\t\tif(targetNum < intArray[i]) {\n\t\t\t\ttargetNum = intArray[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thumidai += targetNum - intArray[i];\n\t\t}\n\n\t\tSystem.out.print(humidai);\n\t}\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] intArray = new int[num];
for(int i = 0; i < num; i++)
{
intArray[i] = sc.nextInt();
}
long humidai = 0;
int targetNum = 0;
for(int i = 0; i < num; i++)
{
if(targetNum < intArray[i]) {
targetNum = intArray[i];
continue;
}
humidai += targetNum - intArray[i];
}
System.out.print(humidai);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
65,
5
],
[
65,
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,
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
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
35,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
43,
46
],
[
43,
47
],
[
35,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
50,
52
],
[
8,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
53,
58
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
6,
62
],
[
62,
63
],
[
0,
64
],
[
64,
65
],
[
64,
66
]
]
| [
"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 long res = 0;\n long m = 0;\n for (int i = 0; i < n; i++) {\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }\n System.out.println(res);\n sc.close();\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 long res = 0;\n long m = 0;\n for (int i = 0; i < n; i++) {\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }\n System.out.println(res);\n sc.close();\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long res = 0;\n long m = 0;\n for (int i = 0; i < n; i++) {\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }\n System.out.println(res);\n sc.close();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long res = 0;\n long m = 0;\n for (int i = 0; i < n; i++) {\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }\n System.out.println(res);\n sc.close();\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long res = 0;",
"res",
"0",
"long m = 0;",
"m",
"0",
"for (int i = 0; i < n; i++) {\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }",
"{\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }",
"long a = sc.nextLong();",
"a",
"sc.nextLong()",
"sc.nextLong",
"sc",
"m = Math.max(m, a)",
"m",
"Math.max(m, a)",
"Math.max",
"Math",
"m",
"a",
"res += m - a",
"res",
"m - a",
"m",
"a",
"System.out.println(res)",
"System.out.println",
"System.out",
"System",
"System.out",
"res",
"sc.close()",
"sc.close",
"sc",
"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 long res = 0;\n long m = 0;\n for (int i = 0; i < n; i++) {\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }\n System.out.println(res);\n sc.close();\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 long res = 0;\n long m = 0;\n for (int i = 0; i < n; i++) {\n long a = sc.nextLong();\n m = Math.max(m, a);\n res += m - a;\n }\n System.out.println(res);\n sc.close();\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();
long res = 0;
long m = 0;
for (int i = 0; i < n; i++) {
long a = sc.nextLong();
m = Math.max(m, a);
res += m - a;
}
System.out.println(res);
sc.close();
}
} |
[
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,
6,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
2,
13,
13,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
2,
2,
13,
13,
17,
2,
2,
13,
13,
17,
0,
13,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
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,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
2,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
6,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
20,
12,
13,
30,
4,
18,
13,
2,
17,
13,
23,
13,
12,
13,
30,
4,
13,
13,
4,
18,
13,
17,
23,
13,
12,
13,
30,
4,
18,
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
],
[
312,
38
],
[
312,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
54,
56
],
[
45,
57
],
[
57,
58
],
[
58,
59
],
[
45,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
63,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
62,
74
],
[
74,
75
],
[
74,
76
],
[
41,
77
],
[
77,
78
],
[
39,
79
],
[
79,
80
],
[
39,
81
],
[
81,
82
],
[
312,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
89,
91
],
[
85,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
85,
97
],
[
97,
98
],
[
97,
99
],
[
85,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
106,
107
],
[
106,
108
],
[
101,
109
],
[
109,
110
],
[
110,
111
],
[
101,
112
],
[
113,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
119,
120
],
[
85,
121
],
[
121,
122
],
[
121,
123
],
[
85,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
124,
129
],
[
129,
130
],
[
129,
131
],
[
124,
132
],
[
132,
133
],
[
133,
134
],
[
124,
135
],
[
136,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
137,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
153,
155
],
[
150,
156
],
[
156,
157
],
[
156,
158
],
[
147,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
147,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
164,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
85,
173
],
[
173,
174
],
[
174,
175
],
[
173,
176
],
[
85,
177
],
[
177,
178
],
[
178,
179
],
[
83,
180
],
[
180,
181
],
[
312,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
182,
186
],
[
186,
187
],
[
182,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
182,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
198,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
197,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
207,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
196,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
182,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
227,
228
],
[
226,
229
],
[
229,
230
],
[
182,
231
],
[
231,
232
],
[
231,
233
],
[
233,
234
],
[
234,
235
],
[
235,
236
],
[
236,
237
],
[
235,
238
],
[
238,
239
],
[
182,
240
],
[
240,
241
],
[
240,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
245,
246
],
[
244,
247
],
[
247,
248
],
[
182,
249
],
[
249,
250
],
[
249,
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
],
[
251,
268
],
[
268,
269
],
[
312,
270
],
[
270,
271
],
[
270,
272
],
[
272,
273
],
[
270,
274
],
[
274,
275
],
[
274,
276
],
[
276,
277
],
[
277,
278
],
[
278,
279
],
[
278,
280
],
[
277,
281
],
[
270,
282
],
[
282,
283
],
[
282,
284
],
[
284,
285
],
[
285,
286
],
[
286,
287
],
[
285,
288
],
[
288,
289
],
[
288,
290
],
[
282,
291
],
[
291,
292
],
[
270,
293
],
[
293,
294
],
[
293,
295
],
[
295,
296
],
[
296,
297
],
[
296,
298
],
[
295,
299
],
[
299,
300
],
[
300,
301
],
[
299,
302
],
[
293,
303
],
[
303,
304
],
[
270,
305
],
[
305,
306
],
[
305,
307
],
[
307,
308
],
[
308,
309
],
[
309,
310
],
[
0,
311
],
[
311,
312
],
[
311,
313
]
]
| [
"import java.io.BufferedReader;\nimport java.io.BufferedWriter;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.OutputStreamWriter;\nimport java.math.BigInteger;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.StringTokenizer;\nimport java.util.TreeSet;\n\n\n/**\n *\n * @author USER\n */\npublic class Main {\n static class FastReader \n { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() \n { \n return Integer.parseInt(next()); \n } \n \n long nextLong() \n { \n return Long.parseLong(next()); \n } \n \n double nextDouble() \n { \n return Double.parseDouble(next()); \n } \n \n String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n } \n } \n \n static class BufPrint\n {\n final BufferedWriter bw;\n public BufPrint()\n {\n this.bw=new BufferedWriter(new OutputStreamWriter(System.out));\n }\n public void print(Object object)throws IOException\n {\n bw.append(\"\"+object);\n }\n public void println(Object object)throws IOException\n {\n print(object);\n bw.append(\"\\n\");\n }\n public void close()throws IOException\n {\n bw.close();\n }\n }\n \n\n public static int GCD(int l,int r) {\n int gcd=1;\n for(int i = 1; i <= l && i <= r; ++i)\n {\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }\n return gcd;\n}\n \n /**\n * @param args the command line arguments\n */\n public static void main(String[] args) throws IOException{\n // TODO code application logic here\n \n FastReader sc=new FastReader(); \n BufPrint bp=new BufPrint();\n\n// int t=sc.nextInt();\n// \n// for(int k1=0;k1<t;k1++){\n int n=sc.nextInt();\n \n int[] a=new int[n];\n \n for(int i=0;i<n;i++)\n {\n a[i]=sc.nextInt();\n }\n long sum=0;\n for(int i=1;i<n;i++)\n {\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }\n bp.println(sum);\n \n// }\n \n \n \n bp.close();\n \n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.BufferedWriter;",
"BufferedWriter",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.OutputStreamWriter;",
"OutputStreamWriter",
"java.io",
"import java.math.BigInteger;",
"BigInteger",
"java.math",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.HashSet;",
"HashSet",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Set;",
"Set",
"java.util",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"import java.util.TreeSet;",
"TreeSet",
"java.util",
"public class Main {\n static class FastReader \n { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() \n { \n return Integer.parseInt(next()); \n } \n \n long nextLong() \n { \n return Long.parseLong(next()); \n } \n \n double nextDouble() \n { \n return Double.parseDouble(next()); \n } \n \n String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n } \n } \n \n static class BufPrint\n {\n final BufferedWriter bw;\n public BufPrint()\n {\n this.bw=new BufferedWriter(new OutputStreamWriter(System.out));\n }\n public void print(Object object)throws IOException\n {\n bw.append(\"\"+object);\n }\n public void println(Object object)throws IOException\n {\n print(object);\n bw.append(\"\\n\");\n }\n public void close()throws IOException\n {\n bw.close();\n }\n }\n \n\n public static int GCD(int l,int r) {\n int gcd=1;\n for(int i = 1; i <= l && i <= r; ++i)\n {\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }\n return gcd;\n}\n \n /**\n * @param args the command line arguments\n */\n public static void main(String[] args) throws IOException{\n // TODO code application logic here\n \n FastReader sc=new FastReader(); \n BufPrint bp=new BufPrint();\n\n// int t=sc.nextInt();\n// \n// for(int k1=0;k1<t;k1++){\n int n=sc.nextInt();\n \n int[] a=new int[n];\n \n for(int i=0;i<n;i++)\n {\n a[i]=sc.nextInt();\n }\n long sum=0;\n for(int i=1;i<n;i++)\n {\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }\n bp.println(sum);\n \n// }\n \n \n \n bp.close();\n \n }\n}",
"Main",
"public static int GCD(int l,int r) {\n int gcd=1;\n for(int i = 1; i <= l && i <= r; ++i)\n {\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }\n return gcd;\n}",
"GCD",
"{\n int gcd=1;\n for(int i = 1; i <= l && i <= r; ++i)\n {\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }\n return gcd;\n}",
"int gcd=1;",
"gcd",
"1",
"for(int i = 1; i <= l && i <= r; ++i)\n {\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i <= l && i <= r",
"i <= l",
"i",
"l",
"i <= r",
"i",
"r",
"++i",
"++i",
"i",
"{\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }",
"{\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }",
"if(l % i==0 && r % i==0)\n gcd = i;",
"l % i==0 && r % i==0",
"l % i==0",
"l % i",
"l",
"i",
"0",
"r % i==0",
"r % i",
"r",
"i",
"0",
"gcd = i",
"gcd",
"i",
"return gcd;",
"gcd",
"int l",
"l",
"int r",
"r",
"/**\n * @param args the command line arguments\n */\n public static void main(String[] args) throws IOException{\n // TODO code application logic here\n \n FastReader sc=new FastReader(); \n BufPrint bp=new BufPrint();\n\n// int t=sc.nextInt();\n// \n// for(int k1=0;k1<t;k1++){\n int n=sc.nextInt();\n \n int[] a=new int[n];\n \n for(int i=0;i<n;i++)\n {\n a[i]=sc.nextInt();\n }\n long sum=0;\n for(int i=1;i<n;i++)\n {\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }\n bp.println(sum);\n \n// }\n \n \n \n bp.close();\n \n }",
"main",
"{\n // TODO code application logic here\n \n FastReader sc=new FastReader(); \n BufPrint bp=new BufPrint();\n\n// int t=sc.nextInt();\n// \n// for(int k1=0;k1<t;k1++){\n int n=sc.nextInt();\n \n int[] a=new int[n];\n \n for(int i=0;i<n;i++)\n {\n a[i]=sc.nextInt();\n }\n long sum=0;\n for(int i=1;i<n;i++)\n {\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }\n bp.println(sum);\n \n// }\n \n \n \n bp.close();\n \n }",
"FastReader sc=new FastReader();",
"sc",
"new FastReader()",
"BufPrint bp=new BufPrint();",
"bp",
"new BufPrint()",
"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 {\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",
"long sum=0;",
"sum",
"0",
"for(int i=1;i<n;i++)\n {\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }",
"{\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }",
"if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }",
"a[i]<a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"{\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }",
"int d=a[i-1]-a[i];",
"d",
"a[i-1]-a[i]",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i]",
"a",
"i",
"sum=sum+d",
"sum",
"sum+d",
"sum",
"d",
"a[i]=a[i]+d",
"a[i]",
"a",
"i",
"a[i]+d",
"a[i]",
"a",
"i",
"d",
"bp.println(sum)",
"bp.println",
"bp",
"sum",
"bp.close()",
"bp.close",
"bp",
"String[] args",
"args",
"static class FastReader \n { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() \n { \n return Integer.parseInt(next()); \n } \n \n long nextLong() \n { \n return Long.parseLong(next()); \n } \n \n double nextDouble() \n { \n return Double.parseDouble(next()); \n } \n \n String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n } \n }",
"FastReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n }",
"FastReader",
"{ \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n }",
"br = new BufferedReader(new\n InputStreamReader(System.in))",
"br",
"new BufferedReader(new\n InputStreamReader(System.in))",
"String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }",
"next",
"{ \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }",
"while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{ \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n }",
"try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n }",
"catch (IOException e) \n { \n e.printStackTrace(); \n }",
"IOException e",
"{ \n e.printStackTrace(); \n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{ \n st = new StringTokenizer(br.readLine()); \n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"int nextInt() \n { \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",
"long nextLong() \n { \n return Long.parseLong(next()); \n }",
"nextLong",
"{ \n return Long.parseLong(next()); \n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() \n { \n return Double.parseDouble(next()); \n }",
"nextDouble",
"{ \n return Double.parseDouble(next()); \n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }",
"nextLine",
"{ \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }",
"String str = \"\";",
"str",
"\"\"",
"try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n }",
"catch (IOException e) \n { \n e.printStackTrace(); \n }",
"IOException e",
"{ \n e.printStackTrace(); \n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{ \n str = br.readLine(); \n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"static class BufPrint\n {\n final BufferedWriter bw;\n public BufPrint()\n {\n this.bw=new BufferedWriter(new OutputStreamWriter(System.out));\n }\n public void print(Object object)throws IOException\n {\n bw.append(\"\"+object);\n }\n public void println(Object object)throws IOException\n {\n print(object);\n bw.append(\"\\n\");\n }\n public void close()throws IOException\n {\n bw.close();\n }\n }",
"BufPrint",
"final BufferedWriter bw;",
"bw",
"public BufPrint()\n {\n this.bw=new BufferedWriter(new OutputStreamWriter(System.out));\n }",
"BufPrint",
"{\n this.bw=new BufferedWriter(new OutputStreamWriter(System.out));\n }",
"this.bw=new BufferedWriter(new OutputStreamWriter(System.out))",
"this.bw",
"this",
"this.bw",
"new BufferedWriter(new OutputStreamWriter(System.out))",
"public void print(Object object)throws IOException\n {\n bw.append(\"\"+object);\n }",
"print",
"{\n bw.append(\"\"+object);\n }",
"bw.append(\"\"+object)",
"bw.append",
"bw",
"\"\"+object",
"\"\"",
"object",
"Object object",
"object",
"public void println(Object object)throws IOException\n {\n print(object);\n bw.append(\"\\n\");\n }",
"println",
"{\n print(object);\n bw.append(\"\\n\");\n }",
"print(object)",
"print",
"object",
"bw.append(\"\\n\")",
"bw.append",
"bw",
"\"\\n\"",
"Object object",
"object",
"public void close()throws IOException\n {\n bw.close();\n }",
"close",
"{\n bw.close();\n }",
"bw.close()",
"bw.close",
"bw",
"public class Main {\n static class FastReader \n { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() \n { \n return Integer.parseInt(next()); \n } \n \n long nextLong() \n { \n return Long.parseLong(next()); \n } \n \n double nextDouble() \n { \n return Double.parseDouble(next()); \n } \n \n String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n } \n } \n \n static class BufPrint\n {\n final BufferedWriter bw;\n public BufPrint()\n {\n this.bw=new BufferedWriter(new OutputStreamWriter(System.out));\n }\n public void print(Object object)throws IOException\n {\n bw.append(\"\"+object);\n }\n public void println(Object object)throws IOException\n {\n print(object);\n bw.append(\"\\n\");\n }\n public void close()throws IOException\n {\n bw.close();\n }\n }\n \n\n public static int GCD(int l,int r) {\n int gcd=1;\n for(int i = 1; i <= l && i <= r; ++i)\n {\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }\n return gcd;\n}\n \n /**\n * @param args the command line arguments\n */\n public static void main(String[] args) throws IOException{\n // TODO code application logic here\n \n FastReader sc=new FastReader(); \n BufPrint bp=new BufPrint();\n\n// int t=sc.nextInt();\n// \n// for(int k1=0;k1<t;k1++){\n int n=sc.nextInt();\n \n int[] a=new int[n];\n \n for(int i=0;i<n;i++)\n {\n a[i]=sc.nextInt();\n }\n long sum=0;\n for(int i=1;i<n;i++)\n {\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }\n bp.println(sum);\n \n// }\n \n \n \n bp.close();\n \n }\n}",
"public class Main {\n static class FastReader \n { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() \n { \n return Integer.parseInt(next()); \n } \n \n long nextLong() \n { \n return Long.parseLong(next()); \n } \n \n double nextDouble() \n { \n return Double.parseDouble(next()); \n } \n \n String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n } \n } \n \n static class BufPrint\n {\n final BufferedWriter bw;\n public BufPrint()\n {\n this.bw=new BufferedWriter(new OutputStreamWriter(System.out));\n }\n public void print(Object object)throws IOException\n {\n bw.append(\"\"+object);\n }\n public void println(Object object)throws IOException\n {\n print(object);\n bw.append(\"\\n\");\n }\n public void close()throws IOException\n {\n bw.close();\n }\n }\n \n\n public static int GCD(int l,int r) {\n int gcd=1;\n for(int i = 1; i <= l && i <= r; ++i)\n {\n // Checks if i is factor of both integers\n if(l % i==0 && r % i==0)\n gcd = i;\n }\n return gcd;\n}\n \n /**\n * @param args the command line arguments\n */\n public static void main(String[] args) throws IOException{\n // TODO code application logic here\n \n FastReader sc=new FastReader(); \n BufPrint bp=new BufPrint();\n\n// int t=sc.nextInt();\n// \n// for(int k1=0;k1<t;k1++){\n int n=sc.nextInt();\n \n int[] a=new int[n];\n \n for(int i=0;i<n;i++)\n {\n a[i]=sc.nextInt();\n }\n long sum=0;\n for(int i=1;i<n;i++)\n {\n if(a[i]<a[i-1]){\n int d=a[i-1]-a[i];\n sum=sum+d;\n a[i]=a[i]+d;\n }\n \n }\n bp.println(sum);\n \n// }\n \n \n \n bp.close();\n \n }\n}",
"Main"
]
| import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
/**
*
* @author USER
*/
public class Main {
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
static class BufPrint
{
final BufferedWriter bw;
public BufPrint()
{
this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object)throws IOException
{
bw.append(""+object);
}
public void println(Object object)throws IOException
{
print(object);
bw.append("\n");
}
public void close()throws IOException
{
bw.close();
}
}
public static int GCD(int l,int r) {
int gcd=1;
for(int i = 1; i <= l && i <= r; ++i)
{
// Checks if i is factor of both integers
if(l % i==0 && r % i==0)
gcd = i;
}
return gcd;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException{
// TODO code application logic here
FastReader sc=new FastReader();
BufPrint bp=new BufPrint();
// int t=sc.nextInt();
//
// for(int k1=0;k1<t;k1++){
int n=sc.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
long sum=0;
for(int i=1;i<n;i++)
{
if(a[i]<a[i-1]){
int d=a[i-1]-a[i];
sum=sum+d;
a[i]=a[i]+d;
}
}
bp.println(sum);
// }
bp.close();
}
} |
[
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,
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,
4,
18,
13,
13,
41,
13,
17,
41,
13,
17,
28,
13,
13,
30,
30,
0,
13,
4,
18,
13,
17,
2,
13,
13,
0,
13,
4,
18,
13,
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,
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,
13,
29,
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
],
[
22,
23
],
[
22,
24
],
[
0,
25
],
[
25,
26
],
[
25,
27
],
[
0,
28
],
[
200,
29
],
[
200,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
35,
37
],
[
32,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
40,
42
],
[
32,
43
],
[
43,
44
],
[
43,
45
],
[
32,
46
],
[
46,
47
],
[
46,
48
],
[
32,
49
],
[
49,
50
],
[
49,
51
],
[
32,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
52,
56
],
[
52,
57
],
[
32,
58
],
[
58,
59
],
[
59,
60
],
[
30,
61
],
[
61,
62
],
[
200,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
67,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
67,
79
],
[
79,
80
],
[
79,
81
],
[
67,
82
],
[
82,
83
],
[
82,
84
],
[
67,
85
],
[
85,
86
],
[
85,
87
],
[
85,
88
],
[
89,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
92,
96
],
[
96,
97
],
[
96,
98
],
[
89,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
101,
105
],
[
67,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
65,
110
],
[
110,
111
],
[
65,
112
],
[
112,
113
],
[
65,
114
],
[
114,
115
],
[
200,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
116,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
128,
130
],
[
122,
131
],
[
131,
132
],
[
116,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
136,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
146,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
135,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
116,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
164,
167
],
[
167,
168
],
[
116,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
171,
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
],
[
190,
192
],
[
189,
193
],
[
193,
194
],
[
171,
195
],
[
195,
196
],
[
169,
197
],
[
197,
198
],
[
0,
199
],
[
199,
200
],
[
199,
201
]
]
| [
"import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\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 CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int[] a = in.readIntArray(n);\n\n long answer = 0;\n int max = 0;\n for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }\n\n out.println(answer);\n }\n\n }\n\n static class InputReader {\n public final 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 int[] readIntArray(int n) {\n int[] x = new int[n];\n for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }\n return x;\n }\n\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.IOException;",
"IOException",
"java.io",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.InputStream;",
"InputStream",
"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 CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int[] a = in.readIntArray(n);\n\n long answer = 0;\n int max = 0;\n for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }\n\n out.println(answer);\n }\n\n }\n\n static class InputReader {\n public final 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 int[] readIntArray(int n) {\n int[] x = new int[n];\n for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }\n return x;\n }\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 CStep solver = new CStep();\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 CStep solver = new CStep();\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)",
"CStep solver = new CStep();",
"solver",
"new CStep()",
"solver.solve(1, in, out)",
"solver.solve",
"solver",
"1",
"in",
"out",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"static class CStep {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int[] a = in.readIntArray(n);\n\n long answer = 0;\n int max = 0;\n for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }\n\n out.println(answer);\n }\n\n }",
"CStep",
"public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int[] a = in.readIntArray(n);\n\n long answer = 0;\n int max = 0;\n for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }\n\n out.println(answer);\n }",
"solve",
"{\n int n = in.nextInt();\n int[] a = in.readIntArray(n);\n\n long answer = 0;\n int max = 0;\n for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }\n\n out.println(answer);\n }",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int[] a = in.readIntArray(n);",
"a",
"in.readIntArray(n)",
"in.readIntArray",
"in",
"n",
"long answer = 0;",
"answer",
"0",
"int max = 0;",
"max",
"0",
"for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }",
"int x",
"a",
"{\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }",
"{\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }",
"answer += Math.max(0, max - x)",
"answer",
"Math.max(0, max - x)",
"Math.max",
"Math",
"0",
"max - x",
"max",
"x",
"max = Math.max(max, x)",
"max",
"Math.max(max, x)",
"Math.max",
"Math",
"max",
"x",
"out.println(answer)",
"out.println",
"out",
"answer",
"int testNumber",
"testNumber",
"InputReader in",
"in",
"PrintWriter out",
"out",
"static class InputReader {\n public final 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 int[] readIntArray(int n) {\n int[] x = new int[n];\n for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }\n return x;\n }\n\n }",
"InputReader",
"public final 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 int[] readIntArray(int n) {\n int[] x = new int[n];\n for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }\n return x;\n }",
"readIntArray",
"{\n int[] x = new int[n];\n for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }\n return x;\n }",
"int[] x = new int[n];",
"x",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n x[i] = nextInt();\n }",
"{\n x[i] = nextInt();\n }",
"x[i] = nextInt()",
"x[i]",
"x",
"i",
"nextInt()",
"nextInt",
"return x;",
"x",
"int 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 CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int[] a = in.readIntArray(n);\n\n long answer = 0;\n int max = 0;\n for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }\n\n out.println(answer);\n }\n\n }\n\n static class InputReader {\n public final 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 int[] readIntArray(int n) {\n int[] x = new int[n];\n for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }\n return x;\n }\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 CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int[] a = in.readIntArray(n);\n\n long answer = 0;\n int max = 0;\n for (int x : a) {\n answer += Math.max(0, max - x);\n max = Math.max(max, x);\n }\n\n out.println(answer);\n }\n\n }\n\n static class InputReader {\n public final 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 int[] readIntArray(int n) {\n int[] x = new int[n];\n for (int i = 0; i < n; i++) {\n x[i] = nextInt();\n }\n return x;\n }\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.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
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);
CStep solver = new CStep();
solver.solve(1, in, out);
out.close();
}
static class CStep {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
int[] a = in.readIntArray(n);
long answer = 0;
int max = 0;
for (int x : a) {
answer += Math.max(0, max - x);
max = Math.max(max, x);
}
out.println(answer);
}
}
static class InputReader {
public final 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());
}
public int[] readIntArray(int n) {
int[] x = new int[n];
for (int i = 0; i < n; i++) {
x[i] = nextInt();
}
return x;
}
}
}
|
[
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,
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,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
4,
18,
13,
13,
4,
18,
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,
20,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
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,
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,
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,
2,
40,
4,
13,
13,
2,
13,
17,
30,
14,
2,
2,
13,
17,
2,
13,
17,
29,
2,
13,
4,
18,
13,
17,
4,
13,
14,
2,
2,
13,
17,
2,
13,
17,
37,
20,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
14,
2,
13,
17,
30,
0,
13,
4,
13,
41,
13,
17,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
29,
2,
13,
4,
18,
13,
17,
4,
13,
14,
2,
2,
13,
17,
2,
13,
17,
37,
20,
0,
13,
17,
0,
13,
2,
2,
13,
17,
13,
0,
13,
4,
13,
29,
2,
13,
13,
12,
13,
30,
41,
13,
4,
13,
42,
4,
13,
13,
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,
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,
12,
13,
30,
29,
4,
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
],
[
558,
20
],
[
558,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
27,
28
],
[
27,
29
],
[
23,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
23,
35
],
[
35,
36
],
[
35,
37
],
[
23,
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
],
[
23,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
23,
64
],
[
64,
65
],
[
64,
66
],
[
23,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
72,
73
],
[
72,
74
],
[
67,
75
],
[
75,
76
],
[
76,
77
],
[
67,
78
],
[
79,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
82,
86
],
[
86,
87
],
[
86,
88
],
[
79,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
23,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
23,
100
],
[
100,
101
],
[
101,
102
],
[
21,
103
],
[
103,
104
],
[
558,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
105,
109
],
[
109,
110
],
[
109,
111
],
[
105,
113
],
[
113,
114
],
[
105,
115
],
[
115,
116
],
[
105,
117
],
[
117,
118
],
[
105,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
119,
127
],
[
127,
128
],
[
105,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
132,
137
],
[
137,
138
],
[
131,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
147,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
156,
159
],
[
143,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
164,
165
],
[
165,
166
],
[
131,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
105,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
174,
178
],
[
178,
179
],
[
178,
180
],
[
174,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
181,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
174,
194
],
[
194,
195
],
[
105,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
198,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
207,
208
],
[
207,
209
],
[
209,
210
],
[
198,
211
],
[
211,
212
],
[
211,
213
],
[
198,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
214,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
221,
222
],
[
218,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
198,
227
],
[
227,
228
],
[
227,
229
],
[
198,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
230,
235
],
[
235,
236
],
[
236,
237
],
[
237,
238
],
[
238,
239
],
[
238,
240
],
[
237,
241
],
[
241,
242
],
[
241,
243
],
[
236,
244
],
[
244,
245
],
[
235,
246
],
[
246,
247
],
[
246,
248
],
[
235,
249
],
[
249,
250
],
[
249,
251
],
[
251,
252
],
[
251,
253
],
[
235,
254
],
[
254,
255
],
[
254,
256
],
[
256,
257
],
[
198,
258
],
[
258,
259
],
[
259,
260
],
[
259,
261
],
[
105,
262
],
[
262,
263
],
[
262,
264
],
[
264,
265
],
[
265,
266
],
[
265,
267
],
[
267,
268
],
[
264,
269
],
[
269,
270
],
[
270,
271
],
[
270,
272
],
[
269,
273
],
[
273,
274
],
[
273,
275
],
[
275,
276
],
[
264,
277
],
[
277,
278
],
[
277,
279
],
[
264,
280
],
[
280,
281
],
[
281,
282
],
[
281,
283
],
[
280,
284
],
[
284,
285
],
[
285,
286
],
[
285,
287
],
[
287,
288
],
[
284,
289
],
[
289,
290
],
[
289,
291
],
[
291,
292
],
[
264,
293
],
[
293,
294
],
[
293,
295
],
[
264,
296
],
[
296,
297
],
[
297,
298
],
[
298,
299
],
[
298,
300
],
[
296,
301
],
[
301,
302
],
[
302,
303
],
[
303,
304
],
[
304,
305
],
[
304,
306
],
[
303,
307
],
[
307,
308
],
[
307,
309
],
[
302,
310
],
[
310,
311
],
[
301,
312
],
[
312,
313
],
[
312,
314
],
[
301,
315
],
[
315,
316
],
[
315,
317
],
[
317,
318
],
[
317,
319
],
[
301,
320
],
[
320,
321
],
[
320,
322
],
[
322,
323
],
[
264,
324
],
[
324,
325
],
[
325,
326
],
[
325,
327
],
[
105,
328
],
[
328,
329
],
[
328,
330
],
[
330,
331
],
[
331,
332
],
[
331,
333
],
[
333,
334
],
[
330,
335
],
[
335,
336
],
[
336,
337
],
[
336,
338
],
[
335,
339
],
[
339,
340
],
[
339,
341
],
[
341,
342
],
[
330,
343
],
[
343,
344
],
[
343,
345
],
[
330,
346
],
[
346,
347
],
[
347,
348
],
[
347,
349
],
[
346,
350
],
[
350,
351
],
[
351,
352
],
[
351,
353
],
[
353,
354
],
[
350,
355
],
[
355,
356
],
[
355,
357
],
[
357,
358
],
[
330,
359
],
[
359,
360
],
[
359,
361
],
[
330,
362
],
[
362,
363
],
[
363,
364
],
[
364,
365
],
[
365,
366
],
[
365,
367
],
[
363,
368
],
[
368,
369
],
[
368,
370
],
[
362,
371
],
[
371,
372
],
[
372,
373
],
[
373,
374
],
[
374,
375
],
[
374,
376
],
[
373,
377
],
[
377,
378
],
[
377,
379
],
[
372,
380
],
[
380,
381
],
[
381,
382
],
[
381,
383
],
[
383,
384
],
[
384,
385
],
[
383,
386
],
[
383,
387
],
[
387,
388
],
[
371,
389
],
[
389,
390
],
[
390,
391
],
[
391,
392
],
[
391,
393
],
[
390,
394
],
[
394,
395
],
[
394,
396
],
[
389,
397
],
[
397,
398
],
[
371,
399
],
[
399,
400
],
[
399,
401
],
[
371,
402
],
[
402,
403
],
[
402,
404
],
[
404,
405
],
[
404,
406
],
[
371,
407
],
[
407,
408
],
[
407,
409
],
[
409,
410
],
[
330,
411
],
[
411,
412
],
[
412,
413
],
[
412,
414
],
[
411,
415
],
[
415,
416
],
[
416,
417
],
[
416,
418
],
[
418,
419
],
[
415,
420
],
[
420,
421
],
[
420,
422
],
[
415,
423
],
[
423,
424
],
[
424,
425
],
[
425,
426
],
[
425,
427
],
[
423,
428
],
[
428,
429
],
[
429,
430
],
[
430,
431
],
[
431,
432
],
[
431,
433
],
[
430,
434
],
[
434,
435
],
[
434,
436
],
[
429,
437
],
[
437,
438
],
[
438,
439
],
[
438,
440
],
[
440,
441
],
[
441,
442
],
[
440,
443
],
[
440,
444
],
[
444,
445
],
[
428,
446
],
[
446,
447
],
[
447,
448
],
[
448,
449
],
[
448,
450
],
[
447,
451
],
[
451,
452
],
[
451,
453
],
[
446,
454
],
[
454,
455
],
[
428,
456
],
[
456,
457
],
[
456,
458
],
[
428,
459
],
[
459,
460
],
[
459,
461
],
[
461,
462
],
[
462,
463
],
[
462,
464
],
[
461,
465
],
[
428,
466
],
[
466,
467
],
[
466,
468
],
[
468,
469
],
[
330,
470
],
[
470,
471
],
[
471,
472
],
[
471,
473
],
[
105,
474
],
[
474,
475
],
[
474,
476
],
[
476,
477
],
[
477,
478
],
[
477,
479
],
[
479,
480
],
[
476,
481
],
[
481,
482
],
[
482,
483
],
[
482,
484
],
[
481,
485
],
[
485,
486
],
[
485,
487
],
[
487,
488
],
[
476,
489
],
[
489,
490
],
[
489,
491
],
[
476,
492
],
[
492,
493
],
[
493,
494
],
[
494,
495
],
[
494,
496
],
[
492,
497
],
[
497,
498
],
[
498,
499
],
[
499,
500
],
[
498,
501
],
[
497,
502
],
[
502,
503
],
[
502,
504
],
[
504,
505
],
[
476,
506
],
[
506,
507
],
[
507,
508
],
[
508,
509
],
[
105,
510
],
[
510,
511
],
[
510,
512
],
[
512,
513
],
[
513,
514
],
[
514,
515
],
[
514,
516
],
[
513,
517
],
[
517,
518
],
[
518,
519
],
[
519,
520
],
[
518,
521
],
[
512,
522
],
[
522,
523
],
[
526,
524
],
[
536,
525
],
[
533,
526
],
[
526,
527
],
[
527,
528
],
[
527,
529
],
[
526,
530
],
[
530,
531
],
[
530,
532
],
[
533,
533
],
[
533,
534
],
[
533,
535
],
[
536,
536
],
[
536,
537
],
[
536,
538
],
[
526,
539
],
[
539,
540
],
[
539,
541
],
[
541,
542
],
[
510,
543
],
[
543,
544
],
[
105,
545
],
[
545,
546
],
[
545,
547
],
[
547,
548
],
[
548,
549
],
[
549,
550
],
[
105,
551
],
[
551,
552
],
[
551,
553
],
[
553,
554
],
[
553,
555
],
[
555,
556
],
[
0,
557
],
[
557,
558
],
[
557,
559
]
]
| [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.*;\n\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tInputReader sc = new InputReader(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\t\t\t\n\t\t}\n\t\tlong maxh = a[0];\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}\n\t\t\n\t\tpw.println(ans);\n\t\t\n\t\tpw.close();\n\t}\n\t\n\t\n\tstatic class InputReader {\n\t\tprivate InputStream stream;\n\t\tprivate byte[] buf = new byte[5];\n\t\tprivate int curChar;\n\t\tprivate int numChars;\n\t\tprivate SpaceCharFilter filter;\n\n\t\tpublic InputReader(InputStream stream) {\n\t\t\tthis.stream = stream;\n\t\t}\n\n\t\tpublic int read() {\n\t\t\tif (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\treturn buf[curChar++];\n\t\t}\n\n\t\tpublic String nextLine() {\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(stream));\n\t\t\tString stock = \"\";\n\t\t\ttry {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn stock;\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\n\t\t\tint sgn = 1;\n\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic String readString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res.toString();\n\t\t}\n\n\t\tpublic boolean isSpaceChar(int c) {\n\t\t\tif (filter != null)\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\treturn readString();\n\t\t}\n\n\t\tpublic interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}\n\t}\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tInputReader sc = new InputReader(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\t\t\t\n\t\t}\n\t\tlong maxh = a[0];\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}\n\t\t\n\t\tpw.println(ans);\n\t\t\n\t\tpw.close();\n\t}\n\t\n\t\n\tstatic class InputReader {\n\t\tprivate InputStream stream;\n\t\tprivate byte[] buf = new byte[5];\n\t\tprivate int curChar;\n\t\tprivate int numChars;\n\t\tprivate SpaceCharFilter filter;\n\n\t\tpublic InputReader(InputStream stream) {\n\t\t\tthis.stream = stream;\n\t\t}\n\n\t\tpublic int read() {\n\t\t\tif (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\treturn buf[curChar++];\n\t\t}\n\n\t\tpublic String nextLine() {\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(stream));\n\t\t\tString stock = \"\";\n\t\t\ttry {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn stock;\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\n\t\t\tint sgn = 1;\n\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic String readString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res.toString();\n\t\t}\n\n\t\tpublic boolean isSpaceChar(int c) {\n\t\t\tif (filter != null)\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\treturn readString();\n\t\t}\n\n\t\tpublic interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tInputReader sc = new InputReader(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\t\t\t\n\t\t}\n\t\tlong maxh = a[0];\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}\n\t\t\n\t\tpw.println(ans);\n\t\t\n\t\tpw.close();\n\t}",
"main",
"{\n\t\tInputReader sc = new InputReader(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\t\t\t\n\t\t}\n\t\tlong maxh = a[0];\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}\n\t\t\n\t\tpw.println(ans);\n\t\t\n\t\tpw.close();\n\t}",
"InputReader sc = new InputReader(System.in);",
"sc",
"new InputReader(System.in)",
"PrintWriter pw = new PrintWriter(System.out);",
"pw",
"new PrintWriter(System.out)",
"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();\t\t\t\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();\t\t\t\n\t\t}",
"{\n\t\t\ta[i] = sc.nextInt();\t\t\t\n\t\t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long maxh = a[0];",
"maxh",
"a[0]",
"a",
"0",
"long ans = 0;",
"ans",
"0",
"for(int i = 1; i < n; i++){\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}",
"{\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}",
"maxh = Math.max(maxh, a[i])",
"maxh",
"Math.max(maxh, a[i])",
"Math.max",
"Math",
"maxh",
"a[i]",
"a",
"i",
"ans += (maxh-a[i])",
"ans",
"(maxh-a[i])",
"maxh",
"a[i]",
"a",
"i",
"pw.println(ans)",
"pw.println",
"pw",
"ans",
"pw.close()",
"pw.close",
"pw",
"String[] args",
"args",
"static class InputReader {\n\t\tprivate InputStream stream;\n\t\tprivate byte[] buf = new byte[5];\n\t\tprivate int curChar;\n\t\tprivate int numChars;\n\t\tprivate SpaceCharFilter filter;\n\n\t\tpublic InputReader(InputStream stream) {\n\t\t\tthis.stream = stream;\n\t\t}\n\n\t\tpublic int read() {\n\t\t\tif (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\treturn buf[curChar++];\n\t\t}\n\n\t\tpublic String nextLine() {\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(stream));\n\t\t\tString stock = \"\";\n\t\t\ttry {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn stock;\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\n\t\t\tint sgn = 1;\n\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic String readString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res.toString();\n\t\t}\n\n\t\tpublic boolean isSpaceChar(int c) {\n\t\t\tif (filter != null)\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\treturn readString();\n\t\t}\n\n\t\tpublic interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}\n\t}",
"InputReader",
"private InputStream stream;",
"stream",
"private byte[] buf = new byte[5];",
"buf",
"new byte[5]",
"5",
"private int curChar;",
"curChar",
"private int numChars;",
"numChars",
"private SpaceCharFilter filter;",
"filter",
"public InputReader(InputStream stream) {\n\t\t\tthis.stream = stream;\n\t\t}",
"InputReader",
"{\n\t\t\tthis.stream = stream;\n\t\t}",
"this.stream = stream",
"this.stream",
"this",
"this.stream",
"stream",
"InputStream stream",
"stream",
"public int read() {\n\t\t\tif (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\treturn buf[curChar++];\n\t\t}",
"read",
"{\n\t\t\tif (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\treturn buf[curChar++];\n\t\t}",
"if (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();",
"numChars == -1",
"numChars",
"-1",
"1",
"throw new InputMismatchException();",
"new InputMismatchException()",
"if (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}",
"curChar >= numChars",
"curChar",
"numChars",
"{\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}",
"curChar = 0",
"curChar",
"0",
"try {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}",
"catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}",
"IOException e",
"{\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}",
"throw new InputMismatchException();",
"new InputMismatchException()",
"{\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t}",
"numChars = stream.read(buf)",
"numChars",
"stream.read(buf)",
"stream.read",
"stream",
"buf",
"if (numChars <= 0)\n\t\t\t\t\treturn -1;",
"numChars <= 0",
"numChars",
"0",
"return -1;",
"-1",
"1",
"return buf[curChar++];",
"buf[curChar++]",
"buf",
"curChar++",
"curChar",
"public String nextLine() {\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(stream));\n\t\t\tString stock = \"\";\n\t\t\ttry {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn stock;\n\t\t}",
"nextLine",
"{\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(stream));\n\t\t\tString stock = \"\";\n\t\t\ttry {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn stock;\n\t\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(stream));",
"br",
"new BufferedReader(new InputStreamReader(stream))",
"String stock = \"\";",
"stock",
"\"\"",
"try {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"IOException e",
"{\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\tstock = br.readLine();\n\t\t\t}",
"stock = br.readLine()",
"stock",
"br.readLine()",
"br.readLine",
"br",
"return stock;",
"stock",
"public int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\n\t\t\tint sgn = 1;\n\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res * sgn;\n\t\t}",
"nextInt",
"{\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\n\t\t\tint sgn = 1;\n\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res * sgn;\n\t\t}",
"int c = read();",
"c",
"read()",
"read",
"while (isSpaceChar(c))\n\t\t\t\tc = read();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c = read()",
"c",
"read()",
"read",
"int sgn = 1;",
"sgn",
"1",
"if (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}",
"c == '-'",
"c",
"'-'",
"{\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}",
"sgn = -1",
"sgn",
"-1",
"1",
"c = read()",
"c",
"read()",
"read",
"int res = 0;",
"res",
"0",
"do {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}",
"if (c < '0' || c > '9')\n\t\t\t\t\tthrow 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 = read()",
"c",
"read()",
"read",
"return res * sgn;",
"res * sgn",
"res",
"sgn",
"public long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}",
"nextLong",
"{\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}",
"int c = read();",
"c",
"read()",
"read",
"while (isSpaceChar(c))\n\t\t\t\tc = read();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c = read()",
"c",
"read()",
"read",
"int sgn = 1;",
"sgn",
"1",
"if (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}",
"c == '-'",
"c",
"'-'",
"{\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}",
"sgn = -1",
"sgn",
"-1",
"1",
"c = read()",
"c",
"read()",
"read",
"long res = 0;",
"res",
"0",
"do {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}",
"if (c < '0' || c > '9')\n\t\t\t\t\tthrow 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 = read()",
"c",
"read()",
"read",
"return res * sgn;",
"res * sgn",
"res",
"sgn",
"public double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}",
"nextDouble",
"{\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}",
"int c = read();",
"c",
"read()",
"read",
"while (isSpaceChar(c))\n\t\t\t\tc = read();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c = read()",
"c",
"read()",
"read",
"int sgn = 1;",
"sgn",
"1",
"if (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}",
"c == '-'",
"c",
"'-'",
"{\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}",
"sgn = -1",
"sgn",
"-1",
"1",
"c = read()",
"c",
"read()",
"read",
"double res = 0;",
"res",
"0",
"while (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}",
"!isSpaceChar(c) && c != '.'",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c != '.'",
"c",
"'.'",
"{\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}",
"if (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());",
"c == 'e' || c == 'E'",
"c == 'e'",
"c",
"'e'",
"c == 'E'",
"c",
"'E'",
"return res * Math.pow(10, nextInt());",
"res * Math.pow(10, nextInt())",
"res",
"Math.pow(10, nextInt())",
"Math.pow",
"Math",
"10",
"nextInt()",
"nextInt",
"if (c < '0' || c > '9')\n\t\t\t\t\tthrow 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 = read()",
"c",
"read()",
"read",
"if (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}",
"c == '.'",
"c",
"'.'",
"{\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}",
"c = read()",
"c",
"read()",
"read",
"double m = 1;",
"m",
"1",
"while (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}",
"if (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());",
"c == 'e' || c == 'E'",
"c == 'e'",
"c",
"'e'",
"c == 'E'",
"c",
"'E'",
"return res * Math.pow(10, nextInt());",
"res * Math.pow(10, nextInt())",
"res",
"Math.pow(10, nextInt())",
"Math.pow",
"Math",
"10",
"nextInt()",
"nextInt",
"if (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();",
"c < '0' || c > '9'",
"c < '0'",
"c",
"'0'",
"c > '9'",
"c",
"'9'",
"throw new InputMismatchException();",
"new InputMismatchException()",
"m /= 10",
"m",
"10",
"res += (c - '0') * m",
"res",
"(c - '0') * m",
"(c - '0')",
"c",
"'0'",
"m",
"c = read()",
"c",
"read()",
"read",
"return res * sgn;",
"res * sgn",
"res",
"sgn",
"public String readString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res.toString();\n\t\t}",
"readString",
"{\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res.toString();\n\t\t}",
"int c = read();",
"c",
"read()",
"read",
"while (isSpaceChar(c))\n\t\t\t\tc = read();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c = read()",
"c",
"read()",
"read",
"StringBuilder res = new StringBuilder();",
"res",
"new StringBuilder()",
"do {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t}",
"res.appendCodePoint(c)",
"res.appendCodePoint",
"res",
"c",
"c = read()",
"c",
"read()",
"read",
"return res.toString();",
"res.toString()",
"res.toString",
"res",
"public boolean isSpaceChar(int c) {\n\t\t\tif (filter != null)\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}",
"isSpaceChar",
"{\n\t\t\tif (filter != null)\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}",
"if (filter != null)\n\t\t\t\treturn 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 String next() {\n\t\t\treturn readString();\n\t\t}",
"next",
"{\n\t\t\treturn readString();\n\t\t}",
"return readString();",
"readString()",
"readString",
"public interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}",
"SpaceCharFilter",
"public boolean isSpaceChar(int ch);",
"isSpaceChar",
"int ch",
"ch",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tInputReader sc = new InputReader(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\t\t\t\n\t\t}\n\t\tlong maxh = a[0];\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}\n\t\t\n\t\tpw.println(ans);\n\t\t\n\t\tpw.close();\n\t}\n\t\n\t\n\tstatic class InputReader {\n\t\tprivate InputStream stream;\n\t\tprivate byte[] buf = new byte[5];\n\t\tprivate int curChar;\n\t\tprivate int numChars;\n\t\tprivate SpaceCharFilter filter;\n\n\t\tpublic InputReader(InputStream stream) {\n\t\t\tthis.stream = stream;\n\t\t}\n\n\t\tpublic int read() {\n\t\t\tif (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\treturn buf[curChar++];\n\t\t}\n\n\t\tpublic String nextLine() {\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(stream));\n\t\t\tString stock = \"\";\n\t\t\ttry {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn stock;\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\n\t\t\tint sgn = 1;\n\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic String readString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res.toString();\n\t\t}\n\n\t\tpublic boolean isSpaceChar(int c) {\n\t\t\tif (filter != null)\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\treturn readString();\n\t\t}\n\n\t\tpublic interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tInputReader sc = new InputReader(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\ta[i] = sc.nextInt();\t\t\t\n\t\t}\n\t\tlong maxh = a[0];\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++){\n\t\t\tmaxh = Math.max(maxh, a[i]);\n\t\t\tans += (maxh-a[i]);\n\t\t}\n\t\t\n\t\tpw.println(ans);\n\t\t\n\t\tpw.close();\n\t}\n\t\n\t\n\tstatic class InputReader {\n\t\tprivate InputStream stream;\n\t\tprivate byte[] buf = new byte[5];\n\t\tprivate int curChar;\n\t\tprivate int numChars;\n\t\tprivate SpaceCharFilter filter;\n\n\t\tpublic InputReader(InputStream stream) {\n\t\t\tthis.stream = stream;\n\t\t}\n\n\t\tpublic int read() {\n\t\t\tif (numChars == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\n\t\t\t\tif (numChars <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\treturn buf[curChar++];\n\t\t}\n\n\t\tpublic String nextLine() {\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(stream));\n\t\t\tString stock = \"\";\n\t\t\ttry {\n\t\t\t\tstock = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn stock;\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\n\t\t\tint sgn = 1;\n\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E')\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic String readString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = read();\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tres.appendCodePoint(c);\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\n\t\t\treturn res.toString();\n\t\t}\n\n\t\tpublic boolean isSpaceChar(int c) {\n\t\t\tif (filter != null)\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\treturn readString();\n\t\t}\n\n\t\tpublic interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}\n\t}\n\n}",
"Main"
]
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputReader sc = new InputReader(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i++){
a[i] = sc.nextInt();
}
long maxh = a[0];
long ans = 0;
for(int i = 1; i < n; i++){
maxh = Math.max(maxh, a[i]);
ans += (maxh-a[i]);
}
pw.println(ans);
pw.close();
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[5];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
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 nextLine() {
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
String stock = "";
try {
stock = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return stock;
}
public int nextInt() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public long nextLong() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public double nextDouble() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
double res = 0;
while (!isSpaceChar(c) && c != '.') {
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
if (c == '.') {
c = read();
double m = 1;
while (!isSpaceChar(c)) {
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
m /= 10;
res += (c - '0') * m;
c = read();
}
}
return res * sgn;
}
public String readString() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public String next() {
return readString();
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
18,
13,
13,
41,
13,
41,
13,
17,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
0,
13,
13,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
30,
0,
13,
2,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
28,
13,
13,
30,
30,
4,
18,
13,
13,
4,
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,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
14,
2,
13,
17,
30,
29,
17,
14,
2,
2,
13,
17,
2,
13,
17,
30,
29,
17,
14,
2,
2,
2,
13,
17,
17,
2,
2,
13,
17,
17,
30,
29,
17,
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,
2,
13,
2,
13,
17,
17,
2,
2,
13,
2,
13,
17,
17,
30,
29,
17,
29,
17,
23,
13,
12,
13,
30,
29,
8,
2,
13,
17,
13,
4,
13,
13,
2,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
2,
2,
13,
4,
13,
13,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
42,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
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,
13,
29,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
2,
13,
18,
13,
13,
23,
13,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
418,
8
],
[
418,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
11,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
23,
25
],
[
11,
26
],
[
26,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
11,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
11,
41
],
[
41,
42
],
[
41,
43
],
[
11,
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
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
58,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
11,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
80,
85
],
[
9,
86
],
[
86,
87
],
[
418,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
94,
97
],
[
98,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
90,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
90,
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
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
88,
130
],
[
130,
131
],
[
418,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
140,
142
],
[
135,
143
],
[
143,
144
],
[
144,
145
],
[
135,
146
],
[
147,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
152,
153
],
[
153,
154
],
[
132,
155
],
[
155,
156
],
[
132,
157
],
[
157,
158
],
[
132,
159
],
[
159,
160
],
[
418,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
169,
170
],
[
169,
171
],
[
164,
172
],
[
172,
173
],
[
173,
174
],
[
164,
175
],
[
176,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
177,
181
],
[
181,
182
],
[
182,
183
],
[
161,
184
],
[
184,
185
],
[
161,
186
],
[
186,
187
],
[
161,
188
],
[
188,
189
],
[
418,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
197,
198
],
[
198,
199
],
[
193,
200
],
[
200,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
201,
205
],
[
205,
206
],
[
205,
207
],
[
200,
208
],
[
208,
209
],
[
209,
210
],
[
200,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
213,
217
],
[
212,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
218,
222
],
[
211,
223
],
[
223,
224
],
[
224,
225
],
[
192,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
229,
232
],
[
228,
233
],
[
192,
234
],
[
234,
235
],
[
235,
236
],
[
236,
237
],
[
236,
238
],
[
234,
239
],
[
239,
240
],
[
239,
241
],
[
234,
242
],
[
242,
243
],
[
243,
244
],
[
243,
245
],
[
234,
246
],
[
247,
247
],
[
247,
248
],
[
248,
249
],
[
249,
250
],
[
250,
251
],
[
251,
252
],
[
251,
253
],
[
253,
254
],
[
253,
255
],
[
250,
256
],
[
249,
257
],
[
257,
258
],
[
258,
259
],
[
258,
260
],
[
260,
261
],
[
260,
262
],
[
257,
263
],
[
248,
264
],
[
264,
265
],
[
265,
266
],
[
192,
267
],
[
267,
268
],
[
190,
269
],
[
269,
270
],
[
418,
271
],
[
271,
272
],
[
271,
273
],
[
273,
274
],
[
274,
275
],
[
275,
276
],
[
276,
277
],
[
276,
278
],
[
275,
279
],
[
275,
280
],
[
280,
281
],
[
280,
282
],
[
280,
283
],
[
283,
284
],
[
283,
285
],
[
271,
286
],
[
286,
287
],
[
271,
288
],
[
288,
289
],
[
418,
290
],
[
290,
291
],
[
290,
292
],
[
292,
293
],
[
293,
294
],
[
294,
295
],
[
295,
296
],
[
295,
297
],
[
297,
298
],
[
297,
299
],
[
297,
300
],
[
294,
301
],
[
290,
302
],
[
302,
303
],
[
290,
304
],
[
304,
305
],
[
418,
306
],
[
306,
307
],
[
306,
308
],
[
308,
309
],
[
308,
310
],
[
306,
311
],
[
311,
312
],
[
311,
313
],
[
306,
314
],
[
314,
315
],
[
314,
316
],
[
316,
317
],
[
317,
318
],
[
318,
319
],
[
319,
320
],
[
320,
321
],
[
317,
322
],
[
322,
323
],
[
323,
324
],
[
324,
325
],
[
324,
326
],
[
326,
327
],
[
327,
328
],
[
328,
329
],
[
323,
330
],
[
330,
331
],
[
331,
332
],
[
331,
333
],
[
316,
334
],
[
334,
335
],
[
335,
336
],
[
336,
337
],
[
306,
338
],
[
338,
339
],
[
338,
340
],
[
340,
341
],
[
341,
342
],
[
342,
343
],
[
343,
344
],
[
342,
345
],
[
345,
346
],
[
306,
347
],
[
347,
348
],
[
347,
349
],
[
349,
350
],
[
350,
351
],
[
350,
352
],
[
349,
354
],
[
354,
355
],
[
355,
356
],
[
356,
357
],
[
356,
358
],
[
354,
359
],
[
359,
360
],
[
359,
361
],
[
354,
362
],
[
362,
363
],
[
363,
364
],
[
354,
365
],
[
366,
366
],
[
366,
367
],
[
367,
368
],
[
368,
369
],
[
368,
370
],
[
367,
371
],
[
371,
372
],
[
349,
373
],
[
373,
374
],
[
347,
375
],
[
375,
376
],
[
306,
377
],
[
377,
378
],
[
377,
379
],
[
379,
380
],
[
380,
381
],
[
381,
382
],
[
382,
383
],
[
381,
384
],
[
384,
385
],
[
418,
386
],
[
386,
387
],
[
386,
388
],
[
388,
389
],
[
386,
390
],
[
390,
391
],
[
386,
392
],
[
392,
393
],
[
392,
394
],
[
394,
395
],
[
395,
396
],
[
395,
397
],
[
394,
398
],
[
398,
399
],
[
398,
400
],
[
392,
401
],
[
401,
402
],
[
392,
403
],
[
403,
404
],
[
386,
405
],
[
405,
406
],
[
405,
407
],
[
407,
408
],
[
408,
409
],
[
409,
410
],
[
409,
411
],
[
411,
412
],
[
411,
413
],
[
405,
414
],
[
414,
415
],
[
386,
416
],
[
0,
417
],
[
417,
418
],
[
417,
419
]
]
| [
"import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n FastScanner fs = new FastScanner();\n int max = Integer.MIN_VALUE, num;\n long sum = 0;\n int test = fs.nextInt();\n num = fs.nextInt();\n max = num;\n for (int i = 0; i < test - 1; i++) {\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }\n System.out.println(sum);\n //bw.flush();\n }\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n\n static void sort(int[] a) {\n ArrayList<Integer> l = new ArrayList<>();\n for (int i : a) {\n l.add(i);\n }\n Collections.sort(l);\n for (int i = 0; i < a.length; i++) {\n a[i] = l.get(i);\n }\n }\n\n static class FastScanner {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n String next() {\n while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] readArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n static class Pair implements Comparable<Pair> {\n\n int a, b;\n\n public Pair(int x, int y) {\n a = x;\n b = y;\n }\n\n @Override\n public int compareTo(Pair p) {\n return a - p.a;\n }\n }\n\n static void forl_0(int n, int[] array, Scanner sc) {\n for (int i = 0; i < n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static void forl_1(int n, int[] array, Scanner sc) {\n for (int i = 1; i <= n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static boolean isPrime(long n) {\n if (n < 2) {\n return false;\n } else if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n long sqrtN = (long) Math.sqrt(n) + 1;\n for (long i = 6L; i <= sqrtN; i += 6) {\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }\n return true;\n }\n\n public static long gcd(long a, long b) {\n return (b == 0) ? a : gcd(b, a % b);\n }\n\n public static long lcm(long a, long b) {\n return a / gcd(a, b) * b;\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n FastScanner fs = new FastScanner();\n int max = Integer.MIN_VALUE, num;\n long sum = 0;\n int test = fs.nextInt();\n num = fs.nextInt();\n max = num;\n for (int i = 0; i < test - 1; i++) {\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }\n System.out.println(sum);\n //bw.flush();\n }\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n\n static void sort(int[] a) {\n ArrayList<Integer> l = new ArrayList<>();\n for (int i : a) {\n l.add(i);\n }\n Collections.sort(l);\n for (int i = 0; i < a.length; i++) {\n a[i] = l.get(i);\n }\n }\n\n static class FastScanner {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n String next() {\n while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] readArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n static class Pair implements Comparable<Pair> {\n\n int a, b;\n\n public Pair(int x, int y) {\n a = x;\n b = y;\n }\n\n @Override\n public int compareTo(Pair p) {\n return a - p.a;\n }\n }\n\n static void forl_0(int n, int[] array, Scanner sc) {\n for (int i = 0; i < n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static void forl_1(int n, int[] array, Scanner sc) {\n for (int i = 1; i <= n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static boolean isPrime(long n) {\n if (n < 2) {\n return false;\n } else if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n long sqrtN = (long) Math.sqrt(n) + 1;\n for (long i = 6L; i <= sqrtN; i += 6) {\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }\n return true;\n }\n\n public static long gcd(long a, long b) {\n return (b == 0) ? a : gcd(b, a % b);\n }\n\n public static long lcm(long a, long b) {\n return a / gcd(a, b) * b;\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n FastScanner fs = new FastScanner();\n int max = Integer.MIN_VALUE, num;\n long sum = 0;\n int test = fs.nextInt();\n num = fs.nextInt();\n max = num;\n for (int i = 0; i < test - 1; i++) {\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }\n System.out.println(sum);\n //bw.flush();\n }",
"main",
"{\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n FastScanner fs = new FastScanner();\n int max = Integer.MIN_VALUE, num;\n long sum = 0;\n int test = fs.nextInt();\n num = fs.nextInt();\n max = num;\n for (int i = 0; i < test - 1; i++) {\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }\n System.out.println(sum);\n //bw.flush();\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));",
"bw",
"new BufferedWriter(new OutputStreamWriter(System.out))",
"FastScanner fs = new FastScanner();",
"fs",
"new FastScanner()",
"int max = Integer.MIN_VALUE",
"max",
"Integer.MIN_VALUE",
"Integer",
"Integer.MIN_VALUE",
"num;",
"num",
"long sum = 0;",
"sum",
"0",
"int test = fs.nextInt();",
"test",
"fs.nextInt()",
"fs.nextInt",
"fs",
"num = fs.nextInt()",
"num",
"fs.nextInt()",
"fs.nextInt",
"fs",
"max = num",
"max",
"num",
"for (int i = 0; i < test - 1; i++) {\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < test - 1",
"i",
"test - 1",
"test",
"1",
"i++",
"i++",
"i",
"{\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }",
"{\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }",
"num = fs.nextInt()",
"num",
"fs.nextInt()",
"fs.nextInt",
"fs",
"if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }",
"num > max",
"num",
"max",
"{\n max = num;\n }",
"max = num",
"max",
"num",
"{\n sum = sum + (max - num);\n }",
"sum = sum + (max - num)",
"sum",
"sum + (max - num)",
"sum",
"(max - num)",
"max",
"num",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"static void sort(int[] a) {\n ArrayList<Integer> l = new ArrayList<>();\n for (int i : a) {\n l.add(i);\n }\n Collections.sort(l);\n for (int i = 0; i < a.length; i++) {\n a[i] = l.get(i);\n }\n }",
"sort",
"{\n ArrayList<Integer> l = new ArrayList<>();\n for (int i : a) {\n l.add(i);\n }\n Collections.sort(l);\n for (int i = 0; i < a.length; i++) {\n a[i] = l.get(i);\n }\n }",
"ArrayList<Integer> l = new ArrayList<>();",
"l",
"new ArrayList<>()",
"for (int i : a) {\n l.add(i);\n }",
"int i",
"a",
"{\n l.add(i);\n }",
"{\n l.add(i);\n }",
"l.add(i)",
"l.add",
"l",
"i",
"Collections.sort(l)",
"Collections.sort",
"Collections",
"l",
"for (int i = 0; i < a.length; i++) {\n a[i] = l.get(i);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a.length",
"i",
"a.length",
"a",
"a.length",
"i++",
"i++",
"i",
"{\n a[i] = l.get(i);\n }",
"{\n a[i] = l.get(i);\n }",
"a[i] = l.get(i)",
"a[i]",
"a",
"i",
"l.get(i)",
"l.get",
"l",
"i",
"int[] a",
"a",
"static void forl_0(int n, int[] array, Scanner sc) {\n for (int i = 0; i < n; i++) {\n array[i] = sc.nextInt();\n }\n }",
"forl_0",
"{\n for (int i = 0; i < n; i++) {\n array[i] = sc.nextInt();\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",
"int n",
"n",
"int[] array",
"array",
"Scanner sc",
"sc",
"static void forl_1(int n, int[] array, Scanner sc) {\n for (int i = 1; i <= n; i++) {\n array[i] = sc.nextInt();\n }\n }",
"forl_1",
"{\n for (int i = 1; i <= n; i++) {\n array[i] = sc.nextInt();\n }\n }",
"for (int i = 1; i <= n; i++) {\n array[i] = sc.nextInt();\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"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",
"int n",
"n",
"int[] array",
"array",
"Scanner sc",
"sc",
"static boolean isPrime(long n) {\n if (n < 2) {\n return false;\n } else if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n long sqrtN = (long) Math.sqrt(n) + 1;\n for (long i = 6L; i <= sqrtN; i += 6) {\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }\n return true;\n }",
"isPrime",
"{\n if (n < 2) {\n return false;\n } else if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n long sqrtN = (long) Math.sqrt(n) + 1;\n for (long i = 6L; i <= sqrtN; i += 6) {\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }\n return true;\n }",
"if (n < 2) {\n return false;\n } else if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }",
"n < 2",
"n",
"2",
"{\n return false;\n }",
"return false;",
"false",
"if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }",
"n == 2 || n == 3",
"n == 2",
"n",
"2",
"n == 3",
"n",
"3",
"{\n return true;\n }",
"return true;",
"true",
"if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }",
"n % 2 == 0 || n % 3 == 0",
"n % 2 == 0",
"n % 2",
"n",
"2",
"0",
"n % 3 == 0",
"n % 3",
"n",
"3",
"0",
"{\n return false;\n }",
"return false;",
"false",
"long sqrtN = (long) Math.sqrt(n) + 1;",
"sqrtN",
"(long) Math.sqrt(n) + 1",
"(long) Math.sqrt(n)",
"Math.sqrt",
"Math",
"n",
"1",
"for (long i = 6L; i <= sqrtN; i += 6) {\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }",
"long i = 6L;",
"long i = 6L;",
"i",
"6L",
"i <= sqrtN",
"i",
"sqrtN",
"i += 6",
"i += 6",
"i",
"6",
"{\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }",
"{\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }",
"if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }",
"n % (i - 1) == 0 || n % (i + 1) == 0",
"n % (i - 1) == 0",
"n % (i - 1)",
"n",
"(i - 1)",
"i",
"1",
"0",
"n % (i + 1) == 0",
"n % (i + 1)",
"n",
"(i + 1)",
"i",
"1",
"0",
"{\n return false;\n }",
"return false;",
"false",
"return true;",
"true",
"long n",
"n",
"public static long gcd(long a, long b) {\n return (b == 0) ? a : gcd(b, a % b);\n }",
"gcd",
"{\n return (b == 0) ? a : gcd(b, a % b);\n }",
"return (b == 0) ? a : gcd(b, a % b);",
"(b == 0) ? a : gcd(b, a % b)",
"(b == 0)",
"b",
"0",
"a",
"gcd(b, a % b)",
"gcd",
"b",
"a % b",
"a",
"b",
"long a",
"a",
"long b",
"b",
"public static long lcm(long a, long b) {\n return a / gcd(a, b) * b;\n }",
"lcm",
"{\n return a / gcd(a, b) * b;\n }",
"return a / gcd(a, b) * b;",
"a / gcd(a, b) * b",
"a / gcd(a, b)",
"a",
"gcd(a, b)",
"gcd",
"a",
"b",
"b",
"long a",
"a",
"long b",
"b",
"static class FastScanner {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n String next() {\n while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] readArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n }",
"FastScanner",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"StringTokenizer st = new StringTokenizer(\"\");",
"st",
"new StringTokenizer(\"\")",
"String next() {\n while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"next",
"{\n while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"{\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"try {\n st = new StringTokenizer(br.readLine());\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 st = new StringTokenizer(br.readLine());\n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"int[] readArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }",
"readArray",
"{\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = nextInt();\n }",
"{\n a[i] = nextInt();\n }",
"a[i] = nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int n",
"n",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"static class Pair implements Comparable<Pair> {\n\n int a, b;\n\n public Pair(int x, int y) {\n a = x;\n b = y;\n }\n\n @Override\n public int compareTo(Pair p) {\n return a - p.a;\n }\n }",
"Pair",
"int a",
"a",
"b;",
"b",
"public Pair(int x, int y) {\n a = x;\n b = y;\n }",
"Pair",
"{\n a = x;\n b = y;\n }",
"a = x",
"a",
"x",
"b = y",
"b",
"y",
"int x",
"x",
"int y",
"y",
"@Override\n public int compareTo(Pair p) {\n return a - p.a;\n }",
"compareTo",
"{\n return a - p.a;\n }",
"return a - p.a;",
"a - p.a",
"a",
"p.a",
"p",
"p.a",
"Pair p",
"p",
"Comparable",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n FastScanner fs = new FastScanner();\n int max = Integer.MIN_VALUE, num;\n long sum = 0;\n int test = fs.nextInt();\n num = fs.nextInt();\n max = num;\n for (int i = 0; i < test - 1; i++) {\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }\n System.out.println(sum);\n //bw.flush();\n }\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n\n static void sort(int[] a) {\n ArrayList<Integer> l = new ArrayList<>();\n for (int i : a) {\n l.add(i);\n }\n Collections.sort(l);\n for (int i = 0; i < a.length; i++) {\n a[i] = l.get(i);\n }\n }\n\n static class FastScanner {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n String next() {\n while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] readArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n static class Pair implements Comparable<Pair> {\n\n int a, b;\n\n public Pair(int x, int y) {\n a = x;\n b = y;\n }\n\n @Override\n public int compareTo(Pair p) {\n return a - p.a;\n }\n }\n\n static void forl_0(int n, int[] array, Scanner sc) {\n for (int i = 0; i < n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static void forl_1(int n, int[] array, Scanner sc) {\n for (int i = 1; i <= n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static boolean isPrime(long n) {\n if (n < 2) {\n return false;\n } else if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n long sqrtN = (long) Math.sqrt(n) + 1;\n for (long i = 6L; i <= sqrtN; i += 6) {\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }\n return true;\n }\n\n public static long gcd(long a, long b) {\n return (b == 0) ? a : gcd(b, a % b);\n }\n\n public static long lcm(long a, long b) {\n return a / gcd(a, b) * b;\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n FastScanner fs = new FastScanner();\n int max = Integer.MIN_VALUE, num;\n long sum = 0;\n int test = fs.nextInt();\n num = fs.nextInt();\n max = num;\n for (int i = 0; i < test - 1; i++) {\n num = fs.nextInt();\n if (num > max) {\n max = num;\n } else {\n sum = sum + (max - num);\n }\n }\n System.out.println(sum);\n //bw.flush();\n }\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n//==============================================//\n\n static void sort(int[] a) {\n ArrayList<Integer> l = new ArrayList<>();\n for (int i : a) {\n l.add(i);\n }\n Collections.sort(l);\n for (int i = 0; i < a.length; i++) {\n a[i] = l.get(i);\n }\n }\n\n static class FastScanner {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n String next() {\n while (!st.hasMoreTokens()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] readArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n }\n\n static class Pair implements Comparable<Pair> {\n\n int a, b;\n\n public Pair(int x, int y) {\n a = x;\n b = y;\n }\n\n @Override\n public int compareTo(Pair p) {\n return a - p.a;\n }\n }\n\n static void forl_0(int n, int[] array, Scanner sc) {\n for (int i = 0; i < n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static void forl_1(int n, int[] array, Scanner sc) {\n for (int i = 1; i <= n; i++) {\n array[i] = sc.nextInt();\n }\n }\n\n static boolean isPrime(long n) {\n if (n < 2) {\n return false;\n } else if (n == 2 || n == 3) {\n return true;\n } else if (n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n long sqrtN = (long) Math.sqrt(n) + 1;\n for (long i = 6L; i <= sqrtN; i += 6) {\n if (n % (i - 1) == 0 || n % (i + 1) == 0) {\n return false;\n }\n }\n return true;\n }\n\n public static long gcd(long a, long b) {\n return (b == 0) ? a : gcd(b, a % b);\n }\n\n public static long lcm(long a, long b) {\n return a / gcd(a, b) * b;\n }\n}",
"Main"
]
| import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
FastScanner fs = new FastScanner();
int max = Integer.MIN_VALUE, num;
long sum = 0;
int test = fs.nextInt();
num = fs.nextInt();
max = num;
for (int i = 0; i < test - 1; i++) {
num = fs.nextInt();
if (num > max) {
max = num;
} else {
sum = sum + (max - num);
}
}
System.out.println(sum);
//bw.flush();
}
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
static void sort(int[] a) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : a) {
l.add(i);
}
Collections.sort(l);
for (int i = 0; i < a.length; i++) {
a[i] = l.get(i);
}
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
}
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
static class Pair implements Comparable<Pair> {
int a, b;
public Pair(int x, int y) {
a = x;
b = y;
}
@Override
public int compareTo(Pair p) {
return a - p.a;
}
}
static void forl_0(int n, int[] array, Scanner sc) {
for (int i = 0; i < n; i++) {
array[i] = sc.nextInt();
}
}
static void forl_1(int n, int[] array, Scanner sc) {
for (int i = 1; i <= n; i++) {
array[i] = sc.nextInt();
}
}
static boolean isPrime(long n) {
if (n < 2) {
return false;
} else if (n == 2 || n == 3) {
return true;
} else if (n % 2 == 0 || n % 3 == 0) {
return false;
}
long sqrtN = (long) Math.sqrt(n) + 1;
for (long i = 6L; i <= sqrtN; i += 6) {
if (n % (i - 1) == 0 || n % (i + 1) == 0) {
return false;
}
}
return true;
}
public static long gcd(long a, long b) {
return (b == 0) ? a : gcd(b, a % b);
}
public static long lcm(long a, long b) {
return a / gcd(a, b) * b;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
78,
5
],
[
78,
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
],
[
22,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
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
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
52,
53
],
[
53,
54
],
[
46,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
55,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
8,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
69,
74
],
[
6,
75
],
[
75,
76
],
[
0,
77
],
[
77,
78
],
[
77,
79
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = Integer.parseInt(scan.next());\n\t\tint preA = Integer.parseInt(scan.next());\n\t\tint postA = 0;\n\t\tlong sum=0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(sum);\n\t}\n\t\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = Integer.parseInt(scan.next());\n\t\tint preA = Integer.parseInt(scan.next());\n\t\tint postA = 0;\n\t\tlong sum=0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(sum);\n\t}\n\t\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = Integer.parseInt(scan.next());\n\t\tint preA = Integer.parseInt(scan.next());\n\t\tint postA = 0;\n\t\tlong sum=0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(sum);\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = Integer.parseInt(scan.next());\n\t\tint preA = Integer.parseInt(scan.next());\n\t\tint postA = 0;\n\t\tlong sum=0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(sum);\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int N = Integer.parseInt(scan.next());",
"N",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"int preA = Integer.parseInt(scan.next());",
"preA",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"int postA = 0;",
"postA",
"0",
"long sum=0;",
"sum",
"0",
"for(int i=1;i<N;i++) {\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\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\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}",
"{\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}",
"postA = Integer.parseInt(scan.next())",
"postA",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"if(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}",
"preA > postA",
"preA",
"postA",
"{\n\t\t\t\tsum += preA - postA;\n\t\t\t}",
"sum += preA - postA",
"sum",
"preA - postA",
"preA",
"postA",
"{\n\t\t\t\tpreA = postA;\n\t\t\t}",
"preA = postA",
"preA",
"postA",
"System.out.print(sum)",
"System.out.print",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = Integer.parseInt(scan.next());\n\t\tint preA = Integer.parseInt(scan.next());\n\t\tint postA = 0;\n\t\tlong sum=0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(sum);\n\t}\n\t\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = Integer.parseInt(scan.next());\n\t\tint preA = Integer.parseInt(scan.next());\n\t\tint postA = 0;\n\t\tlong sum=0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tpostA = Integer.parseInt(scan.next());\n\t\t\tif(preA > postA) {\n\t\t\t\tsum += preA - postA;\n\t\t\t} else {\n\t\t\t\tpreA = postA;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tSystem.out.print(sum);\n\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 = Integer.parseInt(scan.next());
int preA = Integer.parseInt(scan.next());
int postA = 0;
long sum=0;
for(int i=1;i<N;i++) {
postA = Integer.parseInt(scan.next());
if(preA > postA) {
sum += preA - postA;
} else {
preA = postA;
}
}
System.out.print(sum);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
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,
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,
12,
13,
30,
29,
4,
18,
4,
18,
13,
17,
12,
13,
30,
29,
4,
18,
13,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
18,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
18,
13,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
29,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
18,
13,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
29,
13,
12,
13,
30,
29,
4,
18,
4,
18,
20,
23,
13,
12,
13,
30,
41,
13,
17,
42,
2,
13,
17,
30,
14,
2,
2,
13,
17,
17,
30,
0,
13,
13,
0,
13,
13,
0,
13,
2,
13,
13,
0,
13,
13,
0,
13,
17,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
17,
14,
2,
13,
17,
0,
13,
20,
0,
13,
20,
14,
2,
13,
17,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
4,
18,
13,
4,
18,
20,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
40,
13,
0,
13,
2,
2,
2,
13,
17,
13,
13,
4,
18,
18,
13,
13,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
18,
13,
17,
41,
13,
18,
13,
17,
0,
13,
4,
13,
41,
13,
17,
41,
13,
2,
17,
17,
42,
2,
13,
13,
30,
41,
13,
2,
2,
13,
13,
17,
41,
13,
4,
13,
13,
13,
14,
2,
13,
13,
0,
13,
2,
13,
17,
0,
13,
13,
4,
18,
13,
13,
12,
13,
30,
41,
13,
17,
28,
13,
13,
30,
30,
14,
2,
13,
13,
0,
13,
2,
13,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
4,
18,
4,
18,
13,
41,
13,
17,
41,
13,
2,
13,
17,
41,
13,
17,
42,
2,
13,
13,
30,
42,
2,
2,
13,
13,
2,
18,
13,
13,
17,
40,
13,
42,
2,
2,
13,
13,
2,
18,
13,
13,
17,
40,
13,
14,
2,
13,
13,
30,
4,
13,
13,
13,
13,
40,
13,
40,
13,
40,
13,
4,
18,
13,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
4,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
0,
13,
2,
13,
18,
13,
13,
0,
13,
4,
18,
13,
18,
13,
13,
13,
4,
18,
13,
13,
12,
13,
30,
14,
2,
13,
17,
29,
13,
29,
4,
13,
13,
2,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
17,
28,
13,
4,
18,
13,
30,
30,
41,
13,
2,
13,
17,
0,
13,
13,
0,
13,
17,
14,
2,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
29,
17,
41,
13,
2,
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,
13,
40,
13,
14,
2,
13,
17,
29,
17,
29,
17,
23,
13,
23,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
2,
13,
13,
14,
2,
2,
13,
13,
17,
40,
13,
4,
18,
13,
2,
13,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
728,
11
],
[
728,
12
],
[
12,
13
],
[
728,
14
],
[
14,
15
],
[
14,
16
],
[
728,
17
],
[
17,
18
],
[
17,
19
],
[
728,
20
],
[
20,
21
],
[
20,
22
],
[
728,
23
],
[
23,
24
],
[
23,
25
],
[
728,
26
],
[
26,
27
],
[
26,
28
],
[
728,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
34,
36
],
[
31,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
41,
43
],
[
31,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
29,
49
],
[
49,
50
],
[
29,
51
],
[
51,
52
],
[
29,
53
],
[
53,
54
],
[
728,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
57,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
63,
67
],
[
67,
68
],
[
67,
69
],
[
57,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
55,
75
],
[
75,
76
],
[
55,
77
],
[
77,
78
],
[
55,
79
],
[
79,
80
],
[
728,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
85,
90
],
[
728,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
98,
99
],
[
99,
100
],
[
728,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
728,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
113,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
113,
123
],
[
123,
124
],
[
123,
125
],
[
113,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
132,
133
],
[
132,
134
],
[
127,
135
],
[
135,
136
],
[
136,
137
],
[
127,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
144,
145
],
[
143,
146
],
[
146,
147
],
[
146,
148
],
[
113,
149
],
[
149,
150
],
[
728,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
153,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
160,
162
],
[
153,
163
],
[
163,
164
],
[
163,
165
],
[
153,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
167,
172
],
[
172,
173
],
[
172,
174
],
[
167,
175
],
[
175,
176
],
[
176,
177
],
[
167,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
183,
184
],
[
184,
185
],
[
183,
186
],
[
186,
187
],
[
186,
188
],
[
153,
189
],
[
189,
190
],
[
728,
191
],
[
191,
192
],
[
191,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
191,
200
],
[
200,
201
],
[
728,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
204,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
208,
212
],
[
212,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
214,
218
],
[
213,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
219,
223
],
[
223,
224
],
[
223,
225
],
[
212,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
228,
230
],
[
212,
231
],
[
231,
232
],
[
231,
233
],
[
212,
234
],
[
234,
235
],
[
234,
236
],
[
204,
237
],
[
237,
238
],
[
202,
239
],
[
239,
240
],
[
202,
241
],
[
241,
242
],
[
728,
243
],
[
243,
244
],
[
243,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
248,
249
],
[
249,
250
],
[
248,
251
],
[
245,
252
],
[
252,
253
],
[
253,
254
],
[
253,
255
],
[
252,
256
],
[
256,
257
],
[
256,
258
],
[
252,
259
],
[
259,
260
],
[
259,
261
],
[
245,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
262,
266
],
[
266,
267
],
[
267,
268
],
[
267,
269
],
[
269,
270
],
[
270,
271
],
[
271,
272
],
[
272,
273
],
[
269,
274
],
[
266,
275
],
[
275,
276
],
[
275,
277
],
[
277,
278
],
[
278,
279
],
[
279,
280
],
[
280,
281
],
[
245,
282
],
[
282,
283
],
[
283,
284
],
[
245,
285
],
[
285,
286
],
[
286,
287
],
[
243,
288
],
[
288,
289
],
[
728,
290
],
[
290,
291
],
[
290,
292
],
[
292,
293
],
[
293,
294
],
[
293,
295
],
[
295,
296
],
[
292,
297
],
[
297,
298
],
[
297,
299
],
[
299,
300
],
[
300,
301
],
[
292,
302
],
[
302,
303
],
[
302,
304
],
[
304,
305
],
[
305,
306
],
[
292,
307
],
[
307,
308
],
[
307,
309
],
[
292,
310
],
[
310,
311
],
[
310,
312
],
[
292,
313
],
[
313,
314
],
[
314,
315
],
[
315,
316
],
[
315,
317
],
[
313,
318
],
[
318,
319
],
[
318,
320
],
[
313,
321
],
[
321,
322
],
[
322,
323
],
[
313,
324
],
[
325,
325
],
[
325,
326
],
[
326,
327
],
[
325,
328
],
[
328,
329
],
[
328,
330
],
[
330,
331
],
[
331,
332
],
[
332,
333
],
[
332,
334
],
[
331,
335
],
[
330,
336
],
[
292,
337
],
[
337,
338
],
[
338,
339
],
[
339,
340
],
[
339,
341
],
[
337,
342
],
[
728,
343
],
[
343,
344
],
[
343,
345
],
[
345,
346
],
[
346,
347
],
[
346,
348
],
[
348,
349
],
[
345,
350
],
[
350,
351
],
[
350,
352
],
[
352,
353
],
[
352,
354
],
[
345,
355
],
[
355,
356
],
[
355,
357
],
[
357,
358
],
[
357,
359
],
[
345,
360
],
[
360,
361
],
[
360,
362
],
[
362,
363
],
[
345,
364
],
[
364,
365
],
[
364,
366
],
[
345,
367
],
[
367,
368
],
[
367,
369
],
[
369,
370
],
[
369,
371
],
[
345,
372
],
[
372,
373
],
[
373,
374
],
[
373,
375
],
[
372,
376
],
[
376,
377
],
[
377,
378
],
[
377,
379
],
[
379,
380
],
[
380,
381
],
[
380,
382
],
[
379,
383
],
[
376,
384
],
[
384,
385
],
[
384,
386
],
[
386,
387
],
[
386,
388
],
[
386,
389
],
[
376,
390
],
[
390,
391
],
[
391,
392
],
[
391,
393
],
[
390,
394
],
[
394,
395
],
[
394,
396
],
[
396,
397
],
[
396,
398
],
[
390,
399
],
[
399,
400
],
[
399,
401
],
[
345,
402
],
[
402,
403
],
[
403,
404
],
[
402,
405
],
[
728,
406
],
[
406,
407
],
[
406,
408
],
[
408,
409
],
[
409,
410
],
[
409,
411
],
[
408,
412
],
[
412,
413
],
[
412,
414
],
[
412,
415
],
[
416,
416
],
[
416,
417
],
[
417,
418
],
[
418,
419
],
[
418,
420
],
[
417,
421
],
[
421,
422
],
[
421,
423
],
[
423,
424
],
[
423,
425
],
[
408,
426
],
[
426,
427
],
[
406,
428
],
[
428,
429
],
[
406,
430
],
[
430,
431
],
[
728,
432
],
[
432,
433
],
[
432,
434
],
[
434,
435
],
[
435,
436
],
[
435,
437
],
[
437,
438
],
[
434,
439
],
[
439,
440
],
[
439,
441
],
[
441,
442
],
[
442,
443
],
[
443,
444
],
[
444,
445
],
[
434,
446
],
[
446,
447
],
[
446,
448
],
[
434,
449
],
[
449,
450
],
[
449,
451
],
[
451,
452
],
[
451,
453
],
[
434,
454
],
[
454,
455
],
[
454,
456
],
[
434,
457
],
[
457,
458
],
[
458,
459
],
[
458,
460
],
[
457,
461
],
[
461,
462
],
[
462,
463
],
[
463,
464
],
[
464,
465
],
[
464,
466
],
[
463,
467
],
[
467,
468
],
[
468,
469
],
[
468,
470
],
[
467,
471
],
[
462,
472
],
[
472,
473
],
[
461,
474
],
[
474,
475
],
[
475,
476
],
[
476,
477
],
[
476,
478
],
[
475,
479
],
[
479,
480
],
[
480,
481
],
[
480,
482
],
[
479,
483
],
[
474,
484
],
[
484,
485
],
[
461,
486
],
[
486,
487
],
[
487,
488
],
[
487,
489
],
[
486,
490
],
[
490,
491
],
[
491,
492
],
[
491,
493
],
[
491,
494
],
[
491,
495
],
[
490,
496
],
[
496,
497
],
[
490,
498
],
[
498,
499
],
[
490,
500
],
[
500,
501
],
[
434,
502
],
[
502,
503
],
[
503,
504
],
[
502,
505
],
[
728,
506
],
[
506,
507
],
[
506,
508
],
[
508,
509
],
[
509,
510
],
[
509,
511
],
[
511,
512
],
[
508,
513
],
[
513,
514
],
[
513,
515
],
[
515,
516
],
[
508,
517
],
[
517,
518
],
[
517,
519
],
[
508,
520
],
[
520,
521
],
[
520,
522
],
[
508,
523
],
[
523,
524
],
[
524,
525
],
[
525,
526
],
[
525,
527
],
[
523,
528
],
[
528,
529
],
[
528,
530
],
[
523,
531
],
[
531,
532
],
[
532,
533
],
[
523,
534
],
[
535,
535
],
[
535,
536
],
[
536,
537
],
[
537,
538
],
[
538,
539
],
[
538,
540
],
[
537,
541
],
[
536,
542
],
[
542,
543
],
[
542,
544
],
[
544,
545
],
[
544,
546
],
[
546,
547
],
[
546,
548
],
[
535,
549
],
[
549,
550
],
[
549,
551
],
[
551,
552
],
[
552,
553
],
[
551,
554
],
[
554,
555
],
[
554,
556
],
[
551,
557
],
[
508,
558
],
[
558,
559
],
[
559,
560
],
[
558,
561
],
[
728,
562
],
[
562,
563
],
[
562,
564
],
[
564,
565
],
[
565,
566
],
[
566,
567
],
[
566,
568
],
[
565,
569
],
[
569,
570
],
[
564,
571
],
[
571,
572
],
[
572,
573
],
[
572,
574
],
[
572,
575
],
[
575,
576
],
[
575,
577
],
[
562,
578
],
[
578,
579
],
[
562,
580
],
[
580,
581
],
[
728,
582
],
[
582,
583
],
[
582,
584
],
[
584,
585
],
[
585,
586
],
[
585,
587
],
[
587,
588
],
[
588,
589
],
[
584,
590
],
[
590,
591
],
[
590,
592
],
[
584,
593
],
[
593,
594
],
[
593,
595
],
[
595,
596
],
[
596,
597
],
[
593,
598
],
[
599,
599
],
[
599,
600
],
[
600,
601
],
[
600,
602
],
[
602,
603
],
[
602,
604
],
[
599,
605
],
[
605,
606
],
[
605,
607
],
[
599,
608
],
[
608,
609
],
[
608,
610
],
[
584,
611
],
[
611,
612
],
[
612,
613
],
[
612,
614
],
[
611,
615
],
[
615,
616
],
[
616,
617
],
[
615,
618
],
[
611,
619
],
[
619,
620
],
[
620,
621
],
[
619,
622
],
[
728,
623
],
[
623,
624
],
[
623,
625
],
[
625,
626
],
[
626,
627
],
[
626,
628
],
[
628,
629
],
[
629,
630
],
[
625,
631
],
[
631,
632
],
[
631,
633
],
[
633,
634
],
[
634,
635
],
[
625,
636
],
[
636,
637
],
[
637,
638
],
[
637,
639
],
[
636,
640
],
[
640,
641
],
[
625,
642
],
[
642,
643
],
[
642,
644
],
[
644,
645
],
[
644,
646
],
[
625,
647
],
[
647,
648
],
[
648,
649
],
[
649,
650
],
[
649,
651
],
[
651,
652
],
[
651,
653
],
[
647,
654
],
[
654,
655
],
[
654,
656
],
[
647,
657
],
[
657,
658
],
[
658,
659
],
[
647,
660
],
[
661,
661
],
[
661,
662
],
[
662,
663
],
[
663,
664
],
[
664,
665
],
[
665,
666
],
[
664,
667
],
[
663,
668
],
[
668,
669
],
[
669,
670
],
[
668,
671
],
[
662,
672
],
[
672,
673
],
[
661,
674
],
[
674,
675
],
[
675,
676
],
[
675,
677
],
[
674,
678
],
[
678,
679
],
[
625,
680
],
[
680,
681
],
[
623,
682
],
[
682,
683
],
[
623,
684
],
[
684,
685
],
[
728,
686
],
[
686,
687
],
[
686,
688
],
[
688,
689
],
[
689,
690
],
[
689,
691
],
[
691,
692
],
[
688,
693
],
[
693,
694
],
[
693,
695
],
[
695,
696
],
[
695,
697
],
[
688,
698
],
[
698,
699
],
[
698,
700
],
[
700,
701
],
[
700,
702
],
[
688,
703
],
[
703,
704
],
[
703,
705
],
[
705,
706
],
[
705,
707
],
[
688,
708
],
[
708,
709
],
[
708,
710
],
[
710,
711
],
[
710,
712
],
[
688,
713
],
[
713,
714
],
[
714,
715
],
[
715,
716
],
[
715,
717
],
[
714,
718
],
[
713,
719
],
[
719,
720
],
[
688,
721
],
[
721,
722
],
[
722,
723
],
[
721,
724
],
[
724,
725
],
[
724,
726
],
[
0,
727
],
[
727,
728
],
[
727,
729
]
]
| [
"import java.math.*;\nimport java.util.*;\nimport java.io.*;\n \npublic class Main { \n \n static BufferedReader in;\n static PrintWriter out = new PrintWriter(System.out);\n static String file = \"../in\";\n static int test = 10; // 0 for local testing, 1 for std input\n static int inf = 1_000_000, mod = 1_000_000_007;\n\n\n\n void swap(int[]ary, int i, int j)\n {\n int t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n\n void swap(char[]ary, int i, int j)\n {\n char t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n \n String[] split() throws Exception\n {\n return in.readLine().split(\" \");\n }\n\n int readInt() throws Exception\n {\n return Integer.valueOf(in.readLine());\n }\n\n long readLong() throws Exception\n {\n return Long.valueOf(in.readLine());\n }\n\n long[] toLongArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n long[] ary = new long[n];\n for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);\n return ary;\n }\n\n int[] toIntArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);\n return ary;\n }\n\n String reverse(String str)\n {\n return new StringBuilder(str).reverse().toString();\n }\n\n\n long pow(long a, int pow)\n {\n long res = 1;\n while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }\n\n public static void main(String[] args) throws Exception\n {\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n // char[] c = new char[4];\n // c[1] = '.';\n // for(char i = '0'; i <= '9'; i++)\n // {\n // for(char j = '0'; j <= '9'; j++)\n // {\n // for(char k = '0'; k <= '9'; k++)\n // {\n // c[0] = i;\n // c[2] = j;\n // c[3] = k;\n // double d = Double.valueOf(String.valueOf(c));\n // int v = (int)(d * 100);\n // String s1 = String.valueOf(\"\" + c[0] + c[2] + c[3]),\n // s2 = String.valueOf(v);\n // System.out.printf(\"%s %s %b\\n\", s1, s2, s1.equals(s2));\n // }\n // }\n // }\n\n\n new Main().c();\n out.flush();\n }\n void f() throws Exception\n {\n int k = readInt();\n String s = in.readLine();\n int n = s.length();\n long prod = 1;\n int mod = 1_000_000_007;\n for(int i = 0; i < k; i++)\n {\n n++;\n prod = (prod * 26 * n) % mod;\n }\n System.out.println(prod);\n\n }\n\n void e() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], k = ary[1];\n ary = toIntArray();\n int lo = 1, hi = 1 << 30;\n while(lo < hi)\n {\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }\n out.println(lo);\n }\n\n int numCut(int[] ary, int thres)\n {\n int count = 0;\n for(int v : ary)\n {\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }\n return count;\n }\n\n void d() throws Exception\n {\n int n = readInt();\n char[] c = in.readLine().toCharArray();\n int i = 0, j = n - 1, re = 0;\n while(i < j)\n {\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }\n out.println(re);\n }\n\n\n\n void c() throws Exception\n {\n int n = readInt();\n int[] ary = toIntArray();\n long sum = 0;\n int mini = 0;\n for(int i = 0; i < n; i++)\n {\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }\n out.println(sum);\n \n }\n\n int gcd(int a, int b)\n {\n if(b == 0) return a;\n return gcd(b, a % b);\n }\n\n void b() throws Exception\n {\n String str = in.readLine();\n int sum = 0;\n for(char c : str.toCharArray())\n {\n int val = c - '0';\n sum += val;\n sum %= 9;\n }\n if(sum == 0) out.println(\"Yes\");\n else out.println(\"No\");\n \n }\n\n boolean transform(String s1, String s2)\n {\n // from s1 -> s2\n int m = s1.length(), n = s2.length();\n if(m < n) return false;\n int j = n - 1;\n for(int i = m - 1; i >=0; i--)\n {\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }\n return false;\n }\n\n void a() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], x = ary[1], t = ary[2];\n int mult = n / x;\n if(n % x != 0) mult++;\n out.println(mult * t);\n \n }\n}",
"import java.math.*;",
"math.*",
"java",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main { \n \n static BufferedReader in;\n static PrintWriter out = new PrintWriter(System.out);\n static String file = \"../in\";\n static int test = 10; // 0 for local testing, 1 for std input\n static int inf = 1_000_000, mod = 1_000_000_007;\n\n\n\n void swap(int[]ary, int i, int j)\n {\n int t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n\n void swap(char[]ary, int i, int j)\n {\n char t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n \n String[] split() throws Exception\n {\n return in.readLine().split(\" \");\n }\n\n int readInt() throws Exception\n {\n return Integer.valueOf(in.readLine());\n }\n\n long readLong() throws Exception\n {\n return Long.valueOf(in.readLine());\n }\n\n long[] toLongArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n long[] ary = new long[n];\n for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);\n return ary;\n }\n\n int[] toIntArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);\n return ary;\n }\n\n String reverse(String str)\n {\n return new StringBuilder(str).reverse().toString();\n }\n\n\n long pow(long a, int pow)\n {\n long res = 1;\n while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }\n\n public static void main(String[] args) throws Exception\n {\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n // char[] c = new char[4];\n // c[1] = '.';\n // for(char i = '0'; i <= '9'; i++)\n // {\n // for(char j = '0'; j <= '9'; j++)\n // {\n // for(char k = '0'; k <= '9'; k++)\n // {\n // c[0] = i;\n // c[2] = j;\n // c[3] = k;\n // double d = Double.valueOf(String.valueOf(c));\n // int v = (int)(d * 100);\n // String s1 = String.valueOf(\"\" + c[0] + c[2] + c[3]),\n // s2 = String.valueOf(v);\n // System.out.printf(\"%s %s %b\\n\", s1, s2, s1.equals(s2));\n // }\n // }\n // }\n\n\n new Main().c();\n out.flush();\n }\n void f() throws Exception\n {\n int k = readInt();\n String s = in.readLine();\n int n = s.length();\n long prod = 1;\n int mod = 1_000_000_007;\n for(int i = 0; i < k; i++)\n {\n n++;\n prod = (prod * 26 * n) % mod;\n }\n System.out.println(prod);\n\n }\n\n void e() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], k = ary[1];\n ary = toIntArray();\n int lo = 1, hi = 1 << 30;\n while(lo < hi)\n {\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }\n out.println(lo);\n }\n\n int numCut(int[] ary, int thres)\n {\n int count = 0;\n for(int v : ary)\n {\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }\n return count;\n }\n\n void d() throws Exception\n {\n int n = readInt();\n char[] c = in.readLine().toCharArray();\n int i = 0, j = n - 1, re = 0;\n while(i < j)\n {\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }\n out.println(re);\n }\n\n\n\n void c() throws Exception\n {\n int n = readInt();\n int[] ary = toIntArray();\n long sum = 0;\n int mini = 0;\n for(int i = 0; i < n; i++)\n {\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }\n out.println(sum);\n \n }\n\n int gcd(int a, int b)\n {\n if(b == 0) return a;\n return gcd(b, a % b);\n }\n\n void b() throws Exception\n {\n String str = in.readLine();\n int sum = 0;\n for(char c : str.toCharArray())\n {\n int val = c - '0';\n sum += val;\n sum %= 9;\n }\n if(sum == 0) out.println(\"Yes\");\n else out.println(\"No\");\n \n }\n\n boolean transform(String s1, String s2)\n {\n // from s1 -> s2\n int m = s1.length(), n = s2.length();\n if(m < n) return false;\n int j = n - 1;\n for(int i = m - 1; i >=0; i--)\n {\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }\n return false;\n }\n\n void a() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], x = ary[1], t = ary[2];\n int mult = n / x;\n if(n % x != 0) mult++;\n out.println(mult * t);\n \n }\n}",
"Main",
"static BufferedReader in;",
"in",
"static PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"static String file = \"../in\";",
"file",
"\"../in\"",
"static int test = 10; // 0 for local testing, 1 for std input",
"test",
"10",
"static int inf = 1_000_000",
"inf",
"1_000_000",
"mod = 1_000_000_007;",
"mod",
"1_000_000_007",
"void swap(int[]ary, int i, int j)\n {\n int t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }",
"swap",
"{\n int t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }",
"int t = ary[i];",
"t",
"ary[i]",
"ary",
"i",
"ary[i] = ary[j]",
"ary[i]",
"ary",
"i",
"ary[j]",
"ary",
"j",
"ary[j] = t",
"ary[j]",
"ary",
"j",
"t",
"int[]ary",
"ary",
"int i",
"i",
"int j",
"j",
"void swap(char[]ary, int i, int j)\n {\n char t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }",
"swap",
"{\n char t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }",
"char t = ary[i];",
"t",
"ary[i]",
"ary",
"i",
"ary[i] = ary[j]",
"ary[i]",
"ary",
"i",
"ary[j]",
"ary",
"j",
"ary[j] = t",
"ary[j]",
"ary",
"j",
"t",
"char[]ary",
"ary",
"int i",
"i",
"int j",
"j",
"String[] split() throws Exception\n {\n return in.readLine().split(\" \");\n }",
"split",
"{\n return in.readLine().split(\" \");\n }",
"return in.readLine().split(\" \");",
"in.readLine().split(\" \")",
"in.readLine().split",
"in.readLine()",
"in.readLine",
"in",
"\" \"",
"int readInt() throws Exception\n {\n return Integer.valueOf(in.readLine());\n }",
"readInt",
"{\n return Integer.valueOf(in.readLine());\n }",
"return Integer.valueOf(in.readLine());",
"Integer.valueOf(in.readLine())",
"Integer.valueOf",
"Integer",
"in.readLine()",
"in.readLine",
"in",
"long readLong() throws Exception\n {\n return Long.valueOf(in.readLine());\n }",
"readLong",
"{\n return Long.valueOf(in.readLine());\n }",
"return Long.valueOf(in.readLine());",
"Long.valueOf(in.readLine())",
"Long.valueOf",
"Long",
"in.readLine()",
"in.readLine",
"in",
"long[] toLongArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n long[] ary = new long[n];\n for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);\n return ary;\n }",
"toLongArray",
"{\n String[] sp = split();\n int n = sp.length;\n long[] ary = new long[n];\n for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);\n return ary;\n }",
"String[] sp = split();",
"sp",
"split()",
"split",
"int n = sp.length;",
"n",
"sp.length",
"sp",
"sp.length",
"long[] ary = new long[n];",
"ary",
"new long[n]",
"n",
"for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"ary[i] = Long.valueOf(sp[i]);",
"ary[i] = Long.valueOf(sp[i])",
"ary[i]",
"ary",
"i",
"Long.valueOf(sp[i])",
"Long.valueOf",
"Long",
"sp[i]",
"sp",
"i",
"return ary;",
"ary",
"int[] toIntArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);\n return ary;\n }",
"toIntArray",
"{\n String[] sp = split();\n int n = sp.length;\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);\n return ary;\n }",
"String[] sp = split();",
"sp",
"split()",
"split",
"int n = sp.length;",
"n",
"sp.length",
"sp",
"sp.length",
"int[] ary = new int[n];",
"ary",
"new int[n]",
"n",
"for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"ary[i] = Integer.valueOf(sp[i]);",
"ary[i] = Integer.valueOf(sp[i])",
"ary[i]",
"ary",
"i",
"Integer.valueOf(sp[i])",
"Integer.valueOf",
"Integer",
"sp[i]",
"sp",
"i",
"return ary;",
"ary",
"String reverse(String str)\n {\n return new StringBuilder(str).reverse().toString();\n }",
"reverse",
"{\n return new StringBuilder(str).reverse().toString();\n }",
"return new StringBuilder(str).reverse().toString();",
"new StringBuilder(str).reverse().toString()",
"new StringBuilder(str).reverse().toString",
"new StringBuilder(str).reverse()",
"new StringBuilder(str).reverse",
"new StringBuilder(str)",
"String str",
"str",
"long pow(long a, int pow)\n {\n long res = 1;\n while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }",
"pow",
"{\n long res = 1;\n while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }",
"long res = 1;",
"res",
"1",
"while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }",
"pow > 0",
"pow",
"0",
"{\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }",
"if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }",
"pow % 2 != 0",
"pow % 2",
"pow",
"2",
"0",
"{\n res *= a;\n res %= mod;\n }",
"res *= a",
"res",
"a",
"res %= mod",
"res",
"mod",
"a = a * a",
"a",
"a * a",
"a",
"a",
"a %= mod",
"a",
"mod",
"pow /= 2",
"pow",
"2",
"return res;",
"res",
"long a",
"a",
"int pow",
"pow",
"public static void main(String[] args) throws Exception\n {\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n // char[] c = new char[4];\n // c[1] = '.';\n // for(char i = '0'; i <= '9'; i++)\n // {\n // for(char j = '0'; j <= '9'; j++)\n // {\n // for(char k = '0'; k <= '9'; k++)\n // {\n // c[0] = i;\n // c[2] = j;\n // c[3] = k;\n // double d = Double.valueOf(String.valueOf(c));\n // int v = (int)(d * 100);\n // String s1 = String.valueOf(\"\" + c[0] + c[2] + c[3]),\n // s2 = String.valueOf(v);\n // System.out.printf(\"%s %s %b\\n\", s1, s2, s1.equals(s2));\n // }\n // }\n // }\n\n\n new Main().c();\n out.flush();\n }",
"main",
"{\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n // char[] c = new char[4];\n // c[1] = '.';\n // for(char i = '0'; i <= '9'; i++)\n // {\n // for(char j = '0'; j <= '9'; j++)\n // {\n // for(char k = '0'; k <= '9'; k++)\n // {\n // c[0] = i;\n // c[2] = j;\n // c[3] = k;\n // double d = Double.valueOf(String.valueOf(c));\n // int v = (int)(d * 100);\n // String s1 = String.valueOf(\"\" + c[0] + c[2] + c[3]),\n // s2 = String.valueOf(v);\n // System.out.printf(\"%s %s %b\\n\", s1, s2, s1.equals(s2));\n // }\n // }\n // }\n\n\n new Main().c();\n out.flush();\n }",
"int _k = Integer.valueOf(\"1\");",
"_k",
"Integer.valueOf(\"1\")",
"Integer.valueOf",
"Integer",
"\"1\"",
"if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));",
"test > 0",
"test",
"0",
"in = new BufferedReader(new InputStreamReader(System.in))",
"in",
"new BufferedReader(new InputStreamReader(System.in))",
"in = new BufferedReader(new FileReader(file))",
"in",
"new BufferedReader(new FileReader(file))",
"if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}",
"test < 0",
"test",
"0",
"{String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}",
"String[] str = in.readLine().split(\" \");",
"str",
"in.readLine().split(\" \")",
"in.readLine().split",
"in.readLine()",
"in.readLine",
"in",
"\" \"",
"char[] gg = in.readLine().toCharArray();",
"gg",
"in.readLine().toCharArray()",
"in.readLine().toCharArray",
"in.readLine()",
"in.readLine",
"in",
"new Main().c()",
"new Main().c",
"new Main()",
"out.flush()",
"out.flush",
"out",
"String[] args",
"args",
"void f() throws Exception\n {\n int k = readInt();\n String s = in.readLine();\n int n = s.length();\n long prod = 1;\n int mod = 1_000_000_007;\n for(int i = 0; i < k; i++)\n {\n n++;\n prod = (prod * 26 * n) % mod;\n }\n System.out.println(prod);\n\n }",
"f",
"{\n int k = readInt();\n String s = in.readLine();\n int n = s.length();\n long prod = 1;\n int mod = 1_000_000_007;\n for(int i = 0; i < k; i++)\n {\n n++;\n prod = (prod * 26 * n) % mod;\n }\n System.out.println(prod);\n\n }",
"int k = readInt();",
"k",
"readInt()",
"readInt",
"String s = in.readLine();",
"s",
"in.readLine()",
"in.readLine",
"in",
"int n = s.length();",
"n",
"s.length()",
"s.length",
"s",
"long prod = 1;",
"prod",
"1",
"int mod = 1_000_000_007;",
"mod",
"1_000_000_007",
"for(int i = 0; i < k; i++)\n {\n n++;\n prod = (prod * 26 * n) % mod;\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < k",
"i",
"k",
"i++",
"i++",
"i",
"{\n n++;\n prod = (prod * 26 * n) % mod;\n }",
"{\n n++;\n prod = (prod * 26 * n) % mod;\n }",
"n++",
"n",
"prod = (prod * 26 * n) % mod",
"prod",
"(prod * 26 * n) % mod",
"(prod * 26 * n)",
"prod * 26 * n",
"prod",
"26",
"n",
"mod",
"System.out.println(prod)",
"System.out.println",
"System.out",
"System",
"System.out",
"prod",
"void e() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], k = ary[1];\n ary = toIntArray();\n int lo = 1, hi = 1 << 30;\n while(lo < hi)\n {\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }\n out.println(lo);\n }",
"e",
"{\n int[] ary = toIntArray();\n int n = ary[0], k = ary[1];\n ary = toIntArray();\n int lo = 1, hi = 1 << 30;\n while(lo < hi)\n {\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }\n out.println(lo);\n }",
"int[] ary = toIntArray();",
"ary",
"toIntArray()",
"toIntArray",
"int n = ary[0]",
"n",
"ary[0]",
"ary",
"0",
"k = ary[1];",
"k",
"ary[1]",
"ary",
"1",
"ary = toIntArray()",
"ary",
"toIntArray()",
"toIntArray",
"int lo = 1",
"lo",
"1",
"hi = 1 << 30;",
"hi",
"1 << 30",
"1",
"30",
"while(lo < hi)\n {\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }",
"lo < hi",
"lo",
"hi",
"{\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }",
"int m = (lo + hi) / 2;",
"m",
"(lo + hi) / 2",
"(lo + hi)",
"lo",
"hi",
"2",
"int cut = numCut(ary, m);",
"cut",
"numCut(ary, m)",
"numCut",
"ary",
"m",
"if(cut > k) lo = m + 1;\n else hi = m;",
"cut > k",
"cut",
"k",
"lo = m + 1",
"lo",
"m + 1",
"m",
"1",
"hi = m",
"hi",
"m",
"out.println(lo)",
"out.println",
"out",
"lo",
"int numCut(int[] ary, int thres)\n {\n int count = 0;\n for(int v : ary)\n {\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }\n return count;\n }",
"numCut",
"{\n int count = 0;\n for(int v : ary)\n {\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }\n return count;\n }",
"int count = 0;",
"count",
"0",
"for(int v : ary)\n {\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }",
"int v",
"ary",
"{\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }",
"{\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }",
"if(v > thres)\n count += v / thres;",
"v > thres",
"v",
"thres",
"count += v / thres",
"count",
"v / thres",
"v",
"thres",
"return count;",
"count",
"int[] ary",
"ary",
"int thres",
"thres",
"void d() throws Exception\n {\n int n = readInt();\n char[] c = in.readLine().toCharArray();\n int i = 0, j = n - 1, re = 0;\n while(i < j)\n {\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }\n out.println(re);\n }",
"d",
"{\n int n = readInt();\n char[] c = in.readLine().toCharArray();\n int i = 0, j = n - 1, re = 0;\n while(i < j)\n {\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }\n out.println(re);\n }",
"int n = readInt();",
"n",
"readInt()",
"readInt",
"char[] c = in.readLine().toCharArray();",
"c",
"in.readLine().toCharArray()",
"in.readLine().toCharArray",
"in.readLine()",
"in.readLine",
"in",
"int i = 0",
"i",
"0",
"j = n - 1",
"j",
"n - 1",
"n",
"1",
"re = 0;",
"re",
"0",
"while(i < j)\n {\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }",
"i < j",
"i",
"j",
"{\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }",
"while(i < j && c[i] == 'R') i++;",
"i < j && c[i] == 'R'",
"i < j",
"i",
"j",
"c[i] == 'R'",
"c[i]",
"c",
"i",
"'R'",
"i++",
"i",
"while(i < j && c[j] == 'W') j--;",
"i < j && c[j] == 'W'",
"i < j",
"i",
"j",
"c[j] == 'W'",
"c[j]",
"c",
"j",
"'W'",
"j--",
"j",
"if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }",
"i < j",
"i",
"j",
"{\n swap(c, i, j);\n i++;\n j--;\n re++;\n }",
"swap(c, i, j)",
"swap",
"c",
"i",
"j",
"i++",
"i",
"j--",
"j",
"re++",
"re",
"out.println(re)",
"out.println",
"out",
"re",
"void c() throws Exception\n {\n int n = readInt();\n int[] ary = toIntArray();\n long sum = 0;\n int mini = 0;\n for(int i = 0; i < n; i++)\n {\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }\n out.println(sum);\n \n }",
"c",
"{\n int n = readInt();\n int[] ary = toIntArray();\n long sum = 0;\n int mini = 0;\n for(int i = 0; i < n; i++)\n {\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }\n out.println(sum);\n \n }",
"int n = readInt();",
"n",
"readInt()",
"readInt",
"int[] ary = toIntArray();",
"ary",
"toIntArray()",
"toIntArray",
"long sum = 0;",
"sum",
"0",
"int mini = 0;",
"mini",
"0",
"for(int i = 0; i < n; i++)\n {\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }",
"{\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }",
"if(ary[i] < mini) sum += mini - ary[i];",
"ary[i] < mini",
"ary[i]",
"ary",
"i",
"mini",
"sum += mini - ary[i]",
"sum",
"mini - ary[i]",
"mini",
"ary[i]",
"ary",
"i",
"mini = Math.max(ary[i], mini)",
"mini",
"Math.max(ary[i], mini)",
"Math.max",
"Math",
"ary[i]",
"ary",
"i",
"mini",
"out.println(sum)",
"out.println",
"out",
"sum",
"int gcd(int a, int b)\n {\n if(b == 0) return a;\n return gcd(b, a % b);\n }",
"gcd",
"{\n if(b == 0) return a;\n return gcd(b, a % b);\n }",
"if(b == 0) return a;",
"b == 0",
"b",
"0",
"return a;",
"a",
"return gcd(b, a % b);",
"gcd(b, a % b)",
"gcd",
"b",
"a % b",
"a",
"b",
"int a",
"a",
"int b",
"b",
"void b() throws Exception\n {\n String str = in.readLine();\n int sum = 0;\n for(char c : str.toCharArray())\n {\n int val = c - '0';\n sum += val;\n sum %= 9;\n }\n if(sum == 0) out.println(\"Yes\");\n else out.println(\"No\");\n \n }",
"b",
"{\n String str = in.readLine();\n int sum = 0;\n for(char c : str.toCharArray())\n {\n int val = c - '0';\n sum += val;\n sum %= 9;\n }\n if(sum == 0) out.println(\"Yes\");\n else out.println(\"No\");\n \n }",
"String str = in.readLine();",
"str",
"in.readLine()",
"in.readLine",
"in",
"int sum = 0;",
"sum",
"0",
"for(char c : str.toCharArray())\n {\n int val = c - '0';\n sum += val;\n sum %= 9;\n }",
"char c",
"str.toCharArray()",
"str.toCharArray",
"str",
"{\n int val = c - '0';\n sum += val;\n sum %= 9;\n }",
"{\n int val = c - '0';\n sum += val;\n sum %= 9;\n }",
"int val = c - '0';",
"val",
"c - '0'",
"c",
"'0'",
"sum += val",
"sum",
"val",
"sum %= 9",
"sum",
"9",
"if(sum == 0) out.println(\"Yes\");\n else out.println(\"No\");",
"sum == 0",
"sum",
"0",
"out.println(\"Yes\")",
"out.println",
"out",
"\"Yes\"",
"out.println(\"No\")",
"out.println",
"out",
"\"No\"",
"boolean transform(String s1, String s2)\n {\n // from s1 -> s2\n int m = s1.length(), n = s2.length();\n if(m < n) return false;\n int j = n - 1;\n for(int i = m - 1; i >=0; i--)\n {\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }\n return false;\n }",
"transform",
"{\n // from s1 -> s2\n int m = s1.length(), n = s2.length();\n if(m < n) return false;\n int j = n - 1;\n for(int i = m - 1; i >=0; i--)\n {\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }\n return false;\n }",
"int m = s1.length()",
"m",
"s1.length()",
"s1.length",
"s1",
"n = s2.length();",
"n",
"s2.length()",
"s2.length",
"s2",
"if(m < n) return false;",
"m < n",
"m",
"n",
"return false;",
"false",
"int j = n - 1;",
"j",
"n - 1",
"n",
"1",
"for(int i = m - 1; i >=0; i--)\n {\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }",
"int i = m - 1;",
"int i = m - 1;",
"i",
"m - 1",
"m",
"1",
"i >=0",
"i",
"0",
"i--",
"i--",
"i",
"{\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }",
"{\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }",
"if(s1.charAt(i) == s2.charAt(j)) j--;",
"s1.charAt(i) == s2.charAt(j)",
"s1.charAt(i)",
"s1.charAt",
"s1",
"i",
"s2.charAt(j)",
"s2.charAt",
"s2",
"j",
"j--",
"j",
"if(j < 0) return true;",
"j < 0",
"j",
"0",
"return true;",
"true",
"return false;",
"false",
"String s1",
"s1",
"String s2",
"s2",
"void a() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], x = ary[1], t = ary[2];\n int mult = n / x;\n if(n % x != 0) mult++;\n out.println(mult * t);\n \n }",
"a",
"{\n int[] ary = toIntArray();\n int n = ary[0], x = ary[1], t = ary[2];\n int mult = n / x;\n if(n % x != 0) mult++;\n out.println(mult * t);\n \n }",
"int[] ary = toIntArray();",
"ary",
"toIntArray()",
"toIntArray",
"int n = ary[0]",
"n",
"ary[0]",
"ary",
"0",
"x = ary[1]",
"x",
"ary[1]",
"ary",
"1",
"t = ary[2];",
"t",
"ary[2]",
"ary",
"2",
"int mult = n / x;",
"mult",
"n / x",
"n",
"x",
"if(n % x != 0) mult++;",
"n % x != 0",
"n % x",
"n",
"x",
"0",
"mult++",
"mult",
"out.println(mult * t)",
"out.println",
"out",
"mult * t",
"mult",
"t",
"public class Main { \n \n static BufferedReader in;\n static PrintWriter out = new PrintWriter(System.out);\n static String file = \"../in\";\n static int test = 10; // 0 for local testing, 1 for std input\n static int inf = 1_000_000, mod = 1_000_000_007;\n\n\n\n void swap(int[]ary, int i, int j)\n {\n int t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n\n void swap(char[]ary, int i, int j)\n {\n char t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n \n String[] split() throws Exception\n {\n return in.readLine().split(\" \");\n }\n\n int readInt() throws Exception\n {\n return Integer.valueOf(in.readLine());\n }\n\n long readLong() throws Exception\n {\n return Long.valueOf(in.readLine());\n }\n\n long[] toLongArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n long[] ary = new long[n];\n for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);\n return ary;\n }\n\n int[] toIntArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);\n return ary;\n }\n\n String reverse(String str)\n {\n return new StringBuilder(str).reverse().toString();\n }\n\n\n long pow(long a, int pow)\n {\n long res = 1;\n while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }\n\n public static void main(String[] args) throws Exception\n {\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n // char[] c = new char[4];\n // c[1] = '.';\n // for(char i = '0'; i <= '9'; i++)\n // {\n // for(char j = '0'; j <= '9'; j++)\n // {\n // for(char k = '0'; k <= '9'; k++)\n // {\n // c[0] = i;\n // c[2] = j;\n // c[3] = k;\n // double d = Double.valueOf(String.valueOf(c));\n // int v = (int)(d * 100);\n // String s1 = String.valueOf(\"\" + c[0] + c[2] + c[3]),\n // s2 = String.valueOf(v);\n // System.out.printf(\"%s %s %b\\n\", s1, s2, s1.equals(s2));\n // }\n // }\n // }\n\n\n new Main().c();\n out.flush();\n }\n void f() throws Exception\n {\n int k = readInt();\n String s = in.readLine();\n int n = s.length();\n long prod = 1;\n int mod = 1_000_000_007;\n for(int i = 0; i < k; i++)\n {\n n++;\n prod = (prod * 26 * n) % mod;\n }\n System.out.println(prod);\n\n }\n\n void e() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], k = ary[1];\n ary = toIntArray();\n int lo = 1, hi = 1 << 30;\n while(lo < hi)\n {\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }\n out.println(lo);\n }\n\n int numCut(int[] ary, int thres)\n {\n int count = 0;\n for(int v : ary)\n {\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }\n return count;\n }\n\n void d() throws Exception\n {\n int n = readInt();\n char[] c = in.readLine().toCharArray();\n int i = 0, j = n - 1, re = 0;\n while(i < j)\n {\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }\n out.println(re);\n }\n\n\n\n void c() throws Exception\n {\n int n = readInt();\n int[] ary = toIntArray();\n long sum = 0;\n int mini = 0;\n for(int i = 0; i < n; i++)\n {\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }\n out.println(sum);\n \n }\n\n int gcd(int a, int b)\n {\n if(b == 0) return a;\n return gcd(b, a % b);\n }\n\n void b() throws Exception\n {\n String str = in.readLine();\n int sum = 0;\n for(char c : str.toCharArray())\n {\n int val = c - '0';\n sum += val;\n sum %= 9;\n }\n if(sum == 0) out.println(\"Yes\");\n else out.println(\"No\");\n \n }\n\n boolean transform(String s1, String s2)\n {\n // from s1 -> s2\n int m = s1.length(), n = s2.length();\n if(m < n) return false;\n int j = n - 1;\n for(int i = m - 1; i >=0; i--)\n {\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }\n return false;\n }\n\n void a() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], x = ary[1], t = ary[2];\n int mult = n / x;\n if(n % x != 0) mult++;\n out.println(mult * t);\n \n }\n}",
"public class Main { \n \n static BufferedReader in;\n static PrintWriter out = new PrintWriter(System.out);\n static String file = \"../in\";\n static int test = 10; // 0 for local testing, 1 for std input\n static int inf = 1_000_000, mod = 1_000_000_007;\n\n\n\n void swap(int[]ary, int i, int j)\n {\n int t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n\n void swap(char[]ary, int i, int j)\n {\n char t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n \n String[] split() throws Exception\n {\n return in.readLine().split(\" \");\n }\n\n int readInt() throws Exception\n {\n return Integer.valueOf(in.readLine());\n }\n\n long readLong() throws Exception\n {\n return Long.valueOf(in.readLine());\n }\n\n long[] toLongArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n long[] ary = new long[n];\n for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);\n return ary;\n }\n\n int[] toIntArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);\n return ary;\n }\n\n String reverse(String str)\n {\n return new StringBuilder(str).reverse().toString();\n }\n\n\n long pow(long a, int pow)\n {\n long res = 1;\n while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }\n\n public static void main(String[] args) throws Exception\n {\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n // char[] c = new char[4];\n // c[1] = '.';\n // for(char i = '0'; i <= '9'; i++)\n // {\n // for(char j = '0'; j <= '9'; j++)\n // {\n // for(char k = '0'; k <= '9'; k++)\n // {\n // c[0] = i;\n // c[2] = j;\n // c[3] = k;\n // double d = Double.valueOf(String.valueOf(c));\n // int v = (int)(d * 100);\n // String s1 = String.valueOf(\"\" + c[0] + c[2] + c[3]),\n // s2 = String.valueOf(v);\n // System.out.printf(\"%s %s %b\\n\", s1, s2, s1.equals(s2));\n // }\n // }\n // }\n\n\n new Main().c();\n out.flush();\n }\n void f() throws Exception\n {\n int k = readInt();\n String s = in.readLine();\n int n = s.length();\n long prod = 1;\n int mod = 1_000_000_007;\n for(int i = 0; i < k; i++)\n {\n n++;\n prod = (prod * 26 * n) % mod;\n }\n System.out.println(prod);\n\n }\n\n void e() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], k = ary[1];\n ary = toIntArray();\n int lo = 1, hi = 1 << 30;\n while(lo < hi)\n {\n int m = (lo + hi) / 2;\n int cut = numCut(ary, m);\n // System.out.printf(\"%d %d\\n\", m, cut);\n if(cut > k) lo = m + 1;\n else hi = m;\n }\n out.println(lo);\n }\n\n int numCut(int[] ary, int thres)\n {\n int count = 0;\n for(int v : ary)\n {\n if(v > thres)\n count += v / thres;\n // count += v % thres > 0 ? 1 : 0;\n }\n return count;\n }\n\n void d() throws Exception\n {\n int n = readInt();\n char[] c = in.readLine().toCharArray();\n int i = 0, j = n - 1, re = 0;\n while(i < j)\n {\n while(i < j && c[i] == 'R') i++;\n while(i < j && c[j] == 'W') j--;\n if(i < j)\n {\n swap(c, i, j);\n i++;\n j--;\n re++;\n }\n }\n out.println(re);\n }\n\n\n\n void c() throws Exception\n {\n int n = readInt();\n int[] ary = toIntArray();\n long sum = 0;\n int mini = 0;\n for(int i = 0; i < n; i++)\n {\n if(ary[i] < mini) sum += mini - ary[i];\n mini = Math.max(ary[i], mini);\n }\n out.println(sum);\n \n }\n\n int gcd(int a, int b)\n {\n if(b == 0) return a;\n return gcd(b, a % b);\n }\n\n void b() throws Exception\n {\n String str = in.readLine();\n int sum = 0;\n for(char c : str.toCharArray())\n {\n int val = c - '0';\n sum += val;\n sum %= 9;\n }\n if(sum == 0) out.println(\"Yes\");\n else out.println(\"No\");\n \n }\n\n boolean transform(String s1, String s2)\n {\n // from s1 -> s2\n int m = s1.length(), n = s2.length();\n if(m < n) return false;\n int j = n - 1;\n for(int i = m - 1; i >=0; i--)\n {\n if(s1.charAt(i) == s2.charAt(j)) j--;\n if(j < 0) return true;\n }\n return false;\n }\n\n void a() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], x = ary[1], t = ary[2];\n int mult = n / x;\n if(n % x != 0) mult++;\n out.println(mult * t);\n \n }\n}",
"Main"
]
| import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader in;
static PrintWriter out = new PrintWriter(System.out);
static String file = "../in";
static int test = 10; // 0 for local testing, 1 for std input
static int inf = 1_000_000, mod = 1_000_000_007;
void swap(int[]ary, int i, int j)
{
int t = ary[i];
ary[i] = ary[j];
ary[j] = t;
}
void swap(char[]ary, int i, int j)
{
char t = ary[i];
ary[i] = ary[j];
ary[j] = t;
}
String[] split() throws Exception
{
return in.readLine().split(" ");
}
int readInt() throws Exception
{
return Integer.valueOf(in.readLine());
}
long readLong() throws Exception
{
return Long.valueOf(in.readLine());
}
long[] toLongArray() throws Exception
{
String[] sp = split();
int n = sp.length;
long[] ary = new long[n];
for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);
return ary;
}
int[] toIntArray() throws Exception
{
String[] sp = split();
int n = sp.length;
int[] ary = new int[n];
for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
return ary;
}
String reverse(String str)
{
return new StringBuilder(str).reverse().toString();
}
long pow(long a, int pow)
{
long res = 1;
while(pow > 0)
{
if(pow % 2 != 0) {
res *= a;
res %= mod;
}
a = a * a;
a %= mod;
pow /= 2;
}
return res;
}
public static void main(String[] args) throws Exception
{
int _k = Integer.valueOf("1");
if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
else in = new BufferedReader(new FileReader(file));
if(test < 0) {String[] str = in.readLine().split(" ");
char[] gg = in.readLine().toCharArray();}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
// System.out.println((-100 + 0) / 2);
// char[] c = new char[4];
// c[1] = '.';
// for(char i = '0'; i <= '9'; i++)
// {
// for(char j = '0'; j <= '9'; j++)
// {
// for(char k = '0'; k <= '9'; k++)
// {
// c[0] = i;
// c[2] = j;
// c[3] = k;
// double d = Double.valueOf(String.valueOf(c));
// int v = (int)(d * 100);
// String s1 = String.valueOf("" + c[0] + c[2] + c[3]),
// s2 = String.valueOf(v);
// System.out.printf("%s %s %b\n", s1, s2, s1.equals(s2));
// }
// }
// }
new Main().c();
out.flush();
}
void f() throws Exception
{
int k = readInt();
String s = in.readLine();
int n = s.length();
long prod = 1;
int mod = 1_000_000_007;
for(int i = 0; i < k; i++)
{
n++;
prod = (prod * 26 * n) % mod;
}
System.out.println(prod);
}
void e() throws Exception
{
int[] ary = toIntArray();
int n = ary[0], k = ary[1];
ary = toIntArray();
int lo = 1, hi = 1 << 30;
while(lo < hi)
{
int m = (lo + hi) / 2;
int cut = numCut(ary, m);
// System.out.printf("%d %d\n", m, cut);
if(cut > k) lo = m + 1;
else hi = m;
}
out.println(lo);
}
int numCut(int[] ary, int thres)
{
int count = 0;
for(int v : ary)
{
if(v > thres)
count += v / thres;
// count += v % thres > 0 ? 1 : 0;
}
return count;
}
void d() throws Exception
{
int n = readInt();
char[] c = in.readLine().toCharArray();
int i = 0, j = n - 1, re = 0;
while(i < j)
{
while(i < j && c[i] == 'R') i++;
while(i < j && c[j] == 'W') j--;
if(i < j)
{
swap(c, i, j);
i++;
j--;
re++;
}
}
out.println(re);
}
void c() throws Exception
{
int n = readInt();
int[] ary = toIntArray();
long sum = 0;
int mini = 0;
for(int i = 0; i < n; i++)
{
if(ary[i] < mini) sum += mini - ary[i];
mini = Math.max(ary[i], mini);
}
out.println(sum);
}
int gcd(int a, int b)
{
if(b == 0) return a;
return gcd(b, a % b);
}
void b() throws Exception
{
String str = in.readLine();
int sum = 0;
for(char c : str.toCharArray())
{
int val = c - '0';
sum += val;
sum %= 9;
}
if(sum == 0) out.println("Yes");
else out.println("No");
}
boolean transform(String s1, String s2)
{
// from s1 -> s2
int m = s1.length(), n = s2.length();
if(m < n) return false;
int j = n - 1;
for(int i = m - 1; i >=0; i--)
{
if(s1.charAt(i) == s2.charAt(j)) j--;
if(j < 0) return true;
}
return false;
}
void a() throws Exception
{
int[] ary = toIntArray();
int n = ary[0], x = ary[1], t = ary[2];
int mult = n / x;
if(n % x != 0) mult++;
out.println(mult * t);
}
} |
[
7,
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,
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,
30,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
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
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
200,
17
],
[
200,
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,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
36,
41
],
[
41,
42
],
[
41,
43
],
[
36,
44
],
[
44,
45
],
[
45,
46
],
[
36,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
20,
55
],
[
55,
56
],
[
55,
57
],
[
20,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
58,
63
],
[
63,
64
],
[
63,
65
],
[
58,
66
],
[
66,
67
],
[
67,
68
],
[
58,
69
],
[
70,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
72,
78
],
[
78,
79
],
[
78,
80
],
[
71,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
84,
90
],
[
90,
91
],
[
90,
92
],
[
81,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
20,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
20,
106
],
[
106,
107
],
[
107,
108
],
[
18,
109
],
[
109,
110
],
[
200,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
111,
115
],
[
115,
116
],
[
111,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
111,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
126,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
136,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
125,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
111,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
155,
158
],
[
158,
159
],
[
111,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
164,
167
],
[
167,
168
],
[
111,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
173,
176
],
[
176,
177
],
[
111,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
184,
191
],
[
191,
192
],
[
192,
193
],
[
192,
194
],
[
194,
195
],
[
195,
196
],
[
180,
197
],
[
197,
198
],
[
0,
199
],
[
199,
200
],
[
199,
201
]
]
| [
"\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\tpublic static void main(String args[]) throws Exception {\n\n\t\tMyScanner sc = new MyScanner();\n\t\tPrintWriter pr = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tar[i] = sc.nextInt();\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.print(ans);\n\t\tpr.close();\n\t}\n\n\tpublic static class MyScanner {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic MyScanner() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\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",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"public class Main {\n\n\tpublic static void main(String args[]) throws Exception {\n\n\t\tMyScanner sc = new MyScanner();\n\t\tPrintWriter pr = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tar[i] = sc.nextInt();\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.print(ans);\n\t\tpr.close();\n\t}\n\n\tpublic static class MyScanner {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic MyScanner() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n}",
"Main",
"public static void main(String args[]) throws Exception {\n\n\t\tMyScanner sc = new MyScanner();\n\t\tPrintWriter pr = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tar[i] = sc.nextInt();\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.print(ans);\n\t\tpr.close();\n\t}",
"main",
"{\n\n\t\tMyScanner sc = new MyScanner();\n\t\tPrintWriter pr = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tar[i] = sc.nextInt();\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.print(ans);\n\t\tpr.close();\n\t}",
"MyScanner sc = new MyScanner();",
"sc",
"new MyScanner()",
"PrintWriter pr = new PrintWriter(System.out);",
"pr",
"new PrintWriter(System.out)",
"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();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"ar[i] = sc.nextInt();",
"ar[i] = sc.nextInt()",
"ar[i]",
"ar",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long ans = 0;",
"ans",
"0",
"for(int i = 1; i < n; i++) {\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\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\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}",
"{\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}",
"if(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}",
"ar[i - 1] > ar[i]",
"ar[i - 1]",
"ar",
"i - 1",
"i",
"1",
"ar[i]",
"ar",
"i",
"{\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}",
"ans += ar[i - 1] - ar[i]",
"ans",
"ar[i - 1] - ar[i]",
"ar[i - 1]",
"ar",
"i - 1",
"i",
"1",
"ar[i]",
"ar",
"i",
"ar[i] = ar[i - 1]",
"ar[i]",
"ar",
"i",
"ar[i - 1]",
"ar",
"i - 1",
"i",
"1",
"pr.print(ans)",
"pr.print",
"pr",
"ans",
"pr.close()",
"pr.close",
"pr",
"String args[]",
"args",
"public static class MyScanner {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic MyScanner() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}",
"MyScanner",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public MyScanner() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}",
"MyScanner",
"{\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"next",
"{\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"while (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}",
"try {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"IOException e",
"{\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"nextInt",
"{\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"long nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"nextLong",
"{\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"nextDouble",
"{\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}",
"nextLine",
"{\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}",
"String str = \"\";",
"str",
"\"\"",
"try {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"IOException e",
"{\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\tstr = br.readLine();\n\t\t\t}",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main {\n\n\tpublic static void main(String args[]) throws Exception {\n\n\t\tMyScanner sc = new MyScanner();\n\t\tPrintWriter pr = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tar[i] = sc.nextInt();\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.print(ans);\n\t\tpr.close();\n\t}\n\n\tpublic static class MyScanner {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic MyScanner() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String args[]) throws Exception {\n\n\t\tMyScanner sc = new MyScanner();\n\t\tPrintWriter pr = new PrintWriter(System.out);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] ar = new int[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tar[i] = sc.nextInt();\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\n\t\t\tif(ar[i - 1] > ar[i]) {\n\t\t\t\t\n\t\t\t\tans += ar[i - 1] - ar[i];\n\t\t\t\tar[i] = ar[i - 1];\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.print(ans);\n\t\tpr.close();\n\t}\n\n\tpublic static class MyScanner {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic MyScanner() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n}",
"Main"
]
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String args[]) throws Exception {
MyScanner sc = new MyScanner();
PrintWriter pr = new PrintWriter(System.out);
int n = sc.nextInt();
int[] ar = new int[n];
for(int i = 0; i < n; i++)
ar[i] = sc.nextInt();
long ans = 0;
for(int i = 1; i < n; i++) {
if(ar[i - 1] > ar[i]) {
ans += ar[i - 1] - ar[i];
ar[i] = ar[i - 1];
}
}
pr.print(ans);
pr.close();
}
public static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
0,
18,
13,
17,
4,
18,
13,
41,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
4,
18,
13,
17,
2,
13,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
42,
40,
4,
18,
13,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
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
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
11,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
27,
31
],
[
31,
32
],
[
32,
33
],
[
11,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
36,
38
],
[
11,
39
],
[
39,
40
],
[
39,
41
],
[
11,
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
],
[
54,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
64,
68
],
[
68,
69
],
[
68,
70
],
[
54,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
73,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
11,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
11,
86
],
[
86,
87
],
[
87,
88
],
[
9,
89
],
[
89,
90
],
[
7,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
91,
96
],
[
96,
97
],
[
96,
98
],
[
91,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
102,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
107,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
101,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
91,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
129,
130
],
[
91,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
138,
139
],
[
91,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
152,
153
],
[
152,
154
],
[
147,
155
],
[
155,
156
],
[
156,
157
],
[
147,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
163,
164
],
[
142,
165
],
[
165,
166
],
[
140,
167
],
[
167,
168
],
[
91,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
171,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
176,
181
],
[
181,
182
],
[
181,
183
],
[
176,
184
],
[
184,
185
],
[
185,
186
],
[
176,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
188,
192
],
[
192,
193
],
[
171,
194
],
[
194,
195
],
[
169,
196
],
[
196,
197
],
[
169,
198
],
[
198,
199
]
]
| [
"import java.io.*;\nimport java.util.*;\n\nclass Main{\n\n\tpublic static void main(String[] args) {\n FastScanner in = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n int n = in.nextInt();\n int a[] = new int[n];\n a[0] = in.nextInt();\n int prev = a[0];\n long ans = 0;\n for(int i=1;i<n;i++)\n {\n \ta[i] = in.nextInt();\n \tprev = Math.max(prev, a[i]);\n \tans += Math.max(0, prev-a[i]);\n }\n out.println(ans);\n out.flush();\n\t}\n\t\n\tstatic class FastScanner {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st = new StringTokenizer(\"\");\n\t\t\n\t\tString next() {\n\t\t\twhile(!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\t\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t\t\n\t\tint[] readArray(int n) {\n\t\t\tint a[] = new int[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t\t\n\t\tlong[] readArray(int n,long x) {\n\t\t\tlong a[] = new long[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\t\t\n\t}\n}\n\n\n\n\n\n\n\n\n",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"class Main{\n\n\tpublic static void main(String[] args) {\n FastScanner in = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n int n = in.nextInt();\n int a[] = new int[n];\n a[0] = in.nextInt();\n int prev = a[0];\n long ans = 0;\n for(int i=1;i<n;i++)\n {\n \ta[i] = in.nextInt();\n \tprev = Math.max(prev, a[i]);\n \tans += Math.max(0, prev-a[i]);\n }\n out.println(ans);\n out.flush();\n\t}\n\t\n\tstatic class FastScanner {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st = new StringTokenizer(\"\");\n\t\t\n\t\tString next() {\n\t\t\twhile(!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\t\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t\t\n\t\tint[] readArray(int n) {\n\t\t\tint a[] = new int[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t\t\n\t\tlong[] readArray(int n,long x) {\n\t\t\tlong a[] = new long[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\t\t\n\t}\n}",
"Main",
"public static void main(String[] args) {\n FastScanner in = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n int n = in.nextInt();\n int a[] = new int[n];\n a[0] = in.nextInt();\n int prev = a[0];\n long ans = 0;\n for(int i=1;i<n;i++)\n {\n \ta[i] = in.nextInt();\n \tprev = Math.max(prev, a[i]);\n \tans += Math.max(0, prev-a[i]);\n }\n out.println(ans);\n out.flush();\n\t}",
"main",
"{\n FastScanner in = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n int n = in.nextInt();\n int a[] = new int[n];\n a[0] = in.nextInt();\n int prev = a[0];\n long ans = 0;\n for(int i=1;i<n;i++)\n {\n \ta[i] = in.nextInt();\n \tprev = Math.max(prev, a[i]);\n \tans += Math.max(0, prev-a[i]);\n }\n out.println(ans);\n out.flush();\n\t}",
"FastScanner in = new FastScanner();",
"in",
"new FastScanner()",
"PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int a[] = new int[n];",
"a",
"new int[n]",
"n",
"a[0] = in.nextInt()",
"a[0]",
"a",
"0",
"in.nextInt()",
"in.nextInt",
"in",
"int prev = a[0];",
"prev",
"a[0]",
"a",
"0",
"long ans = 0;",
"ans",
"0",
"for(int i=1;i<n;i++)\n {\n \ta[i] = in.nextInt();\n \tprev = Math.max(prev, a[i]);\n \tans += Math.max(0, prev-a[i]);\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \ta[i] = in.nextInt();\n \tprev = Math.max(prev, a[i]);\n \tans += Math.max(0, prev-a[i]);\n }",
"{\n \ta[i] = in.nextInt();\n \tprev = Math.max(prev, a[i]);\n \tans += Math.max(0, prev-a[i]);\n }",
"a[i] = in.nextInt()",
"a[i]",
"a",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"prev = Math.max(prev, a[i])",
"prev",
"Math.max(prev, a[i])",
"Math.max",
"Math",
"prev",
"a[i]",
"a",
"i",
"ans += Math.max(0, prev-a[i])",
"ans",
"Math.max(0, prev-a[i])",
"Math.max",
"Math",
"0",
"prev-a[i]",
"prev",
"a[i]",
"a",
"i",
"out.println(ans)",
"out.println",
"out",
"ans",
"out.flush()",
"out.flush",
"out",
"String[] args",
"args",
"static class FastScanner {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st = new StringTokenizer(\"\");\n\t\t\n\t\tString next() {\n\t\t\twhile(!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\t\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t\t\n\t\tint[] readArray(int n) {\n\t\t\tint a[] = new int[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t\t\n\t\tlong[] readArray(int n,long x) {\n\t\t\tlong a[] = new long[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\t\t\n\t}",
"FastScanner",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"StringTokenizer st = new StringTokenizer(\"\");",
"st",
"new StringTokenizer(\"\")",
"String next() {\n\t\t\twhile(!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"next",
"{\n\t\t\twhile(!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"while(!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"try {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"IOException e",
"{\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"nextInt",
"{\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"long nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"nextLong",
"{\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"int[] readArray(int n) {\n\t\t\tint a[] = new int[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextInt();\n\t\t\treturn a;\n\t\t}",
"readArray",
"{\n\t\t\tint a[] = new int[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextInt();\n\t\t\treturn a;\n\t\t}",
"int a[] = new int[n];",
"a",
"new int[n]",
"n",
"for(int i=0;i<n;i++) a[i] = nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = nextInt();",
"a[i] = nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int n",
"n",
"long[] readArray(int n,long x) {\n\t\t\tlong a[] = new long[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextLong();\n\t\t\treturn a;\n\t\t}",
"readArray",
"{\n\t\t\tlong a[] = new long[n];\n\t\t\tfor(int i=0;i<n;i++) a[i] = nextLong();\n\t\t\treturn a;\n\t\t}",
"long a[] = new long[n];",
"a",
"new long[n]",
"n",
"for(int i=0;i<n;i++) a[i] = nextLong();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = nextLong();",
"a[i] = nextLong()",
"a[i]",
"a",
"i",
"nextLong()",
"nextLong",
"return a;",
"a",
"int n",
"n",
"long x",
"x"
]
| import java.io.*;
import java.util.*;
class Main{
public static void main(String[] args) {
FastScanner in = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int a[] = new int[n];
a[0] = in.nextInt();
int prev = a[0];
long ans = 0;
for(int i=1;i<n;i++)
{
a[i] = in.nextInt();
prev = Math.max(prev, a[i]);
ans += Math.max(0, prev-a[i]);
}
out.println(ans);
out.flush();
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while(!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
}catch(IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
int[] readArray(int n) {
int a[] = new int[n];
for(int i=0;i<n;i++) a[i] = nextInt();
return a;
}
long[] readArray(int n,long x) {
long a[] = new long[n];
for(int i=0;i<n;i++) a[i] = nextLong();
return a;
}
}
}
|
[
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,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
2,
13,
18,
13,
13,
17,
0,
13,
4,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
2,
17,
17,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
0,
13,
20,
13,
0,
13,
0,
13,
17,
12,
13,
30,
0,
13,
20,
0,
13,
20,
13,
0,
13,
0,
13,
17,
23,
13,
12,
13,
30,
41,
13,
20,
17,
41,
13,
17,
41,
13,
42,
2,
0,
13,
4,
13,
40,
17,
30,
14,
2,
13,
17,
3,
0,
18,
13,
40,
13,
13,
29,
20,
12,
13,
30,
41,
13,
4,
13,
42,
4,
18,
13,
13,
30,
0,
13,
4,
13,
41,
13,
20,
4,
18,
13,
13,
0,
13,
4,
13,
42,
40,
4,
18,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
41,
13,
17,
41,
13,
4,
13,
42,
2,
13,
17,
0,
13,
4,
13,
41,
13,
2,
13,
17,
14,
13,
0,
13,
4,
13,
42,
2,
2,
0,
13,
4,
13,
17,
2,
13,
17,
30,
0,
13,
2,
2,
2,
13,
17,
13,
17,
14,
13,
29,
40,
13,
29,
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,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
4,
13,
42,
2,
13,
17,
0,
13,
4,
13,
41,
13,
2,
13,
17,
14,
13,
0,
13,
4,
13,
42,
2,
2,
0,
13,
4,
13,
17,
2,
13,
17,
30,
0,
13,
2,
2,
2,
13,
17,
13,
17,
14,
13,
29,
40,
13,
29,
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,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
4,
13,
42,
4,
18,
13,
13,
30,
0,
13,
4,
13,
29,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
41,
13,
4,
13,
42,
2,
13,
17,
0,
13,
4,
13,
41,
13,
2,
13,
17,
14,
13,
0,
13,
4,
13,
42,
2,
2,
0,
13,
4,
13,
17,
2,
13,
17,
30,
0,
13,
2,
2,
2,
13,
17,
13,
17,
14,
2,
13,
17,
30,
42,
2,
2,
0,
13,
4,
13,
17,
2,
13,
17,
30,
0,
13,
2,
2,
13,
17,
0,
13,
17,
14,
13,
29,
40,
13,
29,
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,
13,
29,
13,
23,
13,
12,
13,
30,
0,
13,
4,
18,
13,
13,
0,
13,
17,
13,
14,
2,
13,
40,
17,
0,
18,
13,
17,
40,
17,
12,
13,
30,
14,
2,
13,
13,
4,
13,
29,
18,
13,
40,
13,
12,
13,
30,
14,
2,
13,
17,
29,
4,
18,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
562,
8
],
[
562,
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
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
11,
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
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
46,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
60,
64
],
[
64,
65
],
[
64,
66
],
[
11,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
9,
73
],
[
73,
74
],
[
0,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
75,
82
],
[
82,
83
],
[
75,
84
],
[
84,
85
],
[
75,
86
],
[
86,
87
],
[
75,
88
],
[
88,
89
],
[
75,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
96,
98
],
[
92,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
75,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
111,
113
],
[
107,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
105,
120
],
[
120,
121
],
[
75,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
129
],
[
129,
130
],
[
129,
131
],
[
124,
132
],
[
132,
133
],
[
124,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
135,
140
],
[
140,
141
],
[
134,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
142,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
148,
153
],
[
124,
154
],
[
154,
155
],
[
75,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
158,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
164,
167
],
[
163,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
158,
173
],
[
173,
174
],
[
173,
175
],
[
158,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
158,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
158,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
186,
189
],
[
184,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
191,
194
],
[
190,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
158,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
75,
203
],
[
203,
204
],
[
203,
205
],
[
205,
206
],
[
206,
207
],
[
206,
208
],
[
205,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
205,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
213,
217
],
[
217,
218
],
[
217,
219
],
[
219,
220
],
[
205,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
223,
225
],
[
205,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
228,
230
],
[
230,
231
],
[
205,
232
],
[
232,
233
],
[
233,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
234,
239
],
[
233,
240
],
[
240,
241
],
[
240,
242
],
[
232,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
246,
247
],
[
247,
248
],
[
248,
249
],
[
248,
250
],
[
247,
251
],
[
246,
252
],
[
205,
253
],
[
253,
254
],
[
253,
255
],
[
255,
256
],
[
256,
257
],
[
205,
258
],
[
258,
259
],
[
75,
260
],
[
260,
261
],
[
260,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
262,
267
],
[
267,
268
],
[
268,
269
],
[
269,
270
],
[
269,
271
],
[
267,
272
],
[
272,
273
],
[
272,
274
],
[
267,
275
],
[
275,
276
],
[
276,
277
],
[
267,
278
],
[
279,
279
],
[
279,
280
],
[
280,
281
],
[
281,
282
],
[
281,
283
],
[
280,
284
],
[
284,
285
],
[
262,
286
],
[
286,
287
],
[
260,
288
],
[
288,
289
],
[
75,
290
],
[
290,
291
],
[
290,
292
],
[
292,
293
],
[
293,
294
],
[
293,
295
],
[
292,
296
],
[
296,
297
],
[
296,
298
],
[
298,
299
],
[
292,
300
],
[
300,
301
],
[
301,
302
],
[
301,
303
],
[
300,
304
],
[
304,
305
],
[
304,
306
],
[
306,
307
],
[
292,
308
],
[
308,
309
],
[
308,
310
],
[
310,
311
],
[
310,
312
],
[
292,
313
],
[
313,
314
],
[
313,
315
],
[
315,
316
],
[
315,
317
],
[
317,
318
],
[
292,
319
],
[
319,
320
],
[
320,
321
],
[
321,
322
],
[
322,
323
],
[
322,
324
],
[
324,
325
],
[
321,
326
],
[
320,
327
],
[
327,
328
],
[
327,
329
],
[
319,
330
],
[
330,
331
],
[
331,
332
],
[
331,
333
],
[
333,
334
],
[
334,
335
],
[
335,
336
],
[
335,
337
],
[
334,
338
],
[
333,
339
],
[
292,
340
],
[
340,
341
],
[
340,
342
],
[
342,
343
],
[
343,
344
],
[
292,
345
],
[
345,
346
],
[
75,
347
],
[
347,
348
],
[
347,
349
],
[
349,
350
],
[
350,
351
],
[
350,
352
],
[
349,
354
],
[
354,
355
],
[
355,
356
],
[
356,
357
],
[
356,
358
],
[
354,
359
],
[
359,
360
],
[
359,
361
],
[
354,
362
],
[
362,
363
],
[
363,
364
],
[
354,
365
],
[
366,
366
],
[
366,
367
],
[
367,
368
],
[
368,
369
],
[
368,
370
],
[
367,
371
],
[
371,
372
],
[
349,
373
],
[
373,
374
],
[
347,
375
],
[
375,
376
],
[
75,
377
],
[
377,
378
],
[
377,
379
],
[
379,
380
],
[
380,
381
],
[
380,
382
],
[
382,
383
],
[
379,
384
],
[
384,
385
],
[
385,
386
],
[
386,
387
],
[
385,
388
],
[
384,
389
],
[
389,
390
],
[
390,
391
],
[
390,
392
],
[
392,
393
],
[
379,
394
],
[
394,
395
],
[
75,
396
],
[
396,
397
],
[
396,
398
],
[
398,
399
],
[
399,
400
],
[
399,
401
],
[
398,
402
],
[
402,
403
],
[
402,
404
],
[
398,
405
],
[
405,
406
],
[
405,
407
],
[
407,
408
],
[
398,
409
],
[
409,
410
],
[
410,
411
],
[
410,
412
],
[
409,
413
],
[
413,
414
],
[
413,
415
],
[
415,
416
],
[
398,
417
],
[
417,
418
],
[
417,
419
],
[
419,
420
],
[
419,
421
],
[
398,
422
],
[
422,
423
],
[
422,
424
],
[
424,
425
],
[
424,
426
],
[
426,
427
],
[
398,
428
],
[
428,
429
],
[
429,
430
],
[
430,
431
],
[
431,
432
],
[
431,
433
],
[
433,
434
],
[
430,
435
],
[
429,
436
],
[
436,
437
],
[
436,
438
],
[
428,
439
],
[
439,
440
],
[
440,
441
],
[
440,
442
],
[
442,
443
],
[
443,
444
],
[
444,
445
],
[
444,
446
],
[
443,
447
],
[
442,
448
],
[
398,
449
],
[
449,
450
],
[
450,
451
],
[
450,
452
],
[
449,
453
],
[
453,
454
],
[
454,
455
],
[
455,
456
],
[
456,
457
],
[
457,
458
],
[
457,
459
],
[
459,
460
],
[
456,
461
],
[
455,
462
],
[
462,
463
],
[
462,
464
],
[
454,
465
],
[
465,
466
],
[
466,
467
],
[
466,
468
],
[
468,
469
],
[
469,
470
],
[
469,
471
],
[
468,
472
],
[
472,
473
],
[
472,
474
],
[
398,
475
],
[
475,
476
],
[
475,
477
],
[
477,
478
],
[
478,
479
],
[
398,
480
],
[
480,
481
],
[
75,
482
],
[
482,
483
],
[
482,
484
],
[
484,
485
],
[
485,
486
],
[
485,
487
],
[
484,
489
],
[
489,
490
],
[
490,
491
],
[
491,
492
],
[
491,
493
],
[
489,
494
],
[
494,
495
],
[
494,
496
],
[
489,
497
],
[
497,
498
],
[
498,
499
],
[
489,
500
],
[
501,
501
],
[
501,
502
],
[
502,
503
],
[
503,
504
],
[
503,
505
],
[
502,
506
],
[
506,
507
],
[
484,
508
],
[
508,
509
],
[
482,
510
],
[
510,
511
],
[
75,
512
],
[
512,
513
],
[
512,
514
],
[
514,
515
],
[
515,
516
],
[
515,
517
],
[
517,
518
],
[
518,
519
],
[
517,
520
],
[
517,
521
],
[
521,
522
],
[
521,
523
],
[
517,
524
],
[
514,
525
],
[
525,
526
],
[
526,
527
],
[
526,
528
],
[
528,
529
],
[
525,
530
],
[
530,
531
],
[
531,
532
],
[
531,
533
],
[
530,
534
],
[
534,
535
],
[
75,
536
],
[
536,
537
],
[
536,
538
],
[
538,
539
],
[
539,
540
],
[
540,
541
],
[
540,
542
],
[
539,
543
],
[
543,
544
],
[
538,
545
],
[
545,
546
],
[
546,
547
],
[
546,
548
],
[
548,
549
],
[
75,
550
],
[
550,
551
],
[
550,
552
],
[
552,
553
],
[
553,
554
],
[
554,
555
],
[
554,
556
],
[
553,
557
],
[
552,
558
],
[
558,
559
],
[
559,
560
],
[
0,
561
],
[
561,
562
],
[
561,
563
]
]
| [
"import java.util.*;\nimport java.io.*;\npublic class Main{\n\n public static void main(String [] args) throws IOException{\n FastScanner sc=new FastScanner();\n int n=sc.nextInt();\n long [] a=sc.nextLongArray(n);\n long max=a[0],ans=0;\n for(int i=1;i<n;i++){\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }\n System.out.println(ans);\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nclass FastScanner{\t\n private int BUFFER_SIZE = 1 << 16;\n \n private DataInputStream din;\n \n private byte[] buffer;\n \n private int bufferPointer, bytesRead;\n \n public FastScanner() {\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public FastScanner( String file_name) throws IOException {\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n \n public String readLine() throws IOException {\n byte[] buf = new byte[64];\n int cnt = 0, c;\n while ((c = read()) != -1) {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n \n public String next() throws IOException{\n\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n \n StringBuilder builder = new StringBuilder();\n builder.append((char)c);\n c = read();\n while(!Character.isWhitespace(c)){\n builder.append((char)c);\n c = read();\n }\n \n return builder.toString();\n }\n\n public int nextInt() throws IOException {\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n \n public int[] nextIntArray( int n) throws IOException {\n int arr[] = new int[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextInt();\n }\n return arr;\n }\n\n public long nextLong() throws IOException {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n \n public long[] nextLongArray( int n) throws IOException {\n long arr[] = new long[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextLong();\n }\n return arr;\n }\n\n public char nextChar() throws IOException{\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n return (char) c;\t\n }\n \n public double nextDouble() throws IOException {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.') {\n while ((c = read()) >= '0' && c <= '9') {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n \n public double[] nextDoubleArray( int n) throws IOException {\n double arr[] = new double[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextDouble();\n }\n return arr;\n }\n\n private void fillBuffer() throws IOException {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException {\n if (din == null)\n return;\n din.close();\n }\n\n}\n",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main{\n\n public static void main(String [] args) throws IOException{\n FastScanner sc=new FastScanner();\n int n=sc.nextInt();\n long [] a=sc.nextLongArray(n);\n long max=a[0],ans=0;\n for(int i=1;i<n;i++){\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }\n System.out.println(ans);\n }\n}",
"Main",
"public static void main(String [] args) throws IOException{\n FastScanner sc=new FastScanner();\n int n=sc.nextInt();\n long [] a=sc.nextLongArray(n);\n long max=a[0],ans=0;\n for(int i=1;i<n;i++){\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }\n System.out.println(ans);\n }",
"main",
"{\n FastScanner sc=new FastScanner();\n int n=sc.nextInt();\n long [] a=sc.nextLongArray(n);\n long max=a[0],ans=0;\n for(int i=1;i<n;i++){\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }\n System.out.println(ans);\n }",
"FastScanner sc=new FastScanner();",
"sc",
"new FastScanner()",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long [] a=sc.nextLongArray(n);",
"a",
"sc.nextLongArray(n)",
"sc.nextLongArray",
"sc",
"n",
"long max=a[0]",
"max",
"a[0]",
"a",
"0",
"ans=0;",
"ans",
"0",
"for(int i=1;i<n;i++){\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }",
"{\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }",
"ans+=Math.max(max-a[i],0)",
"ans",
"Math.max(max-a[i],0)",
"Math.max",
"Math",
"max-a[i]",
"max",
"a[i]",
"a",
"i",
"0",
"max=Math.max(max,a[i])",
"max",
"Math.max(max,a[i])",
"Math.max",
"Math",
"max",
"a[i]",
"a",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String [] args",
"args",
"class FastScanner{\t\n private int BUFFER_SIZE = 1 << 16;\n \n private DataInputStream din;\n \n private byte[] buffer;\n \n private int bufferPointer, bytesRead;\n \n public FastScanner() {\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public FastScanner( String file_name) throws IOException {\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n \n public String readLine() throws IOException {\n byte[] buf = new byte[64];\n int cnt = 0, c;\n while ((c = read()) != -1) {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n \n public String next() throws IOException{\n\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n \n StringBuilder builder = new StringBuilder();\n builder.append((char)c);\n c = read();\n while(!Character.isWhitespace(c)){\n builder.append((char)c);\n c = read();\n }\n \n return builder.toString();\n }\n\n public int nextInt() throws IOException {\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n \n public int[] nextIntArray( int n) throws IOException {\n int arr[] = new int[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextInt();\n }\n return arr;\n }\n\n public long nextLong() throws IOException {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n \n public long[] nextLongArray( int n) throws IOException {\n long arr[] = new long[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextLong();\n }\n return arr;\n }\n\n public char nextChar() throws IOException{\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n return (char) c;\t\n }\n \n public double nextDouble() throws IOException {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.') {\n while ((c = read()) >= '0' && c <= '9') {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n \n public double[] nextDoubleArray( int n) throws IOException {\n double arr[] = new double[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextDouble();\n }\n return arr;\n }\n\n private void fillBuffer() throws IOException {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException {\n if (din == null)\n return;\n din.close();\n }\n\n}",
"FastScanner",
"private int BUFFER_SIZE = 1 << 16;",
"BUFFER_SIZE",
"1 << 16",
"1",
"16",
"private DataInputStream din;",
"din",
"private byte[] buffer;",
"buffer",
"private int bufferPointer",
"bufferPointer",
"bytesRead;",
"bytesRead",
"public FastScanner() {\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }",
"FastScanner",
"{\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }",
"din = new DataInputStream(System.in)",
"din",
"new DataInputStream(System.in)",
"buffer = new byte[BUFFER_SIZE]",
"buffer",
"new byte[BUFFER_SIZE]",
"BUFFER_SIZE",
"bufferPointer = bytesRead = 0",
"bufferPointer",
"bytesRead = 0",
"bytesRead",
"0",
"public FastScanner( String file_name) throws IOException {\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }",
"FastScanner",
"{\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }",
"din = new DataInputStream(new FileInputStream(file_name))",
"din",
"new DataInputStream(new FileInputStream(file_name))",
"buffer = new byte[BUFFER_SIZE]",
"buffer",
"new byte[BUFFER_SIZE]",
"BUFFER_SIZE",
"bufferPointer = bytesRead = 0",
"bufferPointer",
"bytesRead = 0",
"bytesRead",
"0",
"String file_name",
"file_name",
"public String readLine() throws IOException {\n byte[] buf = new byte[64];\n int cnt = 0, c;\n while ((c = read()) != -1) {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }",
"readLine",
"{\n byte[] buf = new byte[64];\n int cnt = 0, c;\n while ((c = read()) != -1) {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }",
"byte[] buf = new byte[64];",
"buf",
"new byte[64]",
"64",
"int cnt = 0",
"cnt",
"0",
"c;",
"c",
"while ((c = read()) != -1) {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }",
"(c = read()) != -1",
"(c = read())",
"c",
"read()",
"read",
"-1",
"1",
"{\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }",
"if (c == '\\n')\n break;",
"c == '\\n'",
"c",
"'\\n'",
"break;",
"buf[cnt++] = (byte) c",
"buf[cnt++]",
"buf",
"cnt++",
"cnt",
"(byte) c",
"return new String(buf, 0, cnt);",
"new String(buf, 0, cnt)",
"public String next() throws IOException{\n\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n \n StringBuilder builder = new StringBuilder();\n builder.append((char)c);\n c = read();\n while(!Character.isWhitespace(c)){\n builder.append((char)c);\n c = read();\n }\n \n return builder.toString();\n }",
"next",
"{\n\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n \n StringBuilder builder = new StringBuilder();\n builder.append((char)c);\n c = read();\n while(!Character.isWhitespace(c)){\n builder.append((char)c);\n c = read();\n }\n \n return builder.toString();\n }",
"byte c = read();",
"c",
"read()",
"read",
"while(Character.isWhitespace(c)){\n c = read();\n }",
"Character.isWhitespace(c)",
"Character.isWhitespace",
"Character",
"c",
"{\n c = read();\n }",
"c = read()",
"c",
"read()",
"read",
"StringBuilder builder = new StringBuilder();",
"builder",
"new StringBuilder()",
"builder.append((char)c)",
"builder.append",
"builder",
"(char)c",
"c = read()",
"c",
"read()",
"read",
"while(!Character.isWhitespace(c)){\n builder.append((char)c);\n c = read();\n }",
"!Character.isWhitespace(c)",
"Character.isWhitespace(c)",
"Character.isWhitespace",
"Character",
"c",
"{\n builder.append((char)c);\n c = read();\n }",
"builder.append((char)c)",
"builder.append",
"builder",
"(char)c",
"c = read()",
"c",
"read()",
"read",
"return builder.toString();",
"builder.toString()",
"builder.toString",
"builder",
"public int nextInt() throws IOException {\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }",
"nextInt",
"{\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }",
"int ret = 0;",
"ret",
"0",
"byte c = read();",
"c",
"read()",
"read",
"while (c <= ' ')\n c = read();",
"c <= ' '",
"c",
"' '",
"c = read()",
"c",
"read()",
"read",
"boolean neg = (c == '-');",
"neg",
"(c == '-')",
"c",
"'-'",
"if (neg)\n c = read();",
"neg",
"c = read()",
"c",
"read()",
"read",
"do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');",
"(c = read()) >= '0' && c <= '9'",
"(c = read()) >= '0'",
"(c = read())",
"c",
"read()",
"read",
"'0'",
"c <= '9'",
"c",
"'9'",
"{\n ret = ret * 10 + c - '0';\n }",
"ret = ret * 10 + c - '0'",
"ret",
"ret * 10 + c - '0'",
"ret * 10 + c",
"ret * 10",
"ret",
"10",
"c",
"'0'",
"if (neg)\n return -ret;",
"neg",
"return -ret;",
"-ret",
"ret",
"return ret;",
"ret",
"public int[] nextIntArray( int n) throws IOException {\n int arr[] = new int[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextInt();\n }\n return arr;\n }",
"nextIntArray",
"{\n int arr[] = new int[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextInt();\n }\n return arr;\n }",
"int arr[] = new int[n];",
"arr",
"new int[n]",
"n",
"for(int i = 0; i < n; i++){\n arr[i] = nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n arr[i] = nextInt();\n }",
"{\n arr[i] = nextInt();\n }",
"arr[i] = nextInt()",
"arr[i]",
"arr",
"i",
"nextInt()",
"nextInt",
"return arr;",
"arr",
"int n",
"n",
"public long nextLong() throws IOException {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }",
"nextLong",
"{\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }",
"long ret = 0;",
"ret",
"0",
"byte c = read();",
"c",
"read()",
"read",
"while (c <= ' ')\n c = read();",
"c <= ' '",
"c",
"' '",
"c = read()",
"c",
"read()",
"read",
"boolean neg = (c == '-');",
"neg",
"(c == '-')",
"c",
"'-'",
"if (neg)\n c = read();",
"neg",
"c = read()",
"c",
"read()",
"read",
"do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');",
"(c = read()) >= '0' && c <= '9'",
"(c = read()) >= '0'",
"(c = read())",
"c",
"read()",
"read",
"'0'",
"c <= '9'",
"c",
"'9'",
"{\n ret = ret * 10 + c - '0';\n }",
"ret = ret * 10 + c - '0'",
"ret",
"ret * 10 + c - '0'",
"ret * 10 + c",
"ret * 10",
"ret",
"10",
"c",
"'0'",
"if (neg)\n return -ret;",
"neg",
"return -ret;",
"-ret",
"ret",
"return ret;",
"ret",
"public long[] nextLongArray( int n) throws IOException {\n long arr[] = new long[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextLong();\n }\n return arr;\n }",
"nextLongArray",
"{\n long arr[] = new long[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextLong();\n }\n return arr;\n }",
"long arr[] = new long[n];",
"arr",
"new long[n]",
"n",
"for(int i = 0; i < n; i++){\n arr[i] = nextLong();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n arr[i] = nextLong();\n }",
"{\n arr[i] = nextLong();\n }",
"arr[i] = nextLong()",
"arr[i]",
"arr",
"i",
"nextLong()",
"nextLong",
"return arr;",
"arr",
"int n",
"n",
"public char nextChar() throws IOException{\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n return (char) c;\t\n }",
"nextChar",
"{\n byte c = read();\n while(Character.isWhitespace(c)){\n c = read();\n }\n return (char) c;\t\n }",
"byte c = read();",
"c",
"read()",
"read",
"while(Character.isWhitespace(c)){\n c = read();\n }",
"Character.isWhitespace(c)",
"Character.isWhitespace",
"Character",
"c",
"{\n c = read();\n }",
"c = read()",
"c",
"read()",
"read",
"return (char) c;",
"(char) c",
"public double nextDouble() throws IOException {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.') {\n while ((c = read()) >= '0' && c <= '9') {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }",
"nextDouble",
"{\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.') {\n while ((c = read()) >= '0' && c <= '9') {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }",
"double ret = 0",
"ret",
"0",
"div = 1;",
"div",
"1",
"byte c = read();",
"c",
"read()",
"read",
"while (c <= ' ')\n c = read();",
"c <= ' '",
"c",
"' '",
"c = read()",
"c",
"read()",
"read",
"boolean neg = (c == '-');",
"neg",
"(c == '-')",
"c",
"'-'",
"if (neg)\n c = read();",
"neg",
"c = read()",
"c",
"read()",
"read",
"do {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');",
"(c = read()) >= '0' && c <= '9'",
"(c = read()) >= '0'",
"(c = read())",
"c",
"read()",
"read",
"'0'",
"c <= '9'",
"c",
"'9'",
"{\n ret = ret * 10 + c - '0';\n }",
"ret = ret * 10 + c - '0'",
"ret",
"ret * 10 + c - '0'",
"ret * 10 + c",
"ret * 10",
"ret",
"10",
"c",
"'0'",
"if (c == '.') {\n while ((c = read()) >= '0' && c <= '9') {\n ret += (c - '0') / (div *= 10);\n }\n }",
"c == '.'",
"c",
"'.'",
"{\n while ((c = read()) >= '0' && c <= '9') {\n ret += (c - '0') / (div *= 10);\n }\n }",
"while ((c = read()) >= '0' && c <= '9') {\n ret += (c - '0') / (div *= 10);\n }",
"(c = read()) >= '0' && c <= '9'",
"(c = read()) >= '0'",
"(c = read())",
"c",
"read()",
"read",
"'0'",
"c <= '9'",
"c",
"'9'",
"{\n ret += (c - '0') / (div *= 10);\n }",
"ret += (c - '0') / (div *= 10)",
"ret",
"(c - '0') / (div *= 10)",
"(c - '0')",
"c",
"'0'",
"(div *= 10)",
"div",
"10",
"if (neg)\n return -ret;",
"neg",
"return -ret;",
"-ret",
"ret",
"return ret;",
"ret",
"public double[] nextDoubleArray( int n) throws IOException {\n double arr[] = new double[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextDouble();\n }\n return arr;\n }",
"nextDoubleArray",
"{\n double arr[] = new double[n];\n for(int i = 0; i < n; i++){\n arr[i] = nextDouble();\n }\n return arr;\n }",
"double arr[] = new double[n];",
"arr",
"new double[n]",
"n",
"for(int i = 0; i < n; i++){\n arr[i] = nextDouble();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n arr[i] = nextDouble();\n }",
"{\n arr[i] = nextDouble();\n }",
"arr[i] = nextDouble()",
"arr[i]",
"arr",
"i",
"nextDouble()",
"nextDouble",
"return arr;",
"arr",
"int n",
"n",
"private void fillBuffer() throws IOException {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }",
"fillBuffer",
"{\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }",
"bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE)",
"bytesRead",
"din.read(buffer, bufferPointer = 0, BUFFER_SIZE)",
"din.read",
"din",
"buffer",
"bufferPointer = 0",
"bufferPointer",
"0",
"BUFFER_SIZE",
"if (bytesRead == -1)\n buffer[0] = -1;",
"bytesRead == -1",
"bytesRead",
"-1",
"1",
"buffer[0] = -1",
"buffer[0]",
"buffer",
"0",
"-1",
"1",
"private byte read() throws IOException {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }",
"read",
"{\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }",
"if (bufferPointer == bytesRead)\n fillBuffer();",
"bufferPointer == bytesRead",
"bufferPointer",
"bytesRead",
"fillBuffer()",
"fillBuffer",
"return buffer[bufferPointer++];",
"buffer[bufferPointer++]",
"buffer",
"bufferPointer++",
"bufferPointer",
"public void close() throws IOException {\n if (din == null)\n return;\n din.close();\n }",
"close",
"{\n if (din == null)\n return;\n din.close();\n }",
"if (din == null)\n return;",
"din == null",
"din",
"null",
"return;",
"din.close()",
"din.close",
"din",
"public class Main{\n\n public static void main(String [] args) throws IOException{\n FastScanner sc=new FastScanner();\n int n=sc.nextInt();\n long [] a=sc.nextLongArray(n);\n long max=a[0],ans=0;\n for(int i=1;i<n;i++){\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }\n System.out.println(ans);\n }\n}",
"public class Main{\n\n public static void main(String [] args) throws IOException{\n FastScanner sc=new FastScanner();\n int n=sc.nextInt();\n long [] a=sc.nextLongArray(n);\n long max=a[0],ans=0;\n for(int i=1;i<n;i++){\n ans+=Math.max(max-a[i],0);\n max=Math.max(max,a[i]);\n }\n System.out.println(ans);\n }\n}",
"Main"
]
| import java.util.*;
import java.io.*;
public class Main{
public static void main(String [] args) throws IOException{
FastScanner sc=new FastScanner();
int n=sc.nextInt();
long [] a=sc.nextLongArray(n);
long max=a[0],ans=0;
for(int i=1;i<n;i++){
ans+=Math.max(max-a[i],0);
max=Math.max(max,a[i]);
}
System.out.println(ans);
}
}
class FastScanner{
private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public FastScanner() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public FastScanner( String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {
byte[] buf = new byte[64];
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n')
break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public String next() throws IOException{
byte c = read();
while(Character.isWhitespace(c)){
c = read();
}
StringBuilder builder = new StringBuilder();
builder.append((char)c);
c = read();
while(!Character.isWhitespace(c)){
builder.append((char)c);
c = read();
}
return builder.toString();
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public int[] nextIntArray( int n) throws IOException {
int arr[] = new int[n];
for(int i = 0; i < n; i++){
arr[i] = nextInt();
}
return arr;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long[] nextLongArray( int n) throws IOException {
long arr[] = new long[n];
for(int i = 0; i < n; i++){
arr[i] = nextLong();
}
return arr;
}
public char nextChar() throws IOException{
byte c = read();
while(Character.isWhitespace(c)){
c = read();
}
return (char) c;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
public double[] nextDoubleArray( int n) throws IOException {
double arr[] = new double[n];
for(int i = 0; i < n; i++){
arr[i] = nextDouble();
}
return arr;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null)
return;
din.close();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
4,
13,
23,
13,
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
9,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
222,
8
],
[
222,
9
],
[
9,
10
],
[
9,
11
],
[
222,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
12,
17
],
[
17,
18
],
[
222,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
21,
27
],
[
27,
28
],
[
27,
29
],
[
21,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
21,
50
],
[
50,
51
],
[
50,
52
],
[
21,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
53,
58
],
[
58,
59
],
[
58,
60
],
[
53,
61
],
[
61,
62
],
[
62,
63
],
[
53,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
66,
76
],
[
66,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
80,
86
],
[
86,
87
],
[
86,
88
],
[
77,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
21,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
222,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
104,
108
],
[
108,
109
],
[
104,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
104,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
119,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
129,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
118,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
104,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
148,
151
],
[
151,
152
],
[
104,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
157,
160
],
[
160,
161
],
[
104,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
166,
169
],
[
169,
170
],
[
104,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
177,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
173,
190
],
[
190,
191
],
[
104,
192
],
[
192,
193
],
[
192,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
194,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
199,
204
],
[
204,
205
],
[
204,
206
],
[
199,
207
],
[
207,
208
],
[
208,
209
],
[
199,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
211,
215
],
[
215,
216
],
[
194,
217
],
[
217,
218
],
[
192,
219
],
[
219,
220
],
[
0,
221
],
[
221,
222
],
[
221,
223
]
]
| [
"\n\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n\tstatic FastReader in = new FastReader();\n\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tstatic void solve() {\n\t\tint n = in.nextInt();\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t\ta[i] = in.nextLong();\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int i = 1; i < n; i++)\n\t\t{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint[] readarr(int abc) {\n\t\t\tint[] a = new int[abc];\n\t\t\tfor (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}\n\n\n",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n\tstatic FastReader in = new FastReader();\n\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tstatic void solve() {\n\t\tint n = in.nextInt();\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t\ta[i] = in.nextLong();\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int i = 1; i < n; i++)\n\t\t{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint[] readarr(int abc) {\n\t\t\tint[] a = new int[abc];\n\t\t\tfor (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}",
"Main",
"static FastReader in = new FastReader();",
"in",
"new FastReader()",
"public static void main(String[] args) {\n\t\tsolve();\n\t}",
"main",
"{\n\t\tsolve();\n\t}",
"solve()",
"solve",
"String[] args",
"args",
"static void solve() {\n\t\tint n = in.nextInt();\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t\ta[i] = in.nextLong();\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int i = 1; i < n; i++)\n\t\t{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}",
"solve",
"{\n\t\tint n = in.nextInt();\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t\ta[i] = in.nextLong();\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int i = 1; i < n; i++)\n\t\t{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"long[] a = new long[n];",
"a",
"new long[n]",
"n",
"for(int i = 0; i < n; i++)\n\t\t\ta[i] = in.nextLong();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = in.nextLong();",
"a[i] = in.nextLong()",
"a[i]",
"a",
"i",
"in.nextLong()",
"in.nextLong",
"in",
"long sum = 0;",
"sum",
"0",
"for(int i = 1; i < n; i++)\n\t\t{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\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\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}",
"if(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}",
"a[i] >= a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"continue;",
"{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}",
"sum += a[i - 1] - a[i]",
"sum",
"a[i - 1] - a[i]",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i]",
"a",
"i",
"a[i] = a[i - 1]",
"a[i]",
"a",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"static class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint[] readarr(int abc) {\n\t\t\tint[] a = new int[abc];\n\t\t\tfor (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t}",
"FastReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}",
"FastReader",
"{\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"next",
"{\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"while (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}",
"try {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"IOException e",
"{\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"nextInt",
"{\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"long nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"nextLong",
"{\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"nextDouble",
"{\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}",
"nextLine",
"{\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}",
"String str = \"\";",
"str",
"\"\"",
"try {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"IOException e",
"{\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\tstr = br.readLine();\n\t\t\t}",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"int[] readarr(int abc) {\n\t\t\tint[] a = new int[abc];\n\t\t\tfor (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}",
"readarr",
"{\n\t\t\tint[] a = new int[abc];\n\t\t\tfor (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}",
"int[] a = new int[abc];",
"a",
"new int[abc]",
"abc",
"for (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < abc",
"i",
"abc",
"i++",
"i++",
"i",
"a[i] = nextInt();",
"a[i] = nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int abc",
"abc",
"public class Main {\n\tstatic FastReader in = new FastReader();\n\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tstatic void solve() {\n\t\tint n = in.nextInt();\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t\ta[i] = in.nextLong();\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int i = 1; i < n; i++)\n\t\t{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint[] readarr(int abc) {\n\t\t\tint[] a = new int[abc];\n\t\t\tfor (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}",
"public class Main {\n\tstatic FastReader in = new FastReader();\n\n\tpublic static void main(String[] args) {\n\t\tsolve();\n\t}\n\n\tstatic void solve() {\n\t\tint n = in.nextInt();\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t\ta[i] = in.nextLong();\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int i = 1; i < n; i++)\n\t\t{\n\t\t\tif(a[i] >= a[i - 1]) continue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i - 1] - a[i];\n\t\t\t\ta[i] = a[i - 1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint[] readarr(int abc) {\n\t\t\tint[] a = new int[abc];\n\t\t\tfor (int i = 0; i < abc; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}",
"Main"
]
|
import java.util.*;
import java.io.*;
public class Main {
static FastReader in = new FastReader();
public static void main(String[] args) {
solve();
}
static void solve() {
int n = in.nextInt();
long[] a = new long[n];
for(int i = 0; i < n; i++)
a[i] = in.nextLong();
long sum = 0;
for(int i = 1; i < n; i++)
{
if(a[i] >= a[i - 1]) continue;
else
{
sum += a[i - 1] - a[i];
a[i] = a[i - 1];
}
}
System.out.println(sum);
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] readarr(int abc) {
int[] a = new int[abc];
for (int i = 0; i < abc; i++)
a[i] = nextInt();
return a;
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
2,
13,
17,
0,
18,
13,
17,
17,
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,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
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
],
[
20,
21
],
[
20,
22
],
[
8,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
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
],
[
48,
50
],
[
8,
51
],
[
51,
52
],
[
51,
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
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
69,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
8,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
6,
95
],
[
95,
96
]
]
| [
"import java.util.Scanner;\nclass 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+1];\n a[0] = 1;\n for(int i = 1; i <= n; i++) {\n a[i] = sc.nextInt();\n }\n\n long ans = 0;\n int max = a[1];\n for(int i = 2; i <= n; i++) {\n if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }\n }\n\n System.out.println(ans);\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[] a = new int[n+1];\n a[0] = 1;\n for(int i = 1; i <= n; i++) {\n a[i] = sc.nextInt();\n }\n\n long ans = 0;\n int max = a[1];\n for(int i = 2; i <= n; i++) {\n if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }\n }\n\n System.out.println(ans);\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+1];\n a[0] = 1;\n for(int i = 1; i <= n; i++) {\n a[i] = sc.nextInt();\n }\n\n long ans = 0;\n int max = a[1];\n for(int i = 2; i <= n; i++) {\n if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }\n }\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+1];\n a[0] = 1;\n for(int i = 1; i <= n; i++) {\n a[i] = sc.nextInt();\n }\n\n long ans = 0;\n int max = a[1];\n for(int i = 2; i <= n; i++) {\n if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }\n }\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+1];",
"a",
"new int[n+1]",
"n+1",
"n",
"1",
"a[0] = 1",
"a[0]",
"a",
"0",
"1",
"for(int i = 1; i <= n; i++) {\n a[i] = sc.nextInt();\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"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",
"long ans = 0;",
"ans",
"0",
"int max = a[1];",
"max",
"a[1]",
"a",
"1",
"for(int i = 2; i <= n; i++) {\n if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }\n }",
"int i = 2;",
"int i = 2;",
"i",
"2",
"i <= n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }\n }",
"{\n if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }\n }",
"if(max > a[i]) {\n ans += (max-a[i]);\n }else{\n max = a[i];\n }",
"max > a[i]",
"max",
"a[i]",
"a",
"i",
"{\n ans += (max-a[i]);\n }",
"ans += (max-a[i])",
"ans",
"(max-a[i])",
"max",
"a[i]",
"a",
"i",
"{\n max = a[i];\n }",
"max = a[i]",
"max",
"a[i]",
"a",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"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+1];
a[0] = 1;
for(int i = 1; i <= n; i++) {
a[i] = sc.nextInt();
}
long ans = 0;
int max = a[1];
for(int i = 2; i <= n; i++) {
if(max > a[i]) {
ans += (max-a[i]);
}else{
max = a[i];
}
}
System.out.println(ans);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
13,
13,
4,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
20,
23,
13,
12,
13,
30,
4,
18,
13,
20,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
12,
13,
30,
4,
18,
13,
17,
12,
13,
30,
4,
18,
13,
17,
12,
13,
30,
4,
18,
13,
17,
12,
13,
30,
4,
18,
13,
17,
12,
13,
30,
4,
18,
13,
17,
12,
13,
30,
4,
18,
13,
17,
12,
13,
30,
4,
18,
13,
8,
13,
17,
17,
23,
13,
12,
13,
30,
4,
18,
13,
8,
13,
17,
17,
23,
13,
12,
13,
30,
4,
18,
13,
8,
13,
17,
17,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
41,
13,
2,
18,
13,
13,
17,
2,
13,
13,
1,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
40,
13,
30,
4,
18,
13,
18,
13,
2,
18,
13,
13,
17,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
41,
13,
2,
18,
13,
13,
17,
2,
13,
13,
1,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
40,
13,
30,
4,
18,
13,
18,
13,
2,
18,
13,
13,
17,
23,
13,
12,
13,
30,
41,
13,
2,
4,
18,
13,
17,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
4,
18,
13,
4,
18,
13,
4,
18,
13,
17,
40,
13,
30,
14,
2,
13,
17,
30,
4,
18,
13,
4,
18,
13,
30,
4,
18,
13,
23,
13,
12,
13,
30,
4,
18,
13,
17,
4,
13,
12,
13,
30,
4,
18,
13,
12,
13,
30,
4,
18,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
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
],
[
545,
14
],
[
545,
15
],
[
15,
16
],
[
15,
17
],
[
545,
18
],
[
18,
19
],
[
18,
20
],
[
545,
21
],
[
21,
22
],
[
545,
23
],
[
23,
24
],
[
23,
25
],
[
545,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
28,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
39,
40
],
[
39,
41
],
[
28,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
42,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
42,
52
],
[
52,
53
],
[
53,
54
],
[
42,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
62,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
28,
76
],
[
76,
77
],
[
76,
78
],
[
28,
79
],
[
79,
80
],
[
26,
81
],
[
81,
82
],
[
545,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
83,
90
],
[
90,
91
],
[
545,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
92,
99
],
[
99,
100
],
[
545,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
101,
108
],
[
108,
109
],
[
545,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
110,
117
],
[
117,
118
],
[
545,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
119,
126
],
[
126,
127
],
[
545,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
128,
135
],
[
135,
136
],
[
545,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
137,
144
],
[
144,
145
],
[
545,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
146,
153
],
[
153,
154
],
[
545,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
158,
161
],
[
155,
162
],
[
162,
163
],
[
545,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
167,
170
],
[
164,
171
],
[
171,
172
],
[
545,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
173,
180
],
[
180,
181
],
[
545,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
185,
188
],
[
182,
189
],
[
189,
190
],
[
545,
191
],
[
191,
192
],
[
191,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
194,
197
],
[
191,
198
],
[
198,
199
],
[
545,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
203,
206
],
[
200,
207
],
[
207,
208
],
[
545,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
545,
215
],
[
215,
216
],
[
215,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
218,
221
],
[
545,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
225,
228
],
[
545,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
232,
233
],
[
233,
234
],
[
232,
235
],
[
545,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
239,
240
],
[
240,
241
],
[
239,
242
],
[
545,
243
],
[
243,
244
],
[
243,
245
],
[
245,
246
],
[
246,
247
],
[
247,
248
],
[
246,
249
],
[
545,
250
],
[
250,
251
],
[
250,
252
],
[
252,
253
],
[
253,
254
],
[
254,
255
],
[
253,
256
],
[
545,
257
],
[
257,
258
],
[
257,
259
],
[
259,
260
],
[
260,
261
],
[
261,
262
],
[
260,
263
],
[
263,
264
],
[
263,
265
],
[
263,
266
],
[
257,
267
],
[
267,
268
],
[
545,
269
],
[
269,
270
],
[
269,
271
],
[
271,
272
],
[
272,
273
],
[
273,
274
],
[
272,
275
],
[
275,
276
],
[
275,
277
],
[
275,
278
],
[
269,
279
],
[
279,
280
],
[
545,
281
],
[
281,
282
],
[
281,
283
],
[
283,
284
],
[
284,
285
],
[
285,
286
],
[
284,
287
],
[
287,
288
],
[
287,
289
],
[
287,
290
],
[
281,
291
],
[
291,
292
],
[
545,
293
],
[
293,
294
],
[
293,
295
],
[
295,
296
],
[
296,
297
],
[
297,
298
],
[
298,
299
],
[
298,
300
],
[
297,
301
],
[
301,
302
],
[
301,
303
],
[
303,
304
],
[
304,
305
],
[
304,
306
],
[
303,
307
],
[
296,
308
],
[
308,
309
],
[
308,
310
],
[
296,
311
],
[
311,
312
],
[
312,
313
],
[
313,
314
],
[
312,
315
],
[
315,
316
],
[
315,
317
],
[
311,
318
],
[
318,
319
],
[
319,
320
],
[
318,
321
],
[
311,
322
],
[
322,
323
],
[
296,
324
],
[
295,
325
],
[
325,
326
],
[
326,
327
],
[
325,
328
],
[
328,
329
],
[
328,
330
],
[
330,
331
],
[
331,
332
],
[
331,
333
],
[
330,
334
],
[
293,
335
],
[
335,
336
],
[
545,
337
],
[
337,
338
],
[
337,
339
],
[
339,
340
],
[
340,
341
],
[
341,
342
],
[
342,
343
],
[
342,
344
],
[
341,
345
],
[
345,
346
],
[
345,
347
],
[
347,
348
],
[
348,
349
],
[
348,
350
],
[
347,
351
],
[
340,
352
],
[
352,
353
],
[
352,
354
],
[
340,
355
],
[
355,
356
],
[
356,
357
],
[
357,
358
],
[
356,
359
],
[
359,
360
],
[
359,
361
],
[
355,
362
],
[
362,
363
],
[
363,
364
],
[
362,
365
],
[
355,
366
],
[
366,
367
],
[
340,
368
],
[
339,
369
],
[
369,
370
],
[
370,
371
],
[
369,
372
],
[
372,
373
],
[
372,
374
],
[
374,
375
],
[
375,
376
],
[
375,
377
],
[
374,
378
],
[
337,
379
],
[
379,
380
],
[
545,
381
],
[
381,
382
],
[
381,
383
],
[
383,
384
],
[
384,
385
],
[
384,
386
],
[
386,
387
],
[
387,
388
],
[
388,
389
],
[
386,
390
],
[
383,
391
],
[
391,
392
],
[
391,
393
],
[
393,
394
],
[
394,
395
],
[
383,
396
],
[
396,
397
],
[
397,
398
],
[
398,
399
],
[
398,
400
],
[
396,
401
],
[
401,
402
],
[
401,
403
],
[
396,
404
],
[
404,
405
],
[
405,
406
],
[
406,
407
],
[
405,
408
],
[
408,
409
],
[
409,
410
],
[
404,
411
],
[
411,
412
],
[
412,
413
],
[
411,
414
],
[
404,
415
],
[
415,
416
],
[
396,
417
],
[
383,
418
],
[
418,
419
],
[
419,
420
],
[
419,
421
],
[
418,
422
],
[
422,
423
],
[
423,
424
],
[
424,
425
],
[
423,
426
],
[
426,
427
],
[
427,
428
],
[
418,
429
],
[
429,
430
],
[
430,
431
],
[
431,
432
],
[
381,
433
],
[
433,
434
],
[
545,
435
],
[
435,
436
],
[
435,
437
],
[
437,
438
],
[
438,
439
],
[
439,
440
],
[
438,
441
],
[
437,
442
],
[
442,
443
],
[
545,
444
],
[
444,
445
],
[
444,
446
],
[
446,
447
],
[
447,
448
],
[
448,
449
],
[
545,
450
],
[
450,
451
],
[
450,
452
],
[
452,
453
],
[
453,
454
],
[
454,
455
],
[
545,
456
],
[
456,
457
],
[
456,
458
],
[
458,
459
],
[
456,
460
],
[
460,
461
],
[
456,
462
],
[
462,
463
],
[
462,
464
],
[
464,
465
],
[
465,
466
],
[
465,
467
],
[
456,
468
],
[
468,
469
],
[
468,
470
],
[
470,
471
],
[
471,
472
],
[
472,
473
],
[
473,
474
],
[
473,
475
],
[
472,
476
],
[
476,
477
],
[
477,
478
],
[
478,
479
],
[
471,
480
],
[
480,
481
],
[
481,
482
],
[
482,
483
],
[
482,
484
],
[
484,
485
],
[
485,
486
],
[
486,
487
],
[
481,
488
],
[
488,
489
],
[
489,
490
],
[
489,
491
],
[
470,
492
],
[
492,
493
],
[
493,
494
],
[
494,
495
],
[
456,
496
],
[
496,
497
],
[
496,
498
],
[
498,
499
],
[
499,
500
],
[
500,
501
],
[
501,
502
],
[
500,
503
],
[
503,
504
],
[
456,
505
],
[
505,
506
],
[
505,
507
],
[
507,
508
],
[
508,
509
],
[
509,
510
],
[
510,
511
],
[
509,
512
],
[
512,
513
],
[
456,
514
],
[
514,
515
],
[
514,
516
],
[
516,
517
],
[
517,
518
],
[
518,
519
],
[
519,
520
],
[
518,
521
],
[
521,
522
],
[
456,
523
],
[
523,
524
],
[
523,
525
],
[
525,
526
],
[
526,
527
],
[
526,
528
],
[
525,
529
],
[
529,
530
],
[
530,
531
],
[
530,
532
],
[
532,
533
],
[
533,
534
],
[
534,
535
],
[
529,
536
],
[
536,
537
],
[
537,
538
],
[
537,
539
],
[
539,
540
],
[
540,
541
],
[
525,
542
],
[
542,
543
],
[
0,
544
],
[
544,
545
],
[
544,
546
]
]
| [
"\nimport java.io.*;\nimport java.util.*;\nimport static java.lang.Math.*;\nimport static java.util.Arrays.*;\n\n/**\n * @author AnonymousP\n * @__WHEN YOU FEEL LIKE QUITTING, THINK ABOUT WHY YOU STARTED__@\n */\n//COMBINATON = nCr = n*(n-1)/2\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n\n int n = sc.nextInt();\n int start = sc.nextInt();\n // int max = start;\n long c = 0;\n for (int i = 0; i < n - 1; i++) {\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }\n\n prln(c);\n\n /*int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }*/\n /*for (int i = n - 1; i >= 0; i--) {\n //prln(\"**********\");\n //prln(\"##DB a[i] \" + a[i]);\n //prln(\"**********\");\n for (int j = i - 1; j >= 0; j--) {\n // prln(\"##DB a[j] \" + a[j]);\n if (a[j] > a[i]) {\n c++;\n }\n //prln(\"**\");\n }\n }*/\n close();\n }\n\n static FastReader sc = new FastReader();\n static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));\n static StringTokenizer input;\n static Random __rand = new Random();\n\n // input\n //*******FAST IO*************FAST IO***************FAST IO****************//\n static class FastReader {\n\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n// output\n\n static void pr(int i) {\n __out.print(i);\n }\n\n static void prln(int i) {\n __out.println(i);\n }\n\n static void pr(long l) {\n __out.print(l);\n }\n\n static void prln(long l) {\n __out.println(l);\n }\n\n static void pr(double d) {\n __out.print(d);\n }\n\n static void prln(double d) {\n __out.println(d);\n }\n\n static void pr(char c) {\n __out.print(c);\n }\n\n static void prln(char c) {\n __out.println(c);\n }\n\n static void pr(char[] s) {\n __out.print(new String(s));\n }\n\n static void prln(char[] s) {\n __out.println(new String(s));\n }\n\n static void pr(String s) {\n __out.print(s);\n }\n\n static void prln(String s) {\n __out.println(s);\n }\n\n static void pr(Object o) {\n __out.print(o);\n }\n\n static void prln(Object o) {\n __out.println(o);\n }\n\n static void prln() {\n __out.println();\n }\n\n static void pryes() {\n __out.println(\"yes\");\n }\n\n static void pry() {\n __out.println(\"Yes\");\n }\n\n static void prY() {\n __out.println(\"YES\");\n }\n\n static void prno() {\n __out.println(\"no\");\n }\n\n static void prn() {\n __out.println(\"No\");\n }\n\n static void prN() {\n __out.println(\"NO\");\n }\n\n static void pryesno(boolean b) {\n __out.println(b ? \"yes\" : \"no\");\n }\n\n ;\n static void pryn(boolean b) {\n __out.println(b ? \"Yes\" : \"No\");\n }\n\n static void prYN(boolean b) {\n __out.println(b ? \"YES\" : \"NO\");\n }\n\n static void prln(int... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static void prln(long... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static <T> void prln(Collection<T> c) {\n int n = c.size() - 1;\n Iterator<T> iter = c.iterator();\n for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);\n if (n >= 0) {\n __out.println(iter.next());\n } else {\n __out.println();\n }\n }\n\n static void h() {\n __out.println(\"hlfd\");\n flush();\n }\n\n static void flush() {\n __out.flush();\n }\n\n static void close() {\n __out.close();\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"import static java.lang.Math.*;",
"import static java.lang.Math.*;",
"import static java.lang.Math.*;",
"import static java.util.Arrays.*;",
"import static java.util.Arrays.*;",
"import static java.util.Arrays.*;",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n\n int n = sc.nextInt();\n int start = sc.nextInt();\n // int max = start;\n long c = 0;\n for (int i = 0; i < n - 1; i++) {\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }\n\n prln(c);\n\n /*int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }*/\n /*for (int i = n - 1; i >= 0; i--) {\n //prln(\"**********\");\n //prln(\"##DB a[i] \" + a[i]);\n //prln(\"**********\");\n for (int j = i - 1; j >= 0; j--) {\n // prln(\"##DB a[j] \" + a[j]);\n if (a[j] > a[i]) {\n c++;\n }\n //prln(\"**\");\n }\n }*/\n close();\n }\n\n static FastReader sc = new FastReader();\n static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));\n static StringTokenizer input;\n static Random __rand = new Random();\n\n // input\n //*******FAST IO*************FAST IO***************FAST IO****************//\n static class FastReader {\n\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n// output\n\n static void pr(int i) {\n __out.print(i);\n }\n\n static void prln(int i) {\n __out.println(i);\n }\n\n static void pr(long l) {\n __out.print(l);\n }\n\n static void prln(long l) {\n __out.println(l);\n }\n\n static void pr(double d) {\n __out.print(d);\n }\n\n static void prln(double d) {\n __out.println(d);\n }\n\n static void pr(char c) {\n __out.print(c);\n }\n\n static void prln(char c) {\n __out.println(c);\n }\n\n static void pr(char[] s) {\n __out.print(new String(s));\n }\n\n static void prln(char[] s) {\n __out.println(new String(s));\n }\n\n static void pr(String s) {\n __out.print(s);\n }\n\n static void prln(String s) {\n __out.println(s);\n }\n\n static void pr(Object o) {\n __out.print(o);\n }\n\n static void prln(Object o) {\n __out.println(o);\n }\n\n static void prln() {\n __out.println();\n }\n\n static void pryes() {\n __out.println(\"yes\");\n }\n\n static void pry() {\n __out.println(\"Yes\");\n }\n\n static void prY() {\n __out.println(\"YES\");\n }\n\n static void prno() {\n __out.println(\"no\");\n }\n\n static void prn() {\n __out.println(\"No\");\n }\n\n static void prN() {\n __out.println(\"NO\");\n }\n\n static void pryesno(boolean b) {\n __out.println(b ? \"yes\" : \"no\");\n }\n\n ;\n static void pryn(boolean b) {\n __out.println(b ? \"Yes\" : \"No\");\n }\n\n static void prYN(boolean b) {\n __out.println(b ? \"YES\" : \"NO\");\n }\n\n static void prln(int... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static void prln(long... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static <T> void prln(Collection<T> c) {\n int n = c.size() - 1;\n Iterator<T> iter = c.iterator();\n for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);\n if (n >= 0) {\n __out.println(iter.next());\n } else {\n __out.println();\n }\n }\n\n static void h() {\n __out.println(\"hlfd\");\n flush();\n }\n\n static void flush() {\n __out.flush();\n }\n\n static void close() {\n __out.close();\n }\n}",
"Main",
"static FastReader sc = new FastReader();",
"sc",
"new FastReader()",
"static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));",
"__out",
"new PrintWriter(new OutputStreamWriter(System.out))",
"static StringTokenizer input;",
"input",
"static Random __rand = new Random();",
"__rand",
"new Random()",
"public static void main(String[] args) throws IOException {\n\n int n = sc.nextInt();\n int start = sc.nextInt();\n // int max = start;\n long c = 0;\n for (int i = 0; i < n - 1; i++) {\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }\n\n prln(c);\n\n /*int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }*/\n /*for (int i = n - 1; i >= 0; i--) {\n //prln(\"**********\");\n //prln(\"##DB a[i] \" + a[i]);\n //prln(\"**********\");\n for (int j = i - 1; j >= 0; j--) {\n // prln(\"##DB a[j] \" + a[j]);\n if (a[j] > a[i]) {\n c++;\n }\n //prln(\"**\");\n }\n }*/\n close();\n }",
"main",
"{\n\n int n = sc.nextInt();\n int start = sc.nextInt();\n // int max = start;\n long c = 0;\n for (int i = 0; i < n - 1; i++) {\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }\n\n prln(c);\n\n /*int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }*/\n /*for (int i = n - 1; i >= 0; i--) {\n //prln(\"**********\");\n //prln(\"##DB a[i] \" + a[i]);\n //prln(\"**********\");\n for (int j = i - 1; j >= 0; j--) {\n // prln(\"##DB a[j] \" + a[j]);\n if (a[j] > a[i]) {\n c++;\n }\n //prln(\"**\");\n }\n }*/\n close();\n }",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int start = sc.nextInt();",
"start",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long c = 0;",
"c",
"0",
"for (int i = 0; i < n - 1; i++) {\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n - 1",
"i",
"n - 1",
"n",
"1",
"i++",
"i++",
"i",
"{\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }",
"{\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }",
"int next = sc.nextInt();",
"next",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if (next < start) {\n c += start - next;\n } else {\n start = next;\n }",
"next < start",
"next",
"start",
"{\n c += start - next;\n }",
"c += start - next",
"c",
"start - next",
"start",
"next",
"{\n start = next;\n }",
"start = next",
"start",
"next",
"prln(c)",
"prln",
"c",
"close()",
"close",
"String[] args",
"args",
"static void pr(int i) {\n __out.print(i);\n }",
"pr",
"{\n __out.print(i);\n }",
"__out.print(i)",
"__out.print",
"__out",
"i",
"int i",
"i",
"static void prln(int i) {\n __out.println(i);\n }",
"prln",
"{\n __out.println(i);\n }",
"__out.println(i)",
"__out.println",
"__out",
"i",
"int i",
"i",
"static void pr(long l) {\n __out.print(l);\n }",
"pr",
"{\n __out.print(l);\n }",
"__out.print(l)",
"__out.print",
"__out",
"l",
"long l",
"l",
"static void prln(long l) {\n __out.println(l);\n }",
"prln",
"{\n __out.println(l);\n }",
"__out.println(l)",
"__out.println",
"__out",
"l",
"long l",
"l",
"static void pr(double d) {\n __out.print(d);\n }",
"pr",
"{\n __out.print(d);\n }",
"__out.print(d)",
"__out.print",
"__out",
"d",
"double d",
"d",
"static void prln(double d) {\n __out.println(d);\n }",
"prln",
"{\n __out.println(d);\n }",
"__out.println(d)",
"__out.println",
"__out",
"d",
"double d",
"d",
"static void pr(char c) {\n __out.print(c);\n }",
"pr",
"{\n __out.print(c);\n }",
"__out.print(c)",
"__out.print",
"__out",
"c",
"char c",
"c",
"static void prln(char c) {\n __out.println(c);\n }",
"prln",
"{\n __out.println(c);\n }",
"__out.println(c)",
"__out.println",
"__out",
"c",
"char c",
"c",
"static void pr(char[] s) {\n __out.print(new String(s));\n }",
"pr",
"{\n __out.print(new String(s));\n }",
"__out.print(new String(s))",
"__out.print",
"__out",
"new String(s)",
"char[] s",
"s",
"static void prln(char[] s) {\n __out.println(new String(s));\n }",
"prln",
"{\n __out.println(new String(s));\n }",
"__out.println(new String(s))",
"__out.println",
"__out",
"new String(s)",
"char[] s",
"s",
"static void pr(String s) {\n __out.print(s);\n }",
"pr",
"{\n __out.print(s);\n }",
"__out.print(s)",
"__out.print",
"__out",
"s",
"String s",
"s",
"static void prln(String s) {\n __out.println(s);\n }",
"prln",
"{\n __out.println(s);\n }",
"__out.println(s)",
"__out.println",
"__out",
"s",
"String s",
"s",
"static void pr(Object o) {\n __out.print(o);\n }",
"pr",
"{\n __out.print(o);\n }",
"__out.print(o)",
"__out.print",
"__out",
"o",
"Object o",
"o",
"static void prln(Object o) {\n __out.println(o);\n }",
"prln",
"{\n __out.println(o);\n }",
"__out.println(o)",
"__out.println",
"__out",
"o",
"Object o",
"o",
"static void prln() {\n __out.println();\n }",
"prln",
"{\n __out.println();\n }",
"__out.println()",
"__out.println",
"__out",
"static void pryes() {\n __out.println(\"yes\");\n }",
"pryes",
"{\n __out.println(\"yes\");\n }",
"__out.println(\"yes\")",
"__out.println",
"__out",
"\"yes\"",
"static void pry() {\n __out.println(\"Yes\");\n }",
"pry",
"{\n __out.println(\"Yes\");\n }",
"__out.println(\"Yes\")",
"__out.println",
"__out",
"\"Yes\"",
"static void prY() {\n __out.println(\"YES\");\n }",
"prY",
"{\n __out.println(\"YES\");\n }",
"__out.println(\"YES\")",
"__out.println",
"__out",
"\"YES\"",
"static void prno() {\n __out.println(\"no\");\n }",
"prno",
"{\n __out.println(\"no\");\n }",
"__out.println(\"no\")",
"__out.println",
"__out",
"\"no\"",
"static void prn() {\n __out.println(\"No\");\n }",
"prn",
"{\n __out.println(\"No\");\n }",
"__out.println(\"No\")",
"__out.println",
"__out",
"\"No\"",
"static void prN() {\n __out.println(\"NO\");\n }",
"prN",
"{\n __out.println(\"NO\");\n }",
"__out.println(\"NO\")",
"__out.println",
"__out",
"\"NO\"",
"static void pryesno(boolean b) {\n __out.println(b ? \"yes\" : \"no\");\n }",
"pryesno",
"{\n __out.println(b ? \"yes\" : \"no\");\n }",
"__out.println(b ? \"yes\" : \"no\")",
"__out.println",
"__out",
"b ? \"yes\" : \"no\"",
"b",
"\"yes\"",
"\"no\"",
"boolean b",
"b",
"static void pryn(boolean b) {\n __out.println(b ? \"Yes\" : \"No\");\n }",
"pryn",
"{\n __out.println(b ? \"Yes\" : \"No\");\n }",
"__out.println(b ? \"Yes\" : \"No\")",
"__out.println",
"__out",
"b ? \"Yes\" : \"No\"",
"b",
"\"Yes\"",
"\"No\"",
"boolean b",
"b",
"static void prYN(boolean b) {\n __out.println(b ? \"YES\" : \"NO\");\n }",
"prYN",
"{\n __out.println(b ? \"YES\" : \"NO\");\n }",
"__out.println(b ? \"YES\" : \"NO\")",
"__out.println",
"__out",
"b ? \"YES\" : \"NO\"",
"b",
"\"YES\"",
"\"NO\"",
"boolean b",
"b",
"static void prln(int... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }",
"prln",
"{\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }",
"for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);",
"int i = 0, len = a.length - 1;",
"int i = 0",
"i",
"0",
"len = a.length - 1;",
"len",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"i < len",
"i",
"len",
"__out.print(a[i]), __out.print(' '), ++i",
"__out.print(a[i])",
"__out.print",
"__out",
"a[i]",
"a",
"i",
"__out.print(' ')",
"__out.print",
"__out",
"' '",
"++i",
"i",
";",
"__out.println(a[a.length - 1])",
"__out.println",
"__out",
"a[a.length - 1]",
"a",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"int... a",
"a",
"static void prln(long... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }",
"prln",
"{\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }",
"for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);",
"int i = 0, len = a.length - 1;",
"int i = 0",
"i",
"0",
"len = a.length - 1;",
"len",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"i < len",
"i",
"len",
"__out.print(a[i]), __out.print(' '), ++i",
"__out.print(a[i])",
"__out.print",
"__out",
"a[i]",
"a",
"i",
"__out.print(' ')",
"__out.print",
"__out",
"' '",
"++i",
"i",
";",
"__out.println(a[a.length - 1])",
"__out.println",
"__out",
"a[a.length - 1]",
"a",
"a.length - 1",
"a.length",
"a",
"a.length",
"1",
"long... a",
"a",
"static <T> void prln(Collection<T> c) {\n int n = c.size() - 1;\n Iterator<T> iter = c.iterator();\n for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);\n if (n >= 0) {\n __out.println(iter.next());\n } else {\n __out.println();\n }\n }",
"prln",
"{\n int n = c.size() - 1;\n Iterator<T> iter = c.iterator();\n for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);\n if (n >= 0) {\n __out.println(iter.next());\n } else {\n __out.println();\n }\n }",
"int n = c.size() - 1;",
"n",
"c.size() - 1",
"c.size()",
"c.size",
"c",
"1",
"Iterator<T> iter = c.iterator();",
"iter",
"c.iterator()",
"c.iterator",
"c",
"for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"__out.print(iter.next()), __out.print(' '), ++i",
"__out.print(iter.next())",
"__out.print",
"__out",
"iter.next()",
"iter.next",
"iter",
"__out.print(' ')",
"__out.print",
"__out",
"' '",
"++i",
"i",
";",
"if (n >= 0) {\n __out.println(iter.next());\n } else {\n __out.println();\n }",
"n >= 0",
"n",
"0",
"{\n __out.println(iter.next());\n }",
"__out.println(iter.next())",
"__out.println",
"__out",
"iter.next()",
"iter.next",
"iter",
"{\n __out.println();\n }",
"__out.println()",
"__out.println",
"__out",
"Collection<T> c",
"c",
"static void h() {\n __out.println(\"hlfd\");\n flush();\n }",
"h",
"{\n __out.println(\"hlfd\");\n flush();\n }",
"__out.println(\"hlfd\")",
"__out.println",
"__out",
"\"hlfd\"",
"flush()",
"flush",
"static void flush() {\n __out.flush();\n }",
"flush",
"{\n __out.flush();\n }",
"__out.flush()",
"__out.flush",
"__out",
"static void close() {\n __out.close();\n }",
"close",
"{\n __out.close();\n }",
"__out.close()",
"__out.close",
"__out",
"static class FastReader {\n\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }",
"FastReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }",
"FastReader",
"{\n br = new BufferedReader(new InputStreamReader(System.in));\n }",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"next",
"{\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"try {\n st = new StringTokenizer(br.readLine());\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 st = new StringTokenizer(br.readLine());\n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }",
"nextLine",
"{\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }",
"String str = \"\";",
"str",
"\"\"",
"try {\n str = br.readLine();\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 str = br.readLine();\n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n\n int n = sc.nextInt();\n int start = sc.nextInt();\n // int max = start;\n long c = 0;\n for (int i = 0; i < n - 1; i++) {\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }\n\n prln(c);\n\n /*int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }*/\n /*for (int i = n - 1; i >= 0; i--) {\n //prln(\"**********\");\n //prln(\"##DB a[i] \" + a[i]);\n //prln(\"**********\");\n for (int j = i - 1; j >= 0; j--) {\n // prln(\"##DB a[j] \" + a[j]);\n if (a[j] > a[i]) {\n c++;\n }\n //prln(\"**\");\n }\n }*/\n close();\n }\n\n static FastReader sc = new FastReader();\n static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));\n static StringTokenizer input;\n static Random __rand = new Random();\n\n // input\n //*******FAST IO*************FAST IO***************FAST IO****************//\n static class FastReader {\n\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n// output\n\n static void pr(int i) {\n __out.print(i);\n }\n\n static void prln(int i) {\n __out.println(i);\n }\n\n static void pr(long l) {\n __out.print(l);\n }\n\n static void prln(long l) {\n __out.println(l);\n }\n\n static void pr(double d) {\n __out.print(d);\n }\n\n static void prln(double d) {\n __out.println(d);\n }\n\n static void pr(char c) {\n __out.print(c);\n }\n\n static void prln(char c) {\n __out.println(c);\n }\n\n static void pr(char[] s) {\n __out.print(new String(s));\n }\n\n static void prln(char[] s) {\n __out.println(new String(s));\n }\n\n static void pr(String s) {\n __out.print(s);\n }\n\n static void prln(String s) {\n __out.println(s);\n }\n\n static void pr(Object o) {\n __out.print(o);\n }\n\n static void prln(Object o) {\n __out.println(o);\n }\n\n static void prln() {\n __out.println();\n }\n\n static void pryes() {\n __out.println(\"yes\");\n }\n\n static void pry() {\n __out.println(\"Yes\");\n }\n\n static void prY() {\n __out.println(\"YES\");\n }\n\n static void prno() {\n __out.println(\"no\");\n }\n\n static void prn() {\n __out.println(\"No\");\n }\n\n static void prN() {\n __out.println(\"NO\");\n }\n\n static void pryesno(boolean b) {\n __out.println(b ? \"yes\" : \"no\");\n }\n\n ;\n static void pryn(boolean b) {\n __out.println(b ? \"Yes\" : \"No\");\n }\n\n static void prYN(boolean b) {\n __out.println(b ? \"YES\" : \"NO\");\n }\n\n static void prln(int... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static void prln(long... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static <T> void prln(Collection<T> c) {\n int n = c.size() - 1;\n Iterator<T> iter = c.iterator();\n for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);\n if (n >= 0) {\n __out.println(iter.next());\n } else {\n __out.println();\n }\n }\n\n static void h() {\n __out.println(\"hlfd\");\n flush();\n }\n\n static void flush() {\n __out.flush();\n }\n\n static void close() {\n __out.close();\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n\n int n = sc.nextInt();\n int start = sc.nextInt();\n // int max = start;\n long c = 0;\n for (int i = 0; i < n - 1; i++) {\n int next = sc.nextInt();\n if (next < start) {\n c += start - next;\n } else {\n start = next;\n }\n }\n\n prln(c);\n\n /*int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }*/\n /*for (int i = n - 1; i >= 0; i--) {\n //prln(\"**********\");\n //prln(\"##DB a[i] \" + a[i]);\n //prln(\"**********\");\n for (int j = i - 1; j >= 0; j--) {\n // prln(\"##DB a[j] \" + a[j]);\n if (a[j] > a[i]) {\n c++;\n }\n //prln(\"**\");\n }\n }*/\n close();\n }\n\n static FastReader sc = new FastReader();\n static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));\n static StringTokenizer input;\n static Random __rand = new Random();\n\n // input\n //*******FAST IO*************FAST IO***************FAST IO****************//\n static class FastReader {\n\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n// output\n\n static void pr(int i) {\n __out.print(i);\n }\n\n static void prln(int i) {\n __out.println(i);\n }\n\n static void pr(long l) {\n __out.print(l);\n }\n\n static void prln(long l) {\n __out.println(l);\n }\n\n static void pr(double d) {\n __out.print(d);\n }\n\n static void prln(double d) {\n __out.println(d);\n }\n\n static void pr(char c) {\n __out.print(c);\n }\n\n static void prln(char c) {\n __out.println(c);\n }\n\n static void pr(char[] s) {\n __out.print(new String(s));\n }\n\n static void prln(char[] s) {\n __out.println(new String(s));\n }\n\n static void pr(String s) {\n __out.print(s);\n }\n\n static void prln(String s) {\n __out.println(s);\n }\n\n static void pr(Object o) {\n __out.print(o);\n }\n\n static void prln(Object o) {\n __out.println(o);\n }\n\n static void prln() {\n __out.println();\n }\n\n static void pryes() {\n __out.println(\"yes\");\n }\n\n static void pry() {\n __out.println(\"Yes\");\n }\n\n static void prY() {\n __out.println(\"YES\");\n }\n\n static void prno() {\n __out.println(\"no\");\n }\n\n static void prn() {\n __out.println(\"No\");\n }\n\n static void prN() {\n __out.println(\"NO\");\n }\n\n static void pryesno(boolean b) {\n __out.println(b ? \"yes\" : \"no\");\n }\n\n ;\n static void pryn(boolean b) {\n __out.println(b ? \"Yes\" : \"No\");\n }\n\n static void prYN(boolean b) {\n __out.println(b ? \"YES\" : \"NO\");\n }\n\n static void prln(int... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static void prln(long... a) {\n for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);\n __out.println(a[a.length - 1]);\n }\n\n static <T> void prln(Collection<T> c) {\n int n = c.size() - 1;\n Iterator<T> iter = c.iterator();\n for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);\n if (n >= 0) {\n __out.println(iter.next());\n } else {\n __out.println();\n }\n }\n\n static void h() {\n __out.println(\"hlfd\");\n flush();\n }\n\n static void flush() {\n __out.flush();\n }\n\n static void close() {\n __out.close();\n }\n}",
"Main"
]
|
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
/**
* @author AnonymousP
* @__WHEN YOU FEEL LIKE QUITTING, THINK ABOUT WHY YOU STARTED__@
*/
//COMBINATON = nCr = n*(n-1)/2
public class Main {
public static void main(String[] args) throws IOException {
int n = sc.nextInt();
int start = sc.nextInt();
// int max = start;
long c = 0;
for (int i = 0; i < n - 1; i++) {
int next = sc.nextInt();
if (next < start) {
c += start - next;
} else {
start = next;
}
}
prln(c);
/*int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}*/
/*for (int i = n - 1; i >= 0; i--) {
//prln("**********");
//prln("##DB a[i] " + a[i]);
//prln("**********");
for (int j = i - 1; j >= 0; j--) {
// prln("##DB a[j] " + a[j]);
if (a[j] > a[i]) {
c++;
}
//prln("**");
}
}*/
close();
}
static FastReader sc = new FastReader();
static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
static StringTokenizer input;
static Random __rand = new Random();
// input
//*******FAST IO*************FAST IO***************FAST IO****************//
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// output
static void pr(int i) {
__out.print(i);
}
static void prln(int i) {
__out.println(i);
}
static void pr(long l) {
__out.print(l);
}
static void prln(long l) {
__out.println(l);
}
static void pr(double d) {
__out.print(d);
}
static void prln(double d) {
__out.println(d);
}
static void pr(char c) {
__out.print(c);
}
static void prln(char c) {
__out.println(c);
}
static void pr(char[] s) {
__out.print(new String(s));
}
static void prln(char[] s) {
__out.println(new String(s));
}
static void pr(String s) {
__out.print(s);
}
static void prln(String s) {
__out.println(s);
}
static void pr(Object o) {
__out.print(o);
}
static void prln(Object o) {
__out.println(o);
}
static void prln() {
__out.println();
}
static void pryes() {
__out.println("yes");
}
static void pry() {
__out.println("Yes");
}
static void prY() {
__out.println("YES");
}
static void prno() {
__out.println("no");
}
static void prn() {
__out.println("No");
}
static void prN() {
__out.println("NO");
}
static void pryesno(boolean b) {
__out.println(b ? "yes" : "no");
}
;
static void pryn(boolean b) {
__out.println(b ? "Yes" : "No");
}
static void prYN(boolean b) {
__out.println(b ? "YES" : "NO");
}
static void prln(int... a) {
for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
__out.println(a[a.length - 1]);
}
static void prln(long... a) {
for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
__out.println(a[a.length - 1]);
}
static <T> void prln(Collection<T> c) {
int n = c.size() - 1;
Iterator<T> iter = c.iterator();
for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
if (n >= 0) {
__out.println(iter.next());
} else {
__out.println();
}
}
static void h() {
__out.println("hlfd");
flush();
}
static void flush() {
__out.flush();
}
static void close() {
__out.close();
}
}
|
[
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,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
2,
13,
13,
14,
2,
13,
13,
30,
0,
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,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
13,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
42,
40,
4,
18,
13,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
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
],
[
248,
50
],
[
248,
51
],
[
51,
52
],
[
51,
53
],
[
248,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
56,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
56,
70
],
[
70,
71
],
[
70,
72
],
[
56,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
73,
78
],
[
78,
79
],
[
78,
80
],
[
73,
81
],
[
81,
82
],
[
82,
83
],
[
73,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
85,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
85,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
56,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
54,
117
],
[
117,
118
],
[
248,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
121,
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
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
139,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
148,
150
],
[
139,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
155,
157
],
[
139,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
121,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
119,
167
],
[
167,
168
],
[
248,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
174,
175
],
[
174,
176
],
[
169,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
180,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
185,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
179,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
169,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
204,
207
],
[
207,
208
],
[
169,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
211,
216
],
[
216,
217
],
[
217,
218
],
[
218,
219
],
[
218,
220
],
[
216,
221
],
[
221,
222
],
[
221,
223
],
[
216,
224
],
[
224,
225
],
[
225,
226
],
[
216,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
228,
232
],
[
232,
233
],
[
211,
234
],
[
234,
235
],
[
209,
236
],
[
236,
237
],
[
169,
238
],
[
238,
239
],
[
238,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
243,
244
],
[
242,
245
],
[
245,
246
],
[
0,
247
],
[
247,
248
],
[
247,
249
]
]
| [
"\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.lang.annotation.Target;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.FormatFlagsConversionMismatchException;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Random;\nimport java.util.StringTokenizer;\n\nimport javax.naming.spi.DirStateFactory.Result;\nimport javax.swing.text.AbstractDocument.BranchElement;\n\nimport org.w3c.dom.css.Counter;\n \npublic class Main {\n\n\t\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs=new FastScanner();\n\t\tint first = fs.nextInt();\n\t\tint temp = fs.nextInt();\n\t\tlong sum=0;\n\t\tfor (int i = 1; i < first; i++) {\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\t\n \n\tstatic final Random random=new Random();\n\t\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\t\n\tstatic class FastScanner {\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st=new StringTokenizer(\"\");\n\t\tString next() {\n\t\t\twhile (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\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",
"import java.lang.annotation.Target;",
"Target",
"java.lang.annotation",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.FormatFlagsConversionMismatchException;",
"FormatFlagsConversionMismatchException",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.HashSet;",
"HashSet",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Random;",
"Random",
"java.util",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"import javax.naming.spi.DirStateFactory.Result;",
"Result",
"javax.naming.spi.DirStateFactory",
"import javax.swing.text.AbstractDocument.BranchElement;",
"BranchElement",
"javax.swing.text.AbstractDocument",
"import org.w3c.dom.css.Counter;",
"Counter",
"org.w3c.dom.css",
"public class Main {\n\n\t\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs=new FastScanner();\n\t\tint first = fs.nextInt();\n\t\tint temp = fs.nextInt();\n\t\tlong sum=0;\n\t\tfor (int i = 1; i < first; i++) {\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\t\n \n\tstatic final Random random=new Random();\n\t\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\t\n\tstatic class FastScanner {\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st=new StringTokenizer(\"\");\n\t\tString next() {\n\t\t\twhile (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n \n\t\n}",
"Main",
"static final Random random=new Random();",
"random",
"new Random()",
"public static void main(String[] args) {\n\t\tFastScanner fs=new FastScanner();\n\t\tint first = fs.nextInt();\n\t\tint temp = fs.nextInt();\n\t\tlong sum=0;\n\t\tfor (int i = 1; i < first; i++) {\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}",
"main",
"{\n\t\tFastScanner fs=new FastScanner();\n\t\tint first = fs.nextInt();\n\t\tint temp = fs.nextInt();\n\t\tlong sum=0;\n\t\tfor (int i = 1; i < first; i++) {\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}",
"FastScanner fs=new FastScanner();",
"fs",
"new FastScanner()",
"int first = fs.nextInt();",
"first",
"fs.nextInt()",
"fs.nextInt",
"fs",
"int temp = fs.nextInt();",
"temp",
"fs.nextInt()",
"fs.nextInt",
"fs",
"long sum=0;",
"sum",
"0",
"for (int i = 1; i < first; i++) {\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < first",
"i",
"first",
"i++",
"i++",
"i",
"{\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}",
"{\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}",
"int sec = fs.nextInt();",
"sec",
"fs.nextInt()",
"fs.nextInt",
"fs",
"if(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}",
"sec<temp",
"sec",
"temp",
"{\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}",
"sum=sum+(temp-sec)",
"sum",
"sum+(temp-sec)",
"sum",
"(temp-sec)",
"temp",
"sec",
"if(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}",
"sec>temp",
"sec",
"temp",
"{\n\t\t\t\ttemp=sec;\n\t\t\t}",
"temp=sec",
"temp",
"sec",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"static void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}",
"ruffleSort",
"{\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}",
"int n=a.length;",
"n",
"a.length",
"a",
"a.length",
"for (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"{\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"int oi=random.nextInt(n)",
"oi",
"random.nextInt(n)",
"random.nextInt",
"random",
"n",
"temp=a[oi];",
"temp",
"a[oi]",
"a",
"oi",
"a[oi]=a[i]",
"a[oi]",
"a",
"oi",
"a[i]",
"a",
"i",
"a[i]=temp",
"a[i]",
"a",
"i",
"temp",
"Arrays.sort(a)",
"Arrays.sort",
"Arrays",
"a",
"int[] a",
"a",
"static class FastScanner {\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st=new StringTokenizer(\"\");\n\t\tString next() {\n\t\t\twhile (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}",
"FastScanner",
"BufferedReader br=new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"StringTokenizer st=new StringTokenizer(\"\");",
"st",
"new StringTokenizer(\"\")",
"String next() {\n\t\t\twhile (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"next",
"{\n\t\t\twhile (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"while (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"try {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"IOException e",
"{\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t}",
"st=new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"nextInt",
"{\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"int[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}",
"readArray",
"{\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}",
"int[] a=new int[n];",
"a",
"new int[n]",
"n",
"for (int i=0; i<n; i++) a[i]=nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=nextInt();",
"a[i]=nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int n",
"n",
"long nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"nextLong",
"{\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"public class Main {\n\n\t\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs=new FastScanner();\n\t\tint first = fs.nextInt();\n\t\tint temp = fs.nextInt();\n\t\tlong sum=0;\n\t\tfor (int i = 1; i < first; i++) {\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\t\n \n\tstatic final Random random=new Random();\n\t\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\t\n\tstatic class FastScanner {\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st=new StringTokenizer(\"\");\n\t\tString next() {\n\t\t\twhile (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n \n\t\n}",
"public class Main {\n\n\t\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs=new FastScanner();\n\t\tint first = fs.nextInt();\n\t\tint temp = fs.nextInt();\n\t\tlong sum=0;\n\t\tfor (int i = 1; i < first; i++) {\n\t\t\tint sec = fs.nextInt();\n\t\t\tif(sec<temp) {\n\t\t\t\tsum=sum+(temp-sec);\n\t\t\t}\n\t\t\tif(sec>temp) {\n\t\t\t\ttemp=sec;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n\t\n \n\tstatic final Random random=new Random();\n\t\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\t\n\tstatic class FastScanner {\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st=new StringTokenizer(\"\");\n\t\tString next() {\n\t\t\twhile (!st.hasMoreTokens())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n \n\t\n}",
"Main"
]
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.FormatFlagsConversionMismatchException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.StringTokenizer;
import javax.naming.spi.DirStateFactory.Result;
import javax.swing.text.AbstractDocument.BranchElement;
import org.w3c.dom.css.Counter;
public class Main {
public static void main(String[] args) {
FastScanner fs=new FastScanner();
int first = fs.nextInt();
int temp = fs.nextInt();
long sum=0;
for (int i = 1; i < first; i++) {
int sec = fs.nextInt();
if(sec<temp) {
sum=sum+(temp-sec);
}
if(sec>temp) {
temp=sec;
}
}
System.out.println(sum);
}
static final Random random=new Random();
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
} |
[
7,
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,
17,
42,
2,
40,
13,
17,
30,
4,
13,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
13,
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,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
13,
13,
23,
13,
23,
13,
6,
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,
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
],
[
181,
17
],
[
181,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
23,
25
],
[
20,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
20,
31
],
[
31,
32
],
[
31,
33
],
[
20,
34
],
[
34,
35
],
[
34,
36
],
[
20,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
40,
44
],
[
40,
45
],
[
20,
46
],
[
46,
47
],
[
47,
48
],
[
18,
49
],
[
49,
50
],
[
181,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
59,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
65,
68
],
[
53,
69
],
[
69,
70
],
[
53,
71
],
[
71,
72
],
[
53,
73
],
[
73,
74
],
[
51,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
77,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
85,
89
],
[
77,
90
],
[
90,
91
],
[
90,
92
],
[
77,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
93,
98
],
[
98,
99
],
[
98,
100
],
[
93,
101
],
[
101,
102
],
[
102,
103
],
[
93,
104
],
[
105,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
110,
112
],
[
107,
113
],
[
113,
114
],
[
113,
115
],
[
106,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
125,
126
],
[
125,
127
],
[
116,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
77,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
75,
141
],
[
141,
142
],
[
75,
143
],
[
143,
144
],
[
181,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
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
],
[
149,
174
],
[
174,
175
],
[
147,
176
],
[
176,
177
],
[
147,
178
],
[
178,
179
],
[
0,
180
],
[
180,
181
],
[
180,
182
]
]
| [
"import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main\n{\n public static void main(String[] args)\n {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskC solver = new TaskC();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskC\n {\n public void solve(int testNumber, Scanner in, PrintWriter out)\n {\n int T = 1;\n while (T-- > 0)\n {\n solveOne(in, out);\n }\n }\n\n private void solveOne(Scanner in, PrintWriter out)\n {\n int N = in.nextInt();\n int H[] = CPUtils.readIntArray(N, in);\n\n long ans = 0;\n for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }\n out.println(ans);\n }\n\n }\n\n static class CPUtils\n {\n public static int[] readIntArray(int size, Scanner in)\n {\n int[] array = new int[size];\n for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }\n return array;\n }\n\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.Scanner;",
"Scanner",
"java.util",
"public class Main\n{\n public static void main(String[] args)\n {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskC solver = new TaskC();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskC\n {\n public void solve(int testNumber, Scanner in, PrintWriter out)\n {\n int T = 1;\n while (T-- > 0)\n {\n solveOne(in, out);\n }\n }\n\n private void solveOne(Scanner in, PrintWriter out)\n {\n int N = in.nextInt();\n int H[] = CPUtils.readIntArray(N, in);\n\n long ans = 0;\n for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }\n out.println(ans);\n }\n\n }\n\n static class CPUtils\n {\n public static int[] readIntArray(int size, Scanner in)\n {\n int[] array = new int[size];\n for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }\n return array;\n }\n\n }\n}",
"Main",
"public static void main(String[] args)\n {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskC solver = new TaskC();\n solver.solve(1, in, out);\n out.close();\n }",
"main",
"{\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskC solver = new TaskC();\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",
"Scanner in = new Scanner(inputStream);",
"in",
"new Scanner(inputStream)",
"PrintWriter out = new PrintWriter(outputStream);",
"out",
"new PrintWriter(outputStream)",
"TaskC solver = new TaskC();",
"solver",
"new TaskC()",
"solver.solve(1, in, out)",
"solver.solve",
"solver",
"1",
"in",
"out",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"static class TaskC\n {\n public void solve(int testNumber, Scanner in, PrintWriter out)\n {\n int T = 1;\n while (T-- > 0)\n {\n solveOne(in, out);\n }\n }\n\n private void solveOne(Scanner in, PrintWriter out)\n {\n int N = in.nextInt();\n int H[] = CPUtils.readIntArray(N, in);\n\n long ans = 0;\n for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }\n out.println(ans);\n }\n\n }",
"TaskC",
"public void solve(int testNumber, Scanner in, PrintWriter out)\n {\n int T = 1;\n while (T-- > 0)\n {\n solveOne(in, out);\n }\n }",
"solve",
"{\n int T = 1;\n while (T-- > 0)\n {\n solveOne(in, out);\n }\n }",
"int T = 1;",
"T",
"1",
"while (T-- > 0)\n {\n solveOne(in, out);\n }",
"T-- > 0",
"T--",
"T",
"0",
"{\n solveOne(in, out);\n }",
"solveOne(in, out)",
"solveOne",
"in",
"out",
"int testNumber",
"testNumber",
"Scanner in",
"in",
"PrintWriter out",
"out",
"private void solveOne(Scanner in, PrintWriter out)\n {\n int N = in.nextInt();\n int H[] = CPUtils.readIntArray(N, in);\n\n long ans = 0;\n for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }\n out.println(ans);\n }",
"solveOne",
"{\n int N = in.nextInt();\n int H[] = CPUtils.readIntArray(N, in);\n\n long ans = 0;\n for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }\n out.println(ans);\n }",
"int N = in.nextInt();",
"N",
"in.nextInt()",
"in.nextInt",
"in",
"int H[] = CPUtils.readIntArray(N, in);",
"H",
"CPUtils.readIntArray(N, in)",
"CPUtils.readIntArray",
"CPUtils",
"N",
"in",
"long ans = 0;",
"ans",
"0",
"for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }",
"{\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }",
"if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }",
"H[i - 1] > H[i]",
"H[i - 1]",
"H",
"i - 1",
"i",
"1",
"H[i]",
"H",
"i",
"{\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }",
"ans += H[i - 1] - H[i]",
"ans",
"H[i - 1] - H[i]",
"H[i - 1]",
"H",
"i - 1",
"i",
"1",
"H[i]",
"H",
"i",
"H[i] = H[i - 1]",
"H[i]",
"H",
"i",
"H[i - 1]",
"H",
"i - 1",
"i",
"1",
"out.println(ans)",
"out.println",
"out",
"ans",
"Scanner in",
"in",
"PrintWriter out",
"out",
"static class CPUtils\n {\n public static int[] readIntArray(int size, Scanner in)\n {\n int[] array = new int[size];\n for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }\n return array;\n }\n\n }",
"CPUtils",
"public static int[] readIntArray(int size, Scanner in)\n {\n int[] array = new int[size];\n for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }\n return array;\n }",
"readIntArray",
"{\n int[] array = new int[size];\n for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }\n return array;\n }",
"int[] array = new int[size];",
"array",
"new int[size]",
"size",
"for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < size",
"i",
"size",
"i++",
"i++",
"i",
"{\n array[i] = in.nextInt();\n }",
"{\n array[i] = in.nextInt();\n }",
"array[i] = in.nextInt()",
"array[i]",
"array",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"return array;",
"array",
"int size",
"size",
"Scanner in",
"in",
"public class Main\n{\n public static void main(String[] args)\n {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskC solver = new TaskC();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskC\n {\n public void solve(int testNumber, Scanner in, PrintWriter out)\n {\n int T = 1;\n while (T-- > 0)\n {\n solveOne(in, out);\n }\n }\n\n private void solveOne(Scanner in, PrintWriter out)\n {\n int N = in.nextInt();\n int H[] = CPUtils.readIntArray(N, in);\n\n long ans = 0;\n for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }\n out.println(ans);\n }\n\n }\n\n static class CPUtils\n {\n public static int[] readIntArray(int size, Scanner in)\n {\n int[] array = new int[size];\n for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }\n return array;\n }\n\n }\n}",
"public class Main\n{\n public static void main(String[] args)\n {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskC solver = new TaskC();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskC\n {\n public void solve(int testNumber, Scanner in, PrintWriter out)\n {\n int T = 1;\n while (T-- > 0)\n {\n solveOne(in, out);\n }\n }\n\n private void solveOne(Scanner in, PrintWriter out)\n {\n int N = in.nextInt();\n int H[] = CPUtils.readIntArray(N, in);\n\n long ans = 0;\n for (int i = 1; i < N; i++)\n {\n if (H[i - 1] > H[i])\n {\n ans += H[i - 1] - H[i];\n H[i] = H[i - 1];\n }\n }\n out.println(ans);\n }\n\n }\n\n static class CPUtils\n {\n public static int[] readIntArray(int size, Scanner in)\n {\n int[] array = new int[size];\n for (int i = 0; i < size; i++)\n {\n array[i] = in.nextInt();\n }\n return array;\n }\n\n }\n}",
"Main"
]
| import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main
{
public static void main(String[] args)
{
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskC solver = new TaskC();
solver.solve(1, in, out);
out.close();
}
static class TaskC
{
public void solve(int testNumber, Scanner in, PrintWriter out)
{
int T = 1;
while (T-- > 0)
{
solveOne(in, out);
}
}
private void solveOne(Scanner in, PrintWriter out)
{
int N = in.nextInt();
int H[] = CPUtils.readIntArray(N, in);
long ans = 0;
for (int i = 1; i < N; i++)
{
if (H[i - 1] > H[i])
{
ans += H[i - 1] - H[i];
H[i] = H[i - 1];
}
}
out.println(ans);
}
}
static class CPUtils
{
public static int[] readIntArray(int size, Scanner in)
{
int[] array = new int[size];
for (int i = 0; i < size; i++)
{
array[i] = in.nextInt();
}
return array;
}
}
}
|
[
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,
13,
41,
13,
17,
0,
18,
13,
17,
4,
18,
13,
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,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
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
],
[
108,
5
],
[
108,
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
],
[
8,
32
],
[
32,
33
],
[
32,
34
],
[
8,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
8,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
62,
65
],
[
65,
66
],
[
65,
67
],
[
57,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
69,
75
],
[
75,
76
],
[
75,
77
],
[
68,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
78,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
8,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
6,
105
],
[
105,
106
],
[
0,
107
],
[
107,
108
],
[
107,
109
]
]
| [
"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 = Integer.parseInt(sc.nextLine());\n\t\tString[] tmp = sc.nextLine().split(\" \");\n\t\tlong[] list = new long[n];\n\t\tlong ans = 0;\n\n\n\t\tlist[0] = Long.parseLong(tmp[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\t}\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 = Integer.parseInt(sc.nextLine());\n\t\tString[] tmp = sc.nextLine().split(\" \");\n\t\tlong[] list = new long[n];\n\t\tlong ans = 0;\n\n\n\t\tlist[0] = Long.parseLong(tmp[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = Integer.parseInt(sc.nextLine());\n\t\tString[] tmp = sc.nextLine().split(\" \");\n\t\tlong[] list = new long[n];\n\t\tlong ans = 0;\n\n\n\t\tlist[0] = Long.parseLong(tmp[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = Integer.parseInt(sc.nextLine());\n\t\tString[] tmp = sc.nextLine().split(\" \");\n\t\tlong[] list = new long[n];\n\t\tlong ans = 0;\n\n\n\t\tlist[0] = Long.parseLong(tmp[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\n\t}",
"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",
"String[] tmp = sc.nextLine().split(\" \");",
"tmp",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"long[] list = new long[n];",
"list",
"new long[n]",
"n",
"long ans = 0;",
"ans",
"0",
"list[0] = Long.parseLong(tmp[0])",
"list[0]",
"list",
"0",
"Long.parseLong(tmp[0])",
"Long.parseLong",
"Long",
"tmp[0]",
"tmp",
"0",
"for(int i = 1; i < n; i++) {\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}",
"{\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}",
"list[i] = Long.parseLong(tmp[i])",
"list[i]",
"list",
"i",
"Long.parseLong(tmp[i])",
"Long.parseLong",
"Long",
"tmp[i]",
"tmp",
"i",
"if(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}",
"list[i - 1] > list[i]",
"list[i - 1]",
"list",
"i - 1",
"i",
"1",
"list[i]",
"list",
"i",
"{\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}",
"ans += list[i - 1] - list[i]",
"ans",
"list[i - 1] - list[i]",
"list[i - 1]",
"list",
"i - 1",
"i",
"1",
"list[i]",
"list",
"i",
"list[i] = list[i - 1]",
"list[i]",
"list",
"i",
"list[i - 1]",
"list",
"i - 1",
"i",
"1",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = Integer.parseInt(sc.nextLine());\n\t\tString[] tmp = sc.nextLine().split(\" \");\n\t\tlong[] list = new long[n];\n\t\tlong ans = 0;\n\n\n\t\tlist[0] = Long.parseLong(tmp[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\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 = Integer.parseInt(sc.nextLine());\n\t\tString[] tmp = sc.nextLine().split(\" \");\n\t\tlong[] list = new long[n];\n\t\tlong ans = 0;\n\n\n\t\tlist[0] = Long.parseLong(tmp[0]);\n\t\tfor(int i = 1; i < n; i++) {\n\n\t\t\tlist[i] = Long.parseLong(tmp[i]);\n\n\t\t\tif(list[i - 1] > list[i]) {\n\n\t\t\t\tans += list[i - 1] - list[i];\n\t\t\t\tlist[i] = list[i - 1];\n\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(ans);\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.parseInt(sc.nextLine());
String[] tmp = sc.nextLine().split(" ");
long[] list = new long[n];
long ans = 0;
list[0] = Long.parseLong(tmp[0]);
for(int i = 1; i < n; i++) {
list[i] = Long.parseLong(tmp[i]);
if(list[i - 1] > list[i]) {
ans += list[i - 1] - list[i];
list[i] = list[i - 1];
}
}
System.out.println(ans);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
2,
17,
17,
41,
13,
2,
17,
17,
41,
13,
17,
41,
13,
17,
41,
13,
2,
17,
17,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
41,
13,
4,
13,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
4,
13,
13,
23,
13,
12,
13,
30,
4,
18,
20,
23,
13,
12,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
29,
17,
41,
13,
17,
11,
1,
41,
13,
13,
2,
13,
17,
1,
0,
13,
17,
30,
30,
14,
2,
2,
13,
17,
17,
0,
13,
2,
2,
13,
13,
13,
0,
13,
2,
2,
13,
13,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
2,
13,
17,
2,
13,
17,
1,
0,
13,
17,
30,
30,
14,
2,
2,
13,
17,
17,
0,
13,
2,
2,
13,
13,
13,
0,
13,
2,
2,
13,
13,
13,
29,
13,
23,
13,
12,
13,
30,
29,
8,
2,
13,
17,
13,
4,
13,
13,
2,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
8,
2,
13,
17,
13,
4,
13,
13,
2,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
13,
8,
4,
18,
13,
18,
13,
13,
20,
0,
13,
20,
41,
13,
4,
18,
13,
41,
13,
8,
13,
4,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
4,
13,
13,
4,
18,
13,
14,
40,
4,
18,
13,
4,
13,
2,
2,
4,
18,
13,
13,
17,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
17,
42,
2,
2,
0,
13,
4,
13,
40,
17,
40,
2,
2,
2,
13,
17,
2,
13,
17,
2,
13,
17,
14,
2,
13,
17,
30,
0,
13,
17,
0,
13,
4,
13,
42,
17,
30,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
2,
2,
13,
17,
2,
13,
17,
30,
29,
8,
13,
40,
13,
13,
0,
13,
4,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
17,
42,
2,
2,
0,
13,
4,
13,
40,
17,
40,
2,
2,
2,
13,
17,
2,
13,
17,
2,
13,
17,
14,
2,
13,
17,
30,
0,
13,
17,
0,
13,
4,
13,
42,
17,
30,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
2,
2,
13,
17,
2,
13,
17,
30,
29,
8,
13,
40,
13,
13,
0,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
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,
29,
40,
2,
2,
13,
17,
2,
13,
17,
23,
13,
12,
13,
30,
41,
13,
42,
2,
2,
0,
13,
4,
13,
40,
17,
4,
13,
13,
29,
13,
12,
13,
30,
41,
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,
20,
13,
41,
13,
4,
13,
41,
13,
17,
42,
2,
2,
13,
13,
40,
4,
13,
13,
30,
0,
18,
13,
40,
13,
13,
0,
13,
4,
13,
29,
8,
2,
13,
13,
13,
4,
18,
13,
13,
13,
23,
13,
12,
13,
30,
14,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
4,
18,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
693,
8
],
[
693,
9
],
[
9,
10
],
[
693,
11
],
[
11,
12
],
[
693,
13
],
[
13,
14
],
[
13,
15
],
[
693,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
18,
20
],
[
693,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
23,
25
],
[
693,
26
],
[
26,
27
],
[
26,
28
],
[
693,
29
],
[
29,
30
],
[
29,
31
],
[
693,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
34,
36
],
[
693,
37
],
[
37,
38
],
[
37,
39
],
[
693,
41
],
[
41,
42
],
[
41,
43
],
[
693,
44
],
[
44,
45
],
[
44,
46
],
[
693,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
58
],
[
58,
59
],
[
58,
60
],
[
49,
61
],
[
61,
62
],
[
61,
63
],
[
49,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
69,
70
],
[
69,
71
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
49,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
87,
88
],
[
87,
89
],
[
82,
90
],
[
90,
91
],
[
91,
92
],
[
82,
93
],
[
94,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
97,
101
],
[
101,
102
],
[
101,
103
],
[
94,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
49,
111
],
[
111,
112
],
[
111,
113
],
[
47,
114
],
[
114,
115
],
[
693,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
693,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
132,
134
],
[
127,
135
],
[
135,
136
],
[
126,
137
],
[
137,
138
],
[
137,
139
],
[
126,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
145,
147
],
[
140,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
140,
152
],
[
153,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
154,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
153,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
126,
174
],
[
174,
175
],
[
124,
176
],
[
176,
177
],
[
124,
178
],
[
178,
179
],
[
693,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
190,
192
],
[
186,
193
],
[
193,
194
],
[
193,
195
],
[
186,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
186,
200
],
[
201,
201
],
[
201,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
202,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
211,
213
],
[
210,
214
],
[
201,
215
],
[
215,
216
],
[
215,
217
],
[
217,
218
],
[
218,
219
],
[
218,
220
],
[
217,
221
],
[
182,
222
],
[
222,
223
],
[
180,
224
],
[
224,
225
],
[
693,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
231,
232
],
[
231,
233
],
[
230,
234
],
[
230,
235
],
[
235,
236
],
[
235,
237
],
[
235,
238
],
[
238,
239
],
[
238,
240
],
[
226,
241
],
[
241,
242
],
[
226,
243
],
[
243,
244
],
[
693,
245
],
[
245,
246
],
[
245,
247
],
[
247,
248
],
[
248,
249
],
[
249,
250
],
[
250,
251
],
[
250,
252
],
[
249,
253
],
[
249,
254
],
[
254,
255
],
[
254,
256
],
[
254,
257
],
[
257,
258
],
[
257,
259
],
[
245,
260
],
[
260,
261
],
[
245,
262
],
[
262,
263
],
[
693,
264
],
[
264,
265
],
[
264,
266
],
[
266,
267
],
[
267,
268
],
[
267,
269
],
[
269,
270
],
[
270,
271
],
[
271,
272
],
[
269,
273
],
[
273,
274
],
[
273,
275
],
[
269,
276
],
[
266,
277
],
[
277,
278
],
[
277,
279
],
[
266,
280
],
[
280,
281
],
[
280,
282
],
[
282,
283
],
[
283,
284
],
[
266,
285
],
[
285,
286
],
[
285,
287
],
[
287,
288
],
[
287,
289
],
[
289,
290
],
[
287,
291
],
[
266,
292
],
[
292,
293
],
[
293,
294
],
[
294,
295
],
[
294,
296
],
[
292,
297
],
[
297,
298
],
[
297,
299
],
[
292,
300
],
[
300,
301
],
[
301,
302
],
[
292,
303
],
[
303,
304
],
[
304,
305
],
[
304,
306
],
[
266,
307
],
[
307,
308
],
[
308,
309
],
[
266,
310
],
[
310,
311
],
[
311,
312
],
[
312,
313
],
[
313,
314
],
[
310,
315
],
[
315,
316
],
[
315,
317
],
[
317,
318
],
[
318,
319
],
[
319,
320
],
[
320,
321
],
[
318,
322
],
[
317,
323
],
[
693,
324
],
[
324,
325
],
[
324,
326
],
[
326,
327
],
[
327,
328
],
[
328,
329
],
[
327,
330
],
[
324,
331
],
[
331,
332
],
[
693,
333
],
[
333,
334
],
[
333,
335
],
[
335,
336
],
[
336,
337
],
[
337,
338
],
[
336,
339
],
[
333,
340
],
[
340,
341
],
[
693,
342
],
[
342,
343
],
[
342,
344
],
[
344,
345
],
[
345,
346
],
[
346,
347
],
[
345,
348
],
[
344,
349
],
[
349,
350
],
[
350,
351
],
[
342,
352
],
[
352,
353
],
[
693,
354
],
[
354,
355
],
[
354,
356
],
[
356,
357
],
[
357,
358
],
[
357,
359
],
[
356,
360
],
[
360,
361
],
[
356,
362
],
[
362,
363
],
[
362,
364
],
[
356,
365
],
[
365,
366
],
[
366,
367
],
[
367,
368
],
[
368,
369
],
[
368,
370
],
[
370,
371
],
[
367,
372
],
[
372,
373
],
[
366,
374
],
[
374,
375
],
[
375,
376
],
[
376,
377
],
[
377,
378
],
[
377,
379
],
[
376,
380
],
[
380,
381
],
[
380,
382
],
[
375,
383
],
[
383,
384
],
[
383,
385
],
[
356,
386
],
[
386,
387
],
[
387,
388
],
[
387,
389
],
[
386,
390
],
[
390,
391
],
[
391,
392
],
[
391,
393
],
[
390,
394
],
[
394,
395
],
[
394,
396
],
[
396,
397
],
[
356,
398
],
[
398,
399
],
[
398,
400
],
[
400,
401
],
[
401,
402
],
[
402,
403
],
[
403,
404
],
[
403,
405
],
[
402,
406
],
[
406,
407
],
[
406,
408
],
[
401,
409
],
[
409,
410
],
[
410,
411
],
[
410,
412
],
[
412,
413
],
[
413,
414
],
[
413,
415
],
[
412,
416
],
[
416,
417
],
[
416,
418
],
[
401,
419
],
[
419,
420
],
[
420,
421
],
[
421,
422
],
[
421,
423
],
[
423,
424
],
[
421,
425
],
[
400,
426
],
[
426,
427
],
[
426,
428
],
[
428,
429
],
[
693,
430
],
[
430,
431
],
[
430,
432
],
[
432,
433
],
[
433,
434
],
[
433,
435
],
[
432,
436
],
[
436,
437
],
[
432,
438
],
[
438,
439
],
[
438,
440
],
[
432,
441
],
[
441,
442
],
[
442,
443
],
[
443,
444
],
[
444,
445
],
[
444,
446
],
[
446,
447
],
[
443,
448
],
[
448,
449
],
[
442,
450
],
[
450,
451
],
[
451,
452
],
[
452,
453
],
[
453,
454
],
[
453,
455
],
[
452,
456
],
[
456,
457
],
[
456,
458
],
[
451,
459
],
[
459,
460
],
[
459,
461
],
[
432,
462
],
[
462,
463
],
[
463,
464
],
[
463,
465
],
[
462,
466
],
[
466,
467
],
[
467,
468
],
[
467,
469
],
[
466,
470
],
[
470,
471
],
[
470,
472
],
[
472,
473
],
[
432,
474
],
[
474,
475
],
[
474,
476
],
[
476,
477
],
[
477,
478
],
[
478,
479
],
[
479,
480
],
[
479,
481
],
[
478,
482
],
[
482,
483
],
[
482,
484
],
[
477,
485
],
[
485,
486
],
[
486,
487
],
[
486,
488
],
[
488,
489
],
[
489,
490
],
[
489,
491
],
[
488,
492
],
[
492,
493
],
[
492,
494
],
[
477,
495
],
[
495,
496
],
[
496,
497
],
[
497,
498
],
[
497,
499
],
[
499,
500
],
[
497,
501
],
[
476,
502
],
[
502,
503
],
[
502,
504
],
[
504,
505
],
[
693,
506
],
[
506,
507
],
[
506,
508
],
[
508,
509
],
[
509,
510
],
[
510,
511
],
[
511,
512
],
[
510,
513
],
[
513,
514
],
[
693,
515
],
[
515,
516
],
[
515,
517
],
[
517,
518
],
[
518,
519
],
[
519,
520
],
[
693,
521
],
[
521,
522
],
[
521,
523
],
[
523,
524
],
[
524,
525
],
[
525,
526
],
[
525,
527
],
[
527,
528
],
[
524,
529
],
[
529,
530
],
[
523,
531
],
[
531,
532
],
[
532,
533
],
[
532,
534
],
[
531,
535
],
[
535,
536
],
[
536,
537
],
[
536,
538
],
[
535,
539
],
[
539,
540
],
[
540,
541
],
[
540,
542
],
[
542,
543
],
[
543,
544
],
[
539,
545
],
[
545,
546
],
[
546,
547
],
[
546,
548
],
[
548,
549
],
[
549,
550
],
[
548,
551
],
[
535,
552
],
[
552,
553
],
[
553,
554
],
[
553,
555
],
[
552,
556
],
[
556,
557
],
[
557,
558
],
[
523,
559
],
[
559,
560
],
[
560,
561
],
[
560,
562
],
[
562,
563
],
[
693,
564
],
[
564,
565
],
[
564,
566
],
[
566,
567
],
[
567,
568
],
[
568,
569
],
[
569,
570
],
[
570,
571
],
[
570,
572
],
[
569,
573
],
[
573,
574
],
[
573,
575
],
[
564,
576
],
[
576,
577
],
[
693,
578
],
[
578,
579
],
[
578,
580
],
[
580,
581
],
[
581,
582
],
[
580,
583
],
[
583,
584
],
[
584,
585
],
[
585,
586
],
[
586,
587
],
[
586,
588
],
[
588,
589
],
[
585,
590
],
[
590,
591
],
[
584,
592
],
[
592,
593
],
[
592,
594
],
[
580,
595
],
[
595,
596
],
[
693,
597
],
[
597,
598
],
[
597,
599
],
[
599,
600
],
[
600,
601
],
[
600,
602
],
[
602,
603
],
[
599,
604
],
[
604,
605
],
[
604,
606
],
[
599,
607
],
[
607,
608
],
[
608,
609
],
[
609,
610
],
[
609,
611
],
[
607,
612
],
[
612,
613
],
[
613,
614
],
[
614,
615
],
[
613,
616
],
[
612,
617
],
[
617,
618
],
[
617,
619
],
[
619,
620
],
[
599,
621
],
[
621,
622
],
[
622,
623
],
[
623,
624
],
[
693,
625
],
[
625,
626
],
[
625,
627
],
[
627,
628
],
[
628,
629
],
[
628,
630
],
[
627,
632
],
[
632,
633
],
[
632,
634
],
[
634,
635
],
[
627,
636
],
[
636,
637
],
[
636,
638
],
[
627,
639
],
[
639,
640
],
[
640,
641
],
[
641,
642
],
[
641,
643
],
[
640,
644
],
[
644,
645
],
[
645,
646
],
[
645,
647
],
[
639,
648
],
[
648,
649
],
[
649,
650
],
[
650,
651
],
[
650,
652
],
[
652,
653
],
[
649,
654
],
[
648,
655
],
[
655,
656
],
[
655,
657
],
[
657,
658
],
[
627,
659
],
[
659,
660
],
[
660,
661
],
[
661,
662
],
[
661,
663
],
[
660,
664
],
[
660,
665
],
[
665,
666
],
[
666,
667
],
[
665,
668
],
[
665,
669
],
[
625,
670
],
[
670,
671
],
[
693,
672
],
[
672,
673
],
[
672,
674
],
[
674,
675
],
[
675,
676
],
[
676,
677
],
[
677,
678
],
[
678,
679
],
[
676,
680
],
[
675,
681
],
[
681,
682
],
[
682,
683
],
[
683,
684
],
[
683,
685
],
[
681,
686
],
[
686,
687
],
[
687,
688
],
[
686,
689
],
[
672,
690
],
[
690,
691
],
[
0,
692
],
[
692,
693
],
[
692,
694
]
]
| [
"import java.io.*;\nimport java.util.*;\n\npublic class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n int MAX = (int) 1e6+2, MOD = (int)1e9+7;\n \n void solve(int TC) {\n \tint n = ni();\n \tint[] a = new int[n];\n \tlong ans = 0;\n \tint mx = 0;\n \tfor(int i=0;i<n;i++) a[i] = ni();\n \tfor(int i=0;i<n;i++) {\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}\n \tpn(ans);\n }\n \n boolean TestCases = false;\n public static void main(String[] args) throws Exception { new Main().run(); }\n \n long pow(long a, long b) { // return pow(a,b) % MOD\n if(b==0 || a==1) return 1;\n long o = 1;\n for(long p = b; p > 0; p>>=1) {\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n } return o;\n }\n \n long inv(long x) { // return Modular Inverse of x\n long o = 1;\n for(long p = MOD-2; p > 0; p>>=1) {\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n } return o;\n }\n long gcd(long a, long b) { return (b==0) ? a : gcd(b,a%b); }\n int gcd(int a, int b) { return (b==0) ? a : gcd(b,a%b); }\n \n void run() throws Exception {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n int T = TestCases ? ni() : 1;\n for(int t=1;t<=T;t++) solve(t);\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n void p(Object o) { out.print(o); }\n void pn(Object o) { out.println(o); }\n void pni(Object o) { out.println(o);out.flush(); }\n double PI = 3.141592653589793238462643383279502884197169399;\n \n int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n double nd() { return Double.parseDouble(ns()); }\n char nc() { return (char)skip(); }\n \n int BUF_SIZE = 1024 * 8; // 1 MB is 1024*1024\n byte[] inbuf = new byte[BUF_SIZE];\n int lenbuf = 0, ptrbuf = 0;\n \n int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n } return inbuf[ptrbuf++];\n }\n \n boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))) { // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n } return sb.toString();\n }\n \n char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n } return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n int MAX = (int) 1e6+2, MOD = (int)1e9+7;\n \n void solve(int TC) {\n \tint n = ni();\n \tint[] a = new int[n];\n \tlong ans = 0;\n \tint mx = 0;\n \tfor(int i=0;i<n;i++) a[i] = ni();\n \tfor(int i=0;i<n;i++) {\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}\n \tpn(ans);\n }\n \n boolean TestCases = false;\n public static void main(String[] args) throws Exception { new Main().run(); }\n \n long pow(long a, long b) { // return pow(a,b) % MOD\n if(b==0 || a==1) return 1;\n long o = 1;\n for(long p = b; p > 0; p>>=1) {\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n } return o;\n }\n \n long inv(long x) { // return Modular Inverse of x\n long o = 1;\n for(long p = MOD-2; p > 0; p>>=1) {\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n } return o;\n }\n long gcd(long a, long b) { return (b==0) ? a : gcd(b,a%b); }\n int gcd(int a, int b) { return (b==0) ? a : gcd(b,a%b); }\n \n void run() throws Exception {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n int T = TestCases ? ni() : 1;\n for(int t=1;t<=T;t++) solve(t);\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n void p(Object o) { out.print(o); }\n void pn(Object o) { out.println(o); }\n void pni(Object o) { out.println(o);out.flush(); }\n double PI = 3.141592653589793238462643383279502884197169399;\n \n int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n double nd() { return Double.parseDouble(ns()); }\n char nc() { return (char)skip(); }\n \n int BUF_SIZE = 1024 * 8; // 1 MB is 1024*1024\n byte[] inbuf = new byte[BUF_SIZE];\n int lenbuf = 0, ptrbuf = 0;\n \n int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n } return inbuf[ptrbuf++];\n }\n \n boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))) { // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n } return sb.toString();\n }\n \n char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n } return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }\n}",
"Main",
"InputStream is;",
"is",
"PrintWriter out;",
"out",
"String INPUT = \"\";",
"INPUT",
"\"\"",
"int MAX = (int) 1e6+2",
"MAX",
"(int) 1e6+2",
"(int) 1e6",
"2",
"MOD = (int)1e9+7;",
"MOD",
"(int)1e9+7",
"(int)1e9",
"7",
"boolean TestCases = false;",
"TestCases",
"false",
"double PI = 3.141592653589793238462643383279502884197169399;",
"PI",
"3.141592653589793238462643383279502884197169399",
"int BUF_SIZE = 1024 * 8; // 1 MB is 1024*1024",
"BUF_SIZE",
"1024 * 8",
"1024",
"8",
"byte[] inbuf = new byte[BUF_SIZE];",
"inbuf",
"new byte[BUF_SIZE]",
"BUF_SIZE",
"int lenbuf = 0",
"lenbuf",
"0",
"ptrbuf = 0;",
"ptrbuf",
"0",
"void solve(int TC) {\n \tint n = ni();\n \tint[] a = new int[n];\n \tlong ans = 0;\n \tint mx = 0;\n \tfor(int i=0;i<n;i++) a[i] = ni();\n \tfor(int i=0;i<n;i++) {\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}\n \tpn(ans);\n }",
"solve",
"{\n \tint n = ni();\n \tint[] a = new int[n];\n \tlong ans = 0;\n \tint mx = 0;\n \tfor(int i=0;i<n;i++) a[i] = ni();\n \tfor(int i=0;i<n;i++) {\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}\n \tpn(ans);\n }",
"int n = ni();",
"n",
"ni()",
"ni",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"long ans = 0;",
"ans",
"0",
"int mx = 0;",
"mx",
"0",
"for(int i=0;i<n;i++) a[i] = ni();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = ni();",
"a[i] = ni()",
"a[i]",
"a",
"i",
"ni()",
"ni",
"for(int i=0;i<n;i++) {\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}",
"{\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}",
"mx = Math.max(mx, a[i])",
"mx",
"Math.max(mx, a[i])",
"Math.max",
"Math",
"mx",
"a[i]",
"a",
"i",
"ans += mx-a[i]",
"ans",
"mx-a[i]",
"mx",
"a[i]",
"a",
"i",
"pn(ans)",
"pn",
"ans",
"int TC",
"TC",
"public static void main(String[] args) throws Exception { new Main().run(); }",
"main",
"{ new Main().run(); }",
"new Main().run()",
"new Main().run",
"new Main()",
"String[] args",
"args",
"long pow(long a, long b) { // return pow(a,b) % MOD\n if(b==0 || a==1) return 1;\n long o = 1;\n for(long p = b; p > 0; p>>=1) {\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n } return o;\n }",
"pow",
"{ // return pow(a,b) % MOD\n if(b==0 || a==1) return 1;\n long o = 1;\n for(long p = b; p > 0; p>>=1) {\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n } return o;\n }",
"if(b==0 || a==1) return 1;",
"b==0 || a==1",
"b==0",
"b",
"0",
"a==1",
"a",
"1",
"return 1;",
"1",
"long o = 1;",
"o",
"1",
"for(long p = b; p > 0; p>>=1) {\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n }",
"long p = b;",
"long p = b;",
"p",
"b",
"p > 0",
"p",
"0",
"p>>=1",
"p>>=1",
"p",
"1",
"{\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n }",
"{\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n }",
"if((p&1)==1) o = (o*a) % MOD;",
"(p&1)==1",
"(p&1)",
"p",
"1",
"1",
"o = (o*a) % MOD",
"o",
"(o*a) % MOD",
"(o*a)",
"o",
"a",
"MOD",
"a = (a*a) % MOD",
"a",
"(a*a) % MOD",
"(a*a)",
"a",
"a",
"MOD",
"return o;",
"o",
"long a",
"a",
"long b",
"b",
"long inv(long x) { // return Modular Inverse of x\n long o = 1;\n for(long p = MOD-2; p > 0; p>>=1) {\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n } return o;\n }",
"inv",
"{ // return Modular Inverse of x\n long o = 1;\n for(long p = MOD-2; p > 0; p>>=1) {\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n } return o;\n }",
"long o = 1;",
"o",
"1",
"for(long p = MOD-2; p > 0; p>>=1) {\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n }",
"long p = MOD-2;",
"long p = MOD-2;",
"p",
"MOD-2",
"MOD",
"2",
"p > 0",
"p",
"0",
"p>>=1",
"p>>=1",
"p",
"1",
"{\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n }",
"{\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n }",
"if((p&1)==1)o = (o*x)%MOD;",
"(p&1)==1",
"(p&1)",
"p",
"1",
"1",
"o = (o*x)%MOD",
"o",
"(o*x)%MOD",
"(o*x)",
"o",
"x",
"MOD",
"x = (x*x)%MOD",
"x",
"(x*x)%MOD",
"(x*x)",
"x",
"x",
"MOD",
"return o;",
"o",
"long x",
"x",
"long gcd(long a, long b) { return (b==0) ? a : gcd(b,a%b); }",
"gcd",
"{ return (b==0) ? a : gcd(b,a%b); }",
"return (b==0) ? a : gcd(b,a%b);",
"(b==0) ? a : gcd(b,a%b)",
"(b==0)",
"b",
"0",
"a",
"gcd(b,a%b)",
"gcd",
"b",
"a%b",
"a",
"b",
"long a",
"a",
"long b",
"b",
"int gcd(int a, int b) { return (b==0) ? a : gcd(b,a%b); }",
"gcd",
"{ return (b==0) ? a : gcd(b,a%b); }",
"return (b==0) ? a : gcd(b,a%b);",
"(b==0) ? a : gcd(b,a%b)",
"(b==0)",
"b",
"0",
"a",
"gcd(b,a%b)",
"gcd",
"b",
"a%b",
"a",
"b",
"int a",
"a",
"int b",
"b",
"void run() throws Exception {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n int T = TestCases ? ni() : 1;\n for(int t=1;t<=T;t++) solve(t);\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }",
"run",
"{\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n int T = TestCases ? ni() : 1;\n for(int t=1;t<=T;t++) solve(t);\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }",
"is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes())",
"is",
"INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes())",
"INPUT.isEmpty()",
"INPUT.isEmpty",
"INPUT",
"System.in",
"System",
"System.in",
"new ByteArrayInputStream(INPUT.getBytes())",
"out = new PrintWriter(System.out)",
"out",
"new PrintWriter(System.out)",
"long s = System.currentTimeMillis();",
"s",
"System.currentTimeMillis()",
"System.currentTimeMillis",
"System",
"int T = TestCases ? ni() : 1;",
"T",
"TestCases ? ni() : 1",
"TestCases",
"ni()",
"ni",
"1",
"for(int t=1;t<=T;t++) solve(t);",
"int t=1;",
"int t=1;",
"t",
"1",
"t<=T",
"t",
"T",
"t++",
"t++",
"t",
"solve(t);",
"solve(t)",
"solve",
"t",
"out.flush()",
"out.flush",
"out",
"if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");",
"!INPUT.isEmpty()",
"INPUT.isEmpty()",
"INPUT.isEmpty",
"INPUT",
"tr(System.currentTimeMillis()-s+\"ms\")",
"tr",
"System.currentTimeMillis()-s+\"ms\"",
"System.currentTimeMillis()-s",
"System.currentTimeMillis()",
"System.currentTimeMillis",
"System",
"s",
"\"ms\"",
"void p(Object o) { out.print(o); }",
"p",
"{ out.print(o); }",
"out.print(o)",
"out.print",
"out",
"o",
"Object o",
"o",
"void pn(Object o) { out.println(o); }",
"pn",
"{ out.println(o); }",
"out.println(o)",
"out.println",
"out",
"o",
"Object o",
"o",
"void pni(Object o) { out.println(o);out.flush(); }",
"pni",
"{ out.println(o);out.flush(); }",
"out.println(o)",
"out.println",
"out",
"o",
"out.flush()",
"out.flush",
"out",
"Object o",
"o",
"int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }",
"ni",
"{\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }",
"int num = 0",
"num",
"0",
"b;",
"b",
"boolean minus = false;",
"minus",
"false",
"while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));",
"(b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')",
"(b = readByte()) != -1",
"(b = readByte())",
"b",
"readByte()",
"readByte",
"-1",
"1",
"!((b >= '0' && b <= '9') || b == '-')",
"((b >= '0' && b <= '9') || b == '-')",
"(b >= '0' && b <= '9')",
"b >= '0'",
"b",
"'0'",
"b <= '9'",
"b",
"'9'",
"b == '-'",
"b",
"'-'",
"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",
"while(true) {\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }",
"true",
"{\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }",
"if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }",
"b >= '0' && b <= '9'",
"b >= '0'",
"b",
"'0'",
"b <= '9'",
"b",
"'9'",
"{\n num = num * 10 + (b - '0');\n }",
"num = num * 10 + (b - '0')",
"num",
"num * 10 + (b - '0')",
"num * 10",
"num",
"10",
"(b - '0')",
"b",
"'0'",
"{\n return minus ? -num : num;\n }",
"return minus ? -num : num;",
"minus ? -num : num",
"minus",
"-num",
"num",
"num",
"b = readByte()",
"b",
"readByte()",
"readByte",
"long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }",
"nl",
"{\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }",
"long num = 0;",
"num",
"0",
"int b;",
"b",
"boolean minus = false;",
"minus",
"false",
"while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));",
"(b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')",
"(b = readByte()) != -1",
"(b = readByte())",
"b",
"readByte()",
"readByte",
"-1",
"1",
"!((b >= '0' && b <= '9') || b == '-')",
"((b >= '0' && b <= '9') || b == '-')",
"(b >= '0' && b <= '9')",
"b >= '0'",
"b",
"'0'",
"b <= '9'",
"b",
"'9'",
"b == '-'",
"b",
"'-'",
"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",
"while(true) {\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }",
"true",
"{\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }",
"if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }",
"b >= '0' && b <= '9'",
"b >= '0'",
"b",
"'0'",
"b <= '9'",
"b",
"'9'",
"{\n num = num * 10 + (b - '0');\n }",
"num = num * 10 + (b - '0')",
"num",
"num * 10 + (b - '0')",
"num * 10",
"num",
"10",
"(b - '0')",
"b",
"'0'",
"{\n return minus ? -num : num;\n }",
"return minus ? -num : num;",
"minus ? -num : num",
"minus",
"-num",
"num",
"num",
"b = readByte()",
"b",
"readByte()",
"readByte",
"double nd() { return Double.parseDouble(ns()); }",
"nd",
"{ return Double.parseDouble(ns()); }",
"return Double.parseDouble(ns());",
"Double.parseDouble(ns())",
"Double.parseDouble",
"Double",
"ns()",
"ns",
"char nc() { return (char)skip(); }",
"nc",
"{ return (char)skip(); }",
"return (char)skip();",
"(char)skip()",
"skip",
"int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n } return inbuf[ptrbuf++];\n }",
"readByte",
"{\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n } return inbuf[ptrbuf++];\n }",
"if(lenbuf == -1)throw new InputMismatchException();",
"lenbuf == -1",
"lenbuf",
"-1",
"1",
"throw new InputMismatchException();",
"new InputMismatchException()",
"if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }",
"ptrbuf >= lenbuf",
"ptrbuf",
"lenbuf",
"{\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }",
"ptrbuf = 0",
"ptrbuf",
"0",
"try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }",
"catch (IOException e) { throw new InputMismatchException(); }",
"IOException e",
"{ throw new InputMismatchException(); }",
"throw new InputMismatchException();",
"new InputMismatchException()",
"{ lenbuf = is.read(inbuf); }",
"lenbuf = is.read(inbuf)",
"lenbuf",
"is.read(inbuf)",
"is.read",
"is",
"inbuf",
"if(lenbuf <= 0)return -1;",
"lenbuf <= 0",
"lenbuf",
"0",
"return -1;",
"-1",
"1",
"return inbuf[ptrbuf++];",
"inbuf[ptrbuf++]",
"inbuf",
"ptrbuf++",
"ptrbuf",
"boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }",
"isSpaceChar",
"{ return !(c >= 33 && c <= 126); }",
"return !(c >= 33 && c <= 126);",
"!(c >= 33 && c <= 126)",
"(c >= 33 && c <= 126)",
"c >= 33",
"c",
"33",
"c <= 126",
"c",
"126",
"int c",
"c",
"int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }",
"skip",
"{ int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }",
"int b;",
"b",
"while((b = readByte()) != -1 && isSpaceChar(b));",
"(b = readByte()) != -1 && isSpaceChar(b)",
"(b = readByte()) != -1",
"(b = readByte())",
"b",
"readByte()",
"readByte",
"-1",
"1",
"isSpaceChar(b)",
"isSpaceChar",
"b",
"return b;",
"b",
"String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))) { // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n } return sb.toString();\n }",
"ns",
"{\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))) { // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n } return sb.toString();\n }",
"int b = skip();",
"b",
"skip()",
"skip",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"while(!(isSpaceChar(b))) { // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n }",
"!(isSpaceChar(b))",
"(isSpaceChar(b))",
"isSpaceChar",
"b",
"{ // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n }",
"sb.appendCodePoint(b)",
"sb.appendCodePoint",
"sb",
"b",
"b = readByte()",
"b",
"readByte()",
"readByte",
"return sb.toString();",
"sb.toString()",
"sb.toString",
"sb",
"char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n } return n == p ? buf : Arrays.copyOf(buf, p);\n }",
"ns",
"{\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n } return n == p ? buf : Arrays.copyOf(buf, p);\n }",
"char[] buf = new char[n];",
"buf",
"new char[n]",
"n",
"int b = skip()",
"b",
"skip()",
"skip",
"p = 0;",
"p",
"0",
"while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }",
"p < n && !(isSpaceChar(b))",
"p < n",
"p",
"n",
"!(isSpaceChar(b))",
"(isSpaceChar(b))",
"isSpaceChar",
"b",
"{\n buf[p++] = (char)b;\n b = readByte();\n }",
"buf[p++] = (char)b",
"buf[p++]",
"buf",
"p++",
"p",
"(char)b",
"b = readByte()",
"b",
"readByte()",
"readByte",
"return n == p ? buf : Arrays.copyOf(buf, p);",
"n == p ? buf : Arrays.copyOf(buf, p)",
"n == p",
"n",
"p",
"buf",
"Arrays.copyOf(buf, p)",
"Arrays.copyOf",
"Arrays",
"buf",
"p",
"int n",
"n",
"void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }",
"tr",
"{ if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }",
"if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o));",
"INPUT.length() > 0",
"INPUT.length()",
"INPUT.length",
"INPUT",
"0",
"System.out.println(Arrays.deepToString(o))",
"System.out.println",
"System.out",
"System",
"System.out",
"Arrays.deepToString(o)",
"Arrays.deepToString",
"Arrays",
"o",
"Object... o",
"o",
"public class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n int MAX = (int) 1e6+2, MOD = (int)1e9+7;\n \n void solve(int TC) {\n \tint n = ni();\n \tint[] a = new int[n];\n \tlong ans = 0;\n \tint mx = 0;\n \tfor(int i=0;i<n;i++) a[i] = ni();\n \tfor(int i=0;i<n;i++) {\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}\n \tpn(ans);\n }\n \n boolean TestCases = false;\n public static void main(String[] args) throws Exception { new Main().run(); }\n \n long pow(long a, long b) { // return pow(a,b) % MOD\n if(b==0 || a==1) return 1;\n long o = 1;\n for(long p = b; p > 0; p>>=1) {\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n } return o;\n }\n \n long inv(long x) { // return Modular Inverse of x\n long o = 1;\n for(long p = MOD-2; p > 0; p>>=1) {\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n } return o;\n }\n long gcd(long a, long b) { return (b==0) ? a : gcd(b,a%b); }\n int gcd(int a, int b) { return (b==0) ? a : gcd(b,a%b); }\n \n void run() throws Exception {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n int T = TestCases ? ni() : 1;\n for(int t=1;t<=T;t++) solve(t);\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n void p(Object o) { out.print(o); }\n void pn(Object o) { out.println(o); }\n void pni(Object o) { out.println(o);out.flush(); }\n double PI = 3.141592653589793238462643383279502884197169399;\n \n int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n double nd() { return Double.parseDouble(ns()); }\n char nc() { return (char)skip(); }\n \n int BUF_SIZE = 1024 * 8; // 1 MB is 1024*1024\n byte[] inbuf = new byte[BUF_SIZE];\n int lenbuf = 0, ptrbuf = 0;\n \n int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n } return inbuf[ptrbuf++];\n }\n \n boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))) { // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n } return sb.toString();\n }\n \n char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n } return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }\n}",
"public class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n int MAX = (int) 1e6+2, MOD = (int)1e9+7;\n \n void solve(int TC) {\n \tint n = ni();\n \tint[] a = new int[n];\n \tlong ans = 0;\n \tint mx = 0;\n \tfor(int i=0;i<n;i++) a[i] = ni();\n \tfor(int i=0;i<n;i++) {\n \t\tmx = Math.max(mx, a[i]);\n \t\tans += mx-a[i];\n \t}\n \tpn(ans);\n }\n \n boolean TestCases = false;\n public static void main(String[] args) throws Exception { new Main().run(); }\n \n long pow(long a, long b) { // return pow(a,b) % MOD\n if(b==0 || a==1) return 1;\n long o = 1;\n for(long p = b; p > 0; p>>=1) {\n if((p&1)==1) o = (o*a) % MOD;\n a = (a*a) % MOD;\n } return o;\n }\n \n long inv(long x) { // return Modular Inverse of x\n long o = 1;\n for(long p = MOD-2; p > 0; p>>=1) {\n if((p&1)==1)o = (o*x)%MOD;\n x = (x*x)%MOD;\n } return o;\n }\n long gcd(long a, long b) { return (b==0) ? a : gcd(b,a%b); }\n int gcd(int a, int b) { return (b==0) ? a : gcd(b,a%b); }\n \n void run() throws Exception {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n int T = TestCases ? ni() : 1;\n for(int t=1;t<=T;t++) solve(t);\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n void p(Object o) { out.print(o); }\n void pn(Object o) { out.println(o); }\n void pni(Object o) { out.println(o);out.flush(); }\n double PI = 3.141592653589793238462643383279502884197169399;\n \n int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-') {\n minus = true;\n b = readByte();\n }\n while(true) {\n if(b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n double nd() { return Double.parseDouble(ns()); }\n char nc() { return (char)skip(); }\n \n int BUF_SIZE = 1024 * 8; // 1 MB is 1024*1024\n byte[] inbuf = new byte[BUF_SIZE];\n int lenbuf = 0, ptrbuf = 0;\n \n int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n } return inbuf[ptrbuf++];\n }\n \n boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))) { // when nextLine, (b != '\\n')\n sb.appendCodePoint(b); b = readByte();\n } return sb.toString();\n }\n \n char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n } return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }\n}",
"Main"
]
| import java.io.*;
import java.util.*;
public class Main {
InputStream is;
PrintWriter out;
String INPUT = "";
int MAX = (int) 1e6+2, MOD = (int)1e9+7;
void solve(int TC) {
int n = ni();
int[] a = new int[n];
long ans = 0;
int mx = 0;
for(int i=0;i<n;i++) a[i] = ni();
for(int i=0;i<n;i++) {
mx = Math.max(mx, a[i]);
ans += mx-a[i];
}
pn(ans);
}
boolean TestCases = false;
public static void main(String[] args) throws Exception { new Main().run(); }
long pow(long a, long b) { // return pow(a,b) % MOD
if(b==0 || a==1) return 1;
long o = 1;
for(long p = b; p > 0; p>>=1) {
if((p&1)==1) o = (o*a) % MOD;
a = (a*a) % MOD;
} return o;
}
long inv(long x) { // return Modular Inverse of x
long o = 1;
for(long p = MOD-2; p > 0; p>>=1) {
if((p&1)==1)o = (o*x)%MOD;
x = (x*x)%MOD;
} return o;
}
long gcd(long a, long b) { return (b==0) ? a : gcd(b,a%b); }
int gcd(int a, int b) { return (b==0) ? a : gcd(b,a%b); }
void run() throws Exception {
is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
long s = System.currentTimeMillis();
int T = TestCases ? ni() : 1;
for(int t=1;t<=T;t++) solve(t);
out.flush();
if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
}
void p(Object o) { out.print(o); }
void pn(Object o) { out.println(o); }
void pni(Object o) { out.println(o);out.flush(); }
double PI = 3.141592653589793238462643383279502884197169399;
int ni() {
int num = 0, b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-') {
minus = true;
b = readByte();
}
while(true) {
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
long nl() {
long num = 0;
int b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-') {
minus = true;
b = readByte();
}
while(true) {
if(b >= '0' && b <= '9') {
num = num * 10 + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
double nd() { return Double.parseDouble(ns()); }
char nc() { return (char)skip(); }
int BUF_SIZE = 1024 * 8; // 1 MB is 1024*1024
byte[] inbuf = new byte[BUF_SIZE];
int lenbuf = 0, ptrbuf = 0;
int readByte() {
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf){
ptrbuf = 0;
try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
if(lenbuf <= 0)return -1;
} return inbuf[ptrbuf++];
}
boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
String ns() {
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b))) { // when nextLine, (b != '\n')
sb.appendCodePoint(b); b = readByte();
} return sb.toString();
}
char[] ns(int n) {
char[] buf = new char[n];
int b = skip(), p = 0;
while(p < n && !(isSpaceChar(b))){
buf[p++] = (char)b;
b = readByte();
} return n == p ? buf : Arrays.copyOf(buf, p);
}
void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }
} |
[
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,
14,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
29,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
2,
13,
13,
30,
14,
2,
18,
13,
13,
18,
13,
13,
30,
0,
13,
4,
18,
13,
2,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
40,
13,
40,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
108,
5
],
[
108,
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
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
45,
52
],
[
8,
53
],
[
53,
54
],
[
53,
55
],
[
8,
56
],
[
56,
57
],
[
56,
58
],
[
8,
59
],
[
59,
60
],
[
59,
61
],
[
8,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
72,
74
],
[
67,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
75,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
66,
95
],
[
95,
96
],
[
66,
97
],
[
97,
98
],
[
8,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
6,
105
],
[
105,
106
],
[
0,
107
],
[
107,
108
],
[
107,
109
]
]
| [
"import java.util.*;\n\npublic class Main{\npublic static void main(String[] args){\n\tScanner scanner = new Scanner(System.in);\n \tint n = scanner.nextInt();\n \tlong[] nums = new long[n];\n \tfor(int i = 0;i < n;i++){\n nums[i] = scanner.nextLong();\n }\n \tif(n == 1){\n System.out.println(0);\n return;\n }\n \tint l = 0;\n \tint r = 1;\n \tlong sum = 0;\n \twhile(r < n){\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }\n System.out.println(sum);\n}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\npublic static void main(String[] args){\n\tScanner scanner = new Scanner(System.in);\n \tint n = scanner.nextInt();\n \tlong[] nums = new long[n];\n \tfor(int i = 0;i < n;i++){\n nums[i] = scanner.nextLong();\n }\n \tif(n == 1){\n System.out.println(0);\n return;\n }\n \tint l = 0;\n \tint r = 1;\n \tlong sum = 0;\n \twhile(r < n){\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }\n System.out.println(sum);\n}\n}",
"Main",
"public static void main(String[] args){\n\tScanner scanner = new Scanner(System.in);\n \tint n = scanner.nextInt();\n \tlong[] nums = new long[n];\n \tfor(int i = 0;i < n;i++){\n nums[i] = scanner.nextLong();\n }\n \tif(n == 1){\n System.out.println(0);\n return;\n }\n \tint l = 0;\n \tint r = 1;\n \tlong sum = 0;\n \twhile(r < n){\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }\n System.out.println(sum);\n}",
"main",
"{\n\tScanner scanner = new Scanner(System.in);\n \tint n = scanner.nextInt();\n \tlong[] nums = new long[n];\n \tfor(int i = 0;i < n;i++){\n nums[i] = scanner.nextLong();\n }\n \tif(n == 1){\n System.out.println(0);\n return;\n }\n \tint l = 0;\n \tint r = 1;\n \tlong sum = 0;\n \twhile(r < n){\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }\n System.out.println(sum);\n}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"long[] nums = new long[n];",
"nums",
"new long[n]",
"n",
"for(int i = 0;i < n;i++){\n nums[i] = scanner.nextLong();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n nums[i] = scanner.nextLong();\n }",
"{\n nums[i] = scanner.nextLong();\n }",
"nums[i] = scanner.nextLong()",
"nums[i]",
"nums",
"i",
"scanner.nextLong()",
"scanner.nextLong",
"scanner",
"if(n == 1){\n System.out.println(0);\n return;\n }",
"n == 1",
"n",
"1",
"{\n System.out.println(0);\n return;\n }",
"System.out.println(0)",
"System.out.println",
"System.out",
"System",
"System.out",
"0",
"return;",
"int l = 0;",
"l",
"0",
"int r = 1;",
"r",
"1",
"long sum = 0;",
"sum",
"0",
"while(r < n){\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }",
"r < n",
"r",
"n",
"{\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }",
"if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }",
"nums[l] > nums[r]",
"nums[l]",
"nums",
"l",
"nums[r]",
"nums",
"r",
"{\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }",
"sum += Math.abs(nums[l] - nums[r])",
"sum",
"Math.abs(nums[l] - nums[r])",
"Math.abs",
"Math",
"nums[l] - nums[r]",
"nums[l]",
"nums",
"l",
"nums[r]",
"nums",
"r",
"nums[r] = nums[l]",
"nums[r]",
"nums",
"r",
"nums[l]",
"nums",
"l",
"l++",
"l",
"r++",
"r",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main{\npublic static void main(String[] args){\n\tScanner scanner = new Scanner(System.in);\n \tint n = scanner.nextInt();\n \tlong[] nums = new long[n];\n \tfor(int i = 0;i < n;i++){\n nums[i] = scanner.nextLong();\n }\n \tif(n == 1){\n System.out.println(0);\n return;\n }\n \tint l = 0;\n \tint r = 1;\n \tlong sum = 0;\n \twhile(r < n){\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }\n System.out.println(sum);\n}\n}",
"public class Main{\npublic static void main(String[] args){\n\tScanner scanner = new Scanner(System.in);\n \tint n = scanner.nextInt();\n \tlong[] nums = new long[n];\n \tfor(int i = 0;i < n;i++){\n nums[i] = scanner.nextLong();\n }\n \tif(n == 1){\n System.out.println(0);\n return;\n }\n \tint l = 0;\n \tint r = 1;\n \tlong sum = 0;\n \twhile(r < n){\n if(nums[l] > nums[r]){\n sum += Math.abs(nums[l] - nums[r]);\n nums[r] = nums[l];\n }\n l++;\n r++;\n }\n System.out.println(sum);\n}\n}",
"Main"
]
| import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
long[] nums = new long[n];
for(int i = 0;i < n;i++){
nums[i] = scanner.nextLong();
}
if(n == 1){
System.out.println(0);
return;
}
int l = 0;
int r = 1;
long sum = 0;
while(r < n){
if(nums[l] > nums[r]){
sum += Math.abs(nums[l] - nums[r]);
nums[r] = nums[l];
}
l++;
r++;
}
System.out.println(sum);
}
} |
[
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,
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,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
9,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
23,
13,
12,
13,
30,
14,
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,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
14,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
37,
20,
30,
29,
4,
18,
13,
29,
4,
18,
13,
17,
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
],
[
216,
26
],
[
216,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
29,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
29,
38
],
[
38,
39
],
[
38,
40
],
[
29,
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
],
[
29,
62
],
[
62,
63
],
[
62,
64
],
[
29,
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
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
77,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
92,
98
],
[
98,
99
],
[
98,
100
],
[
77,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
29,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
110,
115
],
[
27,
116
],
[
116,
117
],
[
216,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
118,
122
],
[
122,
123
],
[
118,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
124,
130
],
[
130,
131
],
[
118,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
135,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
145,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
134,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
118,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
166,
167
],
[
118,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
172,
175
],
[
175,
176
],
[
118,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
181,
184
],
[
184,
185
],
[
118,
186
],
[
186,
187
],
[
186,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
194,
195
],
[
195,
196
],
[
196,
197
],
[
189,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
199,
205
],
[
205,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
188,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
211,
214
],
[
0,
215
],
[
215,
216
],
[
215,
217
]
]
| [
"\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.List;\nimport java.util.StringTokenizer;\nimport java.util.stream.Collectors;\nimport java.util.stream.IntStream;\n\npublic class Main {\n public static void main(final String[] args) {\n final FastScanner scanner = new FastScanner(System.in);\n final int n = scanner.nextInt();\n final int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = scanner.nextInt();\n }\n\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }\n System.out.println(sum);\n }\n\n private static class FastScanner {\n private final BufferedReader reader;\n private StringTokenizer tokenizer;\n\n FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.List;",
"List",
"java.util",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"import java.util.stream.Collectors;",
"Collectors",
"java.util.stream",
"import java.util.stream.IntStream;",
"IntStream",
"java.util.stream",
"public class Main {\n public static void main(final String[] args) {\n final FastScanner scanner = new FastScanner(System.in);\n final int n = scanner.nextInt();\n final int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = scanner.nextInt();\n }\n\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }\n System.out.println(sum);\n }\n\n private static class FastScanner {\n private final BufferedReader reader;\n private StringTokenizer tokenizer;\n\n FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n }\n}",
"Main",
"public static void main(final String[] args) {\n final FastScanner scanner = new FastScanner(System.in);\n final int n = scanner.nextInt();\n final int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = scanner.nextInt();\n }\n\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }\n System.out.println(sum);\n }",
"main",
"{\n final FastScanner scanner = new FastScanner(System.in);\n final int n = scanner.nextInt();\n final int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = scanner.nextInt();\n }\n\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }\n System.out.println(sum);\n }",
"final FastScanner scanner = new FastScanner(System.in);",
"scanner",
"new FastScanner(System.in)",
"final int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"final int[] array = new int[n];",
"array",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n array[i] = scanner.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n array[i] = scanner.nextInt();\n }",
"{\n array[i] = scanner.nextInt();\n }",
"array[i] = scanner.nextInt()",
"array[i]",
"array",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"long sum = 0;",
"sum",
"0",
"for (int i = 1; i < n; i++) {\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }",
"{\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }",
"if (array[i] > array[i - 1]) {\n continue;\n }",
"array[i] > array[i - 1]",
"array[i]",
"array",
"i",
"array[i - 1]",
"array",
"i - 1",
"i",
"1",
"{\n continue;\n }",
"continue;",
"sum += array[i - 1] - array[i]",
"sum",
"array[i - 1] - array[i]",
"array[i - 1]",
"array",
"i - 1",
"i",
"1",
"array[i]",
"array",
"i",
"array[i] = array[i - 1]",
"array[i]",
"array",
"i",
"array[i - 1]",
"array",
"i - 1",
"i",
"1",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"final String[] args",
"args",
"private static class FastScanner {\n private final BufferedReader reader;\n private StringTokenizer tokenizer;\n\n FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n }",
"FastScanner",
"private final BufferedReader reader;",
"reader",
"private StringTokenizer tokenizer;",
"tokenizer",
"FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }",
"FastScanner",
"{\n reader = new BufferedReader(new InputStreamReader(in));\n }",
"reader = new BufferedReader(new InputStreamReader(in))",
"reader",
"new BufferedReader(new InputStreamReader(in))",
"final InputStream in",
"in",
"String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }",
"next",
"{\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }",
"if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final 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 (final IOException e) {\n throw new RuntimeException(e);\n }\n }",
"try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }",
"catch (final IOException e) {\n throw new RuntimeException(e);\n }",
"final 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",
"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",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }",
"nextLine",
"{\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }",
"if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final 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 return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }",
"try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }",
"catch (final IOException e) {\n throw new RuntimeException(e);\n }",
"final IOException e",
"{\n throw new RuntimeException(e);\n }",
"throw new RuntimeException(e);",
"new RuntimeException(e)",
"{\n return reader.readLine();\n }",
"return reader.readLine();",
"reader.readLine()",
"reader.readLine",
"reader",
"return tokenizer.nextToken(\"\\n\");",
"tokenizer.nextToken(\"\\n\")",
"tokenizer.nextToken",
"tokenizer",
"\"\\n\"",
"public class Main {\n public static void main(final String[] args) {\n final FastScanner scanner = new FastScanner(System.in);\n final int n = scanner.nextInt();\n final int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = scanner.nextInt();\n }\n\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }\n System.out.println(sum);\n }\n\n private static class FastScanner {\n private final BufferedReader reader;\n private StringTokenizer tokenizer;\n\n FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n }\n}",
"public class Main {\n public static void main(final String[] args) {\n final FastScanner scanner = new FastScanner(System.in);\n final int n = scanner.nextInt();\n final int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = scanner.nextInt();\n }\n\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (array[i] > array[i - 1]) {\n continue;\n }\n\n sum += array[i - 1] - array[i];\n array[i] = array[i - 1];\n }\n System.out.println(sum);\n }\n\n private static class FastScanner {\n private final BufferedReader reader;\n private StringTokenizer tokenizer;\n\n FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n }\n}",
"Main"
]
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Main {
public static void main(final String[] args) {
final FastScanner scanner = new FastScanner(System.in);
final int n = scanner.nextInt();
final int[] array = new int[n];
for (int i = 0; i < n; i++) {
array[i] = scanner.nextInt();
}
long sum = 0;
for (int i = 1; i < n; i++) {
if (array[i] > array[i - 1]) {
continue;
}
sum += array[i - 1] - array[i];
array[i] = array[i - 1];
}
System.out.println(sum);
}
private static class FastScanner {
private final BufferedReader reader;
private StringTokenizer tokenizer;
FastScanner(final InputStream in) {
reader = new BufferedReader(new InputStreamReader(in));
}
String next() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
return reader.readLine();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken("\n");
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
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,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
74,
5
],
[
74,
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,
23
],
[
23,
24
],
[
23,
25
],
[
8,
26
],
[
26,
27
],
[
26,
28
],
[
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
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
41,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
8,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
65,
70
],
[
6,
71
],
[
71,
72
],
[
0,
73
],
[
73,
74
],
[
73,
75
]
]
| [
"import java.util.*;\n\npublic 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 \n int max = 0;\n long ans = 0;\n int tem = 0;\n \n for(int i = 0; i < N; ++i) {\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }\n System.out.println(ans);\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 \n int N = Integer.parseInt(sc.nextLine());\n \n int max = 0;\n long ans = 0;\n int tem = 0;\n \n for(int i = 0; i < N; ++i) {\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }\n System.out.println(ans);\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 \n int max = 0;\n long ans = 0;\n int tem = 0;\n \n for(int i = 0; i < N; ++i) {\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }\n System.out.println(ans);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n \n int N = Integer.parseInt(sc.nextLine());\n \n int max = 0;\n long ans = 0;\n int tem = 0;\n \n for(int i = 0; i < N; ++i) {\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }\n System.out.println(ans);\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 max = 0;",
"max",
"0",
"long ans = 0;",
"ans",
"0",
"int tem = 0;",
"tem",
"0",
"for(int i = 0; i < N; ++i) {\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"++i",
"++i",
"i",
"{\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }",
"{\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }",
"tem = sc.nextInt()",
"tem",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }",
"tem > max",
"tem",
"max",
"{\n max = tem;\n }",
"max = tem",
"max",
"tem",
"if(tem < max) {\n ans += max - tem;\n }",
"tem < max",
"tem",
"max",
"{\n ans += max - tem;\n }",
"ans += max - tem",
"ans",
"max - tem",
"max",
"tem",
"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 \n int N = Integer.parseInt(sc.nextLine());\n \n int max = 0;\n long ans = 0;\n int tem = 0;\n \n for(int i = 0; i < N; ++i) {\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }\n System.out.println(ans);\n }\n}",
"public 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 \n int max = 0;\n long ans = 0;\n int tem = 0;\n \n for(int i = 0; i < N; ++i) {\n tem = sc.nextInt();\n if(tem > max) {\n max = tem;\n } else if(tem < max) {\n ans += max - tem;\n }\n }\n System.out.println(ans);\n }\n}",
"Main"
]
| import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = Integer.parseInt(sc.nextLine());
int max = 0;
long ans = 0;
int tem = 0;
for(int i = 0; i < N; ++i) {
tem = sc.nextInt();
if(tem > max) {
max = tem;
} else if(tem < max) {
ans += max - tem;
}
}
System.out.println(ans);
}
} |
[
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,
41,
13,
17,
28,
13,
13,
30,
30,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
75,
5
],
[
75,
6
],
[
6,
7
],
[
6,
8
],
[
75,
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
],
[
11,
47
],
[
47,
48
],
[
47,
49
],
[
47,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
52,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
11,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
66,
71
],
[
9,
72
],
[
72,
73
],
[
0,
74
],
[
74,
75
],
[
74,
76
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n static Scanner sc = new Scanner(System.in); \n public static void main(String[] args) {\n int n = sc.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextLong();\n }\n long highest = 0, ans = 0;\n for (long a: arr){\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n } \n System.out.println(ans);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n static Scanner sc = new Scanner(System.in); \n public static void main(String[] args) {\n int n = sc.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextLong();\n }\n long highest = 0, ans = 0;\n for (long a: arr){\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n } \n System.out.println(ans);\n }\n}",
"Main",
"static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args) {\n int n = sc.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextLong();\n }\n long highest = 0, ans = 0;\n for (long a: arr){\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n } \n System.out.println(ans);\n }",
"main",
"{\n int n = sc.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextLong();\n }\n long highest = 0, ans = 0;\n for (long a: arr){\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n } \n System.out.println(ans);\n }",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] arr = new long[n];",
"arr",
"new long[n]",
"n",
"for (int i = 0; i < n; i++) {\n arr[i] = sc.nextLong();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n arr[i] = sc.nextLong();\n }",
"{\n arr[i] = sc.nextLong();\n }",
"arr[i] = sc.nextLong()",
"arr[i]",
"arr",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"long highest = 0",
"highest",
"0",
"ans = 0;",
"ans",
"0",
"for (long a: arr){\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n }",
"long a",
"arr",
"{\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n }",
"{\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n }",
"if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }",
"a < highest",
"a",
"highest",
"{\n ans += highest - a;\n }",
"ans += highest - a",
"ans",
"highest - a",
"highest",
"a",
"{\n highest = a;\n }",
"highest = a",
"highest",
"a",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n static Scanner sc = new Scanner(System.in); \n public static void main(String[] args) {\n int n = sc.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextLong();\n }\n long highest = 0, ans = 0;\n for (long a: arr){\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n } \n System.out.println(ans);\n }\n}",
"public class Main {\n static Scanner sc = new Scanner(System.in); \n public static void main(String[] args) {\n int n = sc.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = sc.nextLong();\n }\n long highest = 0, ans = 0;\n for (long a: arr){\n if (a < highest){\n ans += highest - a;\n }else{\n highest = a;\n }\n } \n System.out.println(ans);\n }\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextLong();
}
long highest = 0, ans = 0;
for (long a: arr){
if (a < highest){
ans += highest - a;
}else{
highest = a;
}
}
System.out.println(ans);
}
} |
[
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
2,
13,
13,
0,
18,
13,
13,
2,
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
],
[
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
],
[
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
],
[
58,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
70,
76
],
[
76,
77
],
[
76,
78
],
[
67,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
67,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
8,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
93,
98
],
[
6,
99
],
[
99,
100
]
]
| [
"import java.util.*;\nclass Main{\n\n public static void main(String args[]){\n Scanner sc=new Scanner(System.in);\n int n=sc.nextInt();\n long a=0;\n long arr[]=new long[n];\n for(int i=0;i<n;i++){\n arr[i]=sc.nextInt();\n }\n for(int i=1;i<n;i++){\n if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }\n }\n System.out.println(a);\n }}\n ",
"import java.util.*;",
"util.*",
"java",
"class Main{\n\n public static void main(String args[]){\n Scanner sc=new Scanner(System.in);\n int n=sc.nextInt();\n long a=0;\n long arr[]=new long[n];\n for(int i=0;i<n;i++){\n arr[i]=sc.nextInt();\n }\n for(int i=1;i<n;i++){\n if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }\n }\n System.out.println(a);\n }}",
"Main",
"public static void main(String args[]){\n Scanner sc=new Scanner(System.in);\n int n=sc.nextInt();\n long a=0;\n long arr[]=new long[n];\n for(int i=0;i<n;i++){\n arr[i]=sc.nextInt();\n }\n for(int i=1;i<n;i++){\n if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }\n }\n System.out.println(a);\n }",
"main",
"{\n Scanner sc=new Scanner(System.in);\n int n=sc.nextInt();\n long a=0;\n long arr[]=new long[n];\n for(int i=0;i<n;i++){\n arr[i]=sc.nextInt();\n }\n for(int i=1;i<n;i++){\n if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }\n }\n System.out.println(a);\n }",
"Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long a=0;",
"a",
"0",
"long arr[]=new long[n];",
"arr",
"new long[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",
"for(int i=1;i<n;i++){\n if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }\n }",
"{\n if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }\n }",
"if(arr[i]<arr[i-1]){\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }",
"arr[i]<arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"{\n long k=arr[i-1]-arr[i];\n a=a+k;\n arr[i]=arr[i]+k;\n }",
"long k=arr[i-1]-arr[i];",
"k",
"arr[i-1]-arr[i]",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]",
"arr",
"i",
"a=a+k",
"a",
"a+k",
"a",
"k",
"arr[i]=arr[i]+k",
"arr[i]",
"arr",
"i",
"arr[i]+k",
"arr[i]",
"arr",
"i",
"k",
"System.out.println(a)",
"System.out.println",
"System.out",
"System",
"System.out",
"a",
"String args[]",
"args"
]
| import java.util.*;
class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long a=0;
long arr[]=new long[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}
for(int i=1;i<n;i++){
if(arr[i]<arr[i-1]){
long k=arr[i-1]-arr[i];
a=a+k;
arr[i]=arr[i]+k;
}
}
System.out.println(a);
}}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
13,
14,
2,
13,
13,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
159,
8
],
[
159,
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,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
25,
27
],
[
11,
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
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
40,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
48,
52
],
[
40,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
11,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
62,
67
],
[
9,
68
],
[
68,
69
],
[
159,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
70,
74
],
[
74,
75
],
[
70,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
70,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
85,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
95,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
84,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
70,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
117,
118
],
[
70,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
126,
127
],
[
70,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
135,
136
],
[
70,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
143,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
139,
156
],
[
156,
157
],
[
0,
158
],
[
158,
159
],
[
158,
160
]
]
| [
"import java.io.*;\nimport java.util.*;\n\npublic class Main {\n static class FastReader { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() { \n return Integer.parseInt(next()); \n } \n \n long nextLong() { \n return Long.parseLong(next()); \n } \n \n double nextDouble() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n\tpublic static void main (String[] args) throws IOException {\n\t\tFastReader sc = new FastReader();\n\t\tint n = sc.nextInt();\n\t\tlong count = 0;\n\t\tint max = Integer.MIN_VALUE;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}\n\t\t\n\t\tSystem.out.println(count);\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n static class FastReader { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() { \n return Integer.parseInt(next()); \n } \n \n long nextLong() { \n return Long.parseLong(next()); \n } \n \n double nextDouble() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n\tpublic static void main (String[] args) throws IOException {\n\t\tFastReader sc = new FastReader();\n\t\tint n = sc.nextInt();\n\t\tlong count = 0;\n\t\tint max = Integer.MIN_VALUE;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\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\tFastReader sc = new FastReader();\n\t\tint n = sc.nextInt();\n\t\tlong count = 0;\n\t\tint max = Integer.MIN_VALUE;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}\n\t\t\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\t\tFastReader sc = new FastReader();\n\t\tint n = sc.nextInt();\n\t\tlong count = 0;\n\t\tint max = Integer.MIN_VALUE;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}\n\t\t\n\t\tSystem.out.println(count);\n\t}",
"FastReader sc = new FastReader();",
"sc",
"new FastReader()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long count = 0;",
"count",
"0",
"int max = Integer.MIN_VALUE;",
"max",
"Integer.MIN_VALUE",
"Integer",
"Integer.MIN_VALUE",
"for (int i = 0; i < n; i++) {\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}",
"{\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}",
"int val = sc.nextInt();",
"val",
"sc.nextInt()",
"sc.nextInt",
"sc",
"max = Math.max(max, val)",
"max",
"Math.max(max, val)",
"Math.max",
"Math",
"max",
"val",
"if (val < max) \n\t\t count += (max - val);",
"val < max",
"val",
"max",
"count += (max - val)",
"count",
"(max - val)",
"max",
"val",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"static class FastReader { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() { \n return Integer.parseInt(next()); \n } \n \n long nextLong() { \n return Long.parseLong(next()); \n } \n \n double nextDouble() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }",
"FastReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n }",
"FastReader",
"{ \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n }",
"br = new BufferedReader(new\n InputStreamReader(System.in))",
"br",
"new BufferedReader(new\n InputStreamReader(System.in))",
"String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }",
"next",
"{ \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }",
"while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{ \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n }",
"try { \n st = new StringTokenizer(br.readLine()); \n } \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 st = new StringTokenizer(br.readLine()); \n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"long nextLong() { \n return Long.parseLong(next()); \n }",
"nextLong",
"{ \n return Long.parseLong(next()); \n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() { \n return Double.parseDouble(next()); \n }",
"nextDouble",
"{ \n return Double.parseDouble(next()); \n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n }",
"nextLine",
"{ \n String str = \"\"; \n try { \n str = br.readLine(); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n }",
"String str = \"\";",
"str",
"\"\"",
"try { \n str = br.readLine(); \n } \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 str = br.readLine(); \n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main {\n static class FastReader { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() { \n return Integer.parseInt(next()); \n } \n \n long nextLong() { \n return Long.parseLong(next()); \n } \n \n double nextDouble() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n\tpublic static void main (String[] args) throws IOException {\n\t\tFastReader sc = new FastReader();\n\t\tint n = sc.nextInt();\n\t\tlong count = 0;\n\t\tint max = Integer.MIN_VALUE;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}\n\t\t\n\t\tSystem.out.println(count);\n\t}\n}",
"public class Main {\n static class FastReader { \n BufferedReader br; \n StringTokenizer st; \n \n public FastReader() { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n \n int nextInt() { \n return Integer.parseInt(next()); \n } \n \n long nextLong() { \n return Long.parseLong(next()); \n } \n \n double nextDouble() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() { \n String str = \"\"; \n try { \n str = br.readLine(); \n } \n catch (IOException e) { \n e.printStackTrace(); \n } \n return str; \n } \n }\n \n\tpublic static void main (String[] args) throws IOException {\n\t\tFastReader sc = new FastReader();\n\t\tint n = sc.nextInt();\n\t\tlong count = 0;\n\t\tint max = Integer.MIN_VALUE;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t int val = sc.nextInt();\n\t\t max = Math.max(max, val);\n\t\t \n\t\t if (val < max) \n\t\t count += (max - val);\n\t\t}\n\t\t\n\t\tSystem.out.println(count);\n\t}\n}",
"Main"
]
| import java.io.*;
import java.util.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main (String[] args) throws IOException {
FastReader sc = new FastReader();
int n = sc.nextInt();
long count = 0;
int max = Integer.MIN_VALUE;
for (int i = 0; i < n; i++) {
int val = sc.nextInt();
max = Math.max(max, val);
if (val < max)
count += (max - val);
}
System.out.println(count);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
64,
5
],
[
64,
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,
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
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
35,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
41,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
52,
54
],
[
8,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
55,
60
],
[
6,
61
],
[
61,
62
],
[
0,
63
],
[
63,
64
],
[
63,
65
]
]
| [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint n = sc.nextInt();\n \tint cur = 0;\n \tlong sum = 0;\n \tfor (int i = 0; i < n; i++) {\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}\n \tSystem.out.println(sum);\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main (String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint n = sc.nextInt();\n \tint cur = 0;\n \tlong sum = 0;\n \tfor (int i = 0; i < n; i++) {\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}\n \tSystem.out.println(sum);\n }\n}",
"Main",
"public static void main (String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint n = sc.nextInt();\n \tint cur = 0;\n \tlong sum = 0;\n \tfor (int i = 0; i < n; i++) {\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}\n \tSystem.out.println(sum);\n }",
"main",
"{\n \tScanner sc = new Scanner(System.in);\n \tint n = sc.nextInt();\n \tint cur = 0;\n \tlong sum = 0;\n \tfor (int i = 0; i < n; i++) {\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}\n \tSystem.out.println(sum);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int cur = 0;",
"cur",
"0",
"long sum = 0;",
"sum",
"0",
"for (int i = 0; i < n; i++) {\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}",
"{\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}",
"int x = sc.nextInt();",
"x",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }",
"cur <= x",
"cur",
"x",
"{\n \t cur = x;\n \t }",
"cur = x",
"cur",
"x",
"{\n \t sum += cur - x;\n \t }",
"sum += cur - x",
"sum",
"cur - x",
"cur",
"x",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main {\n\tpublic static void main (String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint n = sc.nextInt();\n \tint cur = 0;\n \tlong sum = 0;\n \tfor (int i = 0; i < n; i++) {\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}\n \tSystem.out.println(sum);\n }\n}",
"public class Main {\n\tpublic static void main (String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint n = sc.nextInt();\n \tint cur = 0;\n \tlong sum = 0;\n \tfor (int i = 0; i < n; i++) {\n \t int x = sc.nextInt();\n \t if (cur <= x) {\n \t cur = x;\n \t } else {\n \t sum += cur - x;\n \t }\n \t}\n \tSystem.out.println(sum);\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 cur = 0;
long sum = 0;
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
if (cur <= x) {
cur = x;
} else {
sum += cur - x;
}
}
System.out.println(sum);
}
}
|
[
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,
4,
18,
13,
41,
13,
17,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
13,
13,
0,
13,
13,
4,
18,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
4,
18,
20,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
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
],
[
109,
20
],
[
109,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
23,
29
],
[
29,
30
],
[
29,
31
],
[
23,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
34,
36
],
[
23,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
37,
42
],
[
42,
43
],
[
42,
44
],
[
37,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
49,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
49,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
57,
61
],
[
49,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
49,
72
],
[
72,
73
],
[
72,
74
],
[
23,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
21,
79
],
[
79,
80
],
[
21,
81
],
[
81,
82
],
[
109,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
89,
91
],
[
85,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
92,
96
],
[
85,
97
],
[
97,
98
],
[
98,
99
],
[
85,
100
],
[
100,
101
],
[
101,
102
],
[
85,
103
],
[
103,
104
],
[
104,
105
],
[
83,
106
],
[
106,
107
],
[
0,
108
],
[
108,
109
],
[
108,
110
]
]
| [
"import java.io.PrintWriter;\nimport java.math.BigInteger;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n void solve(Scanner sc, PrintWriter pw) {\n int N = sc.nextInt();\n long total = 0;\n int currentMax = Integer.MIN_VALUE;\n for (int i = 0; i < N; i++) {\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }\n pw.println(total);\n }\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }\n}",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.math.BigInteger;",
"BigInteger",
"java.math",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.HashSet;",
"HashSet",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Set;",
"Set",
"java.util",
"public class Main {\n void solve(Scanner sc, PrintWriter pw) {\n int N = sc.nextInt();\n long total = 0;\n int currentMax = Integer.MIN_VALUE;\n for (int i = 0; i < N; i++) {\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }\n pw.println(total);\n }\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }\n}",
"Main",
"void solve(Scanner sc, PrintWriter pw) {\n int N = sc.nextInt();\n long total = 0;\n int currentMax = Integer.MIN_VALUE;\n for (int i = 0; i < N; i++) {\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }\n pw.println(total);\n }",
"solve",
"{\n int N = sc.nextInt();\n long total = 0;\n int currentMax = Integer.MIN_VALUE;\n for (int i = 0; i < N; i++) {\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }\n pw.println(total);\n }",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long total = 0;",
"total",
"0",
"int currentMax = Integer.MIN_VALUE;",
"currentMax",
"Integer.MIN_VALUE",
"Integer",
"Integer.MIN_VALUE",
"for (int i = 0; i < N; i++) {\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }",
"{\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }",
"int val = sc.nextInt();",
"val",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int nextMax = Math.max(currentMax, val);",
"nextMax",
"Math.max(currentMax, val)",
"Math.max",
"Math",
"currentMax",
"val",
"if (i > 0) {\n total += nextMax - val;\n }",
"i > 0",
"i",
"0",
"{\n total += nextMax - val;\n }",
"total += nextMax - val",
"total",
"nextMax - val",
"nextMax",
"val",
"currentMax = nextMax",
"currentMax",
"nextMax",
"pw.println(total)",
"pw.println",
"pw",
"total",
"Scanner sc",
"sc",
"PrintWriter pw",
"pw",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"PrintWriter pw = new PrintWriter(System.out);",
"pw",
"new PrintWriter(System.out)",
"new Main().solve(sc, pw)",
"new Main().solve",
"new Main()",
"sc",
"pw",
"pw.flush()",
"pw.flush",
"pw",
"pw.close()",
"pw.close",
"pw",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"public class Main {\n void solve(Scanner sc, PrintWriter pw) {\n int N = sc.nextInt();\n long total = 0;\n int currentMax = Integer.MIN_VALUE;\n for (int i = 0; i < N; i++) {\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }\n pw.println(total);\n }\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }\n}",
"public class Main {\n void solve(Scanner sc, PrintWriter pw) {\n int N = sc.nextInt();\n long total = 0;\n int currentMax = Integer.MIN_VALUE;\n for (int i = 0; i < N; i++) {\n int val = sc.nextInt();\n int nextMax = Math.max(currentMax, val);\n if (i > 0) {\n total += nextMax - val;\n }\n currentMax = nextMax;\n }\n pw.println(total);\n }\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }\n}",
"Main"
]
| import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
void solve(Scanner sc, PrintWriter pw) {
int N = sc.nextInt();
long total = 0;
int currentMax = Integer.MIN_VALUE;
for (int i = 0; i < N; i++) {
int val = sc.nextInt();
int nextMax = Math.max(currentMax, val);
if (i > 0) {
total += nextMax - val;
}
currentMax = nextMax;
}
pw.println(total);
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
new Main().solve(sc, pw);
pw.flush();
pw.close();
sc.close();
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
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,
0,
13,
18,
13,
13,
41,
13,
18,
13,
17,
11,
1,
41,
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,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
113,
5
],
[
113,
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,
25
],
[
25,
26
],
[
25,
27
],
[
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
],
[
40,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
50,
52
],
[
8,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
55,
57
],
[
8,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
58,
63
],
[
63,
64
],
[
63,
65
],
[
58,
66
],
[
66,
67
],
[
67,
68
],
[
58,
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
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
81,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
71,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
8,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
107,
108
],
[
107,
109
],
[
6,
110
],
[
110,
111
],
[
0,
112
],
[
112,
113
],
[
112,
114
]
]
| [
"import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[]a = new int[n];\n int[]A = new int[n];\n \n long al = 0;\n for(int i=0; i<n; i++) {\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}\n \tlong all= a[0];\n \tfor(int i=1; i<n; i++) {\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}\n \tSystem.out.println(all - al);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[]a = new int[n];\n int[]A = new int[n];\n \n long al = 0;\n for(int i=0; i<n; i++) {\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}\n \tlong all= a[0];\n \tfor(int i=1; i<n; i++) {\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}\n \tSystem.out.println(all - al);\n }\n}",
"Main",
"public static void main(String[] args){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[]a = new int[n];\n int[]A = new int[n];\n \n long al = 0;\n for(int i=0; i<n; i++) {\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}\n \tlong all= a[0];\n \tfor(int i=1; i<n; i++) {\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}\n \tSystem.out.println(all - al);\n }",
"main",
"{\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[]a = new int[n];\n int[]A = new int[n];\n \n long al = 0;\n for(int i=0; i<n; i++) {\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}\n \tlong all= a[0];\n \tfor(int i=1; i<n; i++) {\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}\n \tSystem.out.println(all - al);\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[]A = new int[n];",
"A",
"new int[n]",
"n",
"long al = 0;",
"al",
"0",
"for(int i=0; i<n; i++) {\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}",
"{\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"al += a[i]",
"al",
"a[i]",
"a",
"i",
"long all= a[0];",
"all",
"a[0]",
"a",
"0",
"for(int i=1; i<n; i++) {\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}",
"{\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}",
"if(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}",
"a[i] < a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"{\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}",
"a[i] = a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"all += a[i]",
"all",
"a[i]",
"a",
"i",
"{\n \t\t\tall += a[i];\n \t\t}",
"all += a[i]",
"all",
"a[i]",
"a",
"i",
"System.out.println(all - al)",
"System.out.println",
"System.out",
"System",
"System.out",
"all - al",
"all",
"al",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[]a = new int[n];\n int[]A = new int[n];\n \n long al = 0;\n for(int i=0; i<n; i++) {\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}\n \tlong all= a[0];\n \tfor(int i=1; i<n; i++) {\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}\n \tSystem.out.println(all - al);\n }\n}",
"public class Main {\n public static void main(String[] args){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[]a = new int[n];\n int[]A = new int[n];\n \n long al = 0;\n for(int i=0; i<n; i++) {\n \t\ta[i] = sc.nextInt();\n \t\tal += a[i];\n \t}\n \tlong all= a[0];\n \tfor(int i=1; i<n; i++) {\n \t\tif(a[i] < a[i-1]) {\n \t\t\ta[i] = a[i-1];\n \t\t\tall += a[i];\n \t\t}else {\n \t\t\tall += a[i];\n \t\t}\n \t}\n \tSystem.out.println(all - al);\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];
int[]A = new int[n];
long al = 0;
for(int i=0; i<n; i++) {
a[i] = sc.nextInt();
al += a[i];
}
long all= a[0];
for(int i=1; i<n; i++) {
if(a[i] < a[i-1]) {
a[i] = a[i-1];
all += a[i];
}else {
all += a[i];
}
}
System.out.println(all - al);
}
} |
[
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,
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,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
114,
5
],
[
114,
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
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
30,
33
],
[
8,
34
],
[
34,
35
],
[
34,
36
],
[
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
],
[
58,
60
],
[
8,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
8,
66
],
[
66,
67
],
[
66,
68
],
[
8,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
69,
74
],
[
74,
75
],
[
74,
76
],
[
69,
77
],
[
77,
78
],
[
78,
79
],
[
69,
80
],
[
81,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
83,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
82,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
8,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
8,
108
],
[
108,
109
],
[
109,
110
],
[
6,
111
],
[
111,
112
],
[
0,
113
],
[
113,
114
],
[
113,
115
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tString N = scan.nextLine();\n\t\tint n = Integer.parseInt(N);\n\n\t\tString L = scan.nextLine();\n\t\tString[] l = L.split(\" \");\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}\n\n\t\tlong max = a[0];\n\t\tlong total = 0;\n\t\tfor(int i = 1 ; i < n ; i++) {\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(total);\n\n\t\tscan.close();\n\n\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\n\t\tString N = scan.nextLine();\n\t\tint n = Integer.parseInt(N);\n\n\t\tString L = scan.nextLine();\n\t\tString[] l = L.split(\" \");\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}\n\n\t\tlong max = a[0];\n\t\tlong total = 0;\n\t\tfor(int i = 1 ; i < n ; i++) {\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(total);\n\n\t\tscan.close();\n\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tString N = scan.nextLine();\n\t\tint n = Integer.parseInt(N);\n\n\t\tString L = scan.nextLine();\n\t\tString[] l = L.split(\" \");\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}\n\n\t\tlong max = a[0];\n\t\tlong total = 0;\n\t\tfor(int i = 1 ; i < n ; i++) {\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(total);\n\n\t\tscan.close();\n\n\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tString N = scan.nextLine();\n\t\tint n = Integer.parseInt(N);\n\n\t\tString L = scan.nextLine();\n\t\tString[] l = L.split(\" \");\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}\n\n\t\tlong max = a[0];\n\t\tlong total = 0;\n\t\tfor(int i = 1 ; i < n ; i++) {\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(total);\n\n\t\tscan.close();\n\n\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"String N = scan.nextLine();",
"N",
"scan.nextLine()",
"scan.nextLine",
"scan",
"int n = Integer.parseInt(N);",
"n",
"Integer.parseInt(N)",
"Integer.parseInt",
"Integer",
"N",
"String L = scan.nextLine();",
"L",
"scan.nextLine()",
"scan.nextLine",
"scan",
"String[] l = L.split(\" \");",
"l",
"L.split(\" \")",
"L.split",
"L",
"\" \"",
"long[] a = new long[n];",
"a",
"new long[n]",
"n",
"for(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}",
"{\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}",
"a[i] = Long.parseLong(l[i])",
"a[i]",
"a",
"i",
"Long.parseLong(l[i])",
"Long.parseLong",
"Long",
"l[i]",
"l",
"i",
"long max = a[0];",
"max",
"a[0]",
"a",
"0",
"long total = 0;",
"total",
"0",
"for(int i = 1 ; i < n ; i++) {\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\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\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}",
"if(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}",
"a[i] < max",
"a[i]",
"a",
"i",
"max",
"{\n\t\t\t\ttotal += max - a[i];\n\t\t\t}",
"total += max - a[i]",
"total",
"max - a[i]",
"max",
"a[i]",
"a",
"i",
"{\n\t\t\t\tmax = a[i];\n\t\t\t}",
"max = a[i]",
"max",
"a[i]",
"a",
"i",
"System.out.println(total)",
"System.out.println",
"System.out",
"System",
"System.out",
"total",
"scan.close()",
"scan.close",
"scan",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tString N = scan.nextLine();\n\t\tint n = Integer.parseInt(N);\n\n\t\tString L = scan.nextLine();\n\t\tString[] l = L.split(\" \");\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}\n\n\t\tlong max = a[0];\n\t\tlong total = 0;\n\t\tfor(int i = 1 ; i < n ; i++) {\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(total);\n\n\t\tscan.close();\n\n\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tString N = scan.nextLine();\n\t\tint n = Integer.parseInt(N);\n\n\t\tString L = scan.nextLine();\n\t\tString[] l = L.split(\" \");\n\t\tlong[] a = new long[n];\n\t\tfor(int i = 0 ; i < n ; i++) {\n\t\t\ta[i] = Long.parseLong(l[i]);\n\t\t}\n\n\t\tlong max = a[0];\n\t\tlong total = 0;\n\t\tfor(int i = 1 ; i < n ; i++) {\n\t\t\tif(a[i] < max) {\n\t\t\t\ttotal += max - a[i];\n\t\t\t}else {\n\t\t\t\tmax = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(total);\n\n\t\tscan.close();\n\n\n\t}\n\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String N = scan.nextLine();
int n = Integer.parseInt(N);
String L = scan.nextLine();
String[] l = L.split(" ");
long[] a = new long[n];
for(int i = 0 ; i < n ; i++) {
a[i] = Long.parseLong(l[i]);
}
long max = a[0];
long total = 0;
for(int i = 1 ; i < n ; i++) {
if(a[i] < max) {
total += max - a[i];
}else {
max = a[i];
}
}
System.out.println(total);
scan.close();
}
}
|
[
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,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
30,
0,
13,
2,
13,
2,
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
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
99,
11
],
[
99,
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,
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
],
[
14,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
14,
52
],
[
52,
53
],
[
52,
54
],
[
14,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
55,
60
],
[
60,
61
],
[
60,
62
],
[
55,
63
],
[
63,
64
],
[
64,
65
],
[
55,
66
],
[
67,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
68,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
14,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
12,
96
],
[
96,
97
],
[
0,
98
],
[
98,
99
],
[
98,
100
]
]
| [
"import java.util.*;\nimport java.io.*;\nimport java.math.BigInteger;\n \npublic class Main {\n\tpublic static void main(String[] args) {\n\tScanner s = new Scanner(System.in);\n\tint N = s.nextInt();\n\tint[] A = new int[N];\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tA[i] = s.nextInt();\n\t}\n\n\tint max = A[0];\n\tlong count = 0;\n\tfor(int i = 1; i < N; i++){\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}\n\t\n\t\n\tSystem.out.println(count);\n\t\n\n \n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"import java.math.BigInteger;",
"BigInteger",
"java.math",
"public class Main {\n\tpublic static void main(String[] args) {\n\tScanner s = new Scanner(System.in);\n\tint N = s.nextInt();\n\tint[] A = new int[N];\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tA[i] = s.nextInt();\n\t}\n\n\tint max = A[0];\n\tlong count = 0;\n\tfor(int i = 1; i < N; i++){\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}\n\t\n\t\n\tSystem.out.println(count);\n\t\n\n \n }\n}",
"Main",
"public static void main(String[] args) {\n\tScanner s = new Scanner(System.in);\n\tint N = s.nextInt();\n\tint[] A = new int[N];\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tA[i] = s.nextInt();\n\t}\n\n\tint max = A[0];\n\tlong count = 0;\n\tfor(int i = 1; i < N; i++){\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}\n\t\n\t\n\tSystem.out.println(count);\n\t\n\n \n }",
"main",
"{\n\tScanner s = new Scanner(System.in);\n\tint N = s.nextInt();\n\tint[] A = new int[N];\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tA[i] = s.nextInt();\n\t}\n\n\tint max = A[0];\n\tlong count = 0;\n\tfor(int i = 1; i < N; i++){\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}\n\t\n\t\n\tSystem.out.println(count);\n\t\n\n \n }",
"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\tA[i] = s.nextInt();\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\tA[i] = s.nextInt();\n\t}",
"{\n\t\tA[i] = s.nextInt();\n\t}",
"A[i] = s.nextInt()",
"A[i]",
"A",
"i",
"s.nextInt()",
"s.nextInt",
"s",
"int max = A[0];",
"max",
"A[0]",
"A",
"0",
"long count = 0;",
"count",
"0",
"for(int i = 1; i < N; i++){\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}",
"{\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}",
"if(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}",
"max<A[i]",
"max",
"A[i]",
"A",
"i",
"{\n\t\t\tmax = A[i];\n\t\t}",
"max = A[i]",
"max",
"A[i]",
"A",
"i",
"{\n\t\t\tcount = count + (max - A[i]);\n\t\t}",
"count = count + (max - A[i])",
"count",
"count + (max - A[i])",
"count",
"(max - A[i])",
"max",
"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\tScanner s = new Scanner(System.in);\n\tint N = s.nextInt();\n\tint[] A = new int[N];\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tA[i] = s.nextInt();\n\t}\n\n\tint max = A[0];\n\tlong count = 0;\n\tfor(int i = 1; i < N; i++){\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}\n\t\n\t\n\tSystem.out.println(count);\n\t\n\n \n }\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\tScanner s = new Scanner(System.in);\n\tint N = s.nextInt();\n\tint[] A = new int[N];\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tA[i] = s.nextInt();\n\t}\n\n\tint max = A[0];\n\tlong count = 0;\n\tfor(int i = 1; i < N; i++){\n\t\tif(max<A[i]){\n\t\t\tmax = A[i];\n\t\t}else{\n\t\t\tcount = count + (max - A[i]);\n\t\t}\n\t}\n\t\n\t\n\tSystem.out.println(count);\n\t\n\n \n }\n}",
"Main"
]
| import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
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();
}
int max = A[0];
long count = 0;
for(int i = 1; i < N; i++){
if(max<A[i]){
max = A[i];
}else{
count = count + (max - 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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
0,
13,
4,
18,
13,
18,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
94,
5
],
[
94,
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
],
[
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
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
61,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
8,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
85,
90
],
[
6,
91
],
[
91,
92
],
[
0,
93
],
[
93,
94
],
[
93,
95
]
]
| [
"import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tlong [] in = new long [a]; \n for(int i=0;i<a;i++){\n in[i] = sc.nextLong();\n }\t\t\n long max = in[0];\n\t\tlong ans = 0;\n for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n } \n\t\tSystem.out.println(ans);\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 a = sc.nextInt();\n\t\tlong [] in = new long [a]; \n for(int i=0;i<a;i++){\n in[i] = sc.nextLong();\n }\t\t\n long max = in[0];\n\t\tlong ans = 0;\n for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n } \n\t\tSystem.out.println(ans);\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tlong [] in = new long [a]; \n for(int i=0;i<a;i++){\n in[i] = sc.nextLong();\n }\t\t\n long max = in[0];\n\t\tlong ans = 0;\n for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n } \n\t\tSystem.out.println(ans);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tlong [] in = new long [a]; \n for(int i=0;i<a;i++){\n in[i] = sc.nextLong();\n }\t\t\n long max = in[0];\n\t\tlong ans = 0;\n for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n } \n\t\tSystem.out.println(ans);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int a = sc.nextInt();",
"a",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long [] in = new long [a];",
"in",
"new long [a]",
"a",
"for(int i=0;i<a;i++){\n in[i] = sc.nextLong();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<a",
"i",
"a",
"i++",
"i++",
"i",
"{\n in[i] = sc.nextLong();\n }",
"{\n in[i] = sc.nextLong();\n }",
"in[i] = sc.nextLong()",
"in[i]",
"in",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"long max = in[0];",
"max",
"in[0]",
"in",
"0",
"long ans = 0;",
"ans",
"0",
"for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<a",
"i",
"a",
"i++",
"i++",
"i",
"{if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n }",
"{if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n }",
"if(max>in[i]){ans+=max-in[i];}",
"max>in[i]",
"max",
"in[i]",
"in",
"i",
"{ans+=max-in[i];}",
"ans+=max-in[i]",
"ans",
"max-in[i]",
"max",
"in[i]",
"in",
"i",
"max=Math.max(in[i],max)",
"max",
"Math.max(in[i],max)",
"Math.max",
"Math",
"in[i]",
"in",
"i",
"max",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tlong [] in = new long [a]; \n for(int i=0;i<a;i++){\n in[i] = sc.nextLong();\n }\t\t\n long max = in[0];\n\t\tlong ans = 0;\n for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n } \n\t\tSystem.out.println(ans);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tlong [] in = new long [a]; \n for(int i=0;i<a;i++){\n in[i] = sc.nextLong();\n }\t\t\n long max = in[0];\n\t\tlong ans = 0;\n for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}\n max=Math.max(in[i],max);\n } \n\t\tSystem.out.println(ans);\n\t}\n}",
"Main"
]
| import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
long [] in = new long [a];
for(int i=0;i<a;i++){
in[i] = sc.nextLong();
}
long max = in[0];
long ans = 0;
for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}
max=Math.max(in[i],max);
}
System.out.println(ans);
}
} |
[
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,
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,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
14,
2,
18,
13,
13,
13,
0,
13,
2,
13,
18,
13,
13,
0,
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
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
93,
11
],
[
93,
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,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
27,
32
],
[
32,
33
],
[
32,
34
],
[
27,
35
],
[
35,
36
],
[
36,
37
],
[
27,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
44,
45
],
[
14,
46
],
[
46,
47
],
[
46,
48
],
[
14,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
14,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
54,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
66,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
66,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
14,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
84,
89
],
[
12,
90
],
[
90,
91
],
[
0,
92
],
[
92,
93
],
[
92,
94
]
]
| [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n\t\tint n = 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\n\t\tlong ans = 0;\n\t\tint h = a[0];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];\n\t\tSystem.out.println(ans);\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n\t\tint n = 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\n\t\tlong ans = 0;\n\t\tint h = a[0];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];\n\t\tSystem.out.println(ans);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n\t\tint n = 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\n\t\tlong ans = 0;\n\t\tint h = a[0];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];\n\t\tSystem.out.println(ans);\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n\t\tint n = 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\n\t\tlong ans = 0;\n\t\tint h = a[0];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];\n\t\tSystem.out.println(ans);\n\t}",
"Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));",
"in",
"new Scanner(new BufferedReader(new InputStreamReader(System.in)))",
"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 < n; i++)\n\t\t\ta[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",
"long ans = 0;",
"ans",
"0",
"int h = a[0];",
"h",
"a[0]",
"a",
"0",
"for (int i = 1; i < n; i++)\n\t\t\tif (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"if (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];",
"if (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];",
"a[i] < h",
"a[i]",
"a",
"i",
"h",
"ans += h - a[i]",
"ans",
"h - a[i]",
"h",
"a[i]",
"a",
"i",
"h = a[i]",
"h",
"a[i]",
"a",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n\t\tint n = 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\n\t\tlong ans = 0;\n\t\tint h = a[0];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];\n\t\tSystem.out.println(ans);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n\t\tint n = 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\n\t\tlong ans = 0;\n\t\tint h = a[0];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (a[i] < h)\n\t\t\t\tans += h - a[i];\n\t\t\telse\n\t\t\t\th = a[i];\n\t\tSystem.out.println(ans);\n\t}\n}",
"Main"
]
| import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int n = in.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = in.nextInt();
long ans = 0;
int h = a[0];
for (int i = 1; i < n; i++)
if (a[i] < h)
ans += h - a[i];
else
h = a[i];
System.out.println(ans);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
0,
13,
4,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
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,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
107,
5
],
[
107,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
14,
16
],
[
8,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
17,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
24,
26
],
[
17,
27
],
[
27,
28
],
[
28,
29
],
[
17,
30
],
[
31,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
32,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
43,
45
],
[
31,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
48,
52
],
[
52,
53
],
[
52,
54
],
[
8,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
55,
60
],
[
6,
61
],
[
61,
62
],
[
107,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
65,
74
],
[
74,
75
],
[
74,
76
],
[
65,
77
],
[
77,
78
],
[
77,
79
],
[
65,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
81,
86
],
[
86,
87
],
[
86,
88
],
[
81,
89
],
[
89,
90
],
[
90,
91
],
[
81,
92
],
[
93,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
99,
100
],
[
65,
101
],
[
101,
102
],
[
101,
103
],
[
63,
104
],
[
104,
105
],
[
0,
106
],
[
106,
107
],
[
106,
108
]
]
| [
" \nimport java.util.Scanner;\n \npublic class Main{//2 1 5 4 3\n \n public static void solve(int[] arr){\n \n long ans = 0;\n int prev = Integer.MIN_VALUE;\n for(int i= 0; i < arr.length; i++){\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }\n \n System.out.println(ans);\n }\n \n public static void main(String[] args) {\n Scanner sc=new Scanner(System.in);\n int N=sc.nextInt();\n long ans=0;\n int[] arr = new int[N];\n for(int i=0;i<N;i++){\n arr[i]=sc.nextInt();\n }\n \n \n solve(arr);\n \n \n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{//2 1 5 4 3\n \n public static void solve(int[] arr){\n \n long ans = 0;\n int prev = Integer.MIN_VALUE;\n for(int i= 0; i < arr.length; i++){\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }\n \n System.out.println(ans);\n }\n \n public static void main(String[] args) {\n Scanner sc=new Scanner(System.in);\n int N=sc.nextInt();\n long ans=0;\n int[] arr = new int[N];\n for(int i=0;i<N;i++){\n arr[i]=sc.nextInt();\n }\n \n \n solve(arr);\n \n \n }\n}",
"Main",
"public static void solve(int[] arr){\n \n long ans = 0;\n int prev = Integer.MIN_VALUE;\n for(int i= 0; i < arr.length; i++){\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }\n \n System.out.println(ans);\n }",
"solve",
"{\n \n long ans = 0;\n int prev = Integer.MIN_VALUE;\n for(int i= 0; i < arr.length; i++){\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }\n \n System.out.println(ans);\n }",
"long ans = 0;",
"ans",
"0",
"int prev = Integer.MIN_VALUE;",
"prev",
"Integer.MIN_VALUE",
"Integer",
"Integer.MIN_VALUE",
"for(int i= 0; i < arr.length; i++){\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }",
"int i= 0;",
"int i= 0;",
"i",
"0",
"i < arr.length",
"i",
"arr.length",
"arr",
"arr.length",
"i++",
"i++",
"i",
"{\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }",
"{\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }",
"if(arr[i] < prev){\n ans += prev - arr[i];\n }",
"arr[i] < prev",
"arr[i]",
"arr",
"i",
"prev",
"{\n ans += prev - arr[i];\n }",
"ans += prev - arr[i]",
"ans",
"prev - arr[i]",
"prev",
"arr[i]",
"arr",
"i",
"prev = Math.max(prev,arr[i])",
"prev",
"Math.max(prev,arr[i])",
"Math.max",
"Math",
"prev",
"arr[i]",
"arr",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"int[] arr",
"arr",
"public static void main(String[] args) {\n Scanner sc=new Scanner(System.in);\n int N=sc.nextInt();\n long ans=0;\n int[] arr = new int[N];\n for(int i=0;i<N;i++){\n arr[i]=sc.nextInt();\n }\n \n \n solve(arr);\n \n \n }",
"main",
"{\n Scanner sc=new Scanner(System.in);\n int N=sc.nextInt();\n long ans=0;\n int[] arr = new int[N];\n for(int i=0;i<N;i++){\n arr[i]=sc.nextInt();\n }\n \n \n solve(arr);\n \n \n }",
"Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N=sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long ans=0;",
"ans",
"0",
"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",
"solve(arr)",
"solve",
"arr",
"String[] args",
"args",
"public class Main{//2 1 5 4 3\n \n public static void solve(int[] arr){\n \n long ans = 0;\n int prev = Integer.MIN_VALUE;\n for(int i= 0; i < arr.length; i++){\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }\n \n System.out.println(ans);\n }\n \n public static void main(String[] args) {\n Scanner sc=new Scanner(System.in);\n int N=sc.nextInt();\n long ans=0;\n int[] arr = new int[N];\n for(int i=0;i<N;i++){\n arr[i]=sc.nextInt();\n }\n \n \n solve(arr);\n \n \n }\n}",
"public class Main{//2 1 5 4 3\n \n public static void solve(int[] arr){\n \n long ans = 0;\n int prev = Integer.MIN_VALUE;\n for(int i= 0; i < arr.length; i++){\n if(arr[i] < prev){\n ans += prev - arr[i];\n }\n \n prev = Math.max(prev,arr[i]);\n }\n \n System.out.println(ans);\n }\n \n public static void main(String[] args) {\n Scanner sc=new Scanner(System.in);\n int N=sc.nextInt();\n long ans=0;\n int[] arr = new int[N];\n for(int i=0;i<N;i++){\n arr[i]=sc.nextInt();\n }\n \n \n solve(arr);\n \n \n }\n}",
"Main"
]
|
import java.util.Scanner;
public class Main{//2 1 5 4 3
public static void solve(int[] arr){
long ans = 0;
int prev = Integer.MIN_VALUE;
for(int i= 0; i < arr.length; i++){
if(arr[i] < prev){
ans += prev - arr[i];
}
prev = Math.max(prev,arr[i]);
}
System.out.println(ans);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
long ans=0;
int[] arr = new int[N];
for(int i=0;i<N;i++){
arr[i]=sc.nextInt();
}
solve(arr);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
0,
13,
20,
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
18,
13,
2,
13,
17,
4,
18,
13,
13,
4,
18,
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
],
[
7,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
14,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
26,
29
],
[
29,
30
],
[
30,
31
],
[
14,
32
],
[
32,
33
],
[
32,
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
],
[
60,
61
],
[
14,
62
],
[
62,
63
],
[
62,
64
],
[
14,
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
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
78,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
91,
97
],
[
97,
98
],
[
97,
99
],
[
88,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
14,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
14,
113
],
[
113,
114
],
[
114,
115
],
[
12,
116
],
[
116,
117
]
]
| [
"import java.util.*;\nimport java.io.*;\n\nclass Main{\n static boolean found = false;\n public static void main(String[] args) throws IOException {\n PrintWriter out = new PrintWriter(System.out);\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(br.readLine());\n\n int N = Integer.parseInt(st.nextToken());\n \n st = new StringTokenizer(br.readLine());\n\n int[] arr = new int[N];\n\n for (int i=0; i<N; i++) {\n arr[i] = Integer.parseInt(st.nextToken());\n }\n\n long ans = 0;\n\n for (int i=1; i<N; i++) {\n if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }\n }\n\n out.println(ans);\n\n out.close();\n }\n\n \n}\n\n\n\n\n\n\n\n",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"class Main{\n static boolean found = false;\n public static void main(String[] args) throws IOException {\n PrintWriter out = new PrintWriter(System.out);\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(br.readLine());\n\n int N = Integer.parseInt(st.nextToken());\n \n st = new StringTokenizer(br.readLine());\n\n int[] arr = new int[N];\n\n for (int i=0; i<N; i++) {\n arr[i] = Integer.parseInt(st.nextToken());\n }\n\n long ans = 0;\n\n for (int i=1; i<N; i++) {\n if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }\n }\n\n out.println(ans);\n\n out.close();\n }\n\n \n}",
"Main",
"static boolean found = false;",
"found",
"false",
"public static void main(String[] args) throws IOException {\n PrintWriter out = new PrintWriter(System.out);\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(br.readLine());\n\n int N = Integer.parseInt(st.nextToken());\n \n st = new StringTokenizer(br.readLine());\n\n int[] arr = new int[N];\n\n for (int i=0; i<N; i++) {\n arr[i] = Integer.parseInt(st.nextToken());\n }\n\n long ans = 0;\n\n for (int i=1; i<N; i++) {\n if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }\n }\n\n out.println(ans);\n\n out.close();\n }",
"main",
"{\n PrintWriter out = new PrintWriter(System.out);\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(br.readLine());\n\n int N = Integer.parseInt(st.nextToken());\n \n st = new StringTokenizer(br.readLine());\n\n int[] arr = new int[N];\n\n for (int i=0; i<N; i++) {\n arr[i] = Integer.parseInt(st.nextToken());\n }\n\n long ans = 0;\n\n for (int i=1; i<N; i++) {\n if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }\n }\n\n out.println(ans);\n\n out.close();\n }",
"PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"StringTokenizer st = new StringTokenizer(br.readLine());",
"st",
"new StringTokenizer(br.readLine())",
"int N = Integer.parseInt(st.nextToken());",
"N",
"Integer.parseInt(st.nextToken())",
"Integer.parseInt",
"Integer",
"st.nextToken()",
"st.nextToken",
"st",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"int[] arr = new int[N];",
"arr",
"new int[N]",
"N",
"for (int i=0; i<N; i++) {\n arr[i] = Integer.parseInt(st.nextToken());\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n arr[i] = Integer.parseInt(st.nextToken());\n }",
"{\n arr[i] = Integer.parseInt(st.nextToken());\n }",
"arr[i] = Integer.parseInt(st.nextToken())",
"arr[i]",
"arr",
"i",
"Integer.parseInt(st.nextToken())",
"Integer.parseInt",
"Integer",
"st.nextToken()",
"st.nextToken",
"st",
"long ans = 0;",
"ans",
"0",
"for (int i=1; i<N; i++) {\n if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }\n }",
"{\n if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }\n }",
"if(arr[i]<arr[i-1]){\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }",
"arr[i]<arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"{\n ans+=arr[i-1]-arr[i];\n arr[i] = arr[i-1];\n }",
"ans+=arr[i-1]-arr[i]",
"ans",
"arr[i-1]-arr[i]",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]",
"arr",
"i",
"arr[i] = arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"out.println(ans)",
"out.println",
"out",
"ans",
"out.close()",
"out.close",
"out",
"String[] args",
"args"
]
| import java.util.*;
import java.io.*;
class Main{
static boolean found = false;
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
st = new StringTokenizer(br.readLine());
int[] arr = new int[N];
for (int i=0; i<N; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
long ans = 0;
for (int i=1; i<N; i++) {
if(arr[i]<arr[i-1]){
ans+=arr[i-1]-arr[i];
arr[i] = arr[i-1];
}
}
out.println(ans);
out.close();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
20,
2,
17,
17,
41,
13,
41,
13,
18,
13,
13,
41,
13,
41,
13,
20,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
13,
42,
4,
13,
13,
0,
13,
4,
13,
42,
40,
4,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
14,
2,
13,
17,
37,
20,
14,
2,
13,
13,
30,
0,
13,
17,
0,
13,
4,
18,
13,
13,
14,
2,
13,
17,
29,
40,
17,
29,
18,
13,
40,
13,
12,
13,
30,
41,
13,
17,
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,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
37,
20,
29,
2,
13,
13,
12,
13,
30,
41,
13,
17,
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,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
37,
20,
29,
2,
13,
13,
12,
13,
30,
41,
13,
17,
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,
42,
2,
40,
4,
13,
13,
2,
13,
17,
30,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
37,
20,
14,
2,
13,
17,
30,
0,
13,
4,
13,
41,
13,
17,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
17,
0,
13,
2,
2,
13,
17,
13,
0,
13,
4,
13,
37,
20,
29,
2,
13,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
12,
13,
30,
14,
2,
2,
2,
2,
2,
13,
17,
2,
13,
17,
2,
13,
17,
2,
13,
17,
2,
13,
40,
17,
29,
17,
29,
17,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
13,
13,
4,
18,
13,
17,
23,
13,
12,
13,
30,
4,
18,
13,
12,
13,
30,
4,
18,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
2,
13,
13,
13,
1,
40,
13,
30,
30,
14,
40,
18,
13,
13,
30,
11,
1,
41,
13,
2,
13,
17,
2,
13,
13,
1,
0,
13,
13,
30,
30,
0,
18,
13,
13,
17,
12,
13,
30,
41,
13,
4,
13,
41,
13,
17,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
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,
4,
18,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
13,
18,
13,
2,
13,
17,
4,
13,
2,
13,
17,
4,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
2,
2,
18,
13,
13,
17,
18,
13,
13,
23,
13,
12,
13,
30,
29,
2,
18,
36,
13,
18,
13,
13,
23,
13,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
709,
8
],
[
709,
9
],
[
9,
10
],
[
9,
11
],
[
709,
12
],
[
12,
13
],
[
12,
14
],
[
709,
15
],
[
15,
16
],
[
709,
17
],
[
17,
18
],
[
17,
19
],
[
20,
21
],
[
20,
22
],
[
709,
23
],
[
23,
24
],
[
709,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
27,
29
],
[
709,
30
],
[
30,
31
],
[
709,
32
],
[
32,
33
],
[
32,
34
],
[
709,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
38,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
38,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
59,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
38,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
709,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
74,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
85,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
100,
101
],
[
74,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
709,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
109,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
109,
125
],
[
125,
126
],
[
125,
127
],
[
109,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
132,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
109,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
152,
153
],
[
152,
154
],
[
147,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
155,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
147,
168
],
[
168,
169
],
[
109,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
709,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
176,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
176,
192
],
[
192,
193
],
[
192,
194
],
[
176,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
195,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
199,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
176,
208
],
[
208,
209
],
[
209,
210
],
[
210,
211
],
[
210,
212
],
[
208,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
215,
219
],
[
219,
220
],
[
219,
221
],
[
214,
222
],
[
222,
223
],
[
223,
224
],
[
223,
225
],
[
222,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
228,
230
],
[
222,
231
],
[
231,
232
],
[
231,
233
],
[
233,
234
],
[
214,
235
],
[
235,
236
],
[
176,
237
],
[
237,
238
],
[
238,
239
],
[
238,
240
],
[
709,
241
],
[
241,
242
],
[
241,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
243,
247
],
[
247,
248
],
[
247,
249
],
[
249,
250
],
[
243,
251
],
[
251,
252
],
[
252,
253
],
[
252,
254
],
[
251,
255
],
[
255,
256
],
[
255,
257
],
[
257,
258
],
[
243,
259
],
[
259,
260
],
[
259,
261
],
[
243,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
262,
266
],
[
266,
267
],
[
267,
268
],
[
267,
269
],
[
269,
270
],
[
266,
271
],
[
271,
272
],
[
271,
273
],
[
273,
274
],
[
243,
275
],
[
275,
276
],
[
276,
277
],
[
277,
278
],
[
278,
279
],
[
278,
280
],
[
276,
281
],
[
281,
282
],
[
281,
283
],
[
275,
284
],
[
284,
285
],
[
285,
286
],
[
286,
287
],
[
287,
288
],
[
287,
289
],
[
286,
290
],
[
290,
291
],
[
290,
292
],
[
285,
293
],
[
293,
294
],
[
294,
295
],
[
294,
296
],
[
293,
297
],
[
297,
298
],
[
297,
299
],
[
299,
300
],
[
299,
301
],
[
293,
302
],
[
302,
303
],
[
302,
304
],
[
304,
305
],
[
285,
306
],
[
306,
307
],
[
243,
308
],
[
308,
309
],
[
309,
310
],
[
309,
311
],
[
308,
312
],
[
312,
313
],
[
313,
314
],
[
313,
315
],
[
315,
316
],
[
312,
317
],
[
317,
318
],
[
317,
319
],
[
312,
320
],
[
320,
321
],
[
321,
322
],
[
322,
323
],
[
322,
324
],
[
320,
325
],
[
325,
326
],
[
326,
327
],
[
327,
328
],
[
328,
329
],
[
328,
330
],
[
327,
331
],
[
331,
332
],
[
331,
333
],
[
326,
334
],
[
334,
335
],
[
335,
336
],
[
335,
337
],
[
334,
338
],
[
338,
339
],
[
338,
340
],
[
340,
341
],
[
341,
342
],
[
341,
343
],
[
340,
344
],
[
334,
345
],
[
345,
346
],
[
345,
347
],
[
347,
348
],
[
326,
349
],
[
349,
350
],
[
243,
351
],
[
351,
352
],
[
352,
353
],
[
352,
354
],
[
709,
355
],
[
355,
356
],
[
355,
357
],
[
357,
358
],
[
358,
359
],
[
358,
360
],
[
357,
361
],
[
361,
362
],
[
362,
363
],
[
362,
364
],
[
364,
365
],
[
365,
366
],
[
366,
367
],
[
361,
368
],
[
368,
369
],
[
369,
370
],
[
369,
371
],
[
371,
372
],
[
372,
373
],
[
357,
374
],
[
374,
375
],
[
709,
376
],
[
376,
377
],
[
376,
378
],
[
378,
379
],
[
379,
380
],
[
383,
381
],
[
393,
382
],
[
390,
383
],
[
383,
384
],
[
384,
385
],
[
384,
386
],
[
383,
387
],
[
387,
388
],
[
387,
389
],
[
390,
390
],
[
390,
391
],
[
390,
392
],
[
393,
393
],
[
393,
394
],
[
393,
395
],
[
383,
396
],
[
396,
397
],
[
396,
398
],
[
398,
399
],
[
379,
400
],
[
400,
401
],
[
378,
402
],
[
402,
403
],
[
376,
404
],
[
404,
405
],
[
709,
406
],
[
406,
407
],
[
406,
408
],
[
408,
409
],
[
409,
410
],
[
410,
411
],
[
409,
412
],
[
406,
413
],
[
413,
414
],
[
709,
415
],
[
415,
416
],
[
415,
417
],
[
417,
418
],
[
418,
419
],
[
418,
420
],
[
417,
421
],
[
421,
422
],
[
422,
423
],
[
421,
424
],
[
415,
425
],
[
425,
426
],
[
709,
427
],
[
427,
428
],
[
427,
429
],
[
429,
430
],
[
430,
431
],
[
431,
432
],
[
709,
433
],
[
433,
434
],
[
433,
435
],
[
435,
436
],
[
436,
437
],
[
437,
438
],
[
709,
439
],
[
439,
440
],
[
439,
441
],
[
441,
442
],
[
442,
443
],
[
443,
444
],
[
444,
445
],
[
444,
446
],
[
442,
447
],
[
447,
448
],
[
447,
449
],
[
442,
450
],
[
450,
451
],
[
451,
452
],
[
442,
453
],
[
453,
454
],
[
454,
455
],
[
455,
456
],
[
455,
457
],
[
454,
458
],
[
458,
459
],
[
441,
460
],
[
460,
461
],
[
439,
462
],
[
462,
463
],
[
439,
464
],
[
464,
465
],
[
709,
466
],
[
466,
467
],
[
466,
468
],
[
468,
469
],
[
469,
470
],
[
470,
471
],
[
471,
472
],
[
471,
473
],
[
469,
474
],
[
474,
475
],
[
474,
476
],
[
469,
477
],
[
477,
478
],
[
478,
479
],
[
469,
480
],
[
480,
481
],
[
481,
482
],
[
482,
483
],
[
482,
484
],
[
481,
485
],
[
485,
486
],
[
468,
487
],
[
487,
488
],
[
466,
489
],
[
489,
490
],
[
466,
491
],
[
491,
492
],
[
709,
493
],
[
493,
494
],
[
493,
495
],
[
495,
496
],
[
496,
497
],
[
497,
498
],
[
498,
499
],
[
498,
500
],
[
496,
501
],
[
501,
502
],
[
501,
503
],
[
496,
504
],
[
504,
505
],
[
505,
506
],
[
496,
507
],
[
507,
508
],
[
508,
509
],
[
509,
510
],
[
509,
511
],
[
508,
512
],
[
512,
513
],
[
495,
514
],
[
514,
515
],
[
493,
516
],
[
516,
517
],
[
493,
518
],
[
518,
519
],
[
709,
520
],
[
520,
521
],
[
520,
522
],
[
522,
523
],
[
523,
524
],
[
523,
525
],
[
522,
526
],
[
526,
527
],
[
527,
528
],
[
528,
529
],
[
528,
530
],
[
526,
531
],
[
531,
532
],
[
532,
533
],
[
532,
534
],
[
531,
535
],
[
526,
536
],
[
536,
537
],
[
537,
538
],
[
526,
539
],
[
540,
540
],
[
540,
541
],
[
541,
542
],
[
542,
543
],
[
543,
544
],
[
543,
545
],
[
541,
546
],
[
546,
547
],
[
547,
548
],
[
548,
549
],
[
549,
550
],
[
549,
551
],
[
551,
552
],
[
551,
553
],
[
547,
554
],
[
554,
555
],
[
554,
556
],
[
547,
557
],
[
557,
558
],
[
558,
559
],
[
558,
560
],
[
547,
561
],
[
562,
562
],
[
562,
563
],
[
563,
564
],
[
564,
565
],
[
564,
566
],
[
563,
567
],
[
709,
568
],
[
568,
569
],
[
568,
570
],
[
570,
571
],
[
571,
572
],
[
571,
573
],
[
573,
574
],
[
570,
575
],
[
575,
576
],
[
575,
577
],
[
570,
578
],
[
578,
579
],
[
578,
580
],
[
570,
582
],
[
582,
583
],
[
583,
584
],
[
584,
585
],
[
584,
586
],
[
582,
587
],
[
587,
588
],
[
587,
589
],
[
582,
590
],
[
590,
591
],
[
591,
592
],
[
582,
593
],
[
593,
594
],
[
594,
595
],
[
595,
596
],
[
595,
597
],
[
594,
598
],
[
598,
599
],
[
570,
600
],
[
600,
601
],
[
601,
602
],
[
602,
603
],
[
602,
604
],
[
600,
605
],
[
605,
606
],
[
605,
607
],
[
600,
608
],
[
608,
609
],
[
609,
610
],
[
600,
611
],
[
612,
612
],
[
612,
613
],
[
613,
614
],
[
614,
615
],
[
615,
616
],
[
615,
617
],
[
617,
618
],
[
617,
619
],
[
614,
620
],
[
620,
621
],
[
620,
622
],
[
613,
623
],
[
623,
624
],
[
624,
625
],
[
624,
626
],
[
626,
627
],
[
627,
628
],
[
626,
629
],
[
629,
630
],
[
630,
631
],
[
630,
632
],
[
629,
633
],
[
633,
634
],
[
633,
635
],
[
635,
636
],
[
635,
637
],
[
623,
638
],
[
638,
639
],
[
639,
640
],
[
639,
641
],
[
638,
642
],
[
642,
643
],
[
642,
644
],
[
644,
645
],
[
644,
646
],
[
570,
647
],
[
647,
648
],
[
647,
649
],
[
649,
650
],
[
649,
651
],
[
570,
652
],
[
652,
653
],
[
568,
654
],
[
654,
655
],
[
709,
656
],
[
656,
657
],
[
656,
658
],
[
658,
659
],
[
656,
660
],
[
660,
661
],
[
656,
662
],
[
662,
663
],
[
662,
664
],
[
664,
665
],
[
665,
666
],
[
666,
667
],
[
666,
668
],
[
665,
669
],
[
664,
670
],
[
670,
671
],
[
671,
672
],
[
671,
673
],
[
670,
674
],
[
662,
675
],
[
675,
676
],
[
662,
677
],
[
677,
678
],
[
656,
679
],
[
679,
680
],
[
679,
681
],
[
681,
682
],
[
682,
683
],
[
684,
684
],
[
684,
685
],
[
685,
686
],
[
685,
687
],
[
684,
688
],
[
684,
689
],
[
689,
690
],
[
689,
691
],
[
679,
692
],
[
692,
693
],
[
656,
694
],
[
694,
695
],
[
694,
696
],
[
696,
697
],
[
697,
698
],
[
698,
699
],
[
699,
700
],
[
699,
701
],
[
698,
702
],
[
702,
703
],
[
702,
704
],
[
694,
705
],
[
705,
706
],
[
656,
707
],
[
0,
708
],
[
708,
709
],
[
708,
710
]
]
| [
"import java.util.*;\nimport java.io.*;\npublic class Main {\n///////----------------input----------------//////\n\tstatic BufferedReader br= new BufferedReader(new\n InputStreamReader(System.in)); \n\tstatic BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n\tstatic StringTokenizer st; \n\tstatic byte[] buffer =new byte[10*1024];\n\tstatic int index;\n static InputStream input_stream= System.in;\n static int total;\n\t\n\tstatic String ns() throws IOException\n { \n\t\t StringBuilder sb = new StringBuilder();\n int n = read();\n while (isWhiteSpace(n))\n n = read();\n while (!isWhiteSpace(n)) {\n sb.append((char)n);\n n = read();\n }\n return sb.toString();\n } \n\t\n\tstatic int read() throws IOException\n\t{\n\t\tif(total<0)\n throw new InputMismatchException();\n if(index>=total) {\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }\n return buffer[index++];\n\t}\n\tstatic int ni() throws IOException\n { \n\t\tint integer=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*integer;\n } \n\n\tstatic long nl() throws IOException\n { \n\t\tlong number=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n long neg=1l;\n if(n=='-') {\n neg=-1l;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*number;\n } \n\n\tstatic double nd() throws IOException\n { \n\t\tdouble doub=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)&&n!='.') {\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n\n if(n=='.') {\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }\n return doub*neg;\n } \n\n\tstatic String nsl() throws IOException\n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }\n\tstatic boolean isWhiteSpace(int n) {\n if(n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1)\n return true;\n return false;\n }\n\t\n\t///////-------------output-----------------//////\n\tstatic public void p(String str) throws IOException {\n bw.append(str);\n }\n\tstatic public void pn(String str) throws IOException {\n p(str);\n bw.append(\"\\n\");\n }\n\tstatic public void close()throws IOException {\n bw.close();\n }\n\tstatic public void flush()throws IOException {\n bw.flush();\n }\n\t\n\t///////----------THE FAST I/O METHODS ENDS HERE -----------/////////////\n\t///////////////////////////////////////////////////////////////////////\n\t///////////////////////// FOR INPUT LOOP//////////////////////////////\n\tpublic static int[] loopi(int[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static String[] loops(String[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ns();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static long[] loopl(long[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\t/////////////////////////////////////////////////////////////////////\n\t////////////////////////////////////////////////////////////////////\n\tstatic class Node implements Comparable<Node>{\n\t\tint h;\n\t\tint w;\n\t\tNode(int h,int w)\n\t\t{\n\t\t\tthis.h=h;\n\t\t\tthis.w=w;\n\t\t}\n\t\tpublic static String toString(Node n)\n\t\t{\n\t\t\treturn n.h+\" \"+n.w;\n\t\t}\n\t\t@Override\n\t\tpublic int compareTo(Node n)\n\t\t{\n\t\t\t\n\t\t\t\treturn this.h-n.h;\n\t\t}\n\t\n\t}\n\t\n\tstatic boolean al[]=new boolean[1100000];\n\t public static void prime()\n\t {\n\t int n=1000000;\n\t \n\t for(int i=2;i*i<=n;i++)\n\t {\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }\n\t }\n\t\n\n\t public static void main(String args[]) throws IOException {\n\t \n\t //write your code here\n\t\t// your code goes here\n\t\t\tint n=ni();\n\t\t\tlong total=0;\n\t\t\tlong arr[]=new long[n];\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tarr[i]=nl();\n\t\t\t\n\t\t\tfor(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpn(total+\"\");\n\t\n\t flush();\n\t }\n}\n\n",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n///////----------------input----------------//////\n\tstatic BufferedReader br= new BufferedReader(new\n InputStreamReader(System.in)); \n\tstatic BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n\tstatic StringTokenizer st; \n\tstatic byte[] buffer =new byte[10*1024];\n\tstatic int index;\n static InputStream input_stream= System.in;\n static int total;\n\t\n\tstatic String ns() throws IOException\n { \n\t\t StringBuilder sb = new StringBuilder();\n int n = read();\n while (isWhiteSpace(n))\n n = read();\n while (!isWhiteSpace(n)) {\n sb.append((char)n);\n n = read();\n }\n return sb.toString();\n } \n\t\n\tstatic int read() throws IOException\n\t{\n\t\tif(total<0)\n throw new InputMismatchException();\n if(index>=total) {\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }\n return buffer[index++];\n\t}\n\tstatic int ni() throws IOException\n { \n\t\tint integer=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*integer;\n } \n\n\tstatic long nl() throws IOException\n { \n\t\tlong number=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n long neg=1l;\n if(n=='-') {\n neg=-1l;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*number;\n } \n\n\tstatic double nd() throws IOException\n { \n\t\tdouble doub=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)&&n!='.') {\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n\n if(n=='.') {\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }\n return doub*neg;\n } \n\n\tstatic String nsl() throws IOException\n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }\n\tstatic boolean isWhiteSpace(int n) {\n if(n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1)\n return true;\n return false;\n }\n\t\n\t///////-------------output-----------------//////\n\tstatic public void p(String str) throws IOException {\n bw.append(str);\n }\n\tstatic public void pn(String str) throws IOException {\n p(str);\n bw.append(\"\\n\");\n }\n\tstatic public void close()throws IOException {\n bw.close();\n }\n\tstatic public void flush()throws IOException {\n bw.flush();\n }\n\t\n\t///////----------THE FAST I/O METHODS ENDS HERE -----------/////////////\n\t///////////////////////////////////////////////////////////////////////\n\t///////////////////////// FOR INPUT LOOP//////////////////////////////\n\tpublic static int[] loopi(int[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static String[] loops(String[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ns();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static long[] loopl(long[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\t/////////////////////////////////////////////////////////////////////\n\t////////////////////////////////////////////////////////////////////\n\tstatic class Node implements Comparable<Node>{\n\t\tint h;\n\t\tint w;\n\t\tNode(int h,int w)\n\t\t{\n\t\t\tthis.h=h;\n\t\t\tthis.w=w;\n\t\t}\n\t\tpublic static String toString(Node n)\n\t\t{\n\t\t\treturn n.h+\" \"+n.w;\n\t\t}\n\t\t@Override\n\t\tpublic int compareTo(Node n)\n\t\t{\n\t\t\t\n\t\t\t\treturn this.h-n.h;\n\t\t}\n\t\n\t}\n\t\n\tstatic boolean al[]=new boolean[1100000];\n\t public static void prime()\n\t {\n\t int n=1000000;\n\t \n\t for(int i=2;i*i<=n;i++)\n\t {\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }\n\t }\n\t\n\n\t public static void main(String args[]) throws IOException {\n\t \n\t //write your code here\n\t\t// your code goes here\n\t\t\tint n=ni();\n\t\t\tlong total=0;\n\t\t\tlong arr[]=new long[n];\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tarr[i]=nl();\n\t\t\t\n\t\t\tfor(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpn(total+\"\");\n\t\n\t flush();\n\t }\n}",
"Main",
"///////----------------input----------------//////\n\tstatic BufferedReader br= new BufferedReader(new\n InputStreamReader(System.in));",
"br",
"new BufferedReader(new\n InputStreamReader(System.in))",
"static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));",
"bw",
"new BufferedWriter(new OutputStreamWriter(System.out))",
"static StringTokenizer st;",
"st",
"static byte[] buffer =new byte[10*1024];",
"buffer",
"new byte[10*1024]",
"10*1024",
"10",
"1024",
"static int index;",
"index",
"static InputStream input_stream= System.in;",
"input_stream",
"System.in",
"System",
"System.in",
"static int total;",
"total",
"static boolean al[]=new boolean[1100000];",
"al",
"new boolean[1100000]",
"1100000",
"static String ns() throws IOException\n { \n\t\t StringBuilder sb = new StringBuilder();\n int n = read();\n while (isWhiteSpace(n))\n n = read();\n while (!isWhiteSpace(n)) {\n sb.append((char)n);\n n = read();\n }\n return sb.toString();\n }",
"ns",
"{ \n\t\t StringBuilder sb = new StringBuilder();\n int n = read();\n while (isWhiteSpace(n))\n n = read();\n while (!isWhiteSpace(n)) {\n sb.append((char)n);\n n = read();\n }\n return sb.toString();\n }",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int n = read();",
"n",
"read()",
"read",
"while (isWhiteSpace(n))\n n = read();",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"n = read()",
"n",
"read()",
"read",
"while (!isWhiteSpace(n)) {\n sb.append((char)n);\n n = read();\n }",
"!isWhiteSpace(n)",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"{\n sb.append((char)n);\n n = read();\n }",
"sb.append((char)n)",
"sb.append",
"sb",
"(char)n",
"n = read()",
"n",
"read()",
"read",
"return sb.toString();",
"sb.toString()",
"sb.toString",
"sb",
"static int read() throws IOException\n\t{\n\t\tif(total<0)\n throw new InputMismatchException();\n if(index>=total) {\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }\n return buffer[index++];\n\t}",
"read",
"{\n\t\tif(total<0)\n throw new InputMismatchException();\n if(index>=total) {\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }\n return buffer[index++];\n\t}",
"if(total<0)\n throw new InputMismatchException();",
"total<0",
"total",
"0",
"throw new InputMismatchException();",
"new InputMismatchException()",
"if(index>=total) {\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }",
"index>=total",
"index",
"total",
"{\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }",
"index=0",
"index",
"0",
"total= input_stream.read(buffer)",
"total",
"input_stream.read(buffer)",
"input_stream.read",
"input_stream",
"buffer",
"if(total<=0)\n return -1;",
"total<=0",
"total",
"0",
"return -1;",
"-1",
"1",
"return buffer[index++];",
"buffer[index++]",
"buffer",
"index++",
"index",
"static int ni() throws IOException\n { \n\t\tint integer=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*integer;\n }",
"ni",
"{ \n\t\tint integer=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*integer;\n }",
"int integer=0;",
"integer",
"0",
"int n= read();",
"n",
"read()",
"read",
"while(isWhiteSpace(n))\n n= read();",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"n= read()",
"n",
"read()",
"read",
"int neg=1;",
"neg",
"1",
"if(n=='-') {\n neg=-1;\n n= read();\n }",
"n=='-'",
"n",
"'-'",
"{\n neg=-1;\n n= read();\n }",
"neg=-1",
"neg",
"-1",
"1",
"n= read()",
"n",
"read()",
"read",
"while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }",
"!isWhiteSpace(n)",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"{\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }",
"if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();",
"n>='0'&&n<='9'",
"n>='0'",
"n",
"'0'",
"n<='9'",
"n",
"'9'",
"{\n integer*=10;\n integer+=n-'0';\n n= read();\n }",
"integer*=10",
"integer",
"10",
"integer+=n-'0'",
"integer",
"n-'0'",
"n",
"'0'",
"n= read()",
"n",
"read()",
"read",
"throw new InputMismatchException();",
"new InputMismatchException()",
"return neg*integer;",
"neg*integer",
"neg",
"integer",
"static long nl() throws IOException\n { \n\t\tlong number=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n long neg=1l;\n if(n=='-') {\n neg=-1l;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*number;\n }",
"nl",
"{ \n\t\tlong number=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n long neg=1l;\n if(n=='-') {\n neg=-1l;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*number;\n }",
"long number=0;",
"number",
"0",
"int n= read();",
"n",
"read()",
"read",
"while(isWhiteSpace(n))\n n= read();",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"n= read()",
"n",
"read()",
"read",
"long neg=1l;",
"neg",
"1l",
"if(n=='-') {\n neg=-1l;\n n= read();\n }",
"n=='-'",
"n",
"'-'",
"{\n neg=-1l;\n n= read();\n }",
"neg=-1l",
"neg",
"-1l",
"1l",
"n= read()",
"n",
"read()",
"read",
"while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }",
"!isWhiteSpace(n)",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"{\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }",
"if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();",
"n>='0'&&n<='9'",
"n>='0'",
"n",
"'0'",
"n<='9'",
"n",
"'9'",
"{\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }",
"number*=10l",
"number",
"10l",
"number+=(long)(n-'0')",
"number",
"(long)(n-'0')",
"n",
"'0'",
"n= read()",
"n",
"read()",
"read",
"throw new InputMismatchException();",
"new InputMismatchException()",
"return neg*number;",
"neg*number",
"neg",
"number",
"static double nd() throws IOException\n { \n\t\tdouble doub=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)&&n!='.') {\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n\n if(n=='.') {\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }\n return doub*neg;\n }",
"nd",
"{ \n\t\tdouble doub=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)&&n!='.') {\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n\n if(n=='.') {\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }\n return doub*neg;\n }",
"double doub=0;",
"doub",
"0",
"int n= read();",
"n",
"read()",
"read",
"while(isWhiteSpace(n))\n n= read();",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"n= read()",
"n",
"read()",
"read",
"int neg=1;",
"neg",
"1",
"if(n=='-') {\n neg=-1;\n n= read();\n }",
"n=='-'",
"n",
"'-'",
"{\n neg=-1;\n n= read();\n }",
"neg=-1",
"neg",
"-1",
"1",
"n= read()",
"n",
"read()",
"read",
"while(!isWhiteSpace(n)&&n!='.') {\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }",
"!isWhiteSpace(n)&&n!='.'",
"!isWhiteSpace(n)",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"n!='.'",
"n",
"'.'",
"{\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }",
"if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();",
"n>='0'&&n<='9'",
"n>='0'",
"n",
"'0'",
"n<='9'",
"n",
"'9'",
"{\n doub*=10;\n doub+=n-'0';\n n= read();\n }",
"doub*=10",
"doub",
"10",
"doub+=n-'0'",
"doub",
"n-'0'",
"n",
"'0'",
"n= read()",
"n",
"read()",
"read",
"throw new InputMismatchException();",
"new InputMismatchException()",
"if(n=='.') {\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }",
"n=='.'",
"n",
"'.'",
"{\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }",
"n= read()",
"n",
"read()",
"read",
"double temp=1;",
"temp",
"1",
"while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }",
"!isWhiteSpace(n)",
"isWhiteSpace(n)",
"isWhiteSpace",
"n",
"{\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }",
"if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();",
"n>='0'&&n<='9'",
"n>='0'",
"n",
"'0'",
"n<='9'",
"n",
"'9'",
"{\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }",
"temp/=10",
"temp",
"10",
"doub+=(n-'0')*temp",
"doub",
"(n-'0')*temp",
"(n-'0')",
"n",
"'0'",
"temp",
"n= read()",
"n",
"read()",
"read",
"throw new InputMismatchException();",
"new InputMismatchException()",
"return doub*neg;",
"doub*neg",
"doub",
"neg",
"static String nsl() throws IOException\n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }",
"nsl",
"{ \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }",
"String str = \"\";",
"str",
"\"\"",
"try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n }",
"catch (IOException e) \n { \n e.printStackTrace(); \n }",
"IOException e",
"{ \n e.printStackTrace(); \n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{ \n str = br.readLine(); \n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"static boolean isWhiteSpace(int n) {\n if(n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1)\n return true;\n return false;\n }",
"isWhiteSpace",
"{\n if(n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1)\n return true;\n return false;\n }",
"if(n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1)\n return true;",
"n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1",
"n=='\\t'",
"n=='\\r'",
"n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1",
"n==' '",
"n",
"' '",
"n=='\\n'",
"n",
"'\\n'",
"n=='\\r'",
"n",
"'\\r'",
"n=='\\t'",
"n",
"'\\t'",
"n==-1",
"n",
"-1",
"1",
"return true;",
"true",
"return false;",
"false",
"int n",
"n",
"///////-------------output-----------------//////\n\tstatic public void p(String str) throws IOException {\n bw.append(str);\n }",
"p",
"{\n bw.append(str);\n }",
"bw.append(str)",
"bw.append",
"bw",
"str",
"String str",
"str",
"static public void pn(String str) throws IOException {\n p(str);\n bw.append(\"\\n\");\n }",
"pn",
"{\n p(str);\n bw.append(\"\\n\");\n }",
"p(str)",
"p",
"str",
"bw.append(\"\\n\")",
"bw.append",
"bw",
"\"\\n\"",
"String str",
"str",
"static public void close()throws IOException {\n bw.close();\n }",
"close",
"{\n bw.close();\n }",
"bw.close()",
"bw.close",
"bw",
"static public void flush()throws IOException {\n bw.flush();\n }",
"flush",
"{\n bw.flush();\n }",
"bw.flush()",
"bw.flush",
"bw",
"///////----------THE FAST I/O METHODS ENDS HERE -----------/////////////\n\t///////////////////////////////////////////////////////////////////////\n\t///////////////////////// FOR INPUT LOOP//////////////////////////////\n\tpublic static int[] loopi(int[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}",
"loopi",
"{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}",
"for(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i]=ni();",
"arr[i]=ni()",
"arr[i]",
"arr",
"i",
"ni()",
"ni",
"return arr;",
"arr",
"int[] arr",
"arr",
"int n",
"n",
"public static String[] loops(String[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ns();\n\t\t\n\t\treturn arr;\n\t}",
"loops",
"{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ns();\n\t\t\n\t\treturn arr;\n\t}",
"for(int i=0;i<n;i++)\n\t\t\tarr[i]=ns();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i]=ns();",
"arr[i]=ns()",
"arr[i]",
"arr",
"i",
"ns()",
"ns",
"return arr;",
"arr",
"String[] arr",
"arr",
"int n",
"n",
"public static long[] loopl(long[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}",
"loopl",
"{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}",
"for(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i]=ni();",
"arr[i]=ni()",
"arr[i]",
"arr",
"i",
"ni()",
"ni",
"return arr;",
"arr",
"long[] arr",
"arr",
"int n",
"n",
"public static void prime()\n\t {\n\t int n=1000000;\n\t \n\t for(int i=2;i*i<=n;i++)\n\t {\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }\n\t }",
"prime",
"{\n\t int n=1000000;\n\t \n\t for(int i=2;i*i<=n;i++)\n\t {\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }\n\t }",
"int n=1000000;",
"n",
"1000000",
"for(int i=2;i*i<=n;i++)\n\t {\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }",
"int i=2;",
"int i=2;",
"i",
"2",
"i*i<=n",
"i*i",
"i",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }",
"{\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }",
"if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }",
"!al[i]",
"al[i]",
"al",
"i",
"{\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }",
"for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }",
"int j=i*2;",
"int j=i*2;",
"j",
"i*2",
"i",
"2",
"j<=n",
"j",
"n",
"j+=i",
"j+=i",
"j",
"i",
"{\n\t al[j]=true;\n\t }",
"{\n\t al[j]=true;\n\t }",
"al[j]=true",
"al[j]",
"al",
"j",
"true",
"public static void main(String args[]) throws IOException {\n\t \n\t //write your code here\n\t\t// your code goes here\n\t\t\tint n=ni();\n\t\t\tlong total=0;\n\t\t\tlong arr[]=new long[n];\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tarr[i]=nl();\n\t\t\t\n\t\t\tfor(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpn(total+\"\");\n\t\n\t flush();\n\t }",
"main",
"{\n\t \n\t //write your code here\n\t\t// your code goes here\n\t\t\tint n=ni();\n\t\t\tlong total=0;\n\t\t\tlong arr[]=new long[n];\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tarr[i]=nl();\n\t\t\t\n\t\t\tfor(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpn(total+\"\");\n\t\n\t flush();\n\t }",
"int n=ni();",
"n",
"ni()",
"ni",
"long total=0;",
"total",
"0",
"long arr[]=new long[n];",
"arr",
"new long[n]",
"n",
"for(int i=0;i<n;i++)\n\t\t\t\tarr[i]=nl();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i]=nl();",
"arr[i]=nl()",
"arr[i]",
"arr",
"i",
"nl()",
"nl",
"for(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\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(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}",
"if(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}",
"arr[i-1]>arr[i]",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]",
"arr",
"i",
"{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}",
"total+=(Math.abs(arr[i]-arr[i-1]))",
"total",
"(Math.abs(arr[i]-arr[i-1]))",
"Math.abs",
"Math",
"arr[i]-arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]=arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"pn(total+\"\")",
"pn",
"total+\"\"",
"total",
"\"\"",
"flush()",
"flush",
"String args[]",
"args",
"static class Node implements Comparable<Node>{\n\t\tint h;\n\t\tint w;\n\t\tNode(int h,int w)\n\t\t{\n\t\t\tthis.h=h;\n\t\t\tthis.w=w;\n\t\t}\n\t\tpublic static String toString(Node n)\n\t\t{\n\t\t\treturn n.h+\" \"+n.w;\n\t\t}\n\t\t@Override\n\t\tpublic int compareTo(Node n)\n\t\t{\n\t\t\t\n\t\t\t\treturn this.h-n.h;\n\t\t}\n\t\n\t}",
"Node",
"int h;",
"h",
"int w;",
"w",
"Node(int h,int w)\n\t\t{\n\t\t\tthis.h=h;\n\t\t\tthis.w=w;\n\t\t}",
"Node",
"{\n\t\t\tthis.h=h;\n\t\t\tthis.w=w;\n\t\t}",
"this.h=h",
"this.h",
"this",
"this.h",
"h",
"this.w=w",
"this.w",
"this",
"this.w",
"w",
"int h",
"h",
"int w",
"w",
"public static String toString(Node n)\n\t\t{\n\t\t\treturn n.h+\" \"+n.w;\n\t\t}",
"toString",
"{\n\t\t\treturn n.h+\" \"+n.w;\n\t\t}",
"return n.h+\" \"+n.w;",
"n.h+\" \"+n.w",
"n.h+\" \"+n.w",
"n.h",
"n",
"n.h",
"\" \"",
"n.w",
"n",
"n.w",
"Node n",
"n",
"@Override\n\t\tpublic int compareTo(Node n)\n\t\t{\n\t\t\t\n\t\t\t\treturn this.h-n.h;\n\t\t}",
"compareTo",
"{\n\t\t\t\n\t\t\t\treturn this.h-n.h;\n\t\t}",
"return this.h-n.h;",
"this.h-n.h",
"this.h",
"this",
"this.h",
"n.h",
"n",
"n.h",
"Node n",
"n",
"Comparable",
"public class Main {\n///////----------------input----------------//////\n\tstatic BufferedReader br= new BufferedReader(new\n InputStreamReader(System.in)); \n\tstatic BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n\tstatic StringTokenizer st; \n\tstatic byte[] buffer =new byte[10*1024];\n\tstatic int index;\n static InputStream input_stream= System.in;\n static int total;\n\t\n\tstatic String ns() throws IOException\n { \n\t\t StringBuilder sb = new StringBuilder();\n int n = read();\n while (isWhiteSpace(n))\n n = read();\n while (!isWhiteSpace(n)) {\n sb.append((char)n);\n n = read();\n }\n return sb.toString();\n } \n\t\n\tstatic int read() throws IOException\n\t{\n\t\tif(total<0)\n throw new InputMismatchException();\n if(index>=total) {\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }\n return buffer[index++];\n\t}\n\tstatic int ni() throws IOException\n { \n\t\tint integer=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*integer;\n } \n\n\tstatic long nl() throws IOException\n { \n\t\tlong number=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n long neg=1l;\n if(n=='-') {\n neg=-1l;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*number;\n } \n\n\tstatic double nd() throws IOException\n { \n\t\tdouble doub=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)&&n!='.') {\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n\n if(n=='.') {\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }\n return doub*neg;\n } \n\n\tstatic String nsl() throws IOException\n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }\n\tstatic boolean isWhiteSpace(int n) {\n if(n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1)\n return true;\n return false;\n }\n\t\n\t///////-------------output-----------------//////\n\tstatic public void p(String str) throws IOException {\n bw.append(str);\n }\n\tstatic public void pn(String str) throws IOException {\n p(str);\n bw.append(\"\\n\");\n }\n\tstatic public void close()throws IOException {\n bw.close();\n }\n\tstatic public void flush()throws IOException {\n bw.flush();\n }\n\t\n\t///////----------THE FAST I/O METHODS ENDS HERE -----------/////////////\n\t///////////////////////////////////////////////////////////////////////\n\t///////////////////////// FOR INPUT LOOP//////////////////////////////\n\tpublic static int[] loopi(int[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static String[] loops(String[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ns();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static long[] loopl(long[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\t/////////////////////////////////////////////////////////////////////\n\t////////////////////////////////////////////////////////////////////\n\tstatic class Node implements Comparable<Node>{\n\t\tint h;\n\t\tint w;\n\t\tNode(int h,int w)\n\t\t{\n\t\t\tthis.h=h;\n\t\t\tthis.w=w;\n\t\t}\n\t\tpublic static String toString(Node n)\n\t\t{\n\t\t\treturn n.h+\" \"+n.w;\n\t\t}\n\t\t@Override\n\t\tpublic int compareTo(Node n)\n\t\t{\n\t\t\t\n\t\t\t\treturn this.h-n.h;\n\t\t}\n\t\n\t}\n\t\n\tstatic boolean al[]=new boolean[1100000];\n\t public static void prime()\n\t {\n\t int n=1000000;\n\t \n\t for(int i=2;i*i<=n;i++)\n\t {\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }\n\t }\n\t\n\n\t public static void main(String args[]) throws IOException {\n\t \n\t //write your code here\n\t\t// your code goes here\n\t\t\tint n=ni();\n\t\t\tlong total=0;\n\t\t\tlong arr[]=new long[n];\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tarr[i]=nl();\n\t\t\t\n\t\t\tfor(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpn(total+\"\");\n\t\n\t flush();\n\t }\n}",
"public class Main {\n///////----------------input----------------//////\n\tstatic BufferedReader br= new BufferedReader(new\n InputStreamReader(System.in)); \n\tstatic BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n\tstatic StringTokenizer st; \n\tstatic byte[] buffer =new byte[10*1024];\n\tstatic int index;\n static InputStream input_stream= System.in;\n static int total;\n\t\n\tstatic String ns() throws IOException\n { \n\t\t StringBuilder sb = new StringBuilder();\n int n = read();\n while (isWhiteSpace(n))\n n = read();\n while (!isWhiteSpace(n)) {\n sb.append((char)n);\n n = read();\n }\n return sb.toString();\n } \n\t\n\tstatic int read() throws IOException\n\t{\n\t\tif(total<0)\n throw new InputMismatchException();\n if(index>=total) {\n index=0;\n total= input_stream.read(buffer);\n if(total<=0)\n return -1;\n }\n return buffer[index++];\n\t}\n\tstatic int ni() throws IOException\n { \n\t\tint integer=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n integer*=10;\n integer+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*integer;\n } \n\n\tstatic long nl() throws IOException\n { \n\t\tlong number=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n long neg=1l;\n if(n=='-') {\n neg=-1l;\n n= read();\n }\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n number*=10l;\n number+=(long)(n-'0');\n n= read();\n }\n else throw new InputMismatchException();\n }\n return neg*number;\n } \n\n\tstatic double nd() throws IOException\n { \n\t\tdouble doub=0;\n int n= read();\n while(isWhiteSpace(n))\n n= read();\n int neg=1;\n if(n=='-') {\n neg=-1;\n n= read();\n }\n while(!isWhiteSpace(n)&&n!='.') {\n if(n>='0'&&n<='9') {\n doub*=10;\n doub+=n-'0';\n n= read();\n }\n else throw new InputMismatchException();\n }\n\n if(n=='.') {\n n= read();\n double temp=1;\n while(!isWhiteSpace(n)) {\n if(n>='0'&&n<='9') {\n temp/=10;\n doub+=(n-'0')*temp;\n n= read();\n }\n else throw new InputMismatchException();\n }\n }\n return doub*neg;\n } \n\n\tstatic String nsl() throws IOException\n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n }\n\tstatic boolean isWhiteSpace(int n) {\n if(n==' '|| n=='\\n'|| n=='\\r'|| n=='\\t'|| n==-1)\n return true;\n return false;\n }\n\t\n\t///////-------------output-----------------//////\n\tstatic public void p(String str) throws IOException {\n bw.append(str);\n }\n\tstatic public void pn(String str) throws IOException {\n p(str);\n bw.append(\"\\n\");\n }\n\tstatic public void close()throws IOException {\n bw.close();\n }\n\tstatic public void flush()throws IOException {\n bw.flush();\n }\n\t\n\t///////----------THE FAST I/O METHODS ENDS HERE -----------/////////////\n\t///////////////////////////////////////////////////////////////////////\n\t///////////////////////// FOR INPUT LOOP//////////////////////////////\n\tpublic static int[] loopi(int[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static String[] loops(String[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ns();\n\t\t\n\t\treturn arr;\n\t}\n\tpublic static long[] loopl(long[] arr,int n) throws IOException\n\t{\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i]=ni();\n\t\t\n\t\treturn arr;\n\t}\n\t/////////////////////////////////////////////////////////////////////\n\t////////////////////////////////////////////////////////////////////\n\tstatic class Node implements Comparable<Node>{\n\t\tint h;\n\t\tint w;\n\t\tNode(int h,int w)\n\t\t{\n\t\t\tthis.h=h;\n\t\t\tthis.w=w;\n\t\t}\n\t\tpublic static String toString(Node n)\n\t\t{\n\t\t\treturn n.h+\" \"+n.w;\n\t\t}\n\t\t@Override\n\t\tpublic int compareTo(Node n)\n\t\t{\n\t\t\t\n\t\t\t\treturn this.h-n.h;\n\t\t}\n\t\n\t}\n\t\n\tstatic boolean al[]=new boolean[1100000];\n\t public static void prime()\n\t {\n\t int n=1000000;\n\t \n\t for(int i=2;i*i<=n;i++)\n\t {\n\t if(!al[i]){\n\t for(int j=i*2;j<=n;j+=i)\n\t {\n\t al[j]=true;\n\t }\n\t \n\t }\n\t }\n\t }\n\t\n\n\t public static void main(String args[]) throws IOException {\n\t \n\t //write your code here\n\t\t// your code goes here\n\t\t\tint n=ni();\n\t\t\tlong total=0;\n\t\t\tlong arr[]=new long[n];\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tarr[i]=nl();\n\t\t\t\n\t\t\tfor(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(arr[i-1]>arr[i])\n\t\t\t\t{\n\t\t\t\t\ttotal+=(Math.abs(arr[i]-arr[i-1]));\n\t\t\t\t\tarr[i]=arr[i-1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpn(total+\"\");\n\t\n\t flush();\n\t }\n}",
"Main"
]
| import java.util.*;
import java.io.*;
public class Main {
///////----------------input----------------//////
static BufferedReader br= new BufferedReader(new
InputStreamReader(System.in));
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static byte[] buffer =new byte[10*1024];
static int index;
static InputStream input_stream= System.in;
static int total;
static String ns() throws IOException
{
StringBuilder sb = new StringBuilder();
int n = read();
while (isWhiteSpace(n))
n = read();
while (!isWhiteSpace(n)) {
sb.append((char)n);
n = read();
}
return sb.toString();
}
static int read() throws IOException
{
if(total<0)
throw new InputMismatchException();
if(index>=total) {
index=0;
total= input_stream.read(buffer);
if(total<=0)
return -1;
}
return buffer[index++];
}
static int ni() throws IOException
{
int integer=0;
int n= read();
while(isWhiteSpace(n))
n= read();
int neg=1;
if(n=='-') {
neg=-1;
n= read();
}
while(!isWhiteSpace(n)) {
if(n>='0'&&n<='9') {
integer*=10;
integer+=n-'0';
n= read();
}
else throw new InputMismatchException();
}
return neg*integer;
}
static long nl() throws IOException
{
long number=0;
int n= read();
while(isWhiteSpace(n))
n= read();
long neg=1l;
if(n=='-') {
neg=-1l;
n= read();
}
while(!isWhiteSpace(n)) {
if(n>='0'&&n<='9') {
number*=10l;
number+=(long)(n-'0');
n= read();
}
else throw new InputMismatchException();
}
return neg*number;
}
static double nd() throws IOException
{
double doub=0;
int n= read();
while(isWhiteSpace(n))
n= read();
int neg=1;
if(n=='-') {
neg=-1;
n= read();
}
while(!isWhiteSpace(n)&&n!='.') {
if(n>='0'&&n<='9') {
doub*=10;
doub+=n-'0';
n= read();
}
else throw new InputMismatchException();
}
if(n=='.') {
n= read();
double temp=1;
while(!isWhiteSpace(n)) {
if(n>='0'&&n<='9') {
temp/=10;
doub+=(n-'0')*temp;
n= read();
}
else throw new InputMismatchException();
}
}
return doub*neg;
}
static String nsl() throws IOException
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
static boolean isWhiteSpace(int n) {
if(n==' '|| n=='\n'|| n=='\r'|| n=='\t'|| n==-1)
return true;
return false;
}
///////-------------output-----------------//////
static public void p(String str) throws IOException {
bw.append(str);
}
static public void pn(String str) throws IOException {
p(str);
bw.append("\n");
}
static public void close()throws IOException {
bw.close();
}
static public void flush()throws IOException {
bw.flush();
}
///////----------THE FAST I/O METHODS ENDS HERE -----------/////////////
///////////////////////////////////////////////////////////////////////
///////////////////////// FOR INPUT LOOP//////////////////////////////
public static int[] loopi(int[] arr,int n) throws IOException
{
for(int i=0;i<n;i++)
arr[i]=ni();
return arr;
}
public static String[] loops(String[] arr,int n) throws IOException
{
for(int i=0;i<n;i++)
arr[i]=ns();
return arr;
}
public static long[] loopl(long[] arr,int n) throws IOException
{
for(int i=0;i<n;i++)
arr[i]=ni();
return arr;
}
/////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
static class Node implements Comparable<Node>{
int h;
int w;
Node(int h,int w)
{
this.h=h;
this.w=w;
}
public static String toString(Node n)
{
return n.h+" "+n.w;
}
@Override
public int compareTo(Node n)
{
return this.h-n.h;
}
}
static boolean al[]=new boolean[1100000];
public static void prime()
{
int n=1000000;
for(int i=2;i*i<=n;i++)
{
if(!al[i]){
for(int j=i*2;j<=n;j+=i)
{
al[j]=true;
}
}
}
}
public static void main(String args[]) throws IOException {
//write your code here
// your code goes here
int n=ni();
long total=0;
long arr[]=new long[n];
for(int i=0;i<n;i++)
arr[i]=nl();
for(int i=1;i<n;i++)
{
if(arr[i-1]>arr[i])
{
total+=(Math.abs(arr[i]-arr[i-1]));
arr[i]=arr[i-1];
}
}
pn(total+"");
flush();
}
}
|
[
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,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
100,
5
],
[
100,
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
],
[
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
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
62,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
8,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
88,
93
],
[
8,
94
],
[
94,
95
],
[
95,
96
],
[
6,
97
],
[
97,
98
],
[
0,
99
],
[
99,
100
],
[
99,
101
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tlong arr[] = new long[n];\n\t\t\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tarr[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tlong total = 0;\n\t\tlong largest = arr[0];\n\t\tfor(int i=1; i<n; i++) {\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t\tsc.close();\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tlong arr[] = new long[n];\n\t\t\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tarr[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tlong total = 0;\n\t\tlong largest = arr[0];\n\t\tfor(int i=1; i<n; i++) {\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t\tsc.close();\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tlong arr[] = new long[n];\n\t\t\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tarr[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tlong total = 0;\n\t\tlong largest = arr[0];\n\t\tfor(int i=1; i<n; i++) {\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t\tsc.close();\n\t}",
"main",
"{\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tlong arr[] = new long[n];\n\t\t\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tarr[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tlong total = 0;\n\t\tlong largest = arr[0];\n\t\tfor(int i=1; i<n; i++) {\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long arr[] = new long[n];",
"arr",
"new long[n]",
"n",
"for(int i=0; i<n; i++) {\n\t\t\tarr[i] = sc.nextLong();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\tarr[i] = sc.nextLong();\n\t\t}",
"arr[i] = sc.nextLong()",
"arr[i]",
"arr",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"long total = 0;",
"total",
"0",
"long largest = arr[0];",
"largest",
"arr[0]",
"arr",
"0",
"for(int i=1; i<n; i++) {\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\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\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}",
"{\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}",
"if(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}",
"arr[i] <= largest",
"arr[i]",
"arr",
"i",
"largest",
"{\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}",
"total += largest - arr[i]",
"total",
"largest - arr[i]",
"largest",
"arr[i]",
"arr",
"i",
"if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}",
"arr[i] > largest",
"arr[i]",
"arr",
"i",
"largest",
"{\n\t\t\t\tlargest = arr[i];\n\t\t\t}",
"largest = arr[i]",
"largest",
"arr[i]",
"arr",
"i",
"System.out.println(total)",
"System.out.println",
"System.out",
"System",
"System.out",
"total",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tlong arr[] = new long[n];\n\t\t\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tarr[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tlong total = 0;\n\t\tlong largest = arr[0];\n\t\tfor(int i=1; i<n; i++) {\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t\tsc.close();\n\t}\n\n}",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tlong arr[] = new long[n];\n\t\t\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tarr[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tlong total = 0;\n\t\tlong largest = arr[0];\n\t\tfor(int i=1; i<n; i++) {\n\t\t\t\n\t\t\tif(arr[i] <= largest) {\n\t\t\t\ttotal += largest - arr[i];\n\t\t\t}else if(arr[i] > largest) {\n\t\t\t\tlargest = arr[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(total);\n\t\tsc.close();\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();
long arr[] = new long[n];
for(int i=0; i<n; i++) {
arr[i] = sc.nextLong();
}
long total = 0;
long largest = arr[0];
for(int i=1; i<n; i++) {
if(arr[i] <= largest) {
total += largest - arr[i];
}else if(arr[i] > largest) {
largest = arr[i];
}
}
System.out.println(total);
sc.close();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
41,
13,
17,
41,
13,
40,
17,
28,
13,
13,
30,
30,
0,
13,
4,
18,
13,
13,
13,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
13,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
13,
41,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
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
],
[
286,
11
],
[
286,
12
],
[
12,
13
],
[
12,
14
],
[
286,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
17,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
17,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
17,
35
],
[
35,
36
],
[
35,
37
],
[
17,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
17,
42
],
[
42,
43
],
[
42,
44
],
[
42,
45
],
[
46,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
49,
53
],
[
46,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
56,
58
],
[
17,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
17,
63
],
[
63,
64
],
[
64,
65
],
[
15,
66
],
[
66,
67
],
[
286,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
70,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
76,
81
],
[
81,
82
],
[
81,
83
],
[
76,
84
],
[
84,
85
],
[
85,
86
],
[
76,
87
],
[
88,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
88,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
88,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
104,
106
],
[
88,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
70,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
68,
116
],
[
116,
117
],
[
286,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
123,
125
],
[
120,
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
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
141,
144
],
[
138,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
147,
149
],
[
138,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
154,
155
],
[
154,
156
],
[
138,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
120,
162
],
[
162,
163
],
[
163,
164
],
[
162,
165
],
[
118,
166
],
[
166,
167
],
[
286,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
168,
172
],
[
172,
173
],
[
168,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
168,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
183,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
193,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
182,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
168,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
212,
215
],
[
215,
216
],
[
168,
217
],
[
217,
218
],
[
217,
219
],
[
219,
220
],
[
220,
221
],
[
221,
222
],
[
222,
223
],
[
221,
224
],
[
224,
225
],
[
168,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
231,
232
],
[
230,
233
],
[
233,
234
],
[
168,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
238,
239
],
[
238,
240
],
[
237,
241
],
[
241,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
241,
248
],
[
248,
249
],
[
249,
250
],
[
249,
251
],
[
251,
252
],
[
252,
253
],
[
237,
254
],
[
254,
255
],
[
168,
256
],
[
256,
257
],
[
256,
258
],
[
258,
259
],
[
259,
260
],
[
259,
261
],
[
258,
263
],
[
263,
264
],
[
264,
265
],
[
265,
266
],
[
265,
267
],
[
263,
268
],
[
268,
269
],
[
268,
270
],
[
263,
271
],
[
271,
272
],
[
272,
273
],
[
263,
274
],
[
274,
275
],
[
275,
276
],
[
276,
277
],
[
276,
278
],
[
275,
279
],
[
279,
280
],
[
258,
281
],
[
281,
282
],
[
256,
283
],
[
283,
284
],
[
0,
285
],
[
285,
286
],
[
285,
287
]
]
| [
"import java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tFastReader in = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = in.nextInt();\n\t\tint[] a = in.readArray(n);\n\t\tlong ans = 0;\n\t\tint max = -1;\n\t\tfor(int x:a) {\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\n\tstatic final Random random=new Random();\n\t//\tstatic void ruffleSort(Pair[] a) {\n\t//\t\tint n=a.length;//shuffle, then sort \n\t//\t\tfor (int i=0; i<n; i++) {\n\t//\t\t\tint oi=random.nextInt(n);\n\t//\t\t\tPair temp=a[oi];\n\t//\t\t\ta[oi]=a[i]; a[i]=temp;\n\t//\t\t}\n\t//\t\tArrays.sort(a);\n\t//\t}\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic void ruffleSort(char[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic class FastReader \n\t{ \n\t\tBufferedReader br; \n\t\tStringTokenizer st; \n\n\t\tpublic FastReader() \n\t\t{ \n\t\t\tbr = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in)); \n\t\t} \n\n\t\tString next() \n\t\t{ \n\t\t\twhile (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t} \n\t\t\treturn st.nextToken(); \n\t\t} \n\n\t\tint nextInt() \n\t\t{ \n\t\t\treturn Integer.parseInt(next()); \n\t\t} \n\n\t\tlong nextLong() \n\t\t{ \n\t\t\treturn Long.parseLong(next()); \n\t\t} \n\n\t\tdouble nextDouble() \n\t\t{ \n\t\t\treturn Double.parseDouble(next()); \n\t\t} \n\n\t\tString nextLine() \n\t\t{ \n\t\t\tString str = \"\"; \n\t\t\ttry\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t} \n\t\t\treturn str; \n\t\t} \n\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}\n\n//class Pair implements Comparable<Pair>{\n// int a;\n// int b;\n// public Pair(int a, int b) {\n// this.a = a;\n// this.b = b;\n// }\n// public int compareTo(Pair o) {\n// if(this.a==o.a)\n// return this.b - o.b;\n// return this.a - o.a;\n// } \n//}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tFastReader in = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = in.nextInt();\n\t\tint[] a = in.readArray(n);\n\t\tlong ans = 0;\n\t\tint max = -1;\n\t\tfor(int x:a) {\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\n\tstatic final Random random=new Random();\n\t//\tstatic void ruffleSort(Pair[] a) {\n\t//\t\tint n=a.length;//shuffle, then sort \n\t//\t\tfor (int i=0; i<n; i++) {\n\t//\t\t\tint oi=random.nextInt(n);\n\t//\t\t\tPair temp=a[oi];\n\t//\t\t\ta[oi]=a[i]; a[i]=temp;\n\t//\t\t}\n\t//\t\tArrays.sort(a);\n\t//\t}\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic void ruffleSort(char[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic class FastReader \n\t{ \n\t\tBufferedReader br; \n\t\tStringTokenizer st; \n\n\t\tpublic FastReader() \n\t\t{ \n\t\t\tbr = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in)); \n\t\t} \n\n\t\tString next() \n\t\t{ \n\t\t\twhile (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t} \n\t\t\treturn st.nextToken(); \n\t\t} \n\n\t\tint nextInt() \n\t\t{ \n\t\t\treturn Integer.parseInt(next()); \n\t\t} \n\n\t\tlong nextLong() \n\t\t{ \n\t\t\treturn Long.parseLong(next()); \n\t\t} \n\n\t\tdouble nextDouble() \n\t\t{ \n\t\t\treturn Double.parseDouble(next()); \n\t\t} \n\n\t\tString nextLine() \n\t\t{ \n\t\t\tString str = \"\"; \n\t\t\ttry\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t} \n\t\t\treturn str; \n\t\t} \n\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}",
"Main",
"static final Random random=new Random();",
"random",
"new Random()",
"public static void main(String[] args) {\n\t\tFastReader in = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = in.nextInt();\n\t\tint[] a = in.readArray(n);\n\t\tlong ans = 0;\n\t\tint max = -1;\n\t\tfor(int x:a) {\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}",
"main",
"{\n\t\tFastReader in = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = in.nextInt();\n\t\tint[] a = in.readArray(n);\n\t\tlong ans = 0;\n\t\tint max = -1;\n\t\tfor(int x:a) {\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}",
"FastReader in = new FastReader();",
"in",
"new FastReader()",
"PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int[] a = in.readArray(n);",
"a",
"in.readArray(n)",
"in.readArray",
"in",
"n",
"long ans = 0;",
"ans",
"0",
"int max = -1;",
"max",
"-1",
"1",
"for(int x:a) {\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}",
"int x",
"a",
"{\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}",
"{\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}",
"max = Math.max(max,x)",
"max",
"Math.max(max,x)",
"Math.max",
"Math",
"max",
"x",
"ans += max - x",
"ans",
"max - x",
"max",
"x",
"out.println(ans)",
"out.println",
"out",
"ans",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"//\tstatic void ruffleSort(Pair[] a) {\n\t//\t\tint n=a.length;//shuffle, then sort \n\t//\t\tfor (int i=0; i<n; i++) {\n\t//\t\t\tint oi=random.nextInt(n);\n\t//\t\t\tPair temp=a[oi];\n\t//\t\t\ta[oi]=a[i]; a[i]=temp;\n\t//\t\t}\n\t//\t\tArrays.sort(a);\n\t//\t}\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}",
"ruffleSort",
"{\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}",
"int n=a.length;",
"n",
"a.length",
"a",
"a.length",
"for (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"{\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"int oi=random.nextInt(n)",
"oi",
"random.nextInt(n)",
"random.nextInt",
"random",
"n",
"temp=a[oi];",
"temp",
"a[oi]",
"a",
"oi",
"a[oi]=a[i]",
"a[oi]",
"a",
"oi",
"a[i]",
"a",
"i",
"a[i]=temp",
"a[i]",
"a",
"i",
"temp",
"Arrays.sort(a)",
"Arrays.sort",
"Arrays",
"a",
"int[] a",
"a",
"static void ruffleSort(char[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}",
"ruffleSort",
"{\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}",
"int n=a.length;",
"n",
"a.length",
"a",
"a.length",
"for (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"{\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}",
"int oi=random.nextInt(n);",
"oi",
"random.nextInt(n)",
"random.nextInt",
"random",
"n",
"char temp=a[oi];",
"temp",
"a[oi]",
"a",
"oi",
"a[oi]=a[i]",
"a[oi]",
"a",
"oi",
"a[i]",
"a",
"i",
"a[i]=temp",
"a[i]",
"a",
"i",
"temp",
"Arrays.sort(a)",
"Arrays.sort",
"Arrays",
"a",
"char[] a",
"a",
"static class FastReader \n\t{ \n\t\tBufferedReader br; \n\t\tStringTokenizer st; \n\n\t\tpublic FastReader() \n\t\t{ \n\t\t\tbr = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in)); \n\t\t} \n\n\t\tString next() \n\t\t{ \n\t\t\twhile (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t} \n\t\t\treturn st.nextToken(); \n\t\t} \n\n\t\tint nextInt() \n\t\t{ \n\t\t\treturn Integer.parseInt(next()); \n\t\t} \n\n\t\tlong nextLong() \n\t\t{ \n\t\t\treturn Long.parseLong(next()); \n\t\t} \n\n\t\tdouble nextDouble() \n\t\t{ \n\t\t\treturn Double.parseDouble(next()); \n\t\t} \n\n\t\tString nextLine() \n\t\t{ \n\t\t\tString str = \"\"; \n\t\t\ttry\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t} \n\t\t\treturn str; \n\t\t} \n\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t}",
"FastReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() \n\t\t{ \n\t\t\tbr = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in)); \n\t\t}",
"FastReader",
"{ \n\t\t\tbr = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in)); \n\t\t}",
"br = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in))",
"br",
"new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in))",
"String next() \n\t\t{ \n\t\t\twhile (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t} \n\t\t\treturn st.nextToken(); \n\t\t}",
"next",
"{ \n\t\t\twhile (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t} \n\t\t\treturn st.nextToken(); \n\t\t}",
"while (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t}",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t}",
"try\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t}",
"catch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t}",
"IOException e",
"{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t}",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"int nextInt() \n\t\t{ \n\t\t\treturn Integer.parseInt(next()); \n\t\t}",
"nextInt",
"{ \n\t\t\treturn Integer.parseInt(next()); \n\t\t}",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"long nextLong() \n\t\t{ \n\t\t\treturn Long.parseLong(next()); \n\t\t}",
"nextLong",
"{ \n\t\t\treturn Long.parseLong(next()); \n\t\t}",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() \n\t\t{ \n\t\t\treturn Double.parseDouble(next()); \n\t\t}",
"nextDouble",
"{ \n\t\t\treturn Double.parseDouble(next()); \n\t\t}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() \n\t\t{ \n\t\t\tString str = \"\"; \n\t\t\ttry\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t} \n\t\t\treturn str; \n\t\t}",
"nextLine",
"{ \n\t\t\tString str = \"\"; \n\t\t\ttry\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t} \n\t\t\treturn str; \n\t\t}",
"String str = \"\";",
"str",
"\"\"",
"try\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t}",
"catch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t}",
"IOException e",
"{ \n\t\t\t\te.printStackTrace(); \n\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t}",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"int[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}",
"readArray",
"{\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}",
"int[] a=new int[n];",
"a",
"new int[n]",
"n",
"for (int i=0; i<n; i++) a[i]=nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=nextInt();",
"a[i]=nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int n",
"n",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tFastReader in = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = in.nextInt();\n\t\tint[] a = in.readArray(n);\n\t\tlong ans = 0;\n\t\tint max = -1;\n\t\tfor(int x:a) {\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\n\tstatic final Random random=new Random();\n\t//\tstatic void ruffleSort(Pair[] a) {\n\t//\t\tint n=a.length;//shuffle, then sort \n\t//\t\tfor (int i=0; i<n; i++) {\n\t//\t\t\tint oi=random.nextInt(n);\n\t//\t\t\tPair temp=a[oi];\n\t//\t\t\ta[oi]=a[i]; a[i]=temp;\n\t//\t\t}\n\t//\t\tArrays.sort(a);\n\t//\t}\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic void ruffleSort(char[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic class FastReader \n\t{ \n\t\tBufferedReader br; \n\t\tStringTokenizer st; \n\n\t\tpublic FastReader() \n\t\t{ \n\t\t\tbr = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in)); \n\t\t} \n\n\t\tString next() \n\t\t{ \n\t\t\twhile (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t} \n\t\t\treturn st.nextToken(); \n\t\t} \n\n\t\tint nextInt() \n\t\t{ \n\t\t\treturn Integer.parseInt(next()); \n\t\t} \n\n\t\tlong nextLong() \n\t\t{ \n\t\t\treturn Long.parseLong(next()); \n\t\t} \n\n\t\tdouble nextDouble() \n\t\t{ \n\t\t\treturn Double.parseDouble(next()); \n\t\t} \n\n\t\tString nextLine() \n\t\t{ \n\t\t\tString str = \"\"; \n\t\t\ttry\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t} \n\t\t\treturn str; \n\t\t} \n\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tFastReader in = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = in.nextInt();\n\t\tint[] a = in.readArray(n);\n\t\tlong ans = 0;\n\t\tint max = -1;\n\t\tfor(int x:a) {\n\t\t\tmax = Math.max(max,x);\n\t\t\tans += max - x;\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\n\tstatic final Random random=new Random();\n\t//\tstatic void ruffleSort(Pair[] a) {\n\t//\t\tint n=a.length;//shuffle, then sort \n\t//\t\tfor (int i=0; i<n; i++) {\n\t//\t\t\tint oi=random.nextInt(n);\n\t//\t\t\tPair temp=a[oi];\n\t//\t\t\ta[oi]=a[i]; a[i]=temp;\n\t//\t\t}\n\t//\t\tArrays.sort(a);\n\t//\t}\n\tstatic void ruffleSort(int[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n), temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic void ruffleSort(char[] a) {\n\t\tint n=a.length;//shuffle, then sort \n\t\tfor (int i=0; i<n; i++) {\n\t\t\tint oi=random.nextInt(n);\n\t\t\tchar temp=a[oi];\n\t\t\ta[oi]=a[i]; a[i]=temp;\n\t\t}\n\t\tArrays.sort(a);\n\t}\n\tstatic class FastReader \n\t{ \n\t\tBufferedReader br; \n\t\tStringTokenizer st; \n\n\t\tpublic FastReader() \n\t\t{ \n\t\t\tbr = new BufferedReader(new\n\t\t\t\t\tInputStreamReader(System.in)); \n\t\t} \n\n\t\tString next() \n\t\t{ \n\t\t\twhile (st == null || !st.hasMoreElements()) \n\t\t\t{ \n\t\t\t\ttry\n\t\t\t\t{ \n\t\t\t\t\tst = new StringTokenizer(br.readLine()); \n\t\t\t\t} \n\t\t\t\tcatch (IOException e) \n\t\t\t\t{ \n\t\t\t\t\te.printStackTrace(); \n\t\t\t\t} \n\t\t\t} \n\t\t\treturn st.nextToken(); \n\t\t} \n\n\t\tint nextInt() \n\t\t{ \n\t\t\treturn Integer.parseInt(next()); \n\t\t} \n\n\t\tlong nextLong() \n\t\t{ \n\t\t\treturn Long.parseLong(next()); \n\t\t} \n\n\t\tdouble nextDouble() \n\t\t{ \n\t\t\treturn Double.parseDouble(next()); \n\t\t} \n\n\t\tString nextLine() \n\t\t{ \n\t\t\tString str = \"\"; \n\t\t\ttry\n\t\t\t{ \n\t\t\t\tstr = br.readLine(); \n\t\t\t} \n\t\t\tcatch (IOException e) \n\t\t\t{ \n\t\t\t\te.printStackTrace(); \n\t\t\t} \n\t\t\treturn str; \n\t\t} \n\n\t\tint[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i<n; i++) a[i]=nextInt();\n\t\t\treturn a;\n\t\t}\n\t}\n}",
"Main"
]
| import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
public static void main(String[] args) {
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int[] a = in.readArray(n);
long ans = 0;
int max = -1;
for(int x:a) {
max = Math.max(max,x);
ans += max - x;
}
out.println(ans);
out.close();
}
static final Random random=new Random();
// static void ruffleSort(Pair[] a) {
// int n=a.length;//shuffle, then sort
// for (int i=0; i<n; i++) {
// int oi=random.nextInt(n);
// Pair temp=a[oi];
// a[oi]=a[i]; a[i]=temp;
// }
// Arrays.sort(a);
// }
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static void ruffleSort(char[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n);
char temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
}
}
//class Pair implements Comparable<Pair>{
// int a;
// int b;
// public Pair(int a, int b) {
// this.a = a;
// this.b = b;
// }
// public int compareTo(Pair o) {
// if(this.a==o.a)
// return this.b - o.b;
// return this.a - o.a;
// }
//} |
[
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,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
2,
13,
18,
13,
13,
14,
2,
13,
17,
30,
0,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
92,
5
],
[
92,
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
],
[
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
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
61,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
69,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
8,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
6,
89
],
[
89,
90
],
[
0,
91
],
[
91,
92
],
[
91,
93
]
]
| [
"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\tfor( int i= 0; i<n ; i++ ) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint pmax = a[0];\n\t\tlong s = 0;\n\t\tfor( int i= 1; i<n ; i++ ) {\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tSystem.out.println(s);\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 = 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\tint pmax = a[0];\n\t\tlong s = 0;\n\t\tfor( int i= 1; i<n ; i++ ) {\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tSystem.out.println(s);\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\t\n\t\tint pmax = a[0];\n\t\tlong s = 0;\n\t\tfor( int i= 1; i<n ; i++ ) {\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tSystem.out.println(s);\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\t\n\t\tint pmax = a[0];\n\t\tlong s = 0;\n\t\tfor( int i= 1; i<n ; i++ ) {\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tSystem.out.println(s);\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 pmax = a[0];",
"pmax",
"a[0]",
"a",
"0",
"long s = 0;",
"s",
"0",
"for( int i= 1; i<n ; i++ ) {\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\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\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}",
"{\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}",
"int d = pmax - a[i];",
"d",
"pmax - a[i]",
"pmax",
"a[i]",
"a",
"i",
"if( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}",
"d >= 0",
"d",
"0",
"{\n\t\t\t\ts += d;\n\t\t\t}",
"s += d",
"s",
"d",
"{\n\t\t\t\tpmax = a[i];\n\t\t\t}",
"pmax = a[i]",
"pmax",
"a[i]",
"a",
"i",
"System.out.println(s)",
"System.out.println",
"System.out",
"System",
"System.out",
"s",
"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\tfor( int i= 0; i<n ; i++ ) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint pmax = a[0];\n\t\tlong s = 0;\n\t\tfor( int i= 1; i<n ; i++ ) {\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tSystem.out.println(s);\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\tfor( int i= 0; i<n ; i++ ) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tint pmax = a[0];\n\t\tlong s = 0;\n\t\tfor( int i= 1; i<n ; i++ ) {\n\t\t\tint d = pmax - a[i];\n\t\t\tif( d >= 0 ) {\n\t\t\t\ts += d;\n\t\t\t}else {\n\t\t\t\tpmax = a[i];\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tSystem.out.println(s);\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 pmax = a[0];
long s = 0;
for( int i= 1; i<n ; i++ ) {
int d = pmax - a[i];
if( d >= 0 ) {
s += d;
}else {
pmax = a[i];
}
}
System.out.println(s);
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
4,
18,
13,
4,
18,
13,
4,
18,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
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,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
13,
0,
18,
13,
13,
13,
29,
13,
12,
13,
30,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
136,
5
],
[
136,
6
],
[
6,
7
],
[
136,
8
],
[
8,
9
],
[
136,
10
],
[
10,
11
],
[
136,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
22,
23
],
[
21,
24
],
[
24,
25
],
[
25,
26
],
[
14,
27
],
[
27,
28
],
[
28,
29
],
[
12,
30
],
[
30,
31
],
[
136,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
34,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
45,
46
],
[
34,
47
],
[
47,
48
],
[
47,
49
],
[
34,
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
],
[
32,
71
],
[
71,
72
],
[
136,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
84,
85
],
[
84,
86
],
[
79,
87
],
[
87,
88
],
[
88,
89
],
[
79,
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
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
105,
111
],
[
111,
112
],
[
111,
113
],
[
102,
114
],
[
114,
115
],
[
114,
116
],
[
102,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
75,
122
],
[
122,
123
],
[
136,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
124,
133
],
[
133,
134
],
[
0,
135
],
[
135,
136
],
[
135,
137
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n Main m = new Main(sc);\n m.show(m.solve());\n sc.close();\n }\n \n\t//フィールド\n Scanner sc;\n int N;\n int[] A;\n \n //入力\n Main(Scanner sc) {\n this.sc = sc;\n this.N = sc.nextInt();\n A = new int[N];\n for (int i=0; i<N; i++) {\n \tA[i] = sc.nextInt();\n }\n }\n \n //解答処理\n private long solve() {\n long answer = 0;\n \n for (int i=1; i<N; i++) {\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }\n \n return answer;\n }\n \n //出力\n public void show(long answer) {\n System.out.println(answer);\n }\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n Main m = new Main(sc);\n m.show(m.solve());\n sc.close();\n }\n \n\t//フィールド\n Scanner sc;\n int N;\n int[] A;\n \n //入力\n Main(Scanner sc) {\n this.sc = sc;\n this.N = sc.nextInt();\n A = new int[N];\n for (int i=0; i<N; i++) {\n \tA[i] = sc.nextInt();\n }\n }\n \n //解答処理\n private long solve() {\n long answer = 0;\n \n for (int i=1; i<N; i++) {\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }\n \n return answer;\n }\n \n //出力\n public void show(long answer) {\n System.out.println(answer);\n }\n\n}",
"Main",
"//フィールド\n Scanner sc;",
"sc",
"int N;",
"N",
"int[] A;",
"A",
"public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n Main m = new Main(sc);\n m.show(m.solve());\n sc.close();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n Main m = new Main(sc);\n m.show(m.solve());\n sc.close();\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Main m = new Main(sc);",
"m",
"new Main(sc)",
"m.show(m.solve())",
"m.show",
"m",
"m.solve()",
"m.solve",
"m",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"//入力\n Main(Scanner sc) {\n this.sc = sc;\n this.N = sc.nextInt();\n A = new int[N];\n for (int i=0; i<N; i++) {\n \tA[i] = sc.nextInt();\n }\n }",
"Main",
"{\n this.sc = sc;\n this.N = sc.nextInt();\n A = new int[N];\n for (int i=0; i<N; i++) {\n \tA[i] = sc.nextInt();\n }\n }",
"this.sc = sc",
"this.sc",
"this",
"this.sc",
"sc",
"this.N = sc.nextInt()",
"this.N",
"this",
"this.N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"A = new int[N]",
"A",
"new int[N]",
"N",
"for (int i=0; i<N; i++) {\n \tA[i] = sc.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n \tA[i] = sc.nextInt();\n }",
"{\n \tA[i] = sc.nextInt();\n }",
"A[i] = sc.nextInt()",
"A[i]",
"A",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Scanner sc",
"sc",
"//解答処理\n private long solve() {\n long answer = 0;\n \n for (int i=1; i<N; i++) {\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }\n \n return answer;\n }",
"solve",
"{\n long answer = 0;\n \n for (int i=1; i<N; i++) {\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }\n \n return answer;\n }",
"long answer = 0;",
"answer",
"0",
"for (int i=1; i<N; i++) {\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }",
"{\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }",
"if (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}",
"A[i] < A[i-1]",
"A[i]",
"A",
"i",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"{\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}",
"long tmp = A[i-1]-A[i];",
"tmp",
"A[i-1]-A[i]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"answer += tmp",
"answer",
"tmp",
"A[i] += tmp",
"A[i]",
"A",
"i",
"tmp",
"return answer;",
"answer",
"//出力\n public void show(long answer) {\n System.out.println(answer);\n }",
"show",
"{\n System.out.println(answer);\n }",
"System.out.println(answer)",
"System.out.println",
"System.out",
"System",
"System.out",
"answer",
"long answer",
"answer",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n Main m = new Main(sc);\n m.show(m.solve());\n sc.close();\n }\n \n\t//フィールド\n Scanner sc;\n int N;\n int[] A;\n \n //入力\n Main(Scanner sc) {\n this.sc = sc;\n this.N = sc.nextInt();\n A = new int[N];\n for (int i=0; i<N; i++) {\n \tA[i] = sc.nextInt();\n }\n }\n \n //解答処理\n private long solve() {\n long answer = 0;\n \n for (int i=1; i<N; i++) {\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }\n \n return answer;\n }\n \n //出力\n public void show(long answer) {\n System.out.println(answer);\n }\n\n}",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n Main m = new Main(sc);\n m.show(m.solve());\n sc.close();\n }\n \n\t//フィールド\n Scanner sc;\n int N;\n int[] A;\n \n //入力\n Main(Scanner sc) {\n this.sc = sc;\n this.N = sc.nextInt();\n A = new int[N];\n for (int i=0; i<N; i++) {\n \tA[i] = sc.nextInt();\n }\n }\n \n //解答処理\n private long solve() {\n long answer = 0;\n \n for (int i=1; i<N; i++) {\n \tif (A[i] < A[i-1]) {\n \t\tlong tmp = A[i-1]-A[i];\n \t\tanswer += tmp;\n \t\tA[i] += tmp;\t//踏み台の分を身長に加算\n \t}\n }\n \n return answer;\n }\n \n //出力\n public void show(long answer) {\n System.out.println(answer);\n }\n\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
Main m = new Main(sc);
m.show(m.solve());
sc.close();
}
//フィールド
Scanner sc;
int N;
int[] A;
//入力
Main(Scanner sc) {
this.sc = sc;
this.N = sc.nextInt();
A = new int[N];
for (int i=0; i<N; i++) {
A[i] = sc.nextInt();
}
}
//解答処理
private long solve() {
long answer = 0;
for (int i=1; i<N; i++) {
if (A[i] < A[i-1]) {
long tmp = A[i-1]-A[i];
answer += tmp;
A[i] += tmp; //踏み台の分を身長に加算
}
}
return answer;
}
//出力
public void show(long answer) {
System.out.println(answer);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
0,
13,
4,
18,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
67,
5
],
[
67,
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,
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
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
35,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
48,
50
],
[
35,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
53,
57
],
[
8,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
58,
63
],
[
6,
64
],
[
64,
65
],
[
0,
66
],
[
66,
67
],
[
66,
68
]
]
| [
"//package beginner176;\n\nimport java.util.Scanner;\n\npublic class Main {\n\n\n public static void main(String[] args){\n Scanner in = new Scanner(System.in);\n\n int N = in.nextInt();\n int max = 0;\n\n long result = 0;\n for(int i = 0; i < N; i++){\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }\n System.out.println(result);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\n public static void main(String[] args){\n Scanner in = new Scanner(System.in);\n\n int N = in.nextInt();\n int max = 0;\n\n long result = 0;\n for(int i = 0; i < N; i++){\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }\n System.out.println(result);\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner in = new Scanner(System.in);\n\n int N = in.nextInt();\n int max = 0;\n\n long result = 0;\n for(int i = 0; i < N; i++){\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }\n System.out.println(result);\n }",
"main",
"{\n Scanner in = new Scanner(System.in);\n\n int N = in.nextInt();\n int max = 0;\n\n long result = 0;\n for(int i = 0; i < N; i++){\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }\n System.out.println(result);\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int N = in.nextInt();",
"N",
"in.nextInt()",
"in.nextInt",
"in",
"int max = 0;",
"max",
"0",
"long result = 0;",
"result",
"0",
"for(int i = 0; i < N; i++){\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }",
"{\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }",
"int x = in.nextInt();",
"x",
"in.nextInt()",
"in.nextInt",
"in",
"if(x < max){\n result += max - x;\n }",
"x < max",
"x",
"max",
"{\n result += max - x;\n }",
"result += max - x",
"result",
"max - x",
"max",
"x",
"max = Math.max(max, x)",
"max",
"Math.max(max, x)",
"Math.max",
"Math",
"max",
"x",
"System.out.println(result)",
"System.out.println",
"System.out",
"System",
"System.out",
"result",
"String[] args",
"args",
"public class Main {\n\n\n public static void main(String[] args){\n Scanner in = new Scanner(System.in);\n\n int N = in.nextInt();\n int max = 0;\n\n long result = 0;\n for(int i = 0; i < N; i++){\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }\n System.out.println(result);\n }\n}",
"public class Main {\n\n\n public static void main(String[] args){\n Scanner in = new Scanner(System.in);\n\n int N = in.nextInt();\n int max = 0;\n\n long result = 0;\n for(int i = 0; i < N; i++){\n int x = in.nextInt();\n if(x < max){\n result += max - x;\n }\n max = Math.max(max, x);\n }\n System.out.println(result);\n }\n}",
"Main"
]
| //package beginner176;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int max = 0;
long result = 0;
for(int i = 0; i < N; i++){
int x = in.nextInt();
if(x < max){
result += max - x;
}
max = Math.max(max, x);
}
System.out.println(result);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
0,
18,
13,
17,
4,
18,
13,
41,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
85,
5
],
[
85,
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
],
[
22,
24
],
[
21,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
30,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
8,
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
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
56,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
8,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
76,
81
],
[
6,
82
],
[
82,
83
],
[
0,
84
],
[
84,
85
],
[
84,
86
]
]
| [
"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 // 配列\n int[] a = new int[n];\n a[0] = sc.nextInt();\n int mx = a[0];\n long sum = 0;\n for(int i=1;i<n;i++){\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }\n System.out.println(sum);\n\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 // 配列\n int[] a = new int[n];\n a[0] = sc.nextInt();\n int mx = a[0];\n long sum = 0;\n for(int i=1;i<n;i++){\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }\n System.out.println(sum);\n\n }\n \n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // 配列\n int[] a = new int[n];\n a[0] = sc.nextInt();\n int mx = a[0];\n long sum = 0;\n for(int i=1;i<n;i++){\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }\n System.out.println(sum);\n\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n // 配列\n int[] a = new int[n];\n a[0] = sc.nextInt();\n int mx = a[0];\n long sum = 0;\n for(int i=1;i<n;i++){\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }\n System.out.println(sum);\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",
"a[0] = sc.nextInt()",
"a[0]",
"a",
"0",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int mx = a[0];",
"mx",
"a[0]",
"a",
"0",
"long sum = 0;",
"sum",
"0",
"for(int i=1;i<n;i++){\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }",
"{\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }",
"a[i] = sc.nextInt()",
"a[i]",
"a",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }",
"a[i] < mx",
"a[i]",
"a",
"i",
"mx",
"{\n sum += (mx - a[i]);\n }",
"sum += (mx - a[i])",
"sum",
"(mx - a[i])",
"mx",
"a[i]",
"a",
"i",
"{\n mx = a[i];\n }",
"mx = a[i]",
"mx",
"a[i]",
"a",
"i",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"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 // 配列\n int[] a = new int[n];\n a[0] = sc.nextInt();\n int mx = a[0];\n long sum = 0;\n for(int i=1;i<n;i++){\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }\n System.out.println(sum);\n\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 // 配列\n int[] a = new int[n];\n a[0] = sc.nextInt();\n int mx = a[0];\n long sum = 0;\n for(int i=1;i<n;i++){\n a[i] = sc.nextInt();\n if(a[i] < mx) {\n sum += (mx - a[i]);\n } else {\n mx = a[i];\n }\n }\n System.out.println(sum);\n\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];
a[0] = sc.nextInt();
int mx = a[0];
long sum = 0;
for(int i=1;i<n;i++){
a[i] = sc.nextInt();
if(a[i] < mx) {
sum += (mx - a[i]);
} else {
mx = a[i];
}
}
System.out.println(sum);
}
}
|
[
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,
41,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
14,
2,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
90,
5
],
[
90,
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
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
59,
65
],
[
65,
66
],
[
65,
67
],
[
56,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
72,
78
],
[
78,
79
],
[
78,
80
],
[
8,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
81,
86
],
[
6,
87
],
[
87,
88
],
[
0,
89
],
[
89,
90
],
[
89,
91
]
]
| [
"import java.util.*;\npublic class Main {\n public static void main(String[] args) {\n \tScanner s = new Scanner(System.in);\n int n = s.nextInt();\n int[] arr = new int[n];\n for(int i=0;i<n;i++) {\n arr[i] = s.nextInt(); \n }\n \n long total = 0;\n for(int i=1;i<n;i++) {\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }\n System.out.println(total);\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n \tScanner s = new Scanner(System.in);\n int n = s.nextInt();\n int[] arr = new int[n];\n for(int i=0;i<n;i++) {\n arr[i] = s.nextInt(); \n }\n \n long total = 0;\n for(int i=1;i<n;i++) {\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }\n System.out.println(total);\n }\n}",
"Main",
"public static void main(String[] args) {\n \tScanner s = new Scanner(System.in);\n int n = s.nextInt();\n int[] arr = new int[n];\n for(int i=0;i<n;i++) {\n arr[i] = s.nextInt(); \n }\n \n long total = 0;\n for(int i=1;i<n;i++) {\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }\n System.out.println(total);\n }",
"main",
"{\n \tScanner s = new Scanner(System.in);\n int n = s.nextInt();\n int[] arr = new int[n];\n for(int i=0;i<n;i++) {\n arr[i] = s.nextInt(); \n }\n \n long total = 0;\n for(int i=1;i<n;i++) {\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }\n System.out.println(total);\n }",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int n = s.nextInt();",
"n",
"s.nextInt()",
"s.nextInt",
"s",
"int[] arr = new int[n];",
"arr",
"new int[n]",
"n",
"for(int i=0;i<n;i++) {\n arr[i] = s.nextInt(); \n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n arr[i] = s.nextInt(); \n }",
"{\n arr[i] = s.nextInt(); \n }",
"arr[i] = s.nextInt()",
"arr[i]",
"arr",
"i",
"s.nextInt()",
"s.nextInt",
"s",
"long total = 0;",
"total",
"0",
"for(int i=1;i<n;i++) {\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }",
"{\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }",
"int v = arr[i-1] - arr[i];",
"v",
"arr[i-1] - arr[i]",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]",
"arr",
"i",
"if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }",
"v > 0",
"v",
"0",
"{\n arr[i] += v;\n total += (long)v;\n }",
"arr[i] += v",
"arr[i]",
"arr",
"i",
"v",
"total += (long)v",
"total",
"(long)v",
"System.out.println(total)",
"System.out.println",
"System.out",
"System",
"System.out",
"total",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n \tScanner s = new Scanner(System.in);\n int n = s.nextInt();\n int[] arr = new int[n];\n for(int i=0;i<n;i++) {\n arr[i] = s.nextInt(); \n }\n \n long total = 0;\n for(int i=1;i<n;i++) {\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }\n System.out.println(total);\n }\n}",
"public class Main {\n public static void main(String[] args) {\n \tScanner s = new Scanner(System.in);\n int n = s.nextInt();\n int[] arr = new int[n];\n for(int i=0;i<n;i++) {\n arr[i] = s.nextInt(); \n }\n \n long total = 0;\n for(int i=1;i<n;i++) {\n int v = arr[i-1] - arr[i];\n if(v > 0) {\n arr[i] += v;\n total += (long)v;\n }\n }\n System.out.println(total);\n }\n}",
"Main"
]
| import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++) {
arr[i] = s.nextInt();
}
long total = 0;
for(int i=1;i<n;i++) {
int v = arr[i-1] - arr[i];
if(v > 0) {
arr[i] += v;
total += (long)v;
}
}
System.out.println(total);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
2,
2,
13,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
66,
5
],
[
66,
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
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
37,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
45,
49
],
[
37,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
8,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
6,
63
],
[
63,
64
],
[
0,
65
],
[
65,
66
],
[
65,
67
]
]
| [
"import java.util.Scanner;\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 int maxA = sc.nextInt();\n long res = 0;\n for(int i=1; i<N; i++){\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }\n\t\tSystem.out.println(res);\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 int maxA = sc.nextInt();\n long res = 0;\n for(int i=1; i<N; i++){\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }\n\t\tSystem.out.println(res);\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 int maxA = sc.nextInt();\n long res = 0;\n for(int i=1; i<N; i++){\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }\n\t\tSystem.out.println(res);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n int maxA = sc.nextInt();\n long res = 0;\n for(int i=1; i<N; i++){\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }\n\t\tSystem.out.println(res);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int maxA = sc.nextInt();",
"maxA",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long res = 0;",
"res",
"0",
"for(int i=1; i<N; i++){\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }",
"{\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }",
"int A = sc.nextInt();",
"A",
"sc.nextInt()",
"sc.nextInt",
"sc",
"maxA = Math.max(maxA,A)",
"maxA",
"Math.max(maxA,A)",
"Math.max",
"Math",
"maxA",
"A",
"res = res + maxA - A",
"res",
"res + maxA - A",
"res + maxA",
"res",
"maxA",
"A",
"System.out.println(res)",
"System.out.println",
"System.out",
"System",
"System.out",
"res",
"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 int maxA = sc.nextInt();\n long res = 0;\n for(int i=1; i<N; i++){\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }\n\t\tSystem.out.println(res);\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 int maxA = sc.nextInt();\n long res = 0;\n for(int i=1; i<N; i++){\n int A = sc.nextInt();\n maxA = Math.max(maxA,A);\n res = res + maxA - A;\n \n }\n\t\tSystem.out.println(res);\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 maxA = sc.nextInt();
long res = 0;
for(int i=1; i<N; i++){
int A = sc.nextInt();
maxA = Math.max(maxA,A);
res = res + maxA - A;
}
System.out.println(res);
}
} |
[
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,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
91,
5
],
[
91,
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
],
[
47,
49
],
[
8,
50
],
[
50,
51
],
[
50,
52
],
[
8,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
53,
58
],
[
58,
59
],
[
58,
60
],
[
53,
61
],
[
61,
62
],
[
62,
63
],
[
53,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
68,
72
],
[
72,
73
],
[
72,
74
],
[
65,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
8,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
6,
88
],
[
88,
89
],
[
0,
90
],
[
90,
91
],
[
90,
92
]
]
| [
"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 = Integer.parseInt(sc.next());\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(sc.next());\n }\n\n long ans = 0;\n int max = 0;\n for (int i = 0; i < n; i++) {\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }\n System.out.println(ans);\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 = Integer.parseInt(sc.next());\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(sc.next());\n }\n\n long ans = 0;\n int max = 0;\n for (int i = 0; i < n; i++) {\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }\n System.out.println(ans);\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = Integer.parseInt(sc.next());\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(sc.next());\n }\n\n long ans = 0;\n int max = 0;\n for (int i = 0; i < n; i++) {\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }\n System.out.println(ans);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = Integer.parseInt(sc.next());\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(sc.next());\n }\n\n long ans = 0;\n int max = 0;\n for (int i = 0; i < n; i++) {\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }\n System.out.println(ans);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = Integer.parseInt(sc.next());",
"n",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(sc.next());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = Integer.parseInt(sc.next());\n }",
"{\n a[i] = Integer.parseInt(sc.next());\n }",
"a[i] = Integer.parseInt(sc.next())",
"a[i]",
"a",
"i",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"long ans = 0;",
"ans",
"0",
"int max = 0;",
"max",
"0",
"for (int i = 0; i < n; i++) {\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }",
"{\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }",
"max = Math.max(max, a[i])",
"max",
"Math.max(max, a[i])",
"Math.max",
"Math",
"max",
"a[i]",
"a",
"i",
"ans += max - a[i]",
"ans",
"max - a[i]",
"max",
"a[i]",
"a",
"i",
"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 = Integer.parseInt(sc.next());\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(sc.next());\n }\n\n long ans = 0;\n int max = 0;\n for (int i = 0; i < n; i++) {\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }\n System.out.println(ans);\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = Integer.parseInt(sc.next());\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(sc.next());\n }\n\n long ans = 0;\n int max = 0;\n for (int i = 0; i < n; i++) {\n max = Math.max(max, a[i]);\n ans += max - a[i];\n }\n System.out.println(ans);\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.parseInt(sc.next());
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = Integer.parseInt(sc.next());
}
long ans = 0;
int max = 0;
for (int i = 0; i < n; i++) {
max = Math.max(max, a[i]);
ans += max - a[i];
}
System.out.println(ans);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
79,
5
],
[
79,
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
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
38,
40
],
[
31,
41
],
[
41,
42
],
[
42,
43
],
[
31,
44
],
[
45,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
45,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
55,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
51,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
8,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
70,
75
],
[
6,
76
],
[
76,
77
],
[
0,
78
],
[
78,
79
],
[
78,
80
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner (System.in);\n\t\t\n\t\tlong n =sc.nextInt();\n\t\t\n\t\tint height1=sc.nextInt();\n\t\tint height2=0;\n\t\t\n\t\tint takadai=0;\n\t\tlong sum=0;\n\t\t\n\t\tfor(int i=0;i<(n-1);i++) {\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\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 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner (System.in);\n\t\t\n\t\tlong n =sc.nextInt();\n\t\t\n\t\tint height1=sc.nextInt();\n\t\tint height2=0;\n\t\t\n\t\tint takadai=0;\n\t\tlong sum=0;\n\t\t\n\t\tfor(int i=0;i<(n-1);i++) {\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner (System.in);\n\t\t\n\t\tlong n =sc.nextInt();\n\t\t\n\t\tint height1=sc.nextInt();\n\t\tint height2=0;\n\t\t\n\t\tint takadai=0;\n\t\tlong sum=0;\n\t\t\n\t\tfor(int i=0;i<(n-1);i++) {\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\n\t}",
"main",
"{\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner (System.in);\n\t\t\n\t\tlong n =sc.nextInt();\n\t\t\n\t\tint height1=sc.nextInt();\n\t\tint height2=0;\n\t\t\n\t\tint takadai=0;\n\t\tlong sum=0;\n\t\t\n\t\tfor(int i=0;i<(n-1);i++) {\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\n\t}",
"Scanner sc = new Scanner (System.in);",
"sc",
"new Scanner (System.in)",
"long n =sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int height1=sc.nextInt();",
"height1",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int height2=0;",
"height2",
"0",
"int takadai=0;",
"takadai",
"0",
"long sum=0;",
"sum",
"0",
"for(int i=0;i<(n-1);i++) {\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \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\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}",
"{\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}",
"height2 = sc.nextInt()",
"height2",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}",
"height1>height2",
"height1",
"height2",
"{\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}",
"takadai = height1 - height2",
"takadai",
"height1 - height2",
"height1",
"height2",
"sum = sum + takadai",
"sum",
"sum + takadai",
"sum",
"takadai",
"{\n\t\t\t\theight1 = height2; \n\t\t\t}",
"height1 = height2",
"height1",
"height2",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner (System.in);\n\t\t\n\t\tlong n =sc.nextInt();\n\t\t\n\t\tint height1=sc.nextInt();\n\t\tint height2=0;\n\t\t\n\t\tint takadai=0;\n\t\tlong sum=0;\n\t\t\n\t\tfor(int i=0;i<(n-1);i++) {\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner (System.in);\n\t\t\n\t\tlong n =sc.nextInt();\n\t\t\n\t\tint height1=sc.nextInt();\n\t\tint height2=0;\n\t\t\n\t\tint takadai=0;\n\t\tlong sum=0;\n\t\t\n\t\tfor(int i=0;i<(n-1);i++) {\n\t\t\theight2 = sc.nextInt();\n\t\t\tif(height1>height2) {\n\t\t\t\ttakadai = height1 - height2;\n\t\t\t\tsum = sum + takadai;\n\t\t\t}else {\n\t\t\t\theight1 = height2; \n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\n\t}\n\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner sc = new Scanner (System.in);
long n =sc.nextInt();
int height1=sc.nextInt();
int height2=0;
int takadai=0;
long sum=0;
for(int i=0;i<(n-1);i++) {
height2 = sc.nextInt();
if(height1>height2) {
takadai = height1 - height2;
sum = sum + takadai;
}else {
height1 = height2;
}
}
System.out.println(sum);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
41,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
14,
2,
13,
17,
30,
0,
13,
13,
0,
18,
13,
2,
13,
17,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
23,
13,
12,
13,
30,
0,
13,
20,
23,
13,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
29,
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
],
[
207,
11
],
[
207,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
14,
32
],
[
32,
33
],
[
32,
34
],
[
14,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
35,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
42,
44
],
[
35,
45
],
[
45,
46
],
[
46,
47
],
[
35,
48
],
[
49,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
49,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
69,
75
],
[
14,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
14,
80
],
[
80,
81
],
[
81,
82
],
[
12,
83
],
[
83,
84
],
[
207,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
85,
89
],
[
89,
90
],
[
85,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
91,
97
],
[
97,
98
],
[
85,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
105,
106
],
[
85,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
110,
119
],
[
119,
120
],
[
119,
121
],
[
109,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
85,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
133,
134
],
[
85,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
142,
143
],
[
85,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
85,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
155,
158
],
[
158,
159
],
[
85,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
85,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
174,
179
],
[
179,
180
],
[
179,
181
],
[
174,
182
],
[
182,
183
],
[
183,
184
],
[
174,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
190,
191
],
[
169,
192
],
[
192,
193
],
[
167,
194
],
[
194,
195
],
[
85,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
198,
202
],
[
202,
203
],
[
196,
204
],
[
204,
205
],
[
0,
206
],
[
206,
207
],
[
206,
208
]
]
| [
"import java.io.*;\nimport java.util.*;\nimport java.math.BigInteger;\npublic class Main {\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter syso = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint arr[]=sc.nextArr(n);\n\t\tlong ans=0;\n\t\tfor(int i=0;i<n-1;i++) {\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}\n\t\tsyso.println(ans);\n syso.close();\n }\n \n \n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n \n\t\tpublic Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}\n \n\t\tpublic Scanner(String file) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n \n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n \n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n \n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n \n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n \n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\t\tpublic int[] nextArr(int n) throws IOException{\n\t\t\tint arr[]=new int[n];\n\t\t\tfor(int i=0;i<n;i++)arr[i]=nextInt();\n\t\t\treturn arr;\n\t\t}\n\t\tpublic BigInteger BigInteger(String s) throws IOException{\n\t\t\tBigInteger a=new BigInteger(s);\n\t\t\treturn a;\n\t\t}\n \n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"import java.math.BigInteger;",
"BigInteger",
"java.math",
"public class Main {\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter syso = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint arr[]=sc.nextArr(n);\n\t\tlong ans=0;\n\t\tfor(int i=0;i<n-1;i++) {\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}\n\t\tsyso.println(ans);\n syso.close();\n }\n \n \n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n \n\t\tpublic Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}\n \n\t\tpublic Scanner(String file) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n \n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n \n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n \n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n \n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n \n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\t\tpublic int[] nextArr(int n) throws IOException{\n\t\t\tint arr[]=new int[n];\n\t\t\tfor(int i=0;i<n;i++)arr[i]=nextInt();\n\t\t\treturn arr;\n\t\t}\n\t\tpublic BigInteger BigInteger(String s) throws IOException{\n\t\t\tBigInteger a=new BigInteger(s);\n\t\t\treturn a;\n\t\t}\n \n\t}\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter syso = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint arr[]=sc.nextArr(n);\n\t\tlong ans=0;\n\t\tfor(int i=0;i<n-1;i++) {\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}\n\t\tsyso.println(ans);\n syso.close();\n }",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter syso = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint arr[]=sc.nextArr(n);\n\t\tlong ans=0;\n\t\tfor(int i=0;i<n-1;i++) {\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}\n\t\tsyso.println(ans);\n syso.close();\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"PrintWriter syso = new PrintWriter(System.out);",
"syso",
"new PrintWriter(System.out)",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int arr[]=sc.nextArr(n);",
"arr",
"sc.nextArr(n)",
"sc.nextArr",
"sc",
"n",
"long ans=0;",
"ans",
"0",
"for(int i=0;i<n-1;i++) {\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\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\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}",
"{\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}",
"int a=arr[i]-arr[i+1];",
"a",
"arr[i]-arr[i+1]",
"arr[i]",
"arr",
"i",
"arr[i+1]",
"arr",
"i+1",
"i",
"1",
"if(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}",
"a>0",
"a",
"0",
"{\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}",
"ans+=a",
"ans",
"a",
"arr[i+1]+=a",
"arr[i+1]",
"arr",
"i+1",
"i",
"1",
"a",
"syso.println(ans)",
"syso.println",
"syso",
"ans",
"syso.close()",
"syso.close",
"syso",
"String[] args",
"args",
"static class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n \n\t\tpublic Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}\n \n\t\tpublic Scanner(String file) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n \n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n \n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n \n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n \n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n \n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\t\tpublic int[] nextArr(int n) throws IOException{\n\t\t\tint arr[]=new int[n];\n\t\t\tfor(int i=0;i<n;i++)arr[i]=nextInt();\n\t\t\treturn arr;\n\t\t}\n\t\tpublic BigInteger BigInteger(String s) throws IOException{\n\t\t\tBigInteger a=new BigInteger(s);\n\t\t\treturn a;\n\t\t}\n \n\t}",
"Scanner",
"StringTokenizer st;",
"st",
"BufferedReader br;",
"br",
"public Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}",
"Scanner",
"{\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}",
"br = new BufferedReader(new InputStreamReader(s))",
"br",
"new BufferedReader(new InputStreamReader(s))",
"InputStream s",
"s",
"public Scanner(String file) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}",
"Scanner",
"{\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}",
"br = new BufferedReader(new FileReader(file))",
"br",
"new BufferedReader(new FileReader(file))",
"String file",
"file",
"public String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}",
"next",
"{\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}",
"while (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());",
"st == null || !st.hasMoreTokens()",
"st == null",
"st",
"null",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"public int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"nextInt",
"{\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"public long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"nextLong",
"{\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"public String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}",
"nextLine",
"{\n\t\t\treturn br.readLine();\n\t\t}",
"return br.readLine();",
"br.readLine()",
"br.readLine",
"br",
"public double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"nextDouble",
"{\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"public boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}",
"ready",
"{\n\t\t\treturn br.ready();\n\t\t}",
"return br.ready();",
"br.ready()",
"br.ready",
"br",
"public int[] nextArr(int n) throws IOException{\n\t\t\tint arr[]=new int[n];\n\t\t\tfor(int i=0;i<n;i++)arr[i]=nextInt();\n\t\t\treturn arr;\n\t\t}",
"nextArr",
"{\n\t\t\tint arr[]=new int[n];\n\t\t\tfor(int i=0;i<n;i++)arr[i]=nextInt();\n\t\t\treturn arr;\n\t\t}",
"int arr[]=new int[n];",
"arr",
"new int[n]",
"n",
"for(int i=0;i<n;i++)arr[i]=nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i]=nextInt();",
"arr[i]=nextInt()",
"arr[i]",
"arr",
"i",
"nextInt()",
"nextInt",
"return arr;",
"arr",
"int n",
"n",
"public BigInteger BigInteger(String s) throws IOException{\n\t\t\tBigInteger a=new BigInteger(s);\n\t\t\treturn a;\n\t\t}",
"BigInteger",
"{\n\t\t\tBigInteger a=new BigInteger(s);\n\t\t\treturn a;\n\t\t}",
"BigInteger a=new BigInteger(s);",
"a",
"new BigInteger(s)",
"return a;",
"a",
"String s",
"s",
"public class Main {\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter syso = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint arr[]=sc.nextArr(n);\n\t\tlong ans=0;\n\t\tfor(int i=0;i<n-1;i++) {\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}\n\t\tsyso.println(ans);\n syso.close();\n }\n \n \n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n \n\t\tpublic Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}\n \n\t\tpublic Scanner(String file) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n \n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n \n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n \n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n \n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n \n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\t\tpublic int[] nextArr(int n) throws IOException{\n\t\t\tint arr[]=new int[n];\n\t\t\tfor(int i=0;i<n;i++)arr[i]=nextInt();\n\t\t\treturn arr;\n\t\t}\n\t\tpublic BigInteger BigInteger(String s) throws IOException{\n\t\t\tBigInteger a=new BigInteger(s);\n\t\t\treturn a;\n\t\t}\n \n\t}\n}",
"public class Main {\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter syso = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint arr[]=sc.nextArr(n);\n\t\tlong ans=0;\n\t\tfor(int i=0;i<n-1;i++) {\n\t\t\tint a=arr[i]-arr[i+1];\n\t\t\tif(a>0) {\n\t\t\t\tans+=a;\n\t\t\t\tarr[i+1]+=a;\n\t\t\t}\n\t\t}\n\t\tsyso.println(ans);\n syso.close();\n }\n \n \n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n \n\t\tpublic Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}\n \n\t\tpublic Scanner(String file) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n \n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n \n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n \n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n \n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n \n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\t\tpublic int[] nextArr(int n) throws IOException{\n\t\t\tint arr[]=new int[n];\n\t\t\tfor(int i=0;i<n;i++)arr[i]=nextInt();\n\t\t\treturn arr;\n\t\t}\n\t\tpublic BigInteger BigInteger(String s) throws IOException{\n\t\t\tBigInteger a=new BigInteger(s);\n\t\t\treturn a;\n\t\t}\n \n\t}\n}",
"Main"
]
| import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
PrintWriter syso = new PrintWriter(System.out);
int n=sc.nextInt();
int arr[]=sc.nextArr(n);
long ans=0;
for(int i=0;i<n-1;i++) {
int a=arr[i]-arr[i+1];
if(a>0) {
ans+=a;
arr[i+1]+=a;
}
}
syso.println(ans);
syso.close();
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(String file) throws FileNotFoundException {
br = new BufferedReader(new FileReader(file));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public boolean ready() throws IOException {
return br.ready();
}
public int[] nextArr(int n) throws IOException{
int arr[]=new int[n];
for(int i=0;i<n;i++)arr[i]=nextInt();
return arr;
}
public BigInteger BigInteger(String s) throws IOException{
BigInteger a=new BigInteger(s);
return a;
}
}
} |
[
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,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
2,
18,
13,
2,
13,
17,
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
],
[
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
],
[
42,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
59,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
60,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
73,
79
],
[
79,
80
],
[
79,
81
],
[
70,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
86,
92
],
[
92,
93
],
[
92,
94
],
[
8,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
6,
101
],
[
101,
102
]
]
| [
"import java.util.*;\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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;++i){\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<N;++i){\n\t\t\tif(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n",
"import java.util.*;",
"util.*",
"java",
"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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;++i){\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<N;++i){\n\t\t\tif(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;++i){\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<N;++i){\n\t\t\tif(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;++i){\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tsc.close();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<N;++i){\n\t\t\tif(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] A = new long[N];",
"A",
"new long[N]",
"N",
"for(int i=0;i<N;++i){\n\t\t\tA[i] = sc.nextLong();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"++i",
"++i",
"i",
"{\n\t\t\tA[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextLong();\n\t\t}",
"A[i] = sc.nextLong()",
"A[i]",
"A",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"sc.close()",
"sc.close",
"sc",
"long ans = 0;",
"ans",
"0",
"for(int i=1;i<N;++i){\n\t\t\tif(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\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\tif(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\n\t\t\t}\n\t\t}",
"if(A[i]<A[i-1]){\n\t\t\t\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\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\tans += A[i-1] - A[i];\n\t\t\t\tA[i] += A[i-1] - A[i];\n\t\t\t\t//System.out.println(A[i]);\n\t\t\t}",
"ans += A[i-1] - A[i]",
"ans",
"A[i-1] - A[i]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"A[i] += A[i-1] - A[i]",
"A[i]",
"A",
"i",
"A[i-1] - A[i]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args"
]
| import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long[] A = new long[N];
for(int i=0;i<N;++i){
A[i] = sc.nextLong();
}
sc.close();
long ans = 0;
for(int i=1;i<N;++i){
if(A[i]<A[i-1]){
ans += A[i-1] - A[i];
A[i] += A[i-1] - A[i];
//System.out.println(A[i]);
}
}
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,
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,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
99,
5
],
[
99,
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
],
[
60,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
69,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
8,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
6,
96
],
[
96,
97
],
[
0,
98
],
[
98,
99
],
[
98,
100
]
]
| [
"\nimport 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\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tlong count = 0L;\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 = 0; i < n - 1; i++) {\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\n\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 sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tlong count = 0L;\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 = 0; i < n - 1; i++) {\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tlong count = 0L;\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 = 0; i < n - 1; i++) {\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\n\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tlong count = 0L;\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 = 0; i < n - 1; i++) {\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\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",
"long count = 0L;",
"count",
"0L",
"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 = 0; i < n - 1; i++) {\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\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\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}",
"{\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}",
"if (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\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\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}",
"count += (a[i] - a[i + 1])",
"count",
"(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",
"i",
"1",
"a[i]",
"a",
"i",
"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\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tlong count = 0L;\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 = 0; i < n - 1; i++) {\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\n\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tlong count = 0L;\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 = 0; i < n - 1; i++) {\n\t\t\tif (a[i] > a[i + 1]) {\n\t\t\t\tcount += (a[i] - a[i + 1]);\n\t\t\t\ta[i + 1] = a[i];\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\n\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];
long count = 0L;
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
for (int i = 0; i < n - 1; i++) {
if (a[i] > a[i + 1]) {
count += (a[i] - a[i + 1]);
a[i + 1] = 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,
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,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
9,
30,
0,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
92,
5
],
[
92,
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
],
[
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
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
68,
74
],
[
62,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
8,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
6,
89
],
[
89,
90
],
[
0,
91
],
[
91,
92
],
[
91,
93
]
]
| [
"\nimport java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\t\tint n=sc.nextInt();\n\t\tlong a[]=new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\ta[i]=sc.nextLong();\n\t\t}\n\t\tlong ans=0;\n\t\tlong max=a[0];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\n\t}\n\t \n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\t\tint n=sc.nextInt();\n\t\tlong a[]=new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\ta[i]=sc.nextLong();\n\t\t}\n\t\tlong ans=0;\n\t\tlong max=a[0];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\n\t}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\t\tint n=sc.nextInt();\n\t\tlong a[]=new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\ta[i]=sc.nextLong();\n\t\t}\n\t\tlong ans=0;\n\t\tlong max=a[0];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t}",
"main",
"{\n\t\tScanner sc=new Scanner(System.in);\n\t\t\tint n=sc.nextInt();\n\t\tlong a[]=new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\ta[i]=sc.nextLong();\n\t\t}\n\t\tlong ans=0;\n\t\tlong max=a[0];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t}",
"Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long a[]=new long[n];",
"a",
"new long[n]",
"n",
"for(int i=0;i<n;i++) {\n\t\t\ta[i]=sc.nextLong();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ta[i]=sc.nextLong();\n\t\t}",
"{\n\t\t\ta[i]=sc.nextLong();\n\t\t}",
"a[i]=sc.nextLong()",
"a[i]",
"a",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"long ans=0;",
"ans",
"0",
"long max=a[0];",
"max",
"a[0]",
"a",
"0",
"for(int i=0;i<n;i++) {\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\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\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}",
"if(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}",
"a[i]>=max",
"a[i]",
"a",
"i",
"max",
"{\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}",
"max=a[i]",
"max",
"a[i]",
"a",
"i",
"continue;",
"{\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}",
"ans+=max-a[i]",
"ans",
"max-a[i]",
"max",
"a[i]",
"a",
"i",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\t\tint n=sc.nextInt();\n\t\tlong a[]=new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\ta[i]=sc.nextLong();\n\t\t}\n\t\tlong ans=0;\n\t\tlong max=a[0];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\n\t}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\t\tint n=sc.nextInt();\n\t\tlong a[]=new long[n];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\ta[i]=sc.nextLong();\n\t\t}\n\t\tlong ans=0;\n\t\tlong max=a[0];\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tif(a[i]>=max) {\n\t\t\t\tmax=a[i];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=max-a[i];\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\n\t}",
"Main"
]
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long a[]=new long[n];
for(int i=0;i<n;i++) {
a[i]=sc.nextLong();
}
long ans=0;
long max=a[0];
for(int i=0;i<n;i++) {
if(a[i]>=max) {
max=a[i];
continue;
}
else {
ans+=max-a[i];
}
}
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,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
20,
13,
0,
18,
13,
17,
18,
13,
17,
11,
1,
41,
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,
13,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
13,
0,
13,
2,
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
],
[
135,
5
],
[
135,
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,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
49,
50
],
[
49,
51
],
[
8,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
52,
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
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
80,
82
],
[
65,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
8,
93
],
[
93,
94
],
[
93,
95
],
[
8,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
96,
101
],
[
101,
102
],
[
101,
103
],
[
96,
104
],
[
104,
105
],
[
105,
106
],
[
96,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
114,
116
],
[
109,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
123,
125
],
[
8,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
6,
132
],
[
132,
133
],
[
0,
134
],
[
134,
135
],
[
134,
136
]
]
| [
"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 int mx[] = new int[n];\n mx[0]=a[0];\n for(int i=1;i<n;i++){\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }\n long sum=0;\n for(int i=0;i<n;i++){\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }\n System.out.println(sum);\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 int mx[] = new int[n];\n mx[0]=a[0];\n for(int i=1;i<n;i++){\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }\n long sum=0;\n for(int i=0;i<n;i++){\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }\n System.out.println(sum);\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 int mx[] = new int[n];\n mx[0]=a[0];\n for(int i=1;i<n;i++){\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }\n long sum=0;\n for(int i=0;i<n;i++){\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }\n System.out.println(sum);\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 int mx[] = new int[n];\n mx[0]=a[0];\n for(int i=1;i<n;i++){\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }\n long sum=0;\n for(int i=0;i<n;i++){\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }\n System.out.println(sum);\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",
"int mx[] = new int[n];",
"mx",
"new int[n]",
"n",
"mx[0]=a[0]",
"mx[0]",
"mx",
"0",
"a[0]",
"a",
"0",
"for(int i=1;i<n;i++){\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }",
"{\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }",
"if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }",
"a[i]>mx[i-1]",
"a[i]",
"a",
"i",
"mx[i-1]",
"mx",
"i-1",
"i",
"1",
"{\n mx[i]=a[i];\n }",
"mx[i]=a[i]",
"mx[i]",
"mx",
"i",
"a[i]",
"a",
"i",
"{\n mx[i]=mx[i-1];\n }",
"mx[i]=mx[i-1]",
"mx[i]",
"mx",
"i",
"mx[i-1]",
"mx",
"i-1",
"i",
"1",
"long sum=0;",
"sum",
"0",
"for(int i=0;i<n;i++){\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }",
"{\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }",
"if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);",
"a[i]<mx[i]",
"a[i]",
"a",
"i",
"mx[i]",
"mx",
"i",
"sum+=(long)(mx[i]-a[i])",
"sum",
"(long)(mx[i]-a[i])",
"mx[i]",
"mx",
"i",
"a[i]",
"a",
"i",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"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 int mx[] = new int[n];\n mx[0]=a[0];\n for(int i=1;i<n;i++){\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }\n long sum=0;\n for(int i=0;i<n;i++){\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }\n System.out.println(sum);\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 int mx[] = new int[n];\n mx[0]=a[0];\n for(int i=1;i<n;i++){\n if(a[i]>mx[i-1]){\n mx[i]=a[i];\n }\n else{\n mx[i]=mx[i-1];\n }\n }\n long sum=0;\n for(int i=0;i<n;i++){\n if(a[i]<mx[i])\n sum+=(long)(mx[i]-a[i]);\n }\n System.out.println(sum);\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();
}
int mx[] = new int[n];
mx[0]=a[0];
for(int i=1;i<n;i++){
if(a[i]>mx[i-1]){
mx[i]=a[i];
}
else{
mx[i]=mx[i-1];
}
}
long sum=0;
for(int i=0;i<n;i++){
if(a[i]<mx[i])
sum+=(long)(mx[i]-a[i]);
}
System.out.println(sum);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
66,
5
],
[
66,
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
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
37,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
50,
52
],
[
43,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
8,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
6,
63
],
[
63,
64
],
[
0,
65
],
[
65,
66
],
[
65,
67
]
]
| [
"import java.util.Scanner;\npublic class Main {\n public static void main(String args[]) {\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n long ans=0;\n int prev=s.nextInt();\n for(int i=1;i<n;i++){\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }\n\n System.out.print(ans);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String args[]) {\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n long ans=0;\n int prev=s.nextInt();\n for(int i=1;i<n;i++){\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }\n\n System.out.print(ans);\n }\n}",
"Main",
"public static void main(String args[]) {\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n long ans=0;\n int prev=s.nextInt();\n for(int i=1;i<n;i++){\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }\n\n System.out.print(ans);\n }",
"main",
"{\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n long ans=0;\n int prev=s.nextInt();\n for(int i=1;i<n;i++){\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }\n\n System.out.print(ans);\n }",
"Scanner s=new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int n=s.nextInt();",
"n",
"s.nextInt()",
"s.nextInt",
"s",
"long ans=0;",
"ans",
"0",
"int prev=s.nextInt();",
"prev",
"s.nextInt()",
"s.nextInt",
"s",
"for(int i=1;i<n;i++){\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }",
"{\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }",
"int ele=s.nextInt();",
"ele",
"s.nextInt()",
"s.nextInt",
"s",
"if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }",
"ele<prev",
"ele",
"prev",
"{\n ans+=prev-ele;\n }",
"ans+=prev-ele",
"ans",
"prev-ele",
"prev",
"ele",
"{\n prev=ele;\n }",
"prev=ele",
"prev",
"ele",
"System.out.print(ans)",
"System.out.print",
"System.out",
"System",
"System.out",
"ans",
"String args[]",
"args",
"public class Main {\n public static void main(String args[]) {\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n long ans=0;\n int prev=s.nextInt();\n for(int i=1;i<n;i++){\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }\n\n System.out.print(ans);\n }\n}",
"public class Main {\n public static void main(String args[]) {\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n long ans=0;\n int prev=s.nextInt();\n for(int i=1;i<n;i++){\n int ele=s.nextInt();\n if(ele<prev){\n ans+=prev-ele;\n }\n else{\n prev=ele;\n }\n }\n\n System.out.print(ans);\n }\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
long ans=0;
int prev=s.nextInt();
for(int i=1;i<n;i++){
int ele=s.nextInt();
if(ele<prev){
ans+=prev-ele;
}
else{
prev=ele;
}
}
System.out.print(ans);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
0,
13,
4,
18,
13,
0,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
41,
13,
17,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
0,
13,
13,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
82,
5
],
[
82,
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,
23
],
[
23,
24
],
[
23,
25
],
[
8,
26
],
[
26,
27
],
[
26,
28
],
[
28,
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
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
46,
52
],
[
52,
53
],
[
52,
54
],
[
46,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
59,
65
],
[
65,
66
],
[
65,
67
],
[
46,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
70,
72
],
[
8,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
73,
78
],
[
6,
79
],
[
79,
80
],
[
0,
81
],
[
81,
82
],
[
81,
83
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long sum = 0;\n int tmp = 0;\n int next = 0;\n\n // 一人目\n next = sc.nextInt();\n tmp = next;\n\n for (int i = 1; i < n; i++) {\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }\n System.out.println(sum);\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long sum = 0;\n int tmp = 0;\n int next = 0;\n\n // 一人目\n next = sc.nextInt();\n tmp = next;\n\n for (int i = 1; i < n; i++) {\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }\n System.out.println(sum);\n }\n}",
"Main",
"public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long sum = 0;\n int tmp = 0;\n int next = 0;\n\n // 一人目\n next = sc.nextInt();\n tmp = next;\n\n for (int i = 1; i < n; i++) {\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }\n System.out.println(sum);\n }",
"main",
"{\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long sum = 0;\n int tmp = 0;\n int next = 0;\n\n // 一人目\n next = sc.nextInt();\n tmp = next;\n\n for (int i = 1; i < n; i++) {\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }\n System.out.println(sum);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long sum = 0;",
"sum",
"0",
"int tmp = 0;",
"tmp",
"0",
"int next = 0;",
"next",
"0",
"next = sc.nextInt()",
"next",
"sc.nextInt()",
"sc.nextInt",
"sc",
"tmp = next",
"tmp",
"next",
"for (int i = 1; i < n; i++) {\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }",
"{\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }",
"next = sc.nextInt()",
"next",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int diff = 0;",
"diff",
"0",
"if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }",
"next < tmp",
"next",
"tmp",
"{\n diff = tmp - next;\n sum += diff;\n }",
"diff = tmp - next",
"diff",
"tmp - next",
"tmp",
"next",
"sum += diff",
"sum",
"diff",
"tmp = next + diff",
"tmp",
"next + diff",
"next",
"diff",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long sum = 0;\n int tmp = 0;\n int next = 0;\n\n // 一人目\n next = sc.nextInt();\n tmp = next;\n\n for (int i = 1; i < n; i++) {\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }\n System.out.println(sum);\n }\n}",
"public class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long sum = 0;\n int tmp = 0;\n int next = 0;\n\n // 一人目\n next = sc.nextInt();\n tmp = next;\n\n for (int i = 1; i < n; i++) {\n next = sc.nextInt();\n int diff = 0;\n if (next < tmp) {\n diff = tmp - next;\n sum += diff;\n }\n tmp = next + diff;\n }\n System.out.println(sum);\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();
long sum = 0;
int tmp = 0;
int next = 0;
// 一人目
next = sc.nextInt();
tmp = next;
for (int i = 1; i < n; i++) {
next = sc.nextInt();
int diff = 0;
if (next < tmp) {
diff = tmp - next;
sum += diff;
}
tmp = next + diff;
}
System.out.println(sum);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
20,
41,
13,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
0,
13,
20,
29,
4,
18,
13,
4,
18,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
4,
18,
13,
4,
13,
4,
13,
4,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
41,
13,
17,
41,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
29,
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
],
[
142,
11
],
[
142,
12
],
[
12,
13
],
[
12,
14
],
[
142,
15
],
[
15,
16
],
[
15,
17
],
[
142,
18
],
[
18,
19
],
[
142,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
24,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
23,
32
],
[
32,
33
],
[
32,
34
],
[
22,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
40,
41
],
[
142,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
44,
67
],
[
67,
68
],
[
42,
69
],
[
69,
70
],
[
142,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
73,
83
],
[
83,
84
],
[
84,
85
],
[
71,
86
],
[
86,
87
],
[
142,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
96,
98
],
[
90,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
90,
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
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
117,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
128,
130
],
[
117,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
90,
137
],
[
137,
138
],
[
88,
139
],
[
139,
140
],
[
0,
141
],
[
141,
142
],
[
141,
143
]
]
| [
"import java.io.*;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\n\npublic class Main {\n private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n private static StringTokenizer st;\n\n private static int readInt() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return Integer.parseInt(st.nextToken());\n }\n\n private static int[] readIntArray(final int n) throws IOException {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = readInt();\n return a;\n }\n\n public static void main(String[] args) throws IOException {\n pw.println(solve(readIntArray(readInt())));\n pw.close();\n }\n\n private static long solve(int[] a) {\n int n = a.length;\n\n long res = 0;\n int max = a[0];\n for (int i = 1; i < n; i++) {\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }\n\n return res;\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"public class Main {\n private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n private static StringTokenizer st;\n\n private static int readInt() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return Integer.parseInt(st.nextToken());\n }\n\n private static int[] readIntArray(final int n) throws IOException {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = readInt();\n return a;\n }\n\n public static void main(String[] args) throws IOException {\n pw.println(solve(readIntArray(readInt())));\n pw.close();\n }\n\n private static long solve(int[] a) {\n int n = a.length;\n\n long res = 0;\n int max = a[0];\n for (int i = 1; i < n; i++) {\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }\n\n return res;\n }\n}",
"Main",
"private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));",
"pw",
"new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))",
"private static StringTokenizer st;",
"st",
"private static int readInt() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return Integer.parseInt(st.nextToken());\n }",
"readInt",
"{\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return Integer.parseInt(st.nextToken());\n }",
"while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());",
"st == null || !st.hasMoreTokens()",
"st == null",
"st",
"null",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return Integer.parseInt(st.nextToken());",
"Integer.parseInt(st.nextToken())",
"Integer.parseInt",
"Integer",
"st.nextToken()",
"st.nextToken",
"st",
"private static int[] readIntArray(final int n) throws IOException {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = readInt();\n return a;\n }",
"readIntArray",
"{\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = readInt();\n return a;\n }",
"int[] a = new int[n];",
"a",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) a[i] = readInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"a[i] = readInt();",
"a[i] = readInt()",
"a[i]",
"a",
"i",
"readInt()",
"readInt",
"return a;",
"a",
"final int n",
"n",
"public static void main(String[] args) throws IOException {\n pw.println(solve(readIntArray(readInt())));\n pw.close();\n }",
"main",
"{\n pw.println(solve(readIntArray(readInt())));\n pw.close();\n }",
"pw.println(solve(readIntArray(readInt())))",
"pw.println",
"pw",
"solve(readIntArray(readInt()))",
"solve",
"readIntArray(readInt())",
"readIntArray",
"readInt()",
"readInt",
"pw.close()",
"pw.close",
"pw",
"String[] args",
"args",
"private static long solve(int[] a) {\n int n = a.length;\n\n long res = 0;\n int max = a[0];\n for (int i = 1; i < n; i++) {\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }\n\n return res;\n }",
"solve",
"{\n int n = a.length;\n\n long res = 0;\n int max = a[0];\n for (int i = 1; i < n; i++) {\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }\n\n return res;\n }",
"int n = a.length;",
"n",
"a.length",
"a",
"a.length",
"long res = 0;",
"res",
"0",
"int max = a[0];",
"max",
"a[0]",
"a",
"0",
"for (int i = 1; i < n; i++) {\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }",
"{\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }",
"if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }",
"a[i] < max",
"a[i]",
"a",
"i",
"max",
"{\n res += max - a[i];\n }",
"res += max - a[i]",
"res",
"max - a[i]",
"max",
"a[i]",
"a",
"i",
"{\n max = a[i];\n }",
"max = a[i]",
"max",
"a[i]",
"a",
"i",
"return res;",
"res",
"int[] a",
"a",
"public class Main {\n private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n private static StringTokenizer st;\n\n private static int readInt() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return Integer.parseInt(st.nextToken());\n }\n\n private static int[] readIntArray(final int n) throws IOException {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = readInt();\n return a;\n }\n\n public static void main(String[] args) throws IOException {\n pw.println(solve(readIntArray(readInt())));\n pw.close();\n }\n\n private static long solve(int[] a) {\n int n = a.length;\n\n long res = 0;\n int max = a[0];\n for (int i = 1; i < n; i++) {\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }\n\n return res;\n }\n}",
"public class Main {\n private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n private static StringTokenizer st;\n\n private static int readInt() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return Integer.parseInt(st.nextToken());\n }\n\n private static int[] readIntArray(final int n) throws IOException {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = readInt();\n return a;\n }\n\n public static void main(String[] args) throws IOException {\n pw.println(solve(readIntArray(readInt())));\n pw.close();\n }\n\n private static long solve(int[] a) {\n int n = a.length;\n\n long res = 0;\n int max = a[0];\n for (int i = 1; i < n; i++) {\n if (a[i] < max) {\n res += max - a[i];\n } else {\n max = a[i];\n }\n }\n\n return res;\n }\n}",
"Main"
]
| import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
private static StringTokenizer st;
private static int readInt() throws IOException {
while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
return Integer.parseInt(st.nextToken());
}
private static int[] readIntArray(final int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = readInt();
return a;
}
public static void main(String[] args) throws IOException {
pw.println(solve(readIntArray(readInt())));
pw.close();
}
private static long solve(int[] a) {
int n = a.length;
long res = 0;
int max = a[0];
for (int i = 1; i < n; i++) {
if (a[i] < max) {
res += max - a[i];
} else {
max = a[i];
}
}
return res;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
12,
13,
30,
41,
13,
20,
0,
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,
20,
13,
0,
18,
13,
17,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
13,
18,
13,
13,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
2,
18,
13,
13,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
212,
8
],
[
212,
9
],
[
9,
10
],
[
212,
11
],
[
11,
12
],
[
11,
13
],
[
13,
14
],
[
14,
15
],
[
14,
16
],
[
13,
17
],
[
17,
18
],
[
17,
19
],
[
13,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
13,
25
],
[
25,
26
],
[
25,
27
],
[
13,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
29,
34
],
[
34,
35
],
[
34,
36
],
[
29,
37
],
[
37,
38
],
[
38,
39
],
[
29,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
13,
48
],
[
48,
49
],
[
48,
50
],
[
13,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
56,
58
],
[
13,
59
],
[
59,
60
],
[
59,
61
],
[
13,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
62,
67
],
[
67,
68
],
[
67,
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
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
92,
94
],
[
77,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
95,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
111,
113
],
[
13,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
13,
118
],
[
118,
119
],
[
119,
120
],
[
11,
121
],
[
121,
122
],
[
212,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
123,
127
],
[
127,
128
],
[
123,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
123,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
138,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
148,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
137,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
123,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
167,
170
],
[
170,
171
],
[
123,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
179,
180
],
[
123,
181
],
[
181,
182
],
[
181,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
185,
188
],
[
188,
189
],
[
123,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
196,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
207,
208
],
[
192,
209
],
[
209,
210
],
[
0,
211
],
[
211,
212
],
[
211,
213
]
]
| [
"import java.util.*;\nimport java.io.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n MyScanner scn = new MyScanner();\n out = new PrintWriter(new BufferedOutputStream(System.out));\n\n // Start writing your solution here. -------------------------------------\n\n /*\n * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //\n * read input as long double d = sc.nextDouble(); // read input as double String\n * str = sc.next(); // read input as String String s = sc.nextLine(); // read\n * whole line as String\n * \n * int result = 3*n; out.println(result); // print via PrintWriter\n */\n\n // Stop writing your solution here. -------------------------------------\n\n int n = scn.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n arr[i] = scn.nextLong();\n\n long[] check = new long[n];\n check[0] = arr[0];\n\n long stool = 0;\n for (int i = 1; i < arr.length; i++) {\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }\n out.println(stool);\n out.close();\n }\n\n public static PrintWriter out;\n\n public static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n\n }\n\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n\n public static void main(String[] args) {\n MyScanner scn = new MyScanner();\n out = new PrintWriter(new BufferedOutputStream(System.out));\n\n // Start writing your solution here. -------------------------------------\n\n /*\n * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //\n * read input as long double d = sc.nextDouble(); // read input as double String\n * str = sc.next(); // read input as String String s = sc.nextLine(); // read\n * whole line as String\n * \n * int result = 3*n; out.println(result); // print via PrintWriter\n */\n\n // Stop writing your solution here. -------------------------------------\n\n int n = scn.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n arr[i] = scn.nextLong();\n\n long[] check = new long[n];\n check[0] = arr[0];\n\n long stool = 0;\n for (int i = 1; i < arr.length; i++) {\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }\n out.println(stool);\n out.close();\n }\n\n public static PrintWriter out;\n\n public static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n\n }\n\n}",
"Main",
"public static PrintWriter out;",
"out",
"public static void main(String[] args) {\n MyScanner scn = new MyScanner();\n out = new PrintWriter(new BufferedOutputStream(System.out));\n\n // Start writing your solution here. -------------------------------------\n\n /*\n * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //\n * read input as long double d = sc.nextDouble(); // read input as double String\n * str = sc.next(); // read input as String String s = sc.nextLine(); // read\n * whole line as String\n * \n * int result = 3*n; out.println(result); // print via PrintWriter\n */\n\n // Stop writing your solution here. -------------------------------------\n\n int n = scn.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n arr[i] = scn.nextLong();\n\n long[] check = new long[n];\n check[0] = arr[0];\n\n long stool = 0;\n for (int i = 1; i < arr.length; i++) {\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }\n out.println(stool);\n out.close();\n }",
"main",
"{\n MyScanner scn = new MyScanner();\n out = new PrintWriter(new BufferedOutputStream(System.out));\n\n // Start writing your solution here. -------------------------------------\n\n /*\n * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //\n * read input as long double d = sc.nextDouble(); // read input as double String\n * str = sc.next(); // read input as String String s = sc.nextLine(); // read\n * whole line as String\n * \n * int result = 3*n; out.println(result); // print via PrintWriter\n */\n\n // Stop writing your solution here. -------------------------------------\n\n int n = scn.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n arr[i] = scn.nextLong();\n\n long[] check = new long[n];\n check[0] = arr[0];\n\n long stool = 0;\n for (int i = 1; i < arr.length; i++) {\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }\n out.println(stool);\n out.close();\n }",
"MyScanner scn = new MyScanner();",
"scn",
"new MyScanner()",
"out = new PrintWriter(new BufferedOutputStream(System.out))",
"out",
"new PrintWriter(new BufferedOutputStream(System.out))",
"int n = scn.nextInt();",
"n",
"scn.nextInt()",
"scn.nextInt",
"scn",
"long[] arr = new long[n];",
"arr",
"new long[n]",
"n",
"for (int i = 0; i < n; i++)\n arr[i] = scn.nextLong();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i] = scn.nextLong();",
"arr[i] = scn.nextLong()",
"arr[i]",
"arr",
"i",
"scn.nextLong()",
"scn.nextLong",
"scn",
"long[] check = new long[n];",
"check",
"new long[n]",
"n",
"check[0] = arr[0]",
"check[0]",
"check",
"0",
"arr[0]",
"arr",
"0",
"long stool = 0;",
"stool",
"0",
"for (int i = 1; i < arr.length; i++) {\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < arr.length",
"i",
"arr.length",
"arr",
"arr.length",
"i++",
"i++",
"i",
"{\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }",
"{\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }",
"if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }",
"arr[i] >= check[i - 1]",
"arr[i]",
"arr",
"i",
"check[i - 1]",
"check",
"i - 1",
"i",
"1",
"{\n check[i] = arr[i];\n\n }",
"check[i] = arr[i]",
"check[i]",
"check",
"i",
"arr[i]",
"arr",
"i",
"{\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }",
"check[i] = check[i - 1]",
"check[i]",
"check",
"i",
"check[i - 1]",
"check",
"i - 1",
"i",
"1",
"stool += check[i] - arr[i]",
"stool",
"check[i] - arr[i]",
"check[i]",
"check",
"i",
"arr[i]",
"arr",
"i",
"out.println(stool)",
"out.println",
"out",
"stool",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"public static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n\n }",
"MyScanner",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }",
"MyScanner",
"{\n br = new BufferedReader(new InputStreamReader(System.in));\n }",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"next",
"{\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"try {\n st = new StringTokenizer(br.readLine());\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 st = new StringTokenizer(br.readLine());\n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }",
"nextLine",
"{\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }",
"String str = \"\";",
"str",
"\"\"",
"try {\n str = br.readLine();\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 str = br.readLine();\n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main {\n\n public static void main(String[] args) {\n MyScanner scn = new MyScanner();\n out = new PrintWriter(new BufferedOutputStream(System.out));\n\n // Start writing your solution here. -------------------------------------\n\n /*\n * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //\n * read input as long double d = sc.nextDouble(); // read input as double String\n * str = sc.next(); // read input as String String s = sc.nextLine(); // read\n * whole line as String\n * \n * int result = 3*n; out.println(result); // print via PrintWriter\n */\n\n // Stop writing your solution here. -------------------------------------\n\n int n = scn.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n arr[i] = scn.nextLong();\n\n long[] check = new long[n];\n check[0] = arr[0];\n\n long stool = 0;\n for (int i = 1; i < arr.length; i++) {\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }\n out.println(stool);\n out.close();\n }\n\n public static PrintWriter out;\n\n public static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n\n }\n\n}",
"public class Main {\n\n public static void main(String[] args) {\n MyScanner scn = new MyScanner();\n out = new PrintWriter(new BufferedOutputStream(System.out));\n\n // Start writing your solution here. -------------------------------------\n\n /*\n * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //\n * read input as long double d = sc.nextDouble(); // read input as double String\n * str = sc.next(); // read input as String String s = sc.nextLine(); // read\n * whole line as String\n * \n * int result = 3*n; out.println(result); // print via PrintWriter\n */\n\n // Stop writing your solution here. -------------------------------------\n\n int n = scn.nextInt();\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n arr[i] = scn.nextLong();\n\n long[] check = new long[n];\n check[0] = arr[0];\n\n long stool = 0;\n for (int i = 1; i < arr.length; i++) {\n if (arr[i] >= check[i - 1]) {\n check[i] = arr[i];\n\n } else {\n check[i] = check[i - 1];\n stool += check[i] - arr[i];\n }\n }\n out.println(stool);\n out.close();\n }\n\n public static PrintWriter out;\n\n public static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n\n }\n\n}",
"Main"
]
| import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
MyScanner scn = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
// Start writing your solution here. -------------------------------------
/*
* int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //
* read input as long double d = sc.nextDouble(); // read input as double String
* str = sc.next(); // read input as String String s = sc.nextLine(); // read
* whole line as String
*
* int result = 3*n; out.println(result); // print via PrintWriter
*/
// Stop writing your solution here. -------------------------------------
int n = scn.nextInt();
long[] arr = new long[n];
for (int i = 0; i < n; i++)
arr[i] = scn.nextLong();
long[] check = new long[n];
check[0] = arr[0];
long stool = 0;
for (int i = 1; i < arr.length; i++) {
if (arr[i] >= check[i - 1]) {
check[i] = arr[i];
} else {
check[i] = check[i - 1];
stool += check[i] - arr[i];
}
}
out.println(stool);
out.close();
}
public static PrintWriter out;
public static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} |
[
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,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
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
],
[
97,
5
],
[
97,
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
],
[
58,
64
],
[
64,
65
],
[
64,
66
],
[
57,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
70,
76
],
[
76,
77
],
[
76,
78
],
[
67,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
8,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
88,
93
],
[
6,
94
],
[
94,
95
],
[
0,
96
],
[
96,
97
],
[
96,
98
]
]
| [
"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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;i++) {\n\t\t\tA[i]=sc.nextInt();\n\t\t}\n\t\tlong check = 0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(check);\n\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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;i++) {\n\t\t\tA[i]=sc.nextInt();\n\t\t}\n\t\tlong check = 0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(check);\n\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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;i++) {\n\t\t\tA[i]=sc.nextInt();\n\t\t}\n\t\tlong check = 0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(check);\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;i++) {\n\t\t\tA[i]=sc.nextInt();\n\t\t}\n\t\tlong check = 0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(check);\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] A = new long[N];",
"A",
"new long[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",
"long check = 0;",
"check",
"0",
"for(int i=1;i<N;i++) {\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\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\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}",
"if(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}",
"A[i-1]>A[i]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"{\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}",
"check += A[i-1]-A[i]",
"check",
"A[i-1]-A[i]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"A[i] = A[i-1]",
"A[i]",
"A",
"i",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"System.out.println(check)",
"System.out.println",
"System.out",
"System",
"System.out",
"check",
"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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;i++) {\n\t\t\tA[i]=sc.nextInt();\n\t\t}\n\t\tlong check = 0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(check);\n\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\tlong[] A = new long[N];\n\t\tfor(int i=0;i<N;i++) {\n\t\t\tA[i]=sc.nextInt();\n\t\t}\n\t\tlong check = 0;\n\t\tfor(int i=1;i<N;i++) {\n\t\t\tif(A[i-1]>A[i]) {\n\t\t\t\tcheck += A[i-1]-A[i];\n\t\t\t\tA[i] = A[i-1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(check);\n\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();
long[] A = new long[N];
for(int i=0;i<N;i++) {
A[i]=sc.nextInt();
}
long check = 0;
for(int i=1;i<N;i++) {
if(A[i-1]>A[i]) {
check += A[i-1]-A[i];
A[i] = A[i-1];
}
}
System.out.println(check);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
66,
5
],
[
66,
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
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
37,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
50,
52
],
[
43,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
8,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
6,
63
],
[
63,
64
],
[
0,
65
],
[
65,
66
],
[
65,
67
]
]
| [
"import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n long ans = 0;\n for (int i = 1; i < n; i++) {\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }\n System.out.println(ans);\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n long ans = 0;\n for (int i = 1; i < n; i++) {\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }\n System.out.println(ans);\n\t}\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n long ans = 0;\n for (int i = 1; i < n; i++) {\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }\n System.out.println(ans);\n\t}",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n long ans = 0;\n for (int i = 1; i < n; i++) {\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }\n System.out.println(ans);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int max = sc.nextInt();",
"max",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long ans = 0;",
"ans",
"0",
"for (int i = 1; i < n; i++) {\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }",
"{\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }",
"int a = sc.nextInt();",
"a",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }",
"a <= max",
"a",
"max",
"{\n ans += max - a;\n }",
"ans += max - a",
"ans",
"max - a",
"max",
"a",
"{\n max = a;\n }",
"max = a",
"max",
"a",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n long ans = 0;\n for (int i = 1; i < n; i++) {\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }\n System.out.println(ans);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n long ans = 0;\n for (int i = 1; i < n; i++) {\n int a = sc.nextInt();\n if (a <= max) {\n ans += max - a;\n } else {\n max = a;\n }\n }\n System.out.println(ans);\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 max = sc.nextInt();
long ans = 0;
for (int i = 1; i < n; i++) {
int a = sc.nextInt();
if (a <= max) {
ans += max - a;
} else {
max = a;
}
}
System.out.println(ans);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
40,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
40,
17,
30,
0,
13,
13,
30,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
79,
5
],
[
79,
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
],
[
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
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
36,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
42,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
42,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
51,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
8,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
70,
75
],
[
6,
76
],
[
76,
77
],
[
0,
78
],
[
78,
79
],
[
78,
80
]
]
| [
"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\n int minheight = -1;\n long out = 0;\n \n \n for(int i =0; i<n; i++) {\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }\n \n System.out.println(out);\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\n int minheight = -1;\n long out = 0;\n \n \n for(int i =0; i<n; i++) {\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }\n \n System.out.println(out);\n \n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n\n int minheight = -1;\n long out = 0;\n \n \n for(int i =0; i<n; i++) {\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }\n \n System.out.println(out);\n \n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n\n int minheight = -1;\n long out = 0;\n \n \n for(int i =0; i<n; i++) {\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }\n \n System.out.println(out);\n \n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int minheight = -1;",
"minheight",
"-1",
"1",
"long out = 0;",
"out",
"0",
"for(int i =0; i<n; i++) {\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }",
"int i =0;",
"int i =0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }",
"{\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }",
"int height = sc.nextInt();",
"height",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }",
"minheight == -1",
"minheight",
"-1",
"1",
"{\n minheight = height;\n }",
"minheight = height",
"minheight",
"height",
"{\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }",
"if(height < minheight) {\n out += (minheight-height);\n }",
"height < minheight",
"height",
"minheight",
"{\n out += (minheight-height);\n }",
"out += (minheight-height)",
"out",
"(minheight-height)",
"minheight",
"height",
"if(height > minheight) {\n minheight = height;\n }",
"height > minheight",
"height",
"minheight",
"{\n minheight = height;\n }",
"minheight = height",
"minheight",
"height",
"System.out.println(out)",
"System.out.println",
"System.out",
"System",
"System.out",
"out",
"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\n int minheight = -1;\n long out = 0;\n \n \n for(int i =0; i<n; i++) {\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }\n \n System.out.println(out);\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\n int minheight = -1;\n long out = 0;\n \n \n for(int i =0; i<n; i++) {\n int height = sc.nextInt();\n if(minheight == -1) {\n minheight = height;\n }\n else {\n if(height < minheight) {\n out += (minheight-height);\n }\n if(height > minheight) {\n minheight = height;\n }\n }\n }\n \n System.out.println(out);\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 minheight = -1;
long out = 0;
for(int i =0; i<n; i++) {
int height = sc.nextInt();
if(minheight == -1) {
minheight = height;
}
else {
if(height < minheight) {
out += (minheight-height);
}
if(height > minheight) {
minheight = height;
}
}
}
System.out.println(out);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
41,
13,
17,
41,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
0,
13,
4,
18,
13,
2,
13,
18,
13,
13,
0,
13,
4,
18,
13,
13,
18,
13,
13,
4,
18,
13,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
0,
13,
20,
4,
13,
4,
18,
13,
12,
13,
30,
0,
13,
20,
0,
13,
20,
4,
13,
4,
18,
13,
12,
13,
30,
4,
18,
20,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
23,
13,
12,
13,
30,
0,
13,
20,
23,
13,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
2,
13,
17,
29,
17,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
2,
13,
17,
29,
17,
0,
13,
20,
29,
17,
12,
13,
30,
29,
4,
18,
13,
4,
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,
29,
4,
18,
13,
4,
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,
29,
20,
12,
13,
30,
29,
4,
18,
13,
4,
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,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
362,
11
],
[
362,
12
],
[
12,
13
],
[
362,
14
],
[
14,
15
],
[
362,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
18,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
26,
29
],
[
18,
30
],
[
30,
31
],
[
30,
32
],
[
18,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
35,
37
],
[
18,
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
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
51,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
50,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
69,
73
],
[
73,
74
],
[
73,
75
],
[
18,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
362,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
83,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
90,
97
],
[
97,
98
],
[
90,
99
],
[
99,
100
],
[
100,
101
],
[
362,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
108,
109
],
[
108,
110
],
[
104,
111
],
[
111,
112
],
[
104,
113
],
[
113,
114
],
[
114,
115
],
[
362,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
362,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
124,
128
],
[
128,
129
],
[
124,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
133,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
130,
144
],
[
144,
145
],
[
124,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
146,
152
],
[
152,
153
],
[
124,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
157,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
166,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
170,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
166,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
187,
188
],
[
166,
189
],
[
189,
190
],
[
189,
191
],
[
156,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
124,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
200,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
199,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
208,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
215,
216
],
[
216,
217
],
[
217,
218
],
[
212,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
222,
223
],
[
223,
224
],
[
208,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
],
[
225,
229
],
[
229,
230
],
[
208,
231
],
[
231,
232
],
[
231,
233
],
[
198,
234
],
[
234,
235
],
[
124,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
239,
240
],
[
240,
241
],
[
241,
242
],
[
240,
243
],
[
243,
244
],
[
124,
245
],
[
245,
246
],
[
245,
247
],
[
247,
248
],
[
248,
249
],
[
248,
250
],
[
247,
252
],
[
252,
253
],
[
253,
254
],
[
254,
255
],
[
254,
256
],
[
252,
257
],
[
257,
258
],
[
257,
259
],
[
252,
260
],
[
260,
261
],
[
261,
262
],
[
252,
263
],
[
264,
264
],
[
264,
265
],
[
265,
266
],
[
266,
267
],
[
266,
268
],
[
265,
269
],
[
269,
270
],
[
270,
271
],
[
247,
272
],
[
272,
273
],
[
245,
274
],
[
274,
275
],
[
124,
276
],
[
276,
277
],
[
276,
278
],
[
278,
279
],
[
279,
280
],
[
280,
281
],
[
281,
282
],
[
280,
283
],
[
283,
284
],
[
124,
285
],
[
285,
286
],
[
285,
287
],
[
287,
288
],
[
288,
289
],
[
288,
290
],
[
287,
292
],
[
292,
293
],
[
293,
294
],
[
294,
295
],
[
294,
296
],
[
292,
297
],
[
297,
298
],
[
297,
299
],
[
292,
300
],
[
300,
301
],
[
301,
302
],
[
292,
303
],
[
304,
304
],
[
304,
305
],
[
305,
306
],
[
306,
307
],
[
306,
308
],
[
305,
309
],
[
309,
310
],
[
310,
311
],
[
287,
312
],
[
312,
313
],
[
285,
314
],
[
314,
315
],
[
124,
316
],
[
316,
317
],
[
316,
318
],
[
318,
319
],
[
319,
320
],
[
124,
321
],
[
321,
322
],
[
321,
323
],
[
323,
324
],
[
324,
325
],
[
325,
326
],
[
326,
327
],
[
325,
328
],
[
328,
329
],
[
124,
330
],
[
330,
331
],
[
330,
332
],
[
332,
333
],
[
333,
334
],
[
333,
335
],
[
332,
337
],
[
337,
338
],
[
338,
339
],
[
339,
340
],
[
339,
341
],
[
337,
342
],
[
342,
343
],
[
342,
344
],
[
337,
345
],
[
345,
346
],
[
346,
347
],
[
337,
348
],
[
349,
349
],
[
349,
350
],
[
350,
351
],
[
351,
352
],
[
351,
353
],
[
350,
354
],
[
354,
355
],
[
355,
356
],
[
332,
357
],
[
357,
358
],
[
330,
359
],
[
359,
360
],
[
0,
361
],
[
361,
362
],
[
361,
363
]
]
| [
"import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class Main{\n FastScanner sc;\n PrintWriter p;\n\n void solve() {\n int N = sc.nextInt();\n int A[] = sc.nextIntArray(N);\n long ans = 0;\n long max = A[0];\n for(int i = 1; i < N; i++) {\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }\n p.print(ans);\n }\n\n void run() {\n try {\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n void runIO() {\n\n sc = new FastScanner(System.in);\n p = new PrintWriter(System.out);\n\n solve();\n\n p.close();\n }\n\n class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(File f) {\n try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n public FastScanner(InputStream f) {\n br = new BufferedReader(new InputStreamReader(f));\n }\n\n String next() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }\n return st.nextToken();\n }\n\n boolean hasMoreTokens() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }\n return true;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int N) {\n int[] A = new int[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n }\n return A;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int N) {\n long[] A = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n return A;\n }\n\n BigInteger nextBigInteger() {\n return new BigInteger(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int N) {\n double[] A = new double[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }\n return A;\n }\n\n }\n\n public static void main(String[] args) {\n new Main().runIO();\n }\n}\n\n",
"import java.io.*;",
"io.*",
"java",
"import java.math.*;",
"math.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n FastScanner sc;\n PrintWriter p;\n\n void solve() {\n int N = sc.nextInt();\n int A[] = sc.nextIntArray(N);\n long ans = 0;\n long max = A[0];\n for(int i = 1; i < N; i++) {\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }\n p.print(ans);\n }\n\n void run() {\n try {\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n void runIO() {\n\n sc = new FastScanner(System.in);\n p = new PrintWriter(System.out);\n\n solve();\n\n p.close();\n }\n\n class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(File f) {\n try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n public FastScanner(InputStream f) {\n br = new BufferedReader(new InputStreamReader(f));\n }\n\n String next() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }\n return st.nextToken();\n }\n\n boolean hasMoreTokens() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }\n return true;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int N) {\n int[] A = new int[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n }\n return A;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int N) {\n long[] A = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n return A;\n }\n\n BigInteger nextBigInteger() {\n return new BigInteger(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int N) {\n double[] A = new double[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }\n return A;\n }\n\n }\n\n public static void main(String[] args) {\n new Main().runIO();\n }\n}",
"Main",
"FastScanner sc;",
"sc",
"PrintWriter p;",
"p",
"void solve() {\n int N = sc.nextInt();\n int A[] = sc.nextIntArray(N);\n long ans = 0;\n long max = A[0];\n for(int i = 1; i < N; i++) {\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }\n p.print(ans);\n }",
"solve",
"{\n int N = sc.nextInt();\n int A[] = sc.nextIntArray(N);\n long ans = 0;\n long max = A[0];\n for(int i = 1; i < N; i++) {\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }\n p.print(ans);\n }",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int A[] = sc.nextIntArray(N);",
"A",
"sc.nextIntArray(N)",
"sc.nextIntArray",
"sc",
"N",
"long ans = 0;",
"ans",
"0",
"long max = A[0];",
"max",
"A[0]",
"A",
"0",
"for(int i = 1; i < N; i++) {\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }",
"{\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }",
"if(A[i] < max) \n ans += Math.abs(max - A[i]);",
"A[i] < max",
"A[i]",
"A",
"i",
"max",
"ans += Math.abs(max - A[i])",
"ans",
"Math.abs(max - A[i])",
"Math.abs",
"Math",
"max - A[i]",
"max",
"A[i]",
"A",
"i",
"max = Math.max(max, A[i])",
"max",
"Math.max(max, A[i])",
"Math.max",
"Math",
"max",
"A[i]",
"A",
"i",
"p.print(ans)",
"p.print",
"p",
"ans",
"void run() {\n try {\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }",
"run",
"{\n try {\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }",
"try {\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }",
"catch (FileNotFoundException e) {\n e.printStackTrace();\n }",
"FileNotFoundException e",
"{\n e.printStackTrace();\n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n }",
"sc = new FastScanner(new File(\"CStep.in\"))",
"sc",
"new FastScanner(new File(\"CStep.in\"))",
"p = new PrintWriter(new File(\"CStep.out\"))",
"p",
"new PrintWriter(new File(\"CStep.out\"))",
"solve()",
"solve",
"p.close()",
"p.close",
"p",
"void runIO() {\n\n sc = new FastScanner(System.in);\n p = new PrintWriter(System.out);\n\n solve();\n\n p.close();\n }",
"runIO",
"{\n\n sc = new FastScanner(System.in);\n p = new PrintWriter(System.out);\n\n solve();\n\n p.close();\n }",
"sc = new FastScanner(System.in)",
"sc",
"new FastScanner(System.in)",
"p = new PrintWriter(System.out)",
"p",
"new PrintWriter(System.out)",
"solve()",
"solve",
"p.close()",
"p.close",
"p",
"public static void main(String[] args) {\n new Main().runIO();\n }",
"main",
"{\n new Main().runIO();\n }",
"new Main().runIO()",
"new Main().runIO",
"new Main()",
"String[] args",
"args",
"class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(File f) {\n try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n public FastScanner(InputStream f) {\n br = new BufferedReader(new InputStreamReader(f));\n }\n\n String next() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }\n return st.nextToken();\n }\n\n boolean hasMoreTokens() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }\n return true;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int N) {\n int[] A = new int[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n }\n return A;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int N) {\n long[] A = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n return A;\n }\n\n BigInteger nextBigInteger() {\n return new BigInteger(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int N) {\n double[] A = new double[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }\n return A;\n }\n\n }",
"FastScanner",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastScanner(File f) {\n try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }",
"FastScanner",
"{\n try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }",
"try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }",
"catch (FileNotFoundException e) {\n e.printStackTrace();\n }",
"FileNotFoundException e",
"{\n e.printStackTrace();\n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n br = new BufferedReader(new FileReader(f));\n }",
"br = new BufferedReader(new FileReader(f))",
"br",
"new BufferedReader(new FileReader(f))",
"File f",
"f",
"public FastScanner(InputStream f) {\n br = new BufferedReader(new InputStreamReader(f));\n }",
"FastScanner",
"{\n br = new BufferedReader(new InputStreamReader(f));\n }",
"br = new BufferedReader(new InputStreamReader(f))",
"br",
"new BufferedReader(new InputStreamReader(f))",
"InputStream f",
"f",
"String next() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }\n return st.nextToken();\n }",
"next",
"{\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }\n return st.nextToken();\n }",
"while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }",
"st == null || !st.hasMoreTokens()",
"st == null",
"st",
"null",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"{\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }",
"String s = null;",
"s",
"null",
"try {\n s = br.readLine();\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 s = br.readLine();\n }",
"s = br.readLine()",
"s",
"br.readLine()",
"br.readLine",
"br",
"if (s == null)\n return null;",
"s == null",
"s",
"null",
"return null;",
"null",
"st = new StringTokenizer(s)",
"st",
"new StringTokenizer(s)",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"boolean hasMoreTokens() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }\n return true;\n }",
"hasMoreTokens",
"{\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }\n return true;\n }",
"while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }",
"st == null || !st.hasMoreTokens()",
"st == null",
"st",
"null",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"{\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }",
"String s = null;",
"s",
"null",
"try {\n s = br.readLine();\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 s = br.readLine();\n }",
"s = br.readLine()",
"s",
"br.readLine()",
"br.readLine",
"br",
"if (s == null)\n return false;",
"s == null",
"s",
"null",
"return false;",
"false",
"st = new StringTokenizer(s)",
"st",
"new StringTokenizer(s)",
"return true;",
"true",
"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",
"int[] nextIntArray(int N) {\n int[] A = new int[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n }\n return A;\n }",
"nextIntArray",
"{\n int[] A = new int[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n }\n return A;\n }",
"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",
"return A;",
"A",
"int N",
"N",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"long[] nextLongArray(int N) {\n long[] A = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n return A;\n }",
"nextLongArray",
"{\n long[] A = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n return A;\n }",
"long[] A = new long[N];",
"A",
"new long[N]",
"N",
"for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n A[i] = sc.nextLong();\n }",
"{\n A[i] = sc.nextLong();\n }",
"A[i] = sc.nextLong()",
"A[i]",
"A",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"return A;",
"A",
"int N",
"N",
"BigInteger nextBigInteger() {\n return new BigInteger(next());\n }",
"nextBigInteger",
"{\n return new BigInteger(next());\n }",
"return new BigInteger(next());",
"new BigInteger(next())",
"double nextDouble() {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"double[] nextDoubleArray(int N) {\n double[] A = new double[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }\n return A;\n }",
"nextDoubleArray",
"{\n double[] A = new double[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }\n return A;\n }",
"double[] A = new double[N];",
"A",
"new double[N]",
"N",
"for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n A[i] = sc.nextDouble();\n }",
"{\n A[i] = sc.nextDouble();\n }",
"A[i] = sc.nextDouble()",
"A[i]",
"A",
"i",
"sc.nextDouble()",
"sc.nextDouble",
"sc",
"return A;",
"A",
"int N",
"N",
"public class Main{\n FastScanner sc;\n PrintWriter p;\n\n void solve() {\n int N = sc.nextInt();\n int A[] = sc.nextIntArray(N);\n long ans = 0;\n long max = A[0];\n for(int i = 1; i < N; i++) {\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }\n p.print(ans);\n }\n\n void run() {\n try {\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n void runIO() {\n\n sc = new FastScanner(System.in);\n p = new PrintWriter(System.out);\n\n solve();\n\n p.close();\n }\n\n class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(File f) {\n try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n public FastScanner(InputStream f) {\n br = new BufferedReader(new InputStreamReader(f));\n }\n\n String next() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }\n return st.nextToken();\n }\n\n boolean hasMoreTokens() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }\n return true;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int N) {\n int[] A = new int[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n }\n return A;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int N) {\n long[] A = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n return A;\n }\n\n BigInteger nextBigInteger() {\n return new BigInteger(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int N) {\n double[] A = new double[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }\n return A;\n }\n\n }\n\n public static void main(String[] args) {\n new Main().runIO();\n }\n}",
"public class Main{\n FastScanner sc;\n PrintWriter p;\n\n void solve() {\n int N = sc.nextInt();\n int A[] = sc.nextIntArray(N);\n long ans = 0;\n long max = A[0];\n for(int i = 1; i < N; i++) {\n if(A[i] < max) \n ans += Math.abs(max - A[i]);\n max = Math.max(max, A[i]);\n }\n p.print(ans);\n }\n\n void run() {\n try {\n sc = new FastScanner(new File(\"CStep.in\"));\n p = new PrintWriter(new File(\"CStep.out\"));\n\n solve();\n\n p.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n void runIO() {\n\n sc = new FastScanner(System.in);\n p = new PrintWriter(System.out);\n\n solve();\n\n p.close();\n }\n\n class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(File f) {\n try {\n br = new BufferedReader(new FileReader(f));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n\n public FastScanner(InputStream f) {\n br = new BufferedReader(new InputStreamReader(f));\n }\n\n String next() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return null;\n st = new StringTokenizer(s);\n }\n return st.nextToken();\n }\n\n boolean hasMoreTokens() {\n while (st == null || !st.hasMoreTokens()) {\n String s = null;\n try {\n s = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (s == null)\n return false;\n st = new StringTokenizer(s);\n }\n return true;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int N) {\n int[] A = new int[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n }\n return A;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int N) {\n long[] A = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n return A;\n }\n\n BigInteger nextBigInteger() {\n return new BigInteger(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int N) {\n double[] A = new double[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextDouble();\n }\n return A;\n }\n\n }\n\n public static void main(String[] args) {\n new Main().runIO();\n }\n}",
"Main"
]
| import java.io.*;
import java.math.*;
import java.util.*;
public class Main{
FastScanner sc;
PrintWriter p;
void solve() {
int N = sc.nextInt();
int A[] = sc.nextIntArray(N);
long ans = 0;
long max = A[0];
for(int i = 1; i < N; i++) {
if(A[i] < max)
ans += Math.abs(max - A[i]);
max = Math.max(max, A[i]);
}
p.print(ans);
}
void run() {
try {
sc = new FastScanner(new File("CStep.in"));
p = new PrintWriter(new File("CStep.out"));
solve();
p.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
void runIO() {
sc = new FastScanner(System.in);
p = new PrintWriter(System.out);
solve();
p.close();
}
class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(File f) {
try {
br = new BufferedReader(new FileReader(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public FastScanner(InputStream f) {
br = new BufferedReader(new InputStreamReader(f));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (s == null)
return null;
st = new StringTokenizer(s);
}
return st.nextToken();
}
boolean hasMoreTokens() {
while (st == null || !st.hasMoreTokens()) {
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (s == null)
return false;
st = new StringTokenizer(s);
}
return true;
}
int nextInt() {
return Integer.parseInt(next());
}
int[] nextIntArray(int N) {
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextInt();
}
return A;
}
long nextLong() {
return Long.parseLong(next());
}
long[] nextLongArray(int N) {
long[] A = new long[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextLong();
}
return A;
}
BigInteger nextBigInteger() {
return new BigInteger(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
double[] nextDoubleArray(int N) {
double[] A = new double[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextDouble();
}
return A;
}
}
public static void main(String[] args) {
new Main().runIO();
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
0,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
14,
2,
2,
13,
17,
2,
13,
13,
30,
0,
13,
2,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
81,
5
],
[
81,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
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
],
[
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
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
41,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
47,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
8,
69
],
[
69,
70
],
[
70,
71
],
[
8,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
72,
77
],
[
6,
78
],
[
78,
79
],
[
0,
80
],
[
80,
81
],
[
80,
82
]
]
| [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args){\n \n Scanner sc = null;\n sc = new Scanner(System.in);\n long ans = 0;\n long max = 0;\n long work = 0;\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }\n sc.close();\n System.out.println(ans); \n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args){\n \n Scanner sc = null;\n sc = new Scanner(System.in);\n long ans = 0;\n long max = 0;\n long work = 0;\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }\n sc.close();\n System.out.println(ans); \n }\n}",
"Main",
"public static void main(String[] args){\n \n Scanner sc = null;\n sc = new Scanner(System.in);\n long ans = 0;\n long max = 0;\n long work = 0;\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }\n sc.close();\n System.out.println(ans); \n }",
"main",
"{\n \n Scanner sc = null;\n sc = new Scanner(System.in);\n long ans = 0;\n long max = 0;\n long work = 0;\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }\n sc.close();\n System.out.println(ans); \n }",
"Scanner sc = null;",
"sc",
"null",
"sc = new Scanner(System.in)",
"sc",
"new Scanner(System.in)",
"long ans = 0;",
"ans",
"0",
"long max = 0;",
"max",
"0",
"long work = 0;",
"work",
"0",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < n; i++) {\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }",
"{\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }",
"work = sc.nextLong()",
"work",
"sc.nextLong()",
"sc.nextLong",
"sc",
"if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }",
"i != 0 && work < max",
"i != 0",
"i",
"0",
"work < max",
"work",
"max",
"{\n ans += (max - work);\n }",
"ans += (max - work)",
"ans",
"(max - work)",
"max",
"work",
"if(work > max){\n max = work;\n }",
"work > max",
"work",
"max",
"{\n max = work;\n }",
"max = work",
"max",
"work",
"sc.close()",
"sc.close",
"sc",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args){\n \n Scanner sc = null;\n sc = new Scanner(System.in);\n long ans = 0;\n long max = 0;\n long work = 0;\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }\n sc.close();\n System.out.println(ans); \n }\n}",
"public class Main {\n\tpublic static void main(String[] args){\n \n Scanner sc = null;\n sc = new Scanner(System.in);\n long ans = 0;\n long max = 0;\n long work = 0;\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n work = sc.nextLong();\n if (i != 0 && work < max) {\n ans += (max - work);\n }else if(work > max){\n max = work;\n }\n }\n sc.close();\n System.out.println(ans); \n }\n}",
"Main"
]
| import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = null;
sc = new Scanner(System.in);
long ans = 0;
long max = 0;
long work = 0;
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
work = sc.nextLong();
if (i != 0 && work < max) {
ans += (max - work);
}else if(work > max){
max = work;
}
}
sc.close();
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,
13,
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,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
41,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
13,
0,
18,
13,
2,
13,
17,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
100,
5
],
[
100,
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
],
[
51,
52
],
[
51,
53
],
[
44,
54
],
[
54,
55
],
[
55,
56
],
[
44,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
59,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
69,
81
],
[
81,
82
],
[
81,
83
],
[
69,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
84,
90
],
[
8,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
91,
96
],
[
6,
97
],
[
97,
98
],
[
0,
99
],
[
99,
100
],
[
99,
101
]
]
| [
"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\tlong [] height = new long[N];\n\t\tfor(int i = 0; i < N ; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i < N-1; i++) {\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\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\tlong [] height = new long[N];\n\t\tfor(int i = 0; i < N ; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i < N-1; i++) {\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\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\tlong [] height = new long[N];\n\t\tfor(int i = 0; i < N ; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i < N-1; i++) {\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tlong [] height = new long[N];\n\t\tfor(int i = 0; i < N ; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i < N-1; i++) {\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\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",
"long [] height = new long[N];",
"height",
"new long[N]",
"N",
"for(int i = 0; i < N ; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\theight[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\theight[i] = sc.nextLong();\n\t\t}",
"height[i] = sc.nextLong()",
"height[i]",
"height",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"long ans = 0;",
"ans",
"0",
"for(int i = 0; i < N-1; i++) {\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\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\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\n\t\t}",
"{\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\n\t\t}",
"if(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}",
"height[i] > height[i+1]",
"height[i]",
"height",
"i",
"height[i+1]",
"height",
"i+1",
"i",
"1",
"{\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}",
"long tmp = height[i]-height[i+1];",
"tmp",
"height[i]-height[i+1]",
"height[i]",
"height",
"i",
"height[i+1]",
"height",
"i+1",
"i",
"1",
"ans += tmp",
"ans",
"tmp",
"height[i+1] += tmp",
"height[i+1]",
"height",
"i+1",
"i",
"1",
"tmp",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"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\tlong [] height = new long[N];\n\t\tfor(int i = 0; i < N ; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i < N-1; i++) {\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\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\tlong [] height = new long[N];\n\t\tfor(int i = 0; i < N ; i++) {\n\t\t\theight[i] = sc.nextLong();\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i < N-1; i++) {\n\t\t\tif(height[i] > height[i+1]) {\n\t\t\t\tlong tmp = height[i]-height[i+1];\n\t\t\t\tans += tmp;\n\t\t\t\theight[i+1] += tmp;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\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();
long [] height = new long[N];
for(int i = 0; i < N ; i++) {
height[i] = sc.nextLong();
}
long ans = 0;
for(int i = 0; i < N-1; i++) {
if(height[i] > height[i+1]) {
long tmp = height[i]-height[i+1];
ans += tmp;
height[i+1] += tmp;
}
}
System.out.println(ans);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
17,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
39,
17,
40,
17,
17,
17,
41,
13,
39,
17,
17,
40,
17,
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,
41,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
29,
2,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
252,
8
],
[
252,
9
],
[
9,
10
],
[
9,
11
],
[
252,
12
],
[
12,
13
],
[
12,
14
],
[
252,
15
],
[
15,
16
],
[
15,
17
],
[
252,
18
],
[
18,
19
],
[
18,
20
],
[
252,
21
],
[
21,
22
],
[
252,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
25,
29
],
[
25,
30
],
[
252,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
33,
35
],
[
33,
36
],
[
36,
37
],
[
33,
38
],
[
252,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
41,
47
],
[
47,
48
],
[
47,
49
],
[
41,
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
],
[
41,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
41,
76
],
[
76,
77
],
[
76,
78
],
[
41,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
84,
85
],
[
84,
86
],
[
79,
87
],
[
87,
88
],
[
88,
89
],
[
79,
90
],
[
91,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
92,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
41,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
41,
116
],
[
116,
117
],
[
117,
118
],
[
39,
119
],
[
119,
120
],
[
252,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
121,
130
],
[
130,
131
],
[
121,
132
],
[
132,
133
],
[
121,
134
],
[
134,
135
],
[
252,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
136,
140
],
[
140,
141
],
[
136,
142
],
[
142,
143
],
[
136,
144
],
[
144,
145
],
[
136,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
148,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
146,
159
],
[
159,
160
],
[
146,
161
],
[
161,
162
],
[
252,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
163,
167
],
[
167,
168
],
[
163,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
163,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
178,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
188,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
177,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
163,
203
],
[
203,
204
],
[
203,
205
],
[
205,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
207,
210
],
[
210,
211
],
[
163,
212
],
[
212,
213
],
[
212,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
217,
218
],
[
216,
219
],
[
219,
220
],
[
163,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
225,
228
],
[
228,
229
],
[
163,
230
],
[
230,
231
],
[
230,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
232,
236
],
[
236,
237
],
[
237,
238
],
[
237,
239
],
[
239,
240
],
[
240,
241
],
[
241,
242
],
[
236,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
246,
247
],
[
247,
248
],
[
232,
249
],
[
249,
250
],
[
0,
251
],
[
251,
252
],
[
251,
253
]
]
| [
"import java.util.*;\n\n\nimport java.io.*;\n/**\n * MLASERP\n */\npublic class Main {\n\n \n static MyScanner in = new MyScanner();\n static int mod = 1000000007;\n static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer st;\n static int []dr = {1,-1,0,0};\n static int [] dc = {0,0,-1,1};\npublic static void main(String[] args) {\n int N = in.nextInt();\n int [] a = new int[N];\n for(int i=0;i<N;i++){\n a[i] = in.nextInt();\n }\n int max = a[0];\n long val =0;\n for(int i=1;i<N;i++){\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }\n out.println(val);\n out.flush();\n\n}\nstatic int rcToxy(int r, int c,int W){\n return r*W+c;\n}\nstatic class Node{\n int r, c,prev,change;\n Node(int r, int c){\n this.r =r ;\n this.c = c;\n }\n}\npublic static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n \n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n \n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n\n \n static MyScanner in = new MyScanner();\n static int mod = 1000000007;\n static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer st;\n static int []dr = {1,-1,0,0};\n static int [] dc = {0,0,-1,1};\npublic static void main(String[] args) {\n int N = in.nextInt();\n int [] a = new int[N];\n for(int i=0;i<N;i++){\n a[i] = in.nextInt();\n }\n int max = a[0];\n long val =0;\n for(int i=1;i<N;i++){\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }\n out.println(val);\n out.flush();\n\n}\nstatic int rcToxy(int r, int c,int W){\n return r*W+c;\n}\nstatic class Node{\n int r, c,prev,change;\n Node(int r, int c){\n this.r =r ;\n this.c = c;\n }\n}\npublic static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n \n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n \n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n}",
"Main",
"static MyScanner in = new MyScanner();",
"in",
"new MyScanner()",
"static int mod = 1000000007;",
"mod",
"1000000007",
"static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));",
"out",
"new PrintWriter(new OutputStreamWriter(System.out))",
"static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"static StringTokenizer st;",
"st",
"static int []dr = {1,-1,0,0};",
"dr",
"{1,-1,0,0}",
"1",
"-1",
"1",
"0",
"0",
"static int [] dc = {0,0,-1,1};",
"dc",
"{0,0,-1,1}",
"0",
"0",
"-1",
"1",
"1",
"public static void main(String[] args) {\n int N = in.nextInt();\n int [] a = new int[N];\n for(int i=0;i<N;i++){\n a[i] = in.nextInt();\n }\n int max = a[0];\n long val =0;\n for(int i=1;i<N;i++){\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }\n out.println(val);\n out.flush();\n\n}",
"main",
"{\n int N = in.nextInt();\n int [] a = new int[N];\n for(int i=0;i<N;i++){\n a[i] = in.nextInt();\n }\n int max = a[0];\n long val =0;\n for(int i=1;i<N;i++){\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }\n out.println(val);\n out.flush();\n\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<N;i++){\n a[i] = in.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n a[i] = in.nextInt();\n }",
"{\n a[i] = in.nextInt();\n }",
"a[i] = in.nextInt()",
"a[i]",
"a",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"int max = a[0];",
"max",
"a[0]",
"a",
"0",
"long val =0;",
"val",
"0",
"for(int i=1;i<N;i++){\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }",
"{\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }",
"if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }",
"a[i]<=max",
"a[i]",
"a",
"i",
"max",
"{\n val+=(max-a[i]);\n }",
"val+=(max-a[i])",
"val",
"(max-a[i])",
"max",
"a[i]",
"a",
"i",
"{\n max = a[i];\n }",
"max = a[i]",
"max",
"a[i]",
"a",
"i",
"out.println(val)",
"out.println",
"out",
"val",
"out.flush()",
"out.flush",
"out",
"String[] args",
"args",
"static int rcToxy(int r, int c,int W){\n return r*W+c;\n}",
"rcToxy",
"{\n return r*W+c;\n}",
"return r*W+c;",
"r*W+c",
"r*W",
"r",
"W",
"c",
"int r",
"r",
"int c",
"c",
"int W",
"W",
"static class Node{\n int r, c,prev,change;\n Node(int r, int c){\n this.r =r ;\n this.c = c;\n }\n}",
"Node",
"int r",
"r",
"c",
"c",
"prev",
"prev",
"change;",
"change",
"Node(int r, int c){\n this.r =r ;\n this.c = c;\n }",
"Node",
"{\n this.r =r ;\n this.c = c;\n }",
"this.r =r",
"this.r",
"this",
"this.r",
"r",
"this.c = c",
"this.c",
"this",
"this.c",
"c",
"int r",
"r",
"int c",
"c",
"public static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n \n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n \n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }",
"MyScanner",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }",
"MyScanner",
"{\n br = new BufferedReader(new InputStreamReader(System.in));\n }",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"next",
"{\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }",
"while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"try {\n st = new StringTokenizer(br.readLine());\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 st = new StringTokenizer(br.readLine());\n }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"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",
"long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"double nextDouble() {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }",
"nextLine",
"{\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }",
"String str = \"\";",
"str",
"\"\"",
"try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"IOException e",
"{\n\t e.printStackTrace();\n\t }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t str = br.readLine();\n\t }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public class Main {\n\n \n static MyScanner in = new MyScanner();\n static int mod = 1000000007;\n static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer st;\n static int []dr = {1,-1,0,0};\n static int [] dc = {0,0,-1,1};\npublic static void main(String[] args) {\n int N = in.nextInt();\n int [] a = new int[N];\n for(int i=0;i<N;i++){\n a[i] = in.nextInt();\n }\n int max = a[0];\n long val =0;\n for(int i=1;i<N;i++){\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }\n out.println(val);\n out.flush();\n\n}\nstatic int rcToxy(int r, int c,int W){\n return r*W+c;\n}\nstatic class Node{\n int r, c,prev,change;\n Node(int r, int c){\n this.r =r ;\n this.c = c;\n }\n}\npublic static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n \n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n \n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n}",
"public class Main {\n\n \n static MyScanner in = new MyScanner();\n static int mod = 1000000007;\n static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer st;\n static int []dr = {1,-1,0,0};\n static int [] dc = {0,0,-1,1};\npublic static void main(String[] args) {\n int N = in.nextInt();\n int [] a = new int[N];\n for(int i=0;i<N;i++){\n a[i] = in.nextInt();\n }\n int max = a[0];\n long val =0;\n for(int i=1;i<N;i++){\n if(a[i]<=max){\n val+=(max-a[i]);\n }else{\n max = a[i];\n }\n }\n out.println(val);\n out.flush();\n\n}\nstatic int rcToxy(int r, int c,int W){\n return r*W+c;\n}\nstatic class Node{\n int r, c,prev,change;\n Node(int r, int c){\n this.r =r ;\n this.c = c;\n }\n}\npublic static class MyScanner {\n BufferedReader br;\n StringTokenizer st;\n \n public MyScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n \n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String nextLine(){\n String str = \"\";\n\t try {\n\t str = br.readLine();\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t return str;\n }\n\n }\n}",
"Main"
]
| import java.util.*;
import java.io.*;
/**
* MLASERP
*/
public class Main {
static MyScanner in = new MyScanner();
static int mod = 1000000007;
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static int []dr = {1,-1,0,0};
static int [] dc = {0,0,-1,1};
public static void main(String[] args) {
int N = in.nextInt();
int [] a = new int[N];
for(int i=0;i<N;i++){
a[i] = in.nextInt();
}
int max = a[0];
long val =0;
for(int i=1;i<N;i++){
if(a[i]<=max){
val+=(max-a[i]);
}else{
max = a[i];
}
}
out.println(val);
out.flush();
}
static int rcToxy(int r, int c,int W){
return r*W+c;
}
static class Node{
int r, c,prev,change;
Node(int r, int c){
this.r =r ;
this.c = c;
}
}
public static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} |
[
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,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
98,
5
],
[
98,
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
],
[
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
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
68,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
61,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
8,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
86,
91
],
[
8,
92
],
[
92,
93
],
[
93,
94
],
[
6,
95
],
[
95,
96
],
[
0,
97
],
[
97,
98
],
[
97,
99
]
]
| [
"import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner reader = new Scanner(System.in);\n\t\tint n = reader.nextInt();\n\t\tlong[] arr = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = reader.nextLong();\n\t\t}\n\t\tlong total = 0;\n\t\tlong must = arr[0];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}\n\t\tSystem.out.println(total);\n\t\treader.close();\n\t}\n\t\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner reader = new Scanner(System.in);\n\t\tint n = reader.nextInt();\n\t\tlong[] arr = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = reader.nextLong();\n\t\t}\n\t\tlong total = 0;\n\t\tlong must = arr[0];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}\n\t\tSystem.out.println(total);\n\t\treader.close();\n\t}\n\t\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner reader = new Scanner(System.in);\n\t\tint n = reader.nextInt();\n\t\tlong[] arr = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = reader.nextLong();\n\t\t}\n\t\tlong total = 0;\n\t\tlong must = arr[0];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}\n\t\tSystem.out.println(total);\n\t\treader.close();\n\t}",
"main",
"{\n\t\tScanner reader = new Scanner(System.in);\n\t\tint n = reader.nextInt();\n\t\tlong[] arr = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = reader.nextLong();\n\t\t}\n\t\tlong total = 0;\n\t\tlong must = arr[0];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}\n\t\tSystem.out.println(total);\n\t\treader.close();\n\t}",
"Scanner reader = new Scanner(System.in);",
"reader",
"new Scanner(System.in)",
"int n = reader.nextInt();",
"n",
"reader.nextInt()",
"reader.nextInt",
"reader",
"long[] arr = new long[n];",
"arr",
"new long[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\tarr[i] = reader.nextLong();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tarr[i] = reader.nextLong();\n\t\t}",
"{\n\t\t\tarr[i] = reader.nextLong();\n\t\t}",
"arr[i] = reader.nextLong()",
"arr[i]",
"arr",
"i",
"reader.nextLong()",
"reader.nextLong",
"reader",
"long total = 0;",
"total",
"0",
"long must = arr[0];",
"must",
"arr[0]",
"arr",
"0",
"for (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}",
"{\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}",
"if (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}",
"arr[i] < must",
"arr[i]",
"arr",
"i",
"must",
"{\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}",
"total += must - arr[i]",
"total",
"must - arr[i]",
"must",
"arr[i]",
"arr",
"i",
"arr[i] = must",
"arr[i]",
"arr",
"i",
"must",
"must = arr[i]",
"must",
"arr[i]",
"arr",
"i",
"System.out.println(total)",
"System.out.println",
"System.out",
"System",
"System.out",
"total",
"reader.close()",
"reader.close",
"reader",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner reader = new Scanner(System.in);\n\t\tint n = reader.nextInt();\n\t\tlong[] arr = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = reader.nextLong();\n\t\t}\n\t\tlong total = 0;\n\t\tlong must = arr[0];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}\n\t\tSystem.out.println(total);\n\t\treader.close();\n\t}\n\t\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner reader = new Scanner(System.in);\n\t\tint n = reader.nextInt();\n\t\tlong[] arr = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = reader.nextLong();\n\t\t}\n\t\tlong total = 0;\n\t\tlong must = arr[0];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] < must) {\n\t\t\t\ttotal += must - arr[i];\n\t\t\t\tarr[i] = must;\n\t\t\t}\n\t\t\tmust = arr[i];\n\t\t}\n\t\tSystem.out.println(total);\n\t\treader.close();\n\t}\n\t\n}",
"Main"
]
| import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int n = reader.nextInt();
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = reader.nextLong();
}
long total = 0;
long must = arr[0];
for (int i = 1; i < n; i++) {
if (arr[i] < must) {
total += must - arr[i];
arr[i] = must;
}
must = arr[i];
}
System.out.println(total);
reader.close();
}
}
|
[
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,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
13,
18,
13,
13,
14,
2,
18,
13,
2,
13,
17,
13,
30,
0,
13,
2,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
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
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
54,
56
],
[
47,
57
],
[
57,
58
],
[
58,
59
],
[
47,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
68,
74
],
[
67,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
75,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
85,
91
],
[
8,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
6,
98
],
[
98,
99
]
]
| [
"import java.util.*;\n\nclass 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 long sum = 0;\n int Kijun = 0;\n for(int i2=0;i2<N-1;i2++){\n Kijun = A[i2];\n if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }\n }\n System.out.println(sum);\n }\n}",
"import java.util.*;",
"util.*",
"java",
"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 long sum = 0;\n int Kijun = 0;\n for(int i2=0;i2<N-1;i2++){\n Kijun = A[i2];\n if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }\n }\n System.out.println(sum);\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 long sum = 0;\n int Kijun = 0;\n for(int i2=0;i2<N-1;i2++){\n Kijun = A[i2];\n if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }\n }\n System.out.println(sum);\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 long sum = 0;\n int Kijun = 0;\n for(int i2=0;i2<N-1;i2++){\n Kijun = A[i2];\n if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }\n }\n System.out.println(sum);\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",
"long sum = 0;",
"sum",
"0",
"int Kijun = 0;",
"Kijun",
"0",
"for(int i2=0;i2<N-1;i2++){\n Kijun = A[i2];\n if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }\n }",
"int i2=0;",
"int i2=0;",
"i2",
"0",
"i2<N-1",
"i2",
"N-1",
"N",
"1",
"i2++",
"i2++",
"i2",
"{\n Kijun = A[i2];\n if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }\n }",
"{\n Kijun = A[i2];\n if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }\n }",
"Kijun = A[i2]",
"Kijun",
"A[i2]",
"A",
"i2",
"if(A[i2+1]<Kijun){\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }",
"A[i2+1]<Kijun",
"A[i2+1]",
"A",
"i2+1",
"i2",
"1",
"Kijun",
"{\n sum+=(long)(Kijun-A[i2+1]);\n A[i2+1]=Kijun;\n }",
"sum+=(long)(Kijun-A[i2+1])",
"sum",
"(long)(Kijun-A[i2+1])",
"Kijun",
"A[i2+1]",
"A",
"i2+1",
"i2",
"1",
"A[i2+1]=Kijun",
"A[i2+1]",
"A",
"i2+1",
"i2",
"1",
"Kijun",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args"
]
| import java.util.*;
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();
}
long sum = 0;
int Kijun = 0;
for(int i2=0;i2<N-1;i2++){
Kijun = A[i2];
if(A[i2+1]<Kijun){
sum+=(long)(Kijun-A[i2+1]);
A[i2+1]=Kijun;
}
}
System.out.println(sum);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
2,
17,
17,
12,
13,
30,
0,
13,
20,
41,
13,
4,
13,
41,
13,
17,
41,
13,
4,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
0,
13,
20,
29,
4,
18,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
123,
8
],
[
123,
9
],
[
9,
10
],
[
123,
11
],
[
11,
12
],
[
123,
13
],
[
13,
14
],
[
123,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
17,
19
],
[
123,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
22,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
22,
30
],
[
30,
31
],
[
30,
32
],
[
22,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
22,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
37,
42
],
[
42,
43
],
[
42,
44
],
[
37,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
49,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
49,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
54,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
22,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
20,
74
],
[
74,
75
],
[
123,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
83,
84
],
[
123,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
123,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
101,
102
],
[
123,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
106,
115
],
[
115,
116
],
[
115,
117
],
[
105,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
0,
122
],
[
122,
123
],
[
122,
124
]
]
| [
"import java.util.*; \nimport java.io.*;\n\n\n// A1 * Sum(A2+...+An)\n// +A2 * Sum(A3+...+An)\n// +A3 * Sum(A4+...+An)\npublic class Main {\n static StringTokenizer st;\n static BufferedReader br; \n static PrintWriter out;\n \n static long mod = (long)1e9 + 7;\n\n public static void main(String[] args) throws IOException {\n br = new BufferedReader(new InputStreamReader(System.in));\n int N = nextInt();\n \n long ans = 0;\n int prev = nextInt();\n // we get PreSum\n for (int i=2; i<=N; i++) {\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }\n\n System.out.println(ans);\n }\n\n \n public static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n public static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public static double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n static String next() throws IOException {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine().trim());\n return st.nextToken();\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n static StringTokenizer st;\n static BufferedReader br; \n static PrintWriter out;\n \n static long mod = (long)1e9 + 7;\n\n public static void main(String[] args) throws IOException {\n br = new BufferedReader(new InputStreamReader(System.in));\n int N = nextInt();\n \n long ans = 0;\n int prev = nextInt();\n // we get PreSum\n for (int i=2; i<=N; i++) {\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }\n\n System.out.println(ans);\n }\n\n \n public static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n public static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public static double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n static String next() throws IOException {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine().trim());\n return st.nextToken();\n }\n}",
"Main",
"static StringTokenizer st;",
"st",
"static BufferedReader br;",
"br",
"static PrintWriter out;",
"out",
"static long mod = (long)1e9 + 7;",
"mod",
"(long)1e9 + 7",
"(long)1e9",
"7",
"public static void main(String[] args) throws IOException {\n br = new BufferedReader(new InputStreamReader(System.in));\n int N = nextInt();\n \n long ans = 0;\n int prev = nextInt();\n // we get PreSum\n for (int i=2; i<=N; i++) {\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }\n\n System.out.println(ans);\n }",
"main",
"{\n br = new BufferedReader(new InputStreamReader(System.in));\n int N = nextInt();\n \n long ans = 0;\n int prev = nextInt();\n // we get PreSum\n for (int i=2; i<=N; i++) {\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }\n\n System.out.println(ans);\n }",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"int N = nextInt();",
"N",
"nextInt()",
"nextInt",
"long ans = 0;",
"ans",
"0",
"int prev = nextInt();",
"prev",
"nextInt()",
"nextInt",
"for (int i=2; i<=N; i++) {\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }",
"int i=2;",
"int i=2;",
"i",
"2",
"i<=N",
"i",
"N",
"i++",
"i++",
"i",
"{\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }",
"{\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }",
"int next = nextInt();",
"next",
"nextInt()",
"nextInt",
"if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }",
"next<prev",
"next",
"prev",
"{\n ans += prev-next;\n }",
"ans += prev-next",
"ans",
"prev-next",
"prev",
"next",
"{\n prev = next;\n }",
"prev = next",
"prev",
"next",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public static int nextInt() throws IOException {\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 static long nextLong() throws IOException {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"public static double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }",
"nextDouble",
"{\n return Double.parseDouble(next());\n }",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"static String next() throws IOException {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine().trim());\n return st.nextToken();\n }",
"next",
"{\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine().trim());\n return st.nextToken();\n }",
"while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine().trim());",
"st == null || !st.hasMoreTokens()",
"st == null",
"st",
"null",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"st = new StringTokenizer(br.readLine().trim())",
"st",
"new StringTokenizer(br.readLine().trim())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"public class Main {\n static StringTokenizer st;\n static BufferedReader br; \n static PrintWriter out;\n \n static long mod = (long)1e9 + 7;\n\n public static void main(String[] args) throws IOException {\n br = new BufferedReader(new InputStreamReader(System.in));\n int N = nextInt();\n \n long ans = 0;\n int prev = nextInt();\n // we get PreSum\n for (int i=2; i<=N; i++) {\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }\n\n System.out.println(ans);\n }\n\n \n public static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n public static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public static double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n static String next() throws IOException {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine().trim());\n return st.nextToken();\n }\n}",
"public class Main {\n static StringTokenizer st;\n static BufferedReader br; \n static PrintWriter out;\n \n static long mod = (long)1e9 + 7;\n\n public static void main(String[] args) throws IOException {\n br = new BufferedReader(new InputStreamReader(System.in));\n int N = nextInt();\n \n long ans = 0;\n int prev = nextInt();\n // we get PreSum\n for (int i=2; i<=N; i++) {\n int next = nextInt();\n if(next<prev){\n ans += prev-next;\n }\n else{\n prev = next;\n }\n }\n\n System.out.println(ans);\n }\n\n \n public static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n public static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public static double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n static String next() throws IOException {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine().trim());\n return st.nextToken();\n }\n}",
"Main"
]
| import java.util.*;
import java.io.*;
// A1 * Sum(A2+...+An)
// +A2 * Sum(A3+...+An)
// +A3 * Sum(A4+...+An)
public class Main {
static StringTokenizer st;
static BufferedReader br;
static PrintWriter out;
static long mod = (long)1e9 + 7;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
int N = nextInt();
long ans = 0;
int prev = nextInt();
// we get PreSum
for (int i=2; i<=N; i++) {
int next = nextInt();
if(next<prev){
ans += prev-next;
}
else{
prev = next;
}
}
System.out.println(ans);
}
public static int nextInt() throws IOException {
return Integer.parseInt(next());
}
public static long nextLong() throws IOException {
return Long.parseLong(next());
}
public static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
static String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine().trim());
return st.nextToken();
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
0,
13,
4,
18,
13,
4,
18,
13,
0,
13,
20,
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,
18,
13,
4,
18,
13,
4,
18,
18,
13,
13,
4,
13,
23,
13,
12,
13,
30,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
41,
13,
2,
18,
13,
13,
18,
13,
13,
41,
13,
2,
18,
13,
2,
13,
17,
18,
13,
2,
13,
17,
14,
2,
13,
13,
30,
41,
13,
2,
13,
13,
0,
18,
13,
2,
13,
17,
13,
0,
13,
13,
0,
13,
13,
29,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
138,
5
],
[
138,
6
],
[
6,
7
],
[
138,
8
],
[
8,
9
],
[
138,
10
],
[
10,
11
],
[
138,
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
],
[
14,
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
],
[
51,
54
],
[
54,
55
],
[
55,
56
],
[
14,
57
],
[
57,
58
],
[
58,
59
],
[
14,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
60,
65
],
[
65,
66
],
[
12,
67
],
[
67,
68
],
[
138,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
75,
85
],
[
85,
86
],
[
86,
87
],
[
75,
88
],
[
89,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
96,
98
],
[
89,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
101,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
89,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
119,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
122,
128
],
[
116,
129
],
[
129,
130
],
[
129,
131
],
[
116,
132
],
[
132,
133
],
[
132,
134
],
[
71,
135
],
[
135,
136
],
[
0,
137
],
[
137,
138
],
[
137,
139
]
]
| [
"import java.util.Scanner;\npublic class Main {\n\tpublic static int N;\n\tpublic static int[] A;\n\tpublic static int[] A_work;\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tN = Integer.parseInt(scan.next());\n\t\tA = new int[N];\n\t\tA_work = new int[N];\n\t\tfor (int n = 0;n < N ;n++ ) {\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}\n\t\tscan.close();\n\n\t\tSystem.out.println(search());\n\t}\n\n\tprivate static long search() {\n\t\tlong sum = 0;\n\t\tfor (int n = 0;n < N-1 ;n++ ) {\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static int N;\n\tpublic static int[] A;\n\tpublic static int[] A_work;\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tN = Integer.parseInt(scan.next());\n\t\tA = new int[N];\n\t\tA_work = new int[N];\n\t\tfor (int n = 0;n < N ;n++ ) {\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}\n\t\tscan.close();\n\n\t\tSystem.out.println(search());\n\t}\n\n\tprivate static long search() {\n\t\tlong sum = 0;\n\t\tfor (int n = 0;n < N-1 ;n++ ) {\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}\n}",
"Main",
"public static int N;",
"N",
"public static int[] A;",
"A",
"public static int[] A_work;",
"A_work",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tN = Integer.parseInt(scan.next());\n\t\tA = new int[N];\n\t\tA_work = new int[N];\n\t\tfor (int n = 0;n < N ;n++ ) {\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}\n\t\tscan.close();\n\n\t\tSystem.out.println(search());\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tN = Integer.parseInt(scan.next());\n\t\tA = new int[N];\n\t\tA_work = new int[N];\n\t\tfor (int n = 0;n < N ;n++ ) {\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}\n\t\tscan.close();\n\n\t\tSystem.out.println(search());\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"N = Integer.parseInt(scan.next())",
"N",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"A = new int[N]",
"A",
"new int[N]",
"N",
"A_work = new int[N]",
"A_work",
"new int[N]",
"N",
"for (int n = 0;n < N ;n++ ) {\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}",
"int n = 0;",
"int n = 0;",
"n",
"0",
"n < N",
"n",
"N",
"n++",
"n++",
"n",
"{\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}",
"{\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}",
"A[n] = Integer.parseInt(scan.next())",
"A[n]",
"A",
"n",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"scan.close()",
"scan.close",
"scan",
"System.out.println(search())",
"System.out.println",
"System.out",
"System",
"System.out",
"search()",
"search",
"String[] args",
"args",
"private static long search() {\n\t\tlong sum = 0;\n\t\tfor (int n = 0;n < N-1 ;n++ ) {\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}",
"search",
"{\n\t\tlong sum = 0;\n\t\tfor (int n = 0;n < N-1 ;n++ ) {\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}",
"long sum = 0;",
"sum",
"0",
"for (int n = 0;n < N-1 ;n++ ) {\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}",
"int n = 0;",
"int n = 0;",
"n",
"0",
"n < N-1",
"n",
"N-1",
"N",
"1",
"n++",
"n++",
"n",
"{\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}",
"{\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}",
"int X = A[n] + A_work[n];",
"X",
"A[n] + A_work[n]",
"A[n]",
"A",
"n",
"A_work[n]",
"A_work",
"n",
"int Y = A[n + 1] + A_work[n + 1];",
"Y",
"A[n + 1] + A_work[n + 1]",
"A[n + 1]",
"A",
"n + 1",
"n",
"1",
"A_work[n + 1]",
"A_work",
"n + 1",
"n",
"1",
"if (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}",
"X > Y",
"X",
"Y",
"{\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}",
"int diff = X - Y;",
"diff",
"X - Y",
"X",
"Y",
"A_work[n + 1]+=diff",
"A_work[n + 1]",
"A_work",
"n + 1",
"n",
"1",
"diff",
"Y+=diff",
"Y",
"diff",
"sum+=diff",
"sum",
"diff",
"return sum;",
"sum",
"public class Main {\n\tpublic static int N;\n\tpublic static int[] A;\n\tpublic static int[] A_work;\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tN = Integer.parseInt(scan.next());\n\t\tA = new int[N];\n\t\tA_work = new int[N];\n\t\tfor (int n = 0;n < N ;n++ ) {\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}\n\t\tscan.close();\n\n\t\tSystem.out.println(search());\n\t}\n\n\tprivate static long search() {\n\t\tlong sum = 0;\n\t\tfor (int n = 0;n < N-1 ;n++ ) {\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}\n}",
"public class Main {\n\tpublic static int N;\n\tpublic static int[] A;\n\tpublic static int[] A_work;\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tN = Integer.parseInt(scan.next());\n\t\tA = new int[N];\n\t\tA_work = new int[N];\n\t\tfor (int n = 0;n < N ;n++ ) {\n\t\t\tA[n] = Integer.parseInt(scan.next());\n\t\t}\n\t\tscan.close();\n\n\t\tSystem.out.println(search());\n\t}\n\n\tprivate static long search() {\n\t\tlong sum = 0;\n\t\tfor (int n = 0;n < N-1 ;n++ ) {\n\t\t\tint X = A[n] + A_work[n];\n\t\t\tint Y = A[n + 1] + A_work[n + 1];\n\t\t\tif (X > Y) {\n\t\t\t\tint diff = X - Y;\n\t\t\t\tA_work[n + 1]+=diff;\n\t\t\t\tY+=diff;\n\t\t\t\tsum+=diff;\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}\n}",
"Main"
]
| import java.util.Scanner;
public class Main {
public static int N;
public static int[] A;
public static int[] A_work;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
N = Integer.parseInt(scan.next());
A = new int[N];
A_work = new int[N];
for (int n = 0;n < N ;n++ ) {
A[n] = Integer.parseInt(scan.next());
}
scan.close();
System.out.println(search());
}
private static long search() {
long sum = 0;
for (int n = 0;n < N-1 ;n++ ) {
int X = A[n] + A_work[n];
int Y = A[n + 1] + A_work[n + 1];
if (X > Y) {
int diff = X - Y;
A_work[n + 1]+=diff;
Y+=diff;
sum+=diff;
}
}
return sum;
}
}
|
[
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,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
94,
5
],
[
94,
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
],
[
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
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
62,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
8,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
8,
88
],
[
88,
89
],
[
89,
90
],
[
6,
91
],
[
91,
92
],
[
0,
93
],
[
93,
94
],
[
93,
95
]
]
| [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t// 入力値の取得\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tlong sum = 0;\n\t\tlong temp = A[0];\n\t\t\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}\n\t\t// 結果の出力\n\t\tSystem.out.println(sum);\n\t\t\n\t\tsc.close();\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\n\t\t// 入力値の取得\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tlong sum = 0;\n\t\tlong temp = A[0];\n\t\t\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}\n\t\t// 結果の出力\n\t\tSystem.out.println(sum);\n\t\t\n\t\tsc.close();\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t// 入力値の取得\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tlong sum = 0;\n\t\tlong temp = A[0];\n\t\t\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}\n\t\t// 結果の出力\n\t\tSystem.out.println(sum);\n\t\t\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t// 入力値の取得\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tlong sum = 0;\n\t\tlong temp = A[0];\n\t\t\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}\n\t\t// 結果の出力\n\t\tSystem.out.println(sum);\n\t\t\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] A = new long[N];",
"A",
"new long[N]",
"N",
"for(int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextLong();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tA[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\tA[i] = sc.nextLong();\n\t\t}",
"A[i] = sc.nextLong()",
"A[i]",
"A",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"long sum = 0;",
"sum",
"0",
"long temp = A[0];",
"temp",
"A[0]",
"A",
"0",
"for (int i = 1; i < N; i++) {\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\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\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}",
"{\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}",
"if (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}",
"A[i] < temp",
"A[i]",
"A",
"i",
"temp",
"{\n\t\t\t\tsum += temp - A[i];\n\t\t\t}",
"sum += temp - A[i]",
"sum",
"temp - A[i]",
"temp",
"A[i]",
"A",
"i",
"{\n\t\t\t\ttemp = A[i];\n\t\t\t}",
"temp = A[i]",
"temp",
"A[i]",
"A",
"i",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t// 入力値の取得\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tlong sum = 0;\n\t\tlong temp = A[0];\n\t\t\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}\n\t\t// 結果の出力\n\t\tSystem.out.println(sum);\n\t\t\n\t\tsc.close();\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t// 入力値の取得\n\t\tint N = sc.nextInt();\n\t\tlong[] A = new long[N];\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextLong();\n\t\t}\n\t\tlong sum = 0;\n\t\tlong temp = A[0];\n\t\t\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tif (A[i] < temp) {\n\t\t\t\tsum += temp - A[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp = A[i];\n\t\t\t}\n\t\t}\n\t\t// 結果の出力\n\t\tSystem.out.println(sum);\n\t\t\n\t\tsc.close();\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();
long[] A = new long[N];
for(int i = 0; i < N; i++) {
A[i] = sc.nextLong();
}
long sum = 0;
long temp = A[0];
for (int i = 1; i < N; i++) {
if (A[i] < temp) {
sum += temp - A[i];
}
else {
temp = A[i];
}
}
// 結果の出力
System.out.println(sum);
sc.close();
}
}
|
[
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
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
],
[
96,
5
],
[
96,
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
],
[
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
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
56,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
69,
75
],
[
75,
76
],
[
75,
77
],
[
66,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
8,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
87,
92
],
[
6,
93
],
[
93,
94
],
[
0,
95
],
[
95,
96
],
[
95,
97
]
]
| [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scn = new Scanner(System.in);\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i] = scn.nextInt();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scn = new Scanner(System.in);\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i] = scn.nextInt();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scn = new Scanner(System.in);\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i] = scn.nextInt();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\n\t}",
"main",
"{\n\t\tScanner scn = new Scanner(System.in);\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i] = scn.nextInt();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\n\t}",
"Scanner scn = new Scanner(System.in);",
"scn",
"new Scanner(System.in)",
"int n = scn.nextInt();",
"n",
"scn.nextInt()",
"scn.nextInt",
"scn",
"int[] arr = new int[n];",
"arr",
"new int[n]",
"n",
"for(int i=0;i<n;i++)\n\t\t\tarr[i] = scn.nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i] = scn.nextInt();",
"arr[i] = scn.nextInt()",
"arr[i]",
"arr",
"i",
"scn.nextInt()",
"scn.nextInt",
"scn",
"long ans = 0;",
"ans",
"0",
"for(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}",
"{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}",
"if(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}",
"arr[i]<arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}",
"ans += (arr[i-1]-arr[i])",
"ans",
"(arr[i-1]-arr[i])",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"arr[i]",
"arr",
"i",
"arr[i] = arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scn = new Scanner(System.in);\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i] = scn.nextInt();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scn = new Scanner(System.in);\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++)\n\t\t\tarr[i] = scn.nextInt();\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++)\n\t\t{\n\t\t\tif(arr[i]<arr[i-1])\n\t\t\t\t{\n\t\t\t\t\tans += (arr[i-1]-arr[i]);\n\t\t\t\t\tarr[i] = arr[i-1];\n\t\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\t\n\t}\n}",
"Main"
]
| import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++)
arr[i] = scn.nextInt();
long ans = 0;
for(int i=1;i<n;i++)
{
if(arr[i]<arr[i-1])
{
ans += (arr[i-1]-arr[i]);
arr[i] = arr[i-1];
}
}
System.out.println(ans);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
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,
14,
2,
2,
13,
17,
2,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
13,
2,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
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
],
[
98,
11
],
[
98,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
14,
20
],
[
20,
21
],
[
20,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
14,
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
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
63,
65
],
[
52,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
71,
77
],
[
77,
78
],
[
77,
79
],
[
66,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
14,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
12,
95
],
[
95,
96
],
[
0,
97
],
[
97,
98
],
[
97,
99
]
]
| [
"import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\t//code\n\t\tScanner in=new Scanner(System.in);\n\t\tint n;\n\t\tlong sum=0;\n n=in.nextInt();\n int a[]=new int[n];\n for(int i=0;i<n;i++)\n {\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }\n System.out.println(sum);\n}\n}",
"import java.util.*;",
"util.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n\tpublic static void main (String[] args) {\n\t\t//code\n\t\tScanner in=new Scanner(System.in);\n\t\tint n;\n\t\tlong sum=0;\n n=in.nextInt();\n int a[]=new int[n];\n for(int i=0;i<n;i++)\n {\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }\n System.out.println(sum);\n}\n}",
"Main",
"public static void main (String[] args) {\n\t\t//code\n\t\tScanner in=new Scanner(System.in);\n\t\tint n;\n\t\tlong sum=0;\n n=in.nextInt();\n int a[]=new int[n];\n for(int i=0;i<n;i++)\n {\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }\n System.out.println(sum);\n}",
"main",
"{\n\t\t//code\n\t\tScanner in=new Scanner(System.in);\n\t\tint n;\n\t\tlong sum=0;\n n=in.nextInt();\n int a[]=new int[n];\n for(int i=0;i<n;i++)\n {\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }\n System.out.println(sum);\n}",
"Scanner in=new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int n;",
"n",
"long sum=0;",
"sum",
"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 {\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }",
"{\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }",
"a[i]=in.nextInt()",
"a[i]",
"a",
"i",
"in.nextInt()",
"in.nextInt",
"in",
"if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }",
"i>0&&a[i]<a[i-1]",
"i>0",
"i",
"0",
"a[i]<a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"{\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }",
"sum=sum+(a[i-1]-a[i])",
"sum",
"sum+(a[i-1]-a[i])",
"sum",
"(a[i-1]-a[i])",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i]",
"a",
"i",
"a[i]=a[i-1]",
"a[i]",
"a",
"i",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"String[] args",
"args",
"public class Main {\n\tpublic static void main (String[] args) {\n\t\t//code\n\t\tScanner in=new Scanner(System.in);\n\t\tint n;\n\t\tlong sum=0;\n n=in.nextInt();\n int a[]=new int[n];\n for(int i=0;i<n;i++)\n {\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }\n System.out.println(sum);\n}\n}",
"public class Main {\n\tpublic static void main (String[] args) {\n\t\t//code\n\t\tScanner in=new Scanner(System.in);\n\t\tint n;\n\t\tlong sum=0;\n n=in.nextInt();\n int a[]=new int[n];\n for(int i=0;i<n;i++)\n {\n a[i]=in.nextInt();\n if(i>0&&a[i]<a[i-1])\n {\n sum=sum+(a[i-1]-a[i]);\n a[i]=a[i-1];\n }\n }\n System.out.println(sum);\n}\n}",
"Main"
]
| import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
public static void main (String[] args) {
//code
Scanner in=new Scanner(System.in);
int n;
long sum=0;
n=in.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=in.nextInt();
if(i>0&&a[i]<a[i-1])
{
sum=sum+(a[i-1]-a[i]);
a[i]=a[i-1];
}
}
System.out.println(sum);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
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,
13,
2,
13,
18,
13,
13,
0,
18,
13,
13,
13,
30,
0,
13,
17,
4,
13,
13,
23,
13,
12,
13,
30,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
4,
18,
18,
13,
13,
12,
13,
30,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
18,
13,
13,
28,
13,
13,
30,
0,
13,
4,
18,
13,
13,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
18,
13,
13,
13,
4,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
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
],
[
369,
11
],
[
369,
12
],
[
12,
13
],
[
12,
14
],
[
12,
15
],
[
15,
16
],
[
12,
17
],
[
17,
18
],
[
369,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
21,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
32,
35
],
[
21,
36
],
[
36,
37
],
[
36,
38
],
[
21,
39
],
[
39,
40
],
[
39,
41
],
[
21,
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
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
55,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
70,
72
],
[
65,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
65,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
55,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
21,
89
],
[
89,
90
],
[
89,
91
],
[
19,
92
],
[
92,
93
],
[
369,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
94,
103
],
[
103,
104
],
[
369,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
369,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
113,
122
],
[
122,
123
],
[
369,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
124,
128
],
[
128,
129
],
[
124,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
124,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
139,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
149,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
138,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
124,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
168,
171
],
[
171,
172
],
[
124,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
177,
180
],
[
180,
181
],
[
124,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
187,
189
],
[
184,
190
],
[
190,
191
],
[
190,
192
],
[
190,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
196,
199
],
[
196,
200
],
[
184,
201
],
[
201,
202
],
[
182,
203
],
[
203,
204
],
[
124,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
207,
212
],
[
212,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
212,
217
],
[
217,
218
],
[
217,
219
],
[
212,
220
],
[
220,
221
],
[
221,
222
],
[
212,
223
],
[
223,
224
],
[
224,
225
],
[
225,
226
],
[
225,
227
],
[
224,
228
],
[
228,
229
],
[
207,
230
],
[
230,
231
],
[
205,
232
],
[
232,
233
],
[
124,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
237,
238
],
[
237,
239
],
[
236,
241
],
[
241,
242
],
[
242,
243
],
[
243,
244
],
[
243,
245
],
[
241,
246
],
[
246,
247
],
[
246,
248
],
[
241,
249
],
[
249,
250
],
[
250,
251
],
[
241,
252
],
[
252,
253
],
[
253,
254
],
[
254,
255
],
[
254,
256
],
[
253,
257
],
[
257,
258
],
[
236,
259
],
[
259,
260
],
[
234,
261
],
[
261,
262
],
[
124,
263
],
[
263,
264
],
[
263,
265
],
[
265,
266
],
[
266,
267
],
[
266,
268
],
[
265,
271
],
[
271,
272
],
[
272,
273
],
[
273,
274
],
[
273,
275
],
[
271,
276
],
[
276,
277
],
[
276,
278
],
[
271,
279
],
[
279,
280
],
[
280,
281
],
[
271,
282
],
[
282,
283
],
[
283,
284
],
[
284,
285
],
[
285,
286
],
[
285,
287
],
[
283,
288
],
[
288,
289
],
[
288,
290
],
[
283,
291
],
[
291,
292
],
[
292,
293
],
[
283,
294
],
[
294,
295
],
[
295,
296
],
[
296,
297
],
[
297,
298
],
[
297,
299
],
[
296,
300
],
[
295,
301
],
[
301,
302
],
[
265,
303
],
[
303,
304
],
[
263,
305
],
[
305,
306
],
[
263,
307
],
[
307,
308
],
[
124,
309
],
[
309,
310
],
[
309,
311
],
[
311,
312
],
[
312,
313
],
[
312,
314
],
[
311,
316
],
[
316,
317
],
[
317,
318
],
[
318,
319
],
[
318,
320
],
[
316,
321
],
[
321,
322
],
[
321,
323
],
[
316,
324
],
[
324,
325
],
[
325,
326
],
[
316,
327
],
[
327,
328
],
[
328,
329
],
[
329,
330
],
[
329,
331
],
[
328,
332
],
[
332,
333
],
[
311,
334
],
[
334,
335
],
[
309,
336
],
[
336,
337
],
[
124,
338
],
[
338,
339
],
[
338,
340
],
[
340,
341
],
[
341,
342
],
[
342,
343
],
[
343,
344
],
[
342,
345
],
[
345,
346
],
[
124,
347
],
[
347,
348
],
[
347,
349
],
[
349,
350
],
[
350,
351
],
[
350,
352
],
[
349,
353
],
[
353,
354
],
[
354,
355
],
[
354,
356
],
[
356,
357
],
[
357,
358
],
[
358,
359
],
[
353,
360
],
[
360,
361
],
[
361,
362
],
[
361,
363
],
[
363,
364
],
[
364,
365
],
[
349,
366
],
[
366,
367
],
[
0,
368
],
[
368,
369
],
[
368,
370
]
]
| [
"import java.util.*;\nimport java.io.*;\nimport java.math.*;\n\t public final class Main {\n\t \tstatic void solve(int[] arr, int n) {\n\t \t}\n\t public static void main(String args[]) throws IOException {\n\t \tFastReader sc = new FastReader();\n\t \tint n = sc.nextInt();\n\t \tlong[] arr = sc.readLongArray(n);\n\t \tlong total = 0;\n\t \tlong max = 0;\n\t \tfor(int i = 1;i < n;i++) {\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}\n\t \tpn(total);\n\t }\n\t static void p(Object p){System.out.print(p);}\n\t static void pn(){System.out.println();}\n\t static void pn(Object o){System.out.println(o);}\n\t \n\t static class FastReader {\n\t static BufferedReader br;\n\t StringTokenizer st;\n\t public FastReader() {\n\t br = new BufferedReader(new InputStreamReader(System.in));\n\t }\n\t \n\t String next(){\n\t while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}\n\t return st.nextToken();\n\t }\n\t \n\t int nextInt(){ \n\t return Integer.parseInt(next());\n\t }\n\t \n\t long nextLong(){ \n\t return Long.parseLong(next());\n\t }\n\t \n\t static int max(int[] a){\n\t int max = Integer.MIN_VALUE;\n\t for(int i : a) max = Math.max(max, i);\n\t return max;\n\t }\n\t \n\t public int[] readIntArray(int n) {\n\t int[] arr = new int[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextInt();\n\t return arr;\n\t }\n\t \n\t public long[] readLongArray(int n){\n\t long[] arr = new long[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextLong();\n\t return arr;\n\t }\n\t \n\t public int[][] readIntArray(int m, int n){\n\t int[][] arr = new int[m][n];\n\t for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();\n\t return arr;\n\t }\n\t \n\t public String[] readStringArray(int n) {\n\t String[] arr = new String[n];\n\t for(int i=0; i<n; ++i) arr[i]= nextLine();\n\t return arr;\n\t }\n\t \n\t double nextDouble() {return Double.parseDouble(next());}\n\t \n\t String nextLine() {\n\t String str = \"\";\n\t try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}\n\t return str;}}\n\t }",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"import java.math.*;",
"math.*",
"java",
"public final class Main {\n\t \tstatic void solve(int[] arr, int n) {\n\t \t}\n\t public static void main(String args[]) throws IOException {\n\t \tFastReader sc = new FastReader();\n\t \tint n = sc.nextInt();\n\t \tlong[] arr = sc.readLongArray(n);\n\t \tlong total = 0;\n\t \tlong max = 0;\n\t \tfor(int i = 1;i < n;i++) {\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}\n\t \tpn(total);\n\t }\n\t static void p(Object p){System.out.print(p);}\n\t static void pn(){System.out.println();}\n\t static void pn(Object o){System.out.println(o);}\n\t \n\t static class FastReader {\n\t static BufferedReader br;\n\t StringTokenizer st;\n\t public FastReader() {\n\t br = new BufferedReader(new InputStreamReader(System.in));\n\t }\n\t \n\t String next(){\n\t while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}\n\t return st.nextToken();\n\t }\n\t \n\t int nextInt(){ \n\t return Integer.parseInt(next());\n\t }\n\t \n\t long nextLong(){ \n\t return Long.parseLong(next());\n\t }\n\t \n\t static int max(int[] a){\n\t int max = Integer.MIN_VALUE;\n\t for(int i : a) max = Math.max(max, i);\n\t return max;\n\t }\n\t \n\t public int[] readIntArray(int n) {\n\t int[] arr = new int[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextInt();\n\t return arr;\n\t }\n\t \n\t public long[] readLongArray(int n){\n\t long[] arr = new long[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextLong();\n\t return arr;\n\t }\n\t \n\t public int[][] readIntArray(int m, int n){\n\t int[][] arr = new int[m][n];\n\t for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();\n\t return arr;\n\t }\n\t \n\t public String[] readStringArray(int n) {\n\t String[] arr = new String[n];\n\t for(int i=0; i<n; ++i) arr[i]= nextLine();\n\t return arr;\n\t }\n\t \n\t double nextDouble() {return Double.parseDouble(next());}\n\t \n\t String nextLine() {\n\t String str = \"\";\n\t try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}\n\t return str;}}\n\t }",
"Main",
"static void solve(int[] arr, int n) {\n\t \t}",
"solve",
"{\n\t \t}",
"int[] arr",
"arr",
"int n",
"n",
"public static void main(String args[]) throws IOException {\n\t \tFastReader sc = new FastReader();\n\t \tint n = sc.nextInt();\n\t \tlong[] arr = sc.readLongArray(n);\n\t \tlong total = 0;\n\t \tlong max = 0;\n\t \tfor(int i = 1;i < n;i++) {\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}\n\t \tpn(total);\n\t }",
"main",
"{\n\t \tFastReader sc = new FastReader();\n\t \tint n = sc.nextInt();\n\t \tlong[] arr = sc.readLongArray(n);\n\t \tlong total = 0;\n\t \tlong max = 0;\n\t \tfor(int i = 1;i < n;i++) {\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}\n\t \tpn(total);\n\t }",
"FastReader sc = new FastReader();",
"sc",
"new FastReader()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] arr = sc.readLongArray(n);",
"arr",
"sc.readLongArray(n)",
"sc.readLongArray",
"sc",
"n",
"long total = 0;",
"total",
"0",
"long max = 0;",
"max",
"0",
"for(int i = 1;i < n;i++) {\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\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\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}",
"{\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}",
"if(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}",
"arr[i] < arr[i-1]",
"arr[i]",
"arr",
"i",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"{\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}",
"max = arr[i-1]",
"max",
"arr[i-1]",
"arr",
"i-1",
"i",
"1",
"total += max - arr[i]",
"total",
"max - arr[i]",
"max",
"arr[i]",
"arr",
"i",
"arr[i] = max",
"arr[i]",
"arr",
"i",
"max",
"{\n\t \t\t\tmax = 0;\n\t \t\t}",
"max = 0",
"max",
"0",
"pn(total)",
"pn",
"total",
"String args[]",
"args",
"static void p(Object p){System.out.print(p);}",
"p",
"{System.out.print(p);}",
"System.out.print(p)",
"System.out.print",
"System.out",
"System",
"System.out",
"p",
"Object p",
"p",
"static void pn(){System.out.println();}",
"pn",
"{System.out.println();}",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"static void pn(Object o){System.out.println(o);}",
"pn",
"{System.out.println(o);}",
"System.out.println(o)",
"System.out.println",
"System.out",
"System",
"System.out",
"o",
"Object o",
"o",
"static class FastReader {\n\t static BufferedReader br;\n\t StringTokenizer st;\n\t public FastReader() {\n\t br = new BufferedReader(new InputStreamReader(System.in));\n\t }\n\t \n\t String next(){\n\t while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}\n\t return st.nextToken();\n\t }\n\t \n\t int nextInt(){ \n\t return Integer.parseInt(next());\n\t }\n\t \n\t long nextLong(){ \n\t return Long.parseLong(next());\n\t }\n\t \n\t static int max(int[] a){\n\t int max = Integer.MIN_VALUE;\n\t for(int i : a) max = Math.max(max, i);\n\t return max;\n\t }\n\t \n\t public int[] readIntArray(int n) {\n\t int[] arr = new int[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextInt();\n\t return arr;\n\t }\n\t \n\t public long[] readLongArray(int n){\n\t long[] arr = new long[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextLong();\n\t return arr;\n\t }\n\t \n\t public int[][] readIntArray(int m, int n){\n\t int[][] arr = new int[m][n];\n\t for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();\n\t return arr;\n\t }\n\t \n\t public String[] readStringArray(int n) {\n\t String[] arr = new String[n];\n\t for(int i=0; i<n; ++i) arr[i]= nextLine();\n\t return arr;\n\t }\n\t \n\t double nextDouble() {return Double.parseDouble(next());}\n\t \n\t String nextLine() {\n\t String str = \"\";\n\t try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}\n\t return str;}}",
"FastReader",
"static BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public FastReader() {\n\t br = new BufferedReader(new InputStreamReader(System.in));\n\t }",
"FastReader",
"{\n\t br = new BufferedReader(new InputStreamReader(System.in));\n\t }",
"br = new BufferedReader(new InputStreamReader(System.in))",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String next(){\n\t while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}\n\t return st.nextToken();\n\t }",
"next",
"{\n\t while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}\n\t return st.nextToken();\n\t }",
"while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}",
"try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"IOException e",
"{\n\t e.printStackTrace();\n\t }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t st = new StringTokenizer(br.readLine());\n\t }",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"int nextInt(){ \n\t return Integer.parseInt(next());\n\t }",
"nextInt",
"{ \n\t return Integer.parseInt(next());\n\t }",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"long nextLong(){ \n\t return Long.parseLong(next());\n\t }",
"nextLong",
"{ \n\t return Long.parseLong(next());\n\t }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"static int max(int[] a){\n\t int max = Integer.MIN_VALUE;\n\t for(int i : a) max = Math.max(max, i);\n\t return max;\n\t }",
"max",
"{\n\t int max = Integer.MIN_VALUE;\n\t for(int i : a) max = Math.max(max, i);\n\t return max;\n\t }",
"int max = Integer.MIN_VALUE;",
"max",
"Integer.MIN_VALUE",
"Integer",
"Integer.MIN_VALUE",
"for(int i : a) max = Math.max(max, i);",
"int i",
"a",
"max = Math.max(max, i);",
"max = Math.max(max, i)",
"max",
"Math.max(max, i)",
"Math.max",
"Math",
"max",
"i",
"return max;",
"max",
"int[] a",
"a",
"public int[] readIntArray(int n) {\n\t int[] arr = new int[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextInt();\n\t return arr;\n\t }",
"readIntArray",
"{\n\t int[] arr = new int[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextInt();\n\t return arr;\n\t }",
"int[] arr = new int[n];",
"arr",
"new int[n]",
"n",
"for(int i=0; i<n; ++i) arr[i]=nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"++i",
"++i",
"i",
"arr[i]=nextInt();",
"arr[i]=nextInt()",
"arr[i]",
"arr",
"i",
"nextInt()",
"nextInt",
"return arr;",
"arr",
"int n",
"n",
"public long[] readLongArray(int n){\n\t long[] arr = new long[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextLong();\n\t return arr;\n\t }",
"readLongArray",
"{\n\t long[] arr = new long[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextLong();\n\t return arr;\n\t }",
"long[] arr = new long[n];",
"arr",
"new long[n]",
"n",
"for(int i=0; i<n; ++i) arr[i]=nextLong();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"++i",
"++i",
"i",
"arr[i]=nextLong();",
"arr[i]=nextLong()",
"arr[i]",
"arr",
"i",
"nextLong()",
"nextLong",
"return arr;",
"arr",
"int n",
"n",
"public int[][] readIntArray(int m, int n){\n\t int[][] arr = new int[m][n];\n\t for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();\n\t return arr;\n\t }",
"readIntArray",
"{\n\t int[][] arr = new int[m][n];\n\t for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();\n\t return arr;\n\t }",
"int[][] arr = new int[m][n];",
"arr",
"new int[m][n]",
"m",
"n",
"for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<m",
"i",
"m",
"i++",
"i++",
"i",
"for(int j = 0;j<n;j++) arr[i][j] = nextInt();",
"for(int j = 0;j<n;j++) arr[i][j] = nextInt();",
"int j = 0;",
"int j = 0;",
"j",
"0",
"j<n",
"j",
"n",
"j++",
"j++",
"j",
"arr[i][j] = nextInt();",
"arr[i][j] = nextInt()",
"arr[i][j]",
"arr[i]",
"arr",
"i",
"j",
"nextInt()",
"nextInt",
"return arr;",
"arr",
"int m",
"m",
"int n",
"n",
"public String[] readStringArray(int n) {\n\t String[] arr = new String[n];\n\t for(int i=0; i<n; ++i) arr[i]= nextLine();\n\t return arr;\n\t }",
"readStringArray",
"{\n\t String[] arr = new String[n];\n\t for(int i=0; i<n; ++i) arr[i]= nextLine();\n\t return arr;\n\t }",
"String[] arr = new String[n];",
"arr",
"new String[n]",
"n",
"for(int i=0; i<n; ++i) arr[i]= nextLine();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"++i",
"++i",
"i",
"arr[i]= nextLine();",
"arr[i]= nextLine()",
"arr[i]",
"arr",
"i",
"nextLine()",
"nextLine",
"return arr;",
"arr",
"int n",
"n",
"double nextDouble() {return Double.parseDouble(next());}",
"nextDouble",
"{return Double.parseDouble(next());}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"String nextLine() {\n\t String str = \"\";\n\t try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}\n\t return str;}",
"nextLine",
"{\n\t String str = \"\";\n\t try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}\n\t return str;}",
"String str = \"\";",
"str",
"\"\"",
"try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}",
"catch (IOException e) {e.printStackTrace();}",
"IOException e",
"{e.printStackTrace();}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{str = br.readLine();}",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"public final class Main {\n\t \tstatic void solve(int[] arr, int n) {\n\t \t}\n\t public static void main(String args[]) throws IOException {\n\t \tFastReader sc = new FastReader();\n\t \tint n = sc.nextInt();\n\t \tlong[] arr = sc.readLongArray(n);\n\t \tlong total = 0;\n\t \tlong max = 0;\n\t \tfor(int i = 1;i < n;i++) {\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}\n\t \tpn(total);\n\t }\n\t static void p(Object p){System.out.print(p);}\n\t static void pn(){System.out.println();}\n\t static void pn(Object o){System.out.println(o);}\n\t \n\t static class FastReader {\n\t static BufferedReader br;\n\t StringTokenizer st;\n\t public FastReader() {\n\t br = new BufferedReader(new InputStreamReader(System.in));\n\t }\n\t \n\t String next(){\n\t while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}\n\t return st.nextToken();\n\t }\n\t \n\t int nextInt(){ \n\t return Integer.parseInt(next());\n\t }\n\t \n\t long nextLong(){ \n\t return Long.parseLong(next());\n\t }\n\t \n\t static int max(int[] a){\n\t int max = Integer.MIN_VALUE;\n\t for(int i : a) max = Math.max(max, i);\n\t return max;\n\t }\n\t \n\t public int[] readIntArray(int n) {\n\t int[] arr = new int[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextInt();\n\t return arr;\n\t }\n\t \n\t public long[] readLongArray(int n){\n\t long[] arr = new long[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextLong();\n\t return arr;\n\t }\n\t \n\t public int[][] readIntArray(int m, int n){\n\t int[][] arr = new int[m][n];\n\t for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();\n\t return arr;\n\t }\n\t \n\t public String[] readStringArray(int n) {\n\t String[] arr = new String[n];\n\t for(int i=0; i<n; ++i) arr[i]= nextLine();\n\t return arr;\n\t }\n\t \n\t double nextDouble() {return Double.parseDouble(next());}\n\t \n\t String nextLine() {\n\t String str = \"\";\n\t try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}\n\t return str;}}\n\t }",
"public final class Main {\n\t \tstatic void solve(int[] arr, int n) {\n\t \t}\n\t public static void main(String args[]) throws IOException {\n\t \tFastReader sc = new FastReader();\n\t \tint n = sc.nextInt();\n\t \tlong[] arr = sc.readLongArray(n);\n\t \tlong total = 0;\n\t \tlong max = 0;\n\t \tfor(int i = 1;i < n;i++) {\n\t \t\tif(arr[i] < arr[i-1]) {\n\t \t\t\tmax = arr[i-1];\n\t \t\t\ttotal += max - arr[i];\n\t \t\t\tarr[i] = max;\n\t \t\t}\n\t \t\telse {\n\t \t\t\tmax = 0;\n\t \t\t}\n \t \t}\n\t \tpn(total);\n\t }\n\t static void p(Object p){System.out.print(p);}\n\t static void pn(){System.out.println();}\n\t static void pn(Object o){System.out.println(o);}\n\t \n\t static class FastReader {\n\t static BufferedReader br;\n\t StringTokenizer st;\n\t public FastReader() {\n\t br = new BufferedReader(new InputStreamReader(System.in));\n\t }\n\t \n\t String next(){\n\t while (st == null || !st.hasMoreElements()) {\n\t try{\n\t st = new StringTokenizer(br.readLine());\n\t }\n\t catch (IOException e) {\n\t e.printStackTrace();\n\t }}\n\t return st.nextToken();\n\t }\n\t \n\t int nextInt(){ \n\t return Integer.parseInt(next());\n\t }\n\t \n\t long nextLong(){ \n\t return Long.parseLong(next());\n\t }\n\t \n\t static int max(int[] a){\n\t int max = Integer.MIN_VALUE;\n\t for(int i : a) max = Math.max(max, i);\n\t return max;\n\t }\n\t \n\t public int[] readIntArray(int n) {\n\t int[] arr = new int[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextInt();\n\t return arr;\n\t }\n\t \n\t public long[] readLongArray(int n){\n\t long[] arr = new long[n];\n\t for(int i=0; i<n; ++i) arr[i]=nextLong();\n\t return arr;\n\t }\n\t \n\t public int[][] readIntArray(int m, int n){\n\t int[][] arr = new int[m][n];\n\t for(int i = 0;i<m;i++) \n\t for(int j = 0;j<n;j++) arr[i][j] = nextInt();\n\t return arr;\n\t }\n\t \n\t public String[] readStringArray(int n) {\n\t String[] arr = new String[n];\n\t for(int i=0; i<n; ++i) arr[i]= nextLine();\n\t return arr;\n\t }\n\t \n\t double nextDouble() {return Double.parseDouble(next());}\n\t \n\t String nextLine() {\n\t String str = \"\";\n\t try{str = br.readLine();}\n\t catch (IOException e) {e.printStackTrace();}\n\t return str;}}\n\t }",
"Main"
]
| import java.util.*;
import java.io.*;
import java.math.*;
public final class Main {
static void solve(int[] arr, int n) {
}
public static void main(String args[]) throws IOException {
FastReader sc = new FastReader();
int n = sc.nextInt();
long[] arr = sc.readLongArray(n);
long total = 0;
long max = 0;
for(int i = 1;i < n;i++) {
if(arr[i] < arr[i-1]) {
max = arr[i-1];
total += max - arr[i];
arr[i] = max;
}
else {
max = 0;
}
}
pn(total);
}
static void p(Object p){System.out.print(p);}
static void pn(){System.out.println();}
static void pn(Object o){System.out.println(o);}
static class FastReader {
static BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while (st == null || !st.hasMoreElements()) {
try{
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
static int max(int[] a){
int max = Integer.MIN_VALUE;
for(int i : a) max = Math.max(max, i);
return max;
}
public int[] readIntArray(int n) {
int[] arr = new int[n];
for(int i=0; i<n; ++i) arr[i]=nextInt();
return arr;
}
public long[] readLongArray(int n){
long[] arr = new long[n];
for(int i=0; i<n; ++i) arr[i]=nextLong();
return arr;
}
public int[][] readIntArray(int m, int n){
int[][] arr = new int[m][n];
for(int i = 0;i<m;i++)
for(int j = 0;j<n;j++) arr[i][j] = nextInt();
return arr;
}
public String[] readStringArray(int n) {
String[] arr = new String[n];
for(int i=0; i<n; ++i) arr[i]= nextLine();
return arr;
}
double nextDouble() {return Double.parseDouble(next());}
String nextLine() {
String str = "";
try{str = br.readLine();}
catch (IOException e) {e.printStackTrace();}
return str;}}
}
|
[
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,
11,
1,
41,
13,
17,
2,
13,
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,
13,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
29,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
102,
5
],
[
102,
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
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
54,
56
],
[
47,
57
],
[
57,
58
],
[
58,
59
],
[
47,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
61,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
61,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
61,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
8,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
8,
98
],
[
6,
99
],
[
99,
100
],
[
0,
101
],
[
101,
102
],
[
101,
103
]
]
| [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\t\n\t\tLong[] Ai = new Long[N];\n\t\tLong sum = (long) 0;\n\t\t\n\t\tfor(int i = 0; i<N; i++) {\n\t\t\tAi[i] = sc.nextLong();\n\t\t}\n\t \n\t\tLong max = (long) 0;\n\n\t\tfor(int i = 0; i<N-1; i++) {\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sum);\t\n\t\treturn;\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args){\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\t\n\t\tLong[] Ai = new Long[N];\n\t\tLong sum = (long) 0;\n\t\t\n\t\tfor(int i = 0; i<N; i++) {\n\t\t\tAi[i] = sc.nextLong();\n\t\t}\n\t \n\t\tLong max = (long) 0;\n\n\t\tfor(int i = 0; i<N-1; i++) {\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sum);\t\n\t\treturn;\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\t\n\t\tLong[] Ai = new Long[N];\n\t\tLong sum = (long) 0;\n\t\t\n\t\tfor(int i = 0; i<N; i++) {\n\t\t\tAi[i] = sc.nextLong();\n\t\t}\n\t \n\t\tLong max = (long) 0;\n\n\t\tfor(int i = 0; i<N-1; i++) {\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sum);\t\n\t\treturn;\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\t\n\t\tLong[] Ai = new Long[N];\n\t\tLong sum = (long) 0;\n\t\t\n\t\tfor(int i = 0; i<N; i++) {\n\t\t\tAi[i] = sc.nextLong();\n\t\t}\n\t \n\t\tLong max = (long) 0;\n\n\t\tfor(int i = 0; i<N-1; i++) {\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sum);\t\n\t\treturn;\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Long[] Ai = new Long[N];",
"Ai",
"new Long[N]",
"N",
"Long sum = (long) 0;",
"sum",
"(long) 0",
"for(int i = 0; i<N; i++) {\n\t\t\tAi[i] = sc.nextLong();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tAi[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\tAi[i] = sc.nextLong();\n\t\t}",
"Ai[i] = sc.nextLong()",
"Ai[i]",
"Ai",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"Long max = (long) 0;",
"max",
"(long) 0",
"for(int i = 0; i<N-1; i++) {\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \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\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}",
"{\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}",
"long a1 = Ai[i];",
"a1",
"Ai[i]",
"Ai",
"i",
"long a2 = Ai[i+1];",
"a2",
"Ai[i+1]",
"Ai",
"i+1",
"i",
"1",
"if(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}",
"a1>max",
"a1",
"max",
"{\n\t\t\t\tmax=a1;\n\t\t\t}",
"max=a1",
"max",
"a1",
"if(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}",
"max>a2",
"max",
"a2",
"{\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}",
"sum += (max-a2)",
"sum",
"(max-a2)",
"max",
"a2",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"return;",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args){\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\t\n\t\tLong[] Ai = new Long[N];\n\t\tLong sum = (long) 0;\n\t\t\n\t\tfor(int i = 0; i<N; i++) {\n\t\t\tAi[i] = sc.nextLong();\n\t\t}\n\t \n\t\tLong max = (long) 0;\n\n\t\tfor(int i = 0; i<N-1; i++) {\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sum);\t\n\t\treturn;\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args){\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\t\n\t\tLong[] Ai = new Long[N];\n\t\tLong sum = (long) 0;\n\t\t\n\t\tfor(int i = 0; i<N; i++) {\n\t\t\tAi[i] = sc.nextLong();\n\t\t}\n\t \n\t\tLong max = (long) 0;\n\n\t\tfor(int i = 0; i<N-1; i++) {\n\t\t\tlong a1 = Ai[i];\n\t\t\tlong a2 = Ai[i+1];\n \n \tif(a1>max){\n\t\t\t\tmax=a1;\n\t\t\t}\n \n\t\t\tif(max>a2){\n\t\t\t\tsum += (max-a2);\n \t\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sum);\t\n\t\treturn;\n\t}\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();
Long[] Ai = new Long[N];
Long sum = (long) 0;
for(int i = 0; i<N; i++) {
Ai[i] = sc.nextLong();
}
Long max = (long) 0;
for(int i = 0; i<N-1; i++) {
long a1 = Ai[i];
long a2 = Ai[i+1];
if(a1>max){
max=a1;
}
if(max>a2){
sum += (max-a2);
}
}
System.out.println(sum);
return;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
64,
5
],
[
64,
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,
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
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
35,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
48,
50
],
[
41,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
8,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
55,
60
],
[
6,
61
],
[
61,
62
],
[
0,
63
],
[
63,
64
],
[
63,
65
]
]
| [
"import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint p = sc.nextInt();\n\t\tint before = 0;\n\t\tlong dai = 0;\n\t\tfor (int i = 0; i < p; i++) {\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dai);\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint p = sc.nextInt();\n\t\tint before = 0;\n\t\tlong dai = 0;\n\t\tfor (int i = 0; i < p; i++) {\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dai);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint p = sc.nextInt();\n\t\tint before = 0;\n\t\tlong dai = 0;\n\t\tfor (int i = 0; i < p; i++) {\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dai);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint p = sc.nextInt();\n\t\tint before = 0;\n\t\tlong dai = 0;\n\t\tfor (int i = 0; i < p; i++) {\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dai);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int p = sc.nextInt();",
"p",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int before = 0;",
"before",
"0",
"long dai = 0;",
"dai",
"0",
"for (int i = 0; i < p; i++) {\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < p",
"i",
"p",
"i++",
"i++",
"i",
"{\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}",
"{\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}",
"int height = sc.nextInt();",
"height",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}",
"before > height",
"before",
"height",
"{\n\t\t\t\tdai+=before - height;\n\t\t\t}",
"dai+=before - height",
"dai",
"before - height",
"before",
"height",
"{\n\t\t\t\tbefore = height;\n\t\t\t}",
"before = height",
"before",
"height",
"System.out.println(dai)",
"System.out.println",
"System.out",
"System",
"System.out",
"dai",
"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 p = sc.nextInt();\n\t\tint before = 0;\n\t\tlong dai = 0;\n\t\tfor (int i = 0; i < p; i++) {\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dai);\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 p = sc.nextInt();\n\t\tint before = 0;\n\t\tlong dai = 0;\n\t\tfor (int i = 0; i < p; i++) {\n\t\t\tint height = sc.nextInt();\n\t\t\tif(before > height) {\n\t\t\t\tdai+=before - height;\n\t\t\t}else {\n\t\t\t\tbefore = height;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dai);\n\t}\n}",
"Main"
]
| import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int p = sc.nextInt();
int before = 0;
long dai = 0;
for (int i = 0; i < p; i++) {
int height = sc.nextInt();
if(before > height) {
dai+=before - height;
}else {
before = height;
}
}
System.out.println(dai);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
]
| [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
93,
5
],
[
93,
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
],
[
24,
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
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
45,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
8,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
52,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
64,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
8,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
84,
89
],
[
6,
90
],
[
90,
91
],
[
0,
92
],
[
92,
93
],
[
92,
94
]
]
| [
"import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint N = scan.nextInt();\n\t\tint A[] = new int[N];\n\t\tlong step = 0;\n\t\tint max = 0;\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\n\t\tmax = A[0];\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}\n\t\tSystem.out.println(step);\n\t}\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\n\t\tint N = scan.nextInt();\n\t\tint A[] = new int[N];\n\t\tlong step = 0;\n\t\tint max = 0;\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\n\t\tmax = A[0];\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}\n\t\tSystem.out.println(step);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint N = scan.nextInt();\n\t\tint A[] = new int[N];\n\t\tlong step = 0;\n\t\tint max = 0;\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\n\t\tmax = A[0];\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}\n\t\tSystem.out.println(step);\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint N = scan.nextInt();\n\t\tint A[] = new int[N];\n\t\tlong step = 0;\n\t\tint max = 0;\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\n\t\tmax = A[0];\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}\n\t\tSystem.out.println(step);\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",
"long step = 0;",
"step",
"0",
"int max = 0;",
"max",
"0",
"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",
"max = A[0]",
"max",
"A[0]",
"A",
"0",
"for(int i=0; i<N; i++) {\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}",
"{\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}",
"if(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}",
"max <= A[i]",
"max",
"A[i]",
"A",
"i",
"{\n\t\t\t\tmax = A[i];\n\t\t\t}",
"max = A[i]",
"max",
"A[i]",
"A",
"i",
"step += max - A[i]",
"step",
"max - A[i]",
"max",
"A[i]",
"A",
"i",
"System.out.println(step)",
"System.out.println",
"System.out",
"System",
"System.out",
"step",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint N = scan.nextInt();\n\t\tint A[] = new int[N];\n\t\tlong step = 0;\n\t\tint max = 0;\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\n\t\tmax = A[0];\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}\n\t\tSystem.out.println(step);\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint N = scan.nextInt();\n\t\tint A[] = new int[N];\n\t\tlong step = 0;\n\t\tint max = 0;\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\n\t\tmax = A[0];\n\t\tfor(int i=0; i<N; i++) {\n\t\t\tif(max <= A[i]) {\n\t\t\t\tmax = A[i];\n\t\t\t}\n\t\t\tstep += max - A[i];\n\t\t}\n\t\tSystem.out.println(step);\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 A[] = new int[N];
long step = 0;
int max = 0;
for(int i=0; i<N; i++) {
A[i] = scan.nextInt();
}
max = A[0];
for(int i=0; i<N; i++) {
if(max <= A[i]) {
max = A[i];
}
step += max - A[i];
}
System.out.println(step);
}
}
|
[
7,
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,
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
2,
18,
13,
2,
13,
17,
18,
13,
13,
17,
30,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
4,
18,
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
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
155,
17
],
[
155,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
23,
25
],
[
20,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
20,
31
],
[
31,
32
],
[
31,
33
],
[
20,
34
],
[
34,
35
],
[
34,
36
],
[
20,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
40,
44
],
[
40,
45
],
[
20,
46
],
[
46,
47
],
[
47,
48
],
[
18,
49
],
[
49,
50
],
[
155,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
61,
62
],
[
62,
63
],
[
55,
64
],
[
64,
65
],
[
64,
66
],
[
55,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
68,
76
],
[
76,
77
],
[
77,
78
],
[
68,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
88,
89
],
[
89,
90
],
[
55,
91
],
[
91,
92
],
[
91,
93
],
[
55,
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
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
112,
114
],
[
109,
115
],
[
115,
116
],
[
115,
117
],
[
108,
118
],
[
107,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
122,
128
],
[
128,
129
],
[
128,
130
],
[
119,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
138,
140
],
[
135,
141
],
[
141,
142
],
[
141,
143
],
[
55,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
53,
148
],
[
148,
149
],
[
53,
150
],
[
150,
151
],
[
53,
152
],
[
152,
153
],
[
0,
154
],
[
154,
155
],
[
154,
156
]
]
| [
"import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n // 入力\n int n = Integer.parseInt(in.next());\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }\n long ans = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }\n\n // 出力\n out.println(ans);\n\n }\n\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.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n // 入力\n int n = Integer.parseInt(in.next());\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }\n long ans = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }\n\n // 出力\n out.println(ans);\n\n }\n\n }\n}",
"Main",
"public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }",
"main",
"{\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CStep solver = new CStep();\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",
"Scanner in = new Scanner(inputStream);",
"in",
"new Scanner(inputStream)",
"PrintWriter out = new PrintWriter(outputStream);",
"out",
"new PrintWriter(outputStream)",
"CStep solver = new CStep();",
"solver",
"new CStep()",
"solver.solve(1, in, out)",
"solver.solve",
"solver",
"1",
"in",
"out",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"static class CStep {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n // 入力\n int n = Integer.parseInt(in.next());\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }\n long ans = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }\n\n // 出力\n out.println(ans);\n\n }\n\n }",
"CStep",
"public void solve(int testNumber, Scanner in, PrintWriter out) {\n // 入力\n int n = Integer.parseInt(in.next());\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }\n long ans = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }\n\n // 出力\n out.println(ans);\n\n }",
"solve",
"{\n // 入力\n int n = Integer.parseInt(in.next());\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }\n long ans = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }\n\n // 出力\n out.println(ans);\n\n }",
"int n = Integer.parseInt(in.next());",
"n",
"Integer.parseInt(in.next())",
"Integer.parseInt",
"Integer",
"in.next()",
"in.next",
"in",
"long[] a = new long[n];",
"a",
"new long[n]",
"n",
"for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = Long.parseLong(in.next());\n }",
"{\n a[i] = Long.parseLong(in.next());\n }",
"a[i] = Long.parseLong(in.next())",
"a[i]",
"a",
"i",
"Long.parseLong(in.next())",
"Long.parseLong",
"Long",
"in.next()",
"in.next",
"in",
"long ans = 0;",
"ans",
"0",
"for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }",
"{\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }",
"if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }",
"a[i - 1] - a[i] > 0",
"a[i - 1] - a[i]",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i]",
"a",
"i",
"0",
"{\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }",
"ans += a[i - 1] - a[i]",
"ans",
"a[i - 1] - a[i]",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i]",
"a",
"i",
"a[i] += a[i - 1] - a[i]",
"a[i]",
"a",
"i",
"a[i - 1] - a[i]",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"a[i]",
"a",
"i",
"out.println(ans)",
"out.println",
"out",
"ans",
"int testNumber",
"testNumber",
"Scanner in",
"in",
"PrintWriter out",
"out",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n // 入力\n int n = Integer.parseInt(in.next());\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }\n long ans = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }\n\n // 出力\n out.println(ans);\n\n }\n\n }\n}",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CStep solver = new CStep();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CStep {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n // 入力\n int n = Integer.parseInt(in.next());\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = Long.parseLong(in.next());\n }\n long ans = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] - a[i] > 0) {\n ans += a[i - 1] - a[i];\n a[i] += a[i - 1] - a[i];\n }\n }\n\n // 出力\n out.println(ans);\n\n }\n\n }\n}",
"Main"
]
| import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(inputStream);
PrintWriter out = new PrintWriter(outputStream);
CStep solver = new CStep();
solver.solve(1, in, out);
out.close();
}
static class CStep {
public void solve(int testNumber, Scanner in, PrintWriter out) {
// 入力
int n = Integer.parseInt(in.next());
long[] a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = Long.parseLong(in.next());
}
long ans = 0;
for (int i = 1; i < n; i++) {
if (a[i - 1] - a[i] > 0) {
ans += a[i - 1] - a[i];
a[i] += a[i - 1] - a[i];
}
}
// 出力
out.println(ans);
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
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,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
20,
41,
13,
12,
13,
30,
42,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
29,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
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
],
[
176,
8
],
[
176,
9
],
[
9,
10
],
[
9,
11
],
[
176,
12
],
[
12,
13
],
[
12,
14
],
[
176,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
17,
23
],
[
23,
24
],
[
23,
25
],
[
17,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
27,
32
],
[
32,
33
],
[
32,
34
],
[
27,
35
],
[
35,
36
],
[
36,
37
],
[
27,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
44,
45
],
[
17,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
48,
50
],
[
17,
51
],
[
51,
52
],
[
51,
53
],
[
17,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
54,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
69,
73
],
[
73,
74
],
[
73,
75
],
[
66,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
17,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
17,
87
],
[
87,
88
],
[
88,
89
],
[
15,
90
],
[
90,
91
],
[
176,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
97,
98
],
[
92,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
102,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
112,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
101,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
92,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
133,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
144,
145
],
[
129,
146
],
[
146,
147
],
[
92,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
155,
156
],
[
92,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
161,
164
],
[
164,
165
],
[
92,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
170,
173
],
[
173,
174
],
[
0,
175
],
[
175,
176
],
[
175,
177
]
]
| [
"import java.util.*;\nimport java.io.*;\n\npublic class Main {\n\tstatic FastReader f = new FastReader();\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\n\tpublic static void main(String[] args) {\n\t\tint n = f.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++) arr[i] = f.nextInt();\n\t\tint max = arr[0];\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\t\t\n\n\tstatic class FastReader {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st;\n\n\t\tString next() {\n\t\t\twhile(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n\tstatic FastReader f = new FastReader();\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\n\tpublic static void main(String[] args) {\n\t\tint n = f.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++) arr[i] = f.nextInt();\n\t\tint max = arr[0];\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\t\t\n\n\tstatic class FastReader {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st;\n\n\t\tString next() {\n\t\t\twhile(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n}",
"Main",
"static FastReader f = new FastReader();",
"f",
"new FastReader()",
"static PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"public static void main(String[] args) {\n\t\tint n = f.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++) arr[i] = f.nextInt();\n\t\tint max = arr[0];\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}",
"main",
"{\n\t\tint n = f.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++) arr[i] = f.nextInt();\n\t\tint max = arr[0];\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}",
"int n = f.nextInt();",
"n",
"f.nextInt()",
"f.nextInt",
"f",
"int[] arr = new int[n];",
"arr",
"new int[n]",
"n",
"for(int i=0;i<n;i++) arr[i] = f.nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"arr[i] = f.nextInt();",
"arr[i] = f.nextInt()",
"arr[i]",
"arr",
"i",
"f.nextInt()",
"f.nextInt",
"f",
"int max = arr[0];",
"max",
"arr[0]",
"arr",
"0",
"long ans = 0;",
"ans",
"0",
"for(int i=1;i<n;i++) {\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}",
"int i=1;",
"int i=1;",
"i",
"1",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}",
"{\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}",
"max = Math.max(max, arr[i])",
"max",
"Math.max(max, arr[i])",
"Math.max",
"Math",
"max",
"arr[i]",
"arr",
"i",
"ans += max - arr[i]",
"ans",
"max - arr[i]",
"max",
"arr[i]",
"arr",
"i",
"out.println(ans)",
"out.println",
"out",
"ans",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"static class FastReader {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st;\n\n\t\tString next() {\n\t\t\twhile(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}",
"FastReader",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"StringTokenizer st;",
"st",
"String next() {\n\t\t\twhile(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"next",
"{\n\t\t\twhile(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}",
"while(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}",
"st == null || !st.hasMoreElements()",
"st == null",
"st",
"null",
"!st.hasMoreElements()",
"st.hasMoreElements()",
"st.hasMoreElements",
"st",
"{\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}",
"try {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"IOException e",
"{\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t}",
"st = new StringTokenizer(br.readLine())",
"st",
"new StringTokenizer(br.readLine())",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"String nextLine() {\n\t\t\tString str = \"\";\n\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}",
"nextLine",
"{\n\t\t\tString str = \"\";\n\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}",
"String str = \"\";",
"str",
"\"\"",
"try {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"IOException e",
"{\n\t\t\t\te.printStackTrace();\n\t\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\t\tstr = br.readLine();\n\t\t\t}",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"return str;",
"str",
"int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"nextInt",
"{\n\t\t\treturn Integer.parseInt(next());\n\t\t}",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"nextDouble",
"{\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"long nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"nextLong",
"{\n\t\t\treturn Long.parseLong(next());\n\t\t}",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"public class Main {\n\tstatic FastReader f = new FastReader();\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\n\tpublic static void main(String[] args) {\n\t\tint n = f.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++) arr[i] = f.nextInt();\n\t\tint max = arr[0];\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\t\t\n\n\tstatic class FastReader {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st;\n\n\t\tString next() {\n\t\t\twhile(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n}",
"public class Main {\n\tstatic FastReader f = new FastReader();\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\n\tpublic static void main(String[] args) {\n\t\tint n = f.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor(int i=0;i<n;i++) arr[i] = f.nextInt();\n\t\tint max = arr[0];\n\t\tlong ans = 0;\n\t\tfor(int i=1;i<n;i++) {\n\t\t\tmax = Math.max(max, arr[i]);\n\t\t\tans += max - arr[i];\n\t\t}\n\t\tout.println(ans);\n\t\tout.close();\n\t}\n\t\t\n\n\tstatic class FastReader {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st;\n\n\t\tString next() {\n\t\t\twhile(st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch(IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n}",
"Main"
]
| import java.util.*;
import java.io.*;
public class Main {
static FastReader f = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) {
int n = f.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++) arr[i] = f.nextInt();
int max = arr[0];
long ans = 0;
for(int i=1;i<n;i++) {
max = Math.max(max, arr[i]);
ans += max - arr[i];
}
out.println(ans);
out.close();
}
static class FastReader {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
String next() {
while(st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch(IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch(IOException e) {
e.printStackTrace();
}
return str;
}
int nextInt() {
return Integer.parseInt(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.