buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
N,*A = $<.read.split.map(&:to_i)
A.sort!
n,s = 1,0
while n<N
s += A[-1]
n += 1
A.pop if n&n-1==0
end
p s
| N,*A = $<.read.split.map(&:to_i)
A.sort!
n,s = 1,0
while n<N
s += A[-1]
n += 1
A.pop if n&1==0
end
p s
| [["-", 3, 4, 0, 752, 0, 738, 31, 738, 31, 22], ["-", 3, 4, 0, 752, 0, 738, 31, 738, 17, 33]] | 4 | 54 |
def main():
n = int(input())
comp = list(map(int, input().split()))
comp.sort(reverse=True)
fin = n - 2
p = comp[0]
for i in range(1, n):
if fin == 1:
p += comp[i+1]
break
elif fin == 0:
break
p += comp[i]*2
fin -= 2
... | def main():
n = int(input())
comp = list(map(int, input().split()))
comp.sort(reverse=True)
fin = n - 2
p = comp[0]
for i in range(1, n):
if fin == 1:
p += comp[i]
break
elif fin == 0:
break
p += comp[i]*2
fin -= 2
pr... | [["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]] | 5 | 104 |
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
ans += A[0]
if n > 2:
ans += sum(A[1:(n+1) // 2]) * 2
if n % 2 == 1:
ans -= A[(n+1) // 2]
print(ans) | n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
ans += A[0]
if n > 2:
# print((n+1) // 2, A[1:(n+1) // 2])
ans += sum(A[1:(n+1) // 2]) * 2
if n % 2 == 1:
ans -= A[(n+1) // 2 - 1]
print(ans) | [["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]] | 5 | 89 |
/******************************************************************************
рассвет.
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ... | /******************************************************************************
рассвет.
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ... | [["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 46]] | 1 | 330 |
#include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define test ... | #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define test ... | [["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]] | 1 | 447 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> vec;
int main() {
ll a, b, c, d, e, i, j, k, l, n, m, x, y, t, p;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a;
vec.push_back(a);
}
sort(vec.rbegin(), vec.rend());
x = vec[0];
a = 1;
b = 0;
for (i = 3; i <= n; i+... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> vec;
int main() {
ll a, b, c, d, e, i, j, k, l, n, m, x, y, t, p;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a;
vec.push_back(a);
}
sort(vec.rbegin(), vec.rend());
x = vec[0];
a = 1;
b = 0;
for (i = 3; i <= n; i+... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]] | 1 | 154 |
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int a[N];
int main() {
long long res;
int n, i;
cin >> n;
for (i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
res = a[n - 1];
if (n % 2 == 0)
for (i = n - 2; i >= n / 2; i--)
res += a[i] * 2;
else {
for (i = ... | #include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int a[N];
int main() {
long long res;
int n, i;
cin >> n;
for (i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
res = a[n - 1];
if (n % 2 == 0)
for (i = n - 2; i >= n / 2; i--)
res += a[i] * 2;
else {
for (i = ... | [["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 162 |
N = int(input())
a = list(map(int,input().split()))
total=0
list.sort(a, reverse=True)
print(a)
if N %2== 0:
for i in range(int(N/2)):
if i == 0:
total += a[i]
else:
total += a[i]*2
else:
for i in range(int((N-1)/2)):
if i == 0:
total += a[i]
else:
total += a[i]*2
total += a[int((N-1)/2)]
print(... | N = int(input())
a = list(map(int,input().split()))
total=0
list.sort(a, reverse=True)
if N %2== 0:
for i in range(int(N/2)):
if i == 0:
total += a[i]
else:
total += a[i]*2
else:
for i in range(int((N-1)/2)):
if i == 0:
total += a[i]
else:
total += a[i]*2
total += a[int((N-1)/2 )]
print(total)
| [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 142 |
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed \
ios_base::sync_with_stdio(0); ... | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed \
ios_base::sync_with_stdio(0); ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 187 |
/*
(1)for binary shift operator always use 'LL' 1LL<<63
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set_pair \
tre... | /*
(1)for binary shift operator always use 'LL' 1LL<<63
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set_pair \
tre... | [["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 257 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll... | [["-", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]] | 1 | 297 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
// int INF = numeric_limits<int>::max();
int main(int, char **) {
int n;
cin >> n;
priority_queue<ll> q;
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
q.push(a);
}
ll ret ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
// int INF = numeric_limits<int>::max();
int main(int, char **) {
int n;
cin >> n;
priority_queue<ll> q;
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
q.push(a);
}
ll ret ... | [["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]] | 1 | 158 |
#include <algorithm>
#include <cstdio>
#define ll long long
using namespace std;
const int MAXN = 200010;
int n, a[MAXN];
ll ans;
int main() {
// freopen("in.in","r",stdin);
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", a + i);
sort(a, a + n);
ans += a[n];
int i = 2, j = n;
while (... | #include <algorithm>
#include <cstdio>
#define ll long long
using namespace std;
const int MAXN = 200010;
int n, a[MAXN];
ll ans;
int main() {
// freopen("in.in","r",stdin);
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", a + i);
sort(a + 1, a + n + 1);
ans += a[n];
int i = 2, j = n;
... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 167 |
n = int(input())
x= [int(x) for x in input().split()]
x.sort(reverse=True)
c = 0
if n%2 == 0:
t = (n-2)//2
print(x[n//2] + sum(x[0:t]) + sum(x[1:t+1]))
if n%2 == 1:
t = (n-1)//2
print(sum(x[0:t]) + sum(x[1:t+1])) | n = int(input())
x= [int(x) for x in input().split()]
x.sort(reverse=True)
c = 0
if n%2 == 0:
t = (n-2)//2
print(x[n//2-1] + sum(x[0:t]) + sum(x[1:t+1]))
#print(x[n//2] ,x[0:t], x[1:t+1] )
if n%2 == 1:
t = (n-1)//2
print(sum(x[0:t]) + sum(x[1:t+1])) | [["+", 0, 657, 31, 657, 31, 206, 206, 657, 17, 33], ["+", 0, 657, 31, 657, 31, 206, 206, 657, 12, 612]] | 5 | 124 |
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ANS = A[0]
for i in range(N-2):
index = i // 2
print(index)
ANS += A[index+1]
print(ANS) | N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ANS = A[0]
for i in range(N-2):
index = i // 2
ANS += A[index+1]
print(ANS) | [["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 70 |
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok ? "Yes" : "No");
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
usin... | #include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok ? "Yes" : "No");
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
usin... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 245 |
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tu... | #include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tu... | [["+", 341, 342, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 341, 342, 0, 16, 31, 16, 31, 23, 0, 25]] | 1 | 386 |
#include <bits/stdc++.h>
#define forr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()), (a.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll LI... | #include <bits/stdc++.h>
#define forr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()), (a.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll LI... | [["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 227 |
import sys
sys.setrecursionlimit(10**9)
def main():
n = int(input())
a = list(map(int, input().split()))
print(a)
a.sort(reverse=True)
ans = 0
for i in range(0, n-1):
now_index = (i+1) // 2
ans += a[now_index]
print(ans)
return
if __name__ == "__main__":
main()
... | import sys
sys.setrecursionlimit(10**9)
def main():
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
for i in range(0, n-1):
now_index = (i+1) // 2
ans += a[now_index]
print(ans)
return
if __name__ == "__main__":
main()
sys.exit(... | [["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 103 |
N = int(input())
a = list(map(int, input().split()))
b = sorted(a)[::-1]
if N == 1:
print(a[0])
elif N == 2:
print(a[0])
elif N > 2 and N % 2 == 0:
print(b[0] + sum(b[1:N//2]) * 2)
elif N > 2 and N % 2 == 1:
print(b[0] + sum(b[1:(N-1)//2]) * 2 + b[-1])
| N = int(input())
a = list(map(int, input().split()))
b = sorted(a)[::-1]
if N == 1:
print(a[0])
elif N == 2:
print(a[0])
elif N > 2 and N % 2 == 0:
print(b[0] + sum(b[1:N // 2]) * 2)
elif N > 2 and N % 2 == 1:
print(b[0] + sum(b[1:(N - 1) // 2]) * 2 + b[(N - 1) // 2])
| [["+", 0, 657, 12, 206, 206, 657, 31, 23, 0, 24], ["+", 12, 206, 206, 657, 31, 23, 0, 657, 31, 22], ["+", 0, 657, 12, 206, 206, 657, 31, 23, 0, 25], ["+", 3, 4, 0, 657, 12, 206, 206, 657, 17, 676], ["+", 3, 4, 0, 657, 12, 206, 206, 657, 12, 612]] | 5 | 135 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using pll = pair<long long, long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.1415926535897932384... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using pll = pair<long long, long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.1415926535897932384... | [["-", 0, 1, 0, 11, 12, 11, 31, 69, 28, 22], ["-", 0, 11, 12, 11, 31, 69, 341, 342, 0, 70], ["-", 0, 11, 12, 11, 31, 69, 341, 342, 0, 73], ["-", 8, 9, 0, 1, 0, 11, 12, 11, 17, 32], ["-", 8, 9, 0, 1, 0, 11, 12, 11, 12, 13]] | 1 | 203 |
import math
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
ans = 0
for i in range(N-1):
a = math.floor(i/2)
ans += A[a]
print(ans) | import math
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
ans = 0
for i in range(1,N):
a = math.floor(i/2)
ans += A[a]
print(ans) | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 68 |
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
a.sort(reverse=1)
print(sum(a[:0--n // 2]) * 2 - max(a) - a[n // 2] * n % 2) | #!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
a.sort(reverse=1)
print(sum(a[:0--n // 2]) * 2 - max(a) - a[n // 2] * (n % 2)) | [["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]] | 5 | 65 |
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define LAR(a, b) ((a) = max((a), (b)))
#define SML(a, b) ((a) = min((a), (b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pai... | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define LAR(a, b) ((a) = max((a), (b)))
#define SML(a, b) ((a) = min((a), (b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pai... | [["-", 36, 36, 0, 30, 0, 43, 39, 344, 141, 78], ["+", 36, 36, 0, 30, 0, 43, 39, 344, 141, 78]] | 1 | 341 |
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
from heapq import *
import json
l=[]
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
values=list(c.values()) #aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key... | from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
from heapq import *
import json
l=[]
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
values=list(c.values()) #aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key... | [["-", 0, 1, 0, 662, 12, 657, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 652, 63, 22]] | 5 | 255 |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
const ll MOD = 1000000007;
const long long INF = 1LL << 60;
const double pi = acos(-1);
int main() {
ll N;
cin >> N;
vector<ll> A(N);
rep(i, N) { cin >> A.at(i); }
sort(A... | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
const ll MOD = 1000000007;
const long long INF = 1LL << 60;
const double pi = acos(-1);
int main() {
ll N;
cin >> N;
vector<ll> A(N);
rep(i, N) { cin >> A.at(i); }
sort(A... | [["-", 15, 339, 51, 16, 12, 16, 12, 16, 17, 33], ["-", 15, 339, 51, 16, 12, 16, 12, 16, 12, 13]] | 1 | 191 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int A[N];
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A, A + N);
long long count = 0;
for (int i = 1; i < N; i++) {
count += A[N - i % 2 - 1];
}
cout << count << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int A[N];
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A, A + N);
long long count = 0;
for (int i = 1; i < N; i++) {
count += A[N - i / 2 - 1];
}
cout << count << endl;
} | [["-", 341, 342, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 341, 342, 0, 16, 31, 16, 12, 16, 17, 85]] | 1 | 98 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const ll INF = 1LL << 60;
const int ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const ll INF = 1LL << 60;
const int ... | [["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 232 |
#include <bits/stdc++.h>
#define f(i, a, b) for (register int i = a; i <= b; ++i)
#define ff(i, a, b) for (register int i = a; i >= b; --i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string,... | #include <bits/stdc++.h>
#define f(i, a, b) for (register int i = a; i <= b; ++i)
#define ff(i, a, b) for (register int i = a; i >= b; --i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string,... | [["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 47]] | 1 | 644 |
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
int main() {
int N;
cin >> N;
vector<ll> a(N);
rep(i, N) cin >> a[i];
sort(all(a), greater<ll>());... | #include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
int main() {
int N;
cin >> N;
vector<ll> a(N);
rep(i, N) cin >> a[i];
sort(all(a), greater<ll>());... | [["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 149 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = (int)2e5 + 7;
int n, a[N];
set<pair<int, int>> s;
void ins(int x, int y) {
if (x > y) {
swap(x, y);
}
s.insert({x, y});
}
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = (int)2e5 + 7;
int n, a[N];
multiset<pair<int, int>> s;
void ins(int x, int y) {
if (x > y) {
swap(x, y);
}
s.insert({x, y}... | [["-", 36, 36, 0, 30, 0, 43, 39, 344, 141, 78], ["+", 36, 36, 0, 30, 0, 43, 39, 344, 141, 78], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 287 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>... | [["-", 51, 218, 8, 9, 0, 37, 0, 16, 17, 47], ["+", 51, 218, 8, 9, 0, 37, 0, 16, 17, 18]] | 1 | 1,380 |
import math
n = int(input())
a = list(map(int,input().split()))
b = sorted(a,reverse=True)
x = math.ceil(len(b)/2)
y = b[:x]
z = sum(y*2)-y[0]
if x%2==1:
print(z-y[-1])
else:
print(z) | import math
n = int(input())
a = list(map(int,input().split()))
b = sorted(a,reverse=True)
x = math.ceil(len(b)/2)
y = b[:x]
z = sum(y*2)-y[0]
if len(b)%2==1:
print(z-y[-1])
else:
print(z) | [["-", 0, 656, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 0, 57, 15, 666, 0, 657, 31, 652, 63, 22], ["+", 15, 666, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 15, 666, 0, 657, 31, 652, 3, 4, 0, 22], ["+", 15, 666, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 93 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(a.rbegin(), a.rend());
ll ans = a[0];
rep(i, (n - 2) / 2) { ans += (ll)a[1 + i] * 2; }
if (n % 2 == 1)... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(a.rbegin(), a.rend());
ll ans = a[0];
rep(i, (n - 2) / 2) { ans += (ll)a[1 + i] * 2; }
if (n % 2 == 1)... | [["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 142 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;
int main() {
map<int, int> mp;
int n;
cin >> n;
vector<int> vec(n);
rep(i, n) cin >> vec[i];
sort(all(vec), greater<int>());
ll... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;
int main() {
multimap<int, int> mp;
int n;
cin >> n;
vector<int> vec(n);
rep(i, n) cin >> vec[i];
sort(all(vec), greater<int>());... | [["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78]] | 1 | 237 |
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ... | #include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ... | [["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]] | 1 | 279 |
import heapq
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
Q=[]
heapq.heapify(Q)
heapq.heappush(Q, (-A[0],-A[0],0))
for i in range(1,N):
B=heapq.heappop(Q)
count+=-B[0]
heapq.heappush(Q, (-A[1],-A[i],B[1]))
heapq.heappush(Q, (-A[2],-A[i],B[2]))
print(count) | import heapq
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
Q=[]
heapq.heapify(Q)
heapq.heappush(Q, (-A[0],-A[0],0))
for i in range(1,N):
B=heapq.heappop(Q)
count+=-B[0]
heapq.heappush(Q, (-A[i],-A[i],B[1]))
heapq.heappush(Q, (-A[i],-A[i],B[2]))
print(count) | [["-", 3, 4, 0, 660, 0, 664, 28, 206, 206, 612], ["+", 3, 4, 0, 660, 0, 664, 28, 206, 206, 22]] | 5 | 149 |
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define rep2(i, n) for (int i = 0; i <= n; i++)
#define repr(i, a, n) for (int i = a; i < n; i++)
#define... | #pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define rep2(i, n) for (int i = 0; i <= n; i++)
#define repr(i, a, n) for (int i = a; i < n; i++)
#define... | [["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 1,048 |
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i, a) for (ll i = 0; i < a; i++)
#define Fo(i, a, n) for (ll i = a; i < n; i++)
using namespace std;
void solve() {
ll n;
cin >> n;
vl arr(n);
fo(i, n) { cin >>... | #include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i, a) for (ll i = 0; i < a; i++)
#define Fo(i, a, n) for (ll i = a; i < n; i++)
using namespace std;
/*
void solve(){
int a,b,k,t=0;
cin>>a>>b>>k;
char arr[a... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 191 |
n = int(input())
ls = list(map(int,input().split()))
ls= sorted(ls,reverse=True)
ans = ls[0]
for i in range(2,n):
ans += ls[i//2+1]
print(ans) | n = int(input())
ls = list(map(int,input().split()))
ls= sorted(ls,reverse=True)
ans = ls[0]
for i in range(2,n):
ans += ls[i//2]
print(ans) | [["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]] | 5 | 65 |
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i).sort.reverse
ans = A[0]
A.shift
(1..(N-2)).reverse_each{|i|
ans += A[(i-1)/2]
}
| N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i).sort.reverse
ans = A[0]
A.shift
(1..(N-2)).reverse_each{|i|
ans += A[(i-1)/2]
}
puts ans
| [["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]] | 4 | 64 |
#include <bits/stdc++.h>
using namespace std;
long ans;
long M, N, K;
long X, Y;
long H, W;
vector<long> A, B, C;
// vector<long> P;
int main(void) {
cin >> N;
A.resize(N);
for (long i = 0; i < N; i++) {
cin >> A[i];
}
sort(A.begin(), A.end(), greater<long>());
if (N > 1) {
ans += A[0];
}
f... | #include <bits/stdc++.h>
using namespace std;
long ans;
long M, N, K;
long X, Y;
long H, W;
vector<long> A, B, C;
// vector<long> P;
int main(void) {
cin >> N;
A.resize(N);
for (long i = 0; i < N; i++) {
cin >> A[i];
}
sort(A.begin(), A.end(), greater<long>());
if (N > 1) {
ans += A[0];
}
f... | [["-", 341, 342, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 31, 22]] | 1 | 153 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt, e) for (ll cnt = 0; cnt < e; cnt++)
#define allsort(X) sort(X.begin(), X.end())
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
const ll INF = INT64_MAX;
ll i, j, k;
int main() {
ll N;
cin >> N;
V A(N);
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt, e) for (ll cnt = 0; cnt < e; cnt++)
#define allsort(X) sort(X.begin(), X.end())
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
const ll INF = INT64_MAX;
ll i, j, k;
int main() {
ll N;
cin >> N;
V A(N);
... | [["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]] | 1 | 202 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
ll a[n], i;
for (i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
ll ans = a[n - 1], k = n - 2, m = 0;
for (i = n - 3; i >= 0; i--) {
if (m < 2) {
ans += a[k];
m++;
} else {
ans +... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
ll a[n], i;
for (i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
ll ans = a[n - 1], k = n - 2, m = 0;
for (i = n - 3; i >= 0; i--) {
if (m < 2) {
ans += a[k];
m++;
} else {
ans +... | [["-", 0, 11, 12, 69, 341, 342, 0, 27, 17, 29], ["+", 0, 11, 12, 69, 341, 342, 0, 27, 17, 68]] | 1 | 138 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>... | [["+", 0, 7, 8, 1, 0, 11, 12, 23, 0, 24], ["+", 0, 7, 8, 1, 0, 11, 12, 23, 0, 25], ["-", 0, 11, 12, 69, 341, 342, 0, 27, 17, 29], ["+", 0, 11, 12, 69, 341, 342, 0, 27, 17, 29]] | 1 | 211 |
#include <algorithm>
#include <algorithm> //sort,二分探索,など
#include <bitset> //固定長bit集合
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー
#include <functional> //sortのgreater
#include <iomanip> //setprecision(浮動小数点の出力の誤差)
#include <iostream> ... | #include <algorithm>
#include <algorithm> //sort,二分探索,など
#include <bitset> //固定長bit集合
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー
#include <functional> //sortのgreater
#include <iomanip> //setprecision(浮動小数点の出力の誤差)
#include <iostream> ... | [["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73]] | 1 | 538 |
#include <bits/stdc++.h>
using namespace std;
#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define pb push_back
#define sz(v) ((li)(v).size())
#define bgn(v) ((v).begin())
#define eend(v) ((v).end())
#define all... | #include <bits/stdc++.h>
using namespace std;
#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define pb push_back
#define sz(v) ((li)(v).size())
#define bgn(v) ((v).begin())
#define eend(v) ((v).end())
#define all... | [["-", 12, 69, 341, 342, 0, 16, 12, 16, 17, 109], ["+", 12, 69, 341, 342, 0, 16, 12, 16, 17, 85]] | 1 | 420 |
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Sum = 0
for i in range(N-1):
if i < 2:
Sum += A[i]
else:
Sum += A[(i+2)//2]
print(Sum) | N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Sum = 0
for i in range(N-1):
if i == 0:
Sum += A[i]
else:
Sum += A[(i+1)//2]
#print(A[(i+1)//2])
print(Sum) | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["-", 12, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["+", 12, 206, 206, 657, 31, 23, 0, 657, 12, 612]] | 5 | 75 |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll a[200100];
int main() {
ll n;
scanf("%lld", &n);
ll i, j;
for (i = 0; i < n; i++)
scanf("%lld", &... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll a[200100];
int main() {
ll n;
scanf("%lld", &n);
ll i, j;
for (i = 0; i < n; i++)
scanf("%lld", &... | [["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 182 |
//
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
tem... | //
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
tem... | [["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 415 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;
int main() {
int n, n_tmp, tmp;
ll ans = 0;
cin >> n;
n_tmp = n;
prior... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;
int main() {
int n, n_tmp, tmp;
ll ans = 0;
cin >> n;
n_tmp = n;
prior... | [["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]] | 1 | 170 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
ll n;
cin >> n;
vector<ll> a(n);
rep(i, n) cin >> a[i]... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
ll n;
cin >> n;
vector<ll> a(n);
rep(i, n) cin >> a[i]... | [["-", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["+", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78]] | 1 | 258 |
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse = True)
a = 0
for i in range(int(n//2+1)):
a += c[i]
if n%2==0:
print(a*2-c[0])
else:
print(a*2-c[0]-c[n//2]) | n = int(input())
c = list(map(int, input().split()))
c.sort(reverse = True)
a = 0
for i in range(int((n+1)//2)):
a += c[i]
if n%2==0:
print(a*2-c[0])
else:
print(a*2-c[0]-c[n//2]) | [["+", 0, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["-", 0, 652, 3, 4, 0, 657, 31, 657, 17, 676], ["-", 0, 652, 3, 4, 0, 657, 31, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 657, 31, 23, 0, 25], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 676], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 95 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int64_t> a(n);
for (auto i = 0; i < n; i++)
cin >> a[i];
sort(a.begin(), a.end(), greater<>());
int64_t ans = a[0];
int index = 1;
for (auto i = 2; i < n; i++) {
ans += a[index];
if (i % 2 == 0)
index+... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int64_t> a(n);
for (auto i = 0; i < n; i++)
cin >> a[i];
sort(a.begin(), a.end(), greater<>());
int64_t ans = a[0];
int index = 1;
for (auto i = 2; i < n; i++) {
ans += a[index];
if (i % 2)
index++;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 126 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll, ll> pl; //
typedef pair<db, db> pd; //
//
typedef vector<int> vi;... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll, ll> pl; //
typedef pair<db, db> pd; //
//
typedef vector<int> vi;... | [["-", 0, 83, 0, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 83, 0, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 14, 8, 9, 0, 9, 0, 43, 0, 35], ["+", 8, 9, 0, 9, 0, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 27, 17, 68]] | 1 | 869 |
n=int(input())
a=list(map(int,input().split()))
aa = sorted(a,reverse=True)
print(aa)
ans=0
if n%2 == 0:
for i in range(n//2):
ans = aa[i]*2+ans
else:
for i in range((n+1)//2):
ans = aa[i]*2+ans
ans = ans - aa[(n-1)//2]
ans = ans - aa[0]
print(ans) | n=int(input())
a=list(map(int,input().split()))
aa = sorted(a,reverse=True)
ans=0
if n%2 == 0:
for i in range(n//2):
ans = aa[i]*2+ans
else:
for i in range((n+1)//2):
ans = aa[i]*2+ans
ans = ans - aa[(n-1)//2]
ans = ans - aa[0]
print(ans)
| [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 121 |
#include <algorithm>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <limits>
#include <... | #include <algorithm>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <limits>
#include <... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 2,076 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stdlib.h>
#include <string>
#include <vector>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;
int main() {
int n;
cin >> n;
vector<int> ar(n);... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stdlib.h>
#include <string>
#include <vector>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;
int main() {
int n;
cin >> n;
vector<int> ar(n);... | [["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 147], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 195 |
# Contest No.: ABC173
# Problem No.: D
# Solver: JEMINI
# Date: 20200705
import sys
import heapq
def main():
n = int(input())
nums = list(map(int, sys.stdin.readline().split()))
nums.sort()
ans = 0
# initial
temp = nums.pop()
ans += temp
n -= 2
for i in range(n /... | # Contest No.: ABC173
# Problem No.: D
# Solver: JEMINI
# Date: 20200705
import sys
import heapq
def main():
n = int(input())
nums = list(map(int, sys.stdin.readline().split()))
nums.sort()
ans = 0
# initial
temp = nums.pop()
ans += temp
n -= 2
for i in range(n /... | [["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]] | 5 | 116 |
n = int(input())
ns = list(map(int, input().split()))
ns = sorted(ns, reverse=True)
if n % 2 == 1:
a = n //2 + 1
print(a)
print(sum(ns[:a]) * 2 - ns[0] - ns[a-1])
else:
a = n // 2
print(sum(ns[:a]) * 2 - ns[0]) | n = int(input())
ns = list(map(int, input().split()))
ns = sorted(ns, reverse=True)
if n % 2 == 1:
a = n //2 + 1
print(sum(ns[:a]) * 2 - ns[0] - ns[a-1])
else:
a = n // 2
print(sum(ns[:a]) * 2 - ns[0]) | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24]] | 5 | 103 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
}
sort(A.begin(), A.end());
reverse(A.begin(), A.end());
int64_t ans = 0;
for (int i = 0; i < (N / 2); i++) {
if (i == 0) {
ans += A.at(i);
} e... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
}
sort(A.begin(), A.end());
reverse(A.begin(), A.end());
int64_t ans = 0;
for (int i = 0; i < (N / 2); i++) {
if (i == 0) {
ans += A.at(i);
} e... | [["-", 12, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["-", 12, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]] | 1 | 175 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout ... | [["-", 0, 16, 12, 23, 0, 16, 31, 16, 17, 85], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 12, 13], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 17, 85], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 12, 13]] | 1 | 179 |
// author: hitch_hiker42;
#include "bits/stdc++.h"
using namespace std;
// solution:
#define int int64_t
#define span(a) begin(a), end(a)
void hike() {
int n;
cin >> n;
vector<int> a(n);
for (int &i : a)
cin >> i;
sort(span(a), greater<int>());
int cost = a.front(), j = 1;
for (int i = n - 2; ~i; i ... | // author: hitch_hiker42;
#include "bits/stdc++.h"
using namespace std;
// solution:
#define int int64_t
#define span(a) begin(a), end(a)
void hike() {
int n;
cin >> n;
vector<int> a(n);
for (int &i : a)
cin >> i;
sort(span(a), greater<int>());
int cost = a.front(), j = 1;
for (int i = n - 2; i > 0;... | [["-", 0, 14, 8, 9, 0, 7, 15, 91, 17, 92], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]] | 1 | 168 |
from collections import defaultdict as dd
import heapq
N = int(input())
a = list(map(int,input().split()))
res = 0
a = sorted(a, reverse=True)
dic=dd(list)
ls = [a[0]]
heapq.heapify(ls)
for val in a[1:]:
tmp = heapq.heappop(ls)
res += tmp
heapq.heappush(ls,val)
heapq.heappush(ls,val)
print(res) | from collections import defaultdict as dd
import heapq
N = int(input())
a = list(map(int,input().split()))
res = 0
a = sorted(a, reverse=True)
dic=dd(list)
ls = [-a[0]]
heapq.heapify(ls)
for val in a[1:]:
tmp = -heapq.heappop(ls)
res += tmp
heapq.heappush(ls,-val)
heapq.heappush(ls,-val)
print(res) | [["+", 0, 1, 0, 662, 12, 634, 0, 664, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 664, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33]] | 5 | 106 |
N = int(input())
A = list(map(int, input().split()))
A_sorted = sorted(A,reverse = True)
import heapq
circle = []
heapq.heappush(circle, -A_sorted[1])
heapq.heappush(circle, -A_sorted[1])
answer = A_sorted[0]
for i in range(2,N):
target = A[i]
popped = heapq.heappop(circle)
answer -= popped
heapq.he... | import heapq
N = int(input())
A = list(map(int, input().split()))
A_sorted = sorted(A,reverse = True)
circle = []
heapq.heappush(circle, -A_sorted[1])
heapq.heappush(circle, -A_sorted[1])
answer = A_sorted[0]
for i in range(2,N):
target = A_sorted[i]
popped = heapq.heappop(circle)
answer -= popped
h... | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["-", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22]] | 5 | 120 |
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1 << 30;
constexpr int mo = 1e9 + 7;
constexpr ll infl = 1ll << 60;
int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> v(n);
for (auto &a : v)
... | #include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1 << 30;
constexpr int mo = 1e9 + 7;
constexpr ll infl = 1ll << 60;
int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> v(n);
for (auto &a : v)
... | [["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["+", 0, 7, 8, 9, 0, 43, 39, 361, 0, 190], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 195 |
n = int(input())
a = list(map(int, input().split()))
list.sort(a, reverse=True)
if n % 2 == 0:
ans = sum(a[: int(n/2)])*2 - a[0]
if n % 2 == 1:
ans = sum(a[: int(n/2 + 0.5)])*2 -a[0] - a[int(n/2 + 0.5)]
print(int(ans)) | n = int(input())
a = list(map(int, input().split()))
list.sort(a, reverse=True)
if n % 2 == 0:
ans = sum(a[: int(n/2)])*2 - a[0]
if n % 2 == 1:
ans = sum(a[: int(n/2 + 0.5)])*2 -a[0] - a[int(n/2 - 0.5)]
print(int(ans)) | [["-", 12, 206, 206, 652, 3, 4, 0, 657, 17, 72], ["+", 12, 206, 206, 652, 3, 4, 0, 657, 17, 33]] | 5 | 114 |
def main():
n = int(input())
a=[int(i) for i in input().split()]
a.sort(reverse = True)
#隙間には2個入る
res = a[0]
tmp = a[1]
k = 1
cnt = 0
for i in range(2,n):
res += tmp
cnt+=1
if(cnt == 2):
k+=1
tmp = a[k]
print(res)
if __name__ == '... | def main():
n = int(input())
a=[int(i) for i in input().split()]
a.sort(reverse = True)
#隙間には2個入る
res = a[0]
tmp = a[1]
k = 1
cnt = 0
for i in range(2,n):
res += tmp
cnt+=1
if(cnt == 2):
k+=1
tmp = a[k]
cnt = 0
print(re... | [["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]] | 5 | 104 |
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
int n, i, ans = 0, t, k;
cin >> n;
int a[n];
for (i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
// for(i=1;i<n;i++)ans+=a[i];
vector<int> v;
ans = a[n - 1];
t = n - 2;
k = n - 2;
while (1) {
if (!t)
... | #include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
int n, i, ans = 0, t, k;
cin >> n;
int a[n];
for (i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
// for(i=1;i<n;i++)ans+=a[i];
vector<int> v;
ans = a[n - 1];
t = n - 2;
k = n - 2;
while (1) {
if (!t)
... | [["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]] | 1 | 142 |
n = gets.to_i
a = gets.split.map(&:to_i)
a.sort!
a.reverse!
if n.even?
puts a.slice(1..((n-2)/2)).sum*2+a[0]
else
puts a.slice(1..((n-3)/2)).sum*2+a[0]+a[(n+1)/2]
end | n = gets.to_i
a = gets.split.map(&:to_i)
a.sort!
a.reverse!
if n.even?
puts a.slice(1..((n-2)/2)).sum*2+a[0]
else
puts a.slice(1..((n-3)/2)).sum*2+a[0]+a[n/2]
end | [["-", 0, 738, 12, 742, 0, 738, 31, 739, 0, 24], ["-", 12, 742, 0, 738, 31, 739, 0, 738, 17, 72], ["-", 12, 742, 0, 738, 31, 739, 0, 738, 12, 612], ["-", 0, 738, 12, 742, 0, 738, 31, 739, 0, 25]] | 4 | 91 |
#include <bits/stdc++.h>
using namespace std;
int read() {
int x;
scanf("%d", &x);
return x;
}
const int maxn = 2e5 + 10;
const int INF = 1e9;
int n, m, K, a[maxn];
int main() {
#ifdef LOCAL
freopen("1.in", "r", stdin);
#endif
n = read();
for (int i = 1; i <= n; ++i)
a[i] = read();
sort(a + 1, a + 1 +... | #include <bits/stdc++.h>
using namespace std;
int read() {
int x;
scanf("%d", &x);
return x;
}
const int maxn = 2e5 + 10;
const int INF = 1e9;
int n, m, K, a[maxn];
int main() {
#ifdef LOCAL
freopen("1.in", "r", stdin);
#endif
n = read();
for (int i = 1; i <= n; ++i)
a[i] = read();
sort(a + 1, a + 1 +... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 193 |
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0
for i in range(n):
if i==0:
ans += 0
elif i == 1:
ans += a[0]
else:
ans += a[i//2 + 1]
print(ans) | n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0
for i in range(n):
if i==0:
ans += 0
elif i == 1:
ans += a[0]
else:
ans += a[i//2]
print(ans) | [["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]] | 5 | 79 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll, ll>
#define tii tuple<ll, ll, ll>
#define all(v) (v).begin(), (v).end()
#define ll long long
#define ull unsigned long l... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll, ll>
#define tii tuple<ll, ll, ll>
#define all(v) (v).begin(), (v).end()
#define ll long long
#define ull unsigned long l... | [["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 222 |
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import heapq
def resolve():
N,=pin()
A=[*pin()]
A.sort(reverse=T... | #!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import heapq
def resolve():
N,=pin()
A=[*pin()]
A.sort(reverse=T... | [["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 169 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N;
vector<ll> cat(N);
for (int i = 0; i < N; i++)
cin >> cat[i];
sort(cat.begin(), cat.end());
reverse(cat.begin(), cat.end());
int fl = 0;
int cp = 1;
ll ans = 0;
for (int i = 1; i < N; i++) {
if (cp == 0) {
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
vector<ll> cat(N);
for (int i = 0; i < N; i++)
cin >> cat[i];
sort(cat.begin(), cat.end());
reverse(cat.begin(), cat.end());
int fl = 0;
int cp = 1;
ll ans = 0;
for (int i = 1; i < N; i++) {
if ... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 152 |
/*** akshaykumar99 ***/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using id_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long MOD = 1e9 + 7;
const long double PI = acos(... | /*** akshaykumar99 ***/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using id_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long MOD = 1e9 + 7;
const long double PI = acos(... | [["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]] | 1 | 249 |
N = int(input())
A = sorted(list(map(int, input().split())))[::-1]
ans = A[0]
if (N-2)%2==0:
for i in range((N-2)//2):
ans+=A[i+1]*2
else:
for i in range((N-2)//2):
ans+=A[i+1]*2
ans+=A[(N-1)//2+1]
print(ans) | N = int(input())
A = sorted(list(map(int, input().split())))[::-1]
ans = A[0]
if (N-2)%2==0:
for i in range((N-2)//2):
ans+=A[i+1]*2
else:
for i in range((N-2)//2):
ans+=A[i+1]*2
ans+=A[(N-2)//2+1]
print(ans)
| [["-", 206, 657, 31, 657, 31, 23, 0, 657, 12, 612], ["+", 206, 657, 31, 657, 31, 23, 0, 657, 12, 612]] | 5 | 119 |
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
ll sum = a[n - 1];
ll x = n - 2;
if (x > 0) {
for... | #include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
ll sum = a[n - 1];
ll x = n - 2;
if (x > 0) {
for... | [["-", 0, 57, 64, 9, 0, 7, 26, 11, 17, 110], ["-", 0, 57, 64, 9, 0, 7, 26, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 26, 27, 17, 68]] | 1 | 178 |
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (long long i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define rrep(i, n) for (long long i = int(n); i > 0; i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbe... | #include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (long long i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define rrep(i, n) for (long long i = int(n); i > 0; i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbe... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]] | 1 | 431 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;
const double pi = 3.14159265358979323846;
const ll mod = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdi... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;
const double pi = 3.14159265358979323846;
const ll mod = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdi... | [["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 200 |
import collections
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
b = collections.Counter(a)
c = list(b.items())
now = 0
tnp = 1
l = 0
l += c[0][1]
if (l>=n-1):
print(c[0][0]*(n-1))
exit()
now = l*c[0][0]
while True:
if (l+c[tnp][1]*2>=n-1):
print(now + (n-l-1)*c[tnp][0])
... | import collections
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
b = collections.Counter(a)
c = list(b.items())
now = 0
tnp = 1
l = 0
l += c[0][1]*2-1
if (l>=n-1):
print(c[0][0]*(n-1))
exit()
now = l*c[0][0]
while True:
if (l+c[tnp][1]*2>=n-1):
print(now + (n-l-1)*c[tnp][... | [["+", 0, 1, 0, 677, 12, 657, 31, 657, 17, 48], ["+", 0, 1, 0, 677, 12, 657, 31, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 677, 12, 657, 17, 33], ["+", 0, 656, 0, 1, 0, 677, 12, 657, 12, 612]] | 5 | 190 |
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
ans = 0
if N%2 == 0:
ans = 2*sum(A[:N//2]) - A[0]
else:
ans = 2*sum(A[:(N//2+1)]) - A[0] - A[(N//2+1)]
print(ans) | N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
ans = 0
if N%2 == 0:
ans = 2*sum(A[:N//2]) - A[0]
else:
ans = 2*sum(A[:(N//2+1)]) - A[0] - A[N//2]
print(ans) | [["-", 0, 662, 12, 657, 12, 206, 206, 23, 0, 24], ["-", 12, 657, 12, 206, 206, 23, 0, 657, 17, 72], ["-", 12, 657, 12, 206, 206, 23, 0, 657, 12, 612], ["-", 0, 662, 12, 657, 12, 206, 206, 23, 0, 25]] | 5 | 103 |
/*==============================================*\
ID: shahidul_brur
Name: Md. Shahidul Islam
Study: CSE, BRUR
Address: Rangpur, Bangladesh
mail: shahidul.cse.brur@gmail.com
FB : fb.com/shahidul.brur
Blog: shahidul-brur.blogspot.com(in Bengali),
shahidul-brur-en.blogspot.com(in English)
... | /*==============================================*\
ID: shahidul_brur
Name: Md. Shahidul Islam
Study: CSE, BRUR
Address: Rangpur, Bangladesh
mail: shahidul.cse.brur@gmail.com
FB : fb.com/shahidul.brur
Blog: shahidul-brur.blogspot.com(in Bengali),
shahidul-brur-en.blogspot.com(in English)
... | [["-", 8, 9, 0, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 9, 0, 1, 0, 27, 17, 68]] | 1 | 418 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 732 |
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(begin(a), end(a));
reverse(begin(a), end(a));
lint ans = 0;
int cur = 1;
... | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(begin(a), end(a));
reverse(begin(a), end(a));
lint ans = 0;
int cur = 1;
... | [["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13]] | 1 | 190 |
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", \
"inline") // Optimization flags
#pragma GCC option("arch=native", "tune=native", "no-zero-upper") // Enable AVX
#pragma GCC target("avx2") // Enable AVX
#include <bits/stdc++.h>
... | #pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", \
"inline") // Optimization flags
#pragma GCC option("arch=native", "tune=native", "no-zero-upper") // Enable AVX
#pragma GCC target("avx2") // Enable AVX
#include <bits/stdc++.h>
... | [["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 435 |
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(a.begin(), a.end(), greater<int>());
ll ans = 0;
rep(i, n - 1)... | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(a.begin(), a.end(), greater<int>());
ll ans = 0;
rep(i, n - 1)... | [["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]] | 1 | 127 |
//
// ~oisín~ C++ Template
//
#include <bits/stdc++.h>
#define MX_N 5001
#define mp make_pair
#define mod7 1000000007
#define modpi 314159
#define PI 3.141592653589793238
#define pb push_back
#define FastIO \
ios_base::sync_with_stdio(false); ... | //
// ~oisín~ C++ Template
//
#include <bits/stdc++.h>
#define MX_N 5001
#define mp make_pair
#define mod7 1000000007
#define modpi 314159
#define PI 3.141592653589793238
#define pb push_back
#define FastIO \
ios_base::sync_with_stdio(false); ... | [["-", 12, 69, 341, 342, 0, 16, 31, 23, 0, 24], ["-", 341, 342, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 341, 342, 0, 16, 31, 23, 0, 16, 12, 13], ["-", 12, 69, 341, 342, 0, 16, 31, 23, 0, 25]] | 1 | 368 |
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];
long ans = 0;
for (int i = 0; i < N; i++) {
A[i] = sc.nextLong();
}
Arrays.sort(A);
int n = N % 2;
int K = N / 2... | 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];
long ans = 0;
for (int i = 0; i < N; i++) {
A[i] = sc.nextLong();
}
Arrays.sort(A);
int n = N % 2;
int K = N / 2... | [["-", 0, 1, 0, 11, 12, 16, 12, 504, 71, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 504, 71, 22]] | 3 | 209 |
bool DBG = false;
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ... | bool DBG = false;
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]] | 1 | 1,232 |
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i, 0, a.size()) cin >> a[i]
#define outputv(a) \
for (... | #include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i, 0, a.size()) cin >> a[i]
#define outputv(a) \
for (... | [["-", 0, 14, 8, 9, 0, 7, 26, 11, 17, 32], ["-", 8, 9, 0, 7, 26, 11, 12, 27, 28, 22]] | 1 | 366 |
# coding: utf-8
def main():
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = A[0]
rest = N-2
i = 1
while rest > 0:
if i == len(A):
break
if rest >= 2:
ans += 2 * A[i]
rest -= 2
else:
... | # coding: utf-8
def main():
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = A[0]
rest = N-2
i = 1
while rest > 0:
if i == len(A):
break
if rest >= 2:
ans += 2 * A[i]
rest -= 2
else:
... | [["+", 0, 52, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 12, 612]] | 5 | 104 |
#include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
#define watch(x)... | #include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
#define watch(x)... | [["-", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 0, 35], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 68]] | 1 | 239 |
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered... | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered... | [["+", 75, 23, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 75, 23, 0, 69, 341, 342, 0, 16, 12, 13]] | 1 | 941 |
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=a[0]
for i in range(2,len(a)):
ans+=(a[(i+1)//2])
print(ans)
| n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=a[0]
for i in range(2,len(a)):
ans+=(a[(i)//2])
print(ans)
| [["-", 0, 206, 206, 657, 31, 23, 0, 657, 17, 72], ["-", 0, 206, 206, 657, 31, 23, 0, 657, 12, 612]] | 5 | 70 |
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n + 1; i++)
int main() {
ll N... | #include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n + 1; i++)
int main() {
ll N... | [["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 198 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ini, n) for (int i = ini; i < n; i++)
#define _rep(i, ini, n) for (int i = ini; i >= n; i--)
#define ToEnd(a) a.begin(), a.end()
uint64_t MOD = 1000000007;
int main() {
int N;
cin >> N;
vector<int64_t> A(N);
rep(n, 0, N) cin >> A.at(n);
sort(ToEnd... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, ini, n) for (int i = ini; i < n; i++)
#define _rep(i, ini, n) for (int i = ini; i >= n; i--)
#define ToEnd(a) a.begin(), a.end()
uint64_t MOD = 1000000007;
int main() {
int N;
cin >> N;
vector<int64_t> A(N);
rep(n, 0, N) cin >> A.at(n);
sort(ToEnd... | [["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]] | 1 | 154 |
n=int(input())
ls=list(map(int,input().split()))
ls.sort(reserved=True)
ans=ls[0]
pls=[ls.pop(0),ls.pop(0)]#入った人を突っ込む
cnt=0#plsの隣使いきりカウント
scnt=0#2人行けるからそこのカウント
for i in ls:
pls.append(i)
ans+=pls[cnt+1]
if scnt==0:
scnt=1
else:
scnt=0
cnt+=1
print(ans) | n=int(input())
ls=list(map(int,input().split()))
ls.sort(reverse=True)
ans=ls[0]
pls=[ls.pop(0),ls.pop(0)]#入った人を突っ込む
cnt=0#plsの隣使いきりカウント
scnt=0#2人行けるからそこのカウント
for i in ls:
pls.append(i)
ans+=pls[cnt+1]
if scnt==0:
scnt=1
else:
scnt=0
cnt+=1
print(ans)
| [["-", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22]] | 5 | 104 |
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)
int main() {
lli n, a;
vector<lli> v;
cin... | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)
int main() {
lli n, a;
vector<lli> v;
cin... | [["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 173 |
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import... | from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import... | [["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 676], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]] | 5 | 198 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.