iidai/codenet huggingface dataset:
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

const double PI = acos(-1.0);
int sig(double d) { return fabs(d) < 1e-8 ? 0 : d < 0 ? -1 : 1; }

struct Point {
    double x, y;
    double k;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    void set(double x, double y) {
        this->x = x;
        this->y = y;
    }
    double mod() { return sqrt(x * x + y * y); }
    double mod_pow() { return x * x + y * y; }
    void output() { printf("x = %f, y = %f\n", x, y); }
    bool operator<(const Point &p) const {
        return sig(x - p.x) != 0 ? x < p.x : sig(y - p.y) < 0;
    }
} P[110];
int ch[110];
double ang[110], ans[110];
double dot(Point &o, Point &a, Point &b) {
    return (a.x - o.x) * (b.x - o.x) + (a.y - o.y) * (b.y - o.y);
}

double dot(Point &a, Point &b) { return a.x * b.x + a.y * b.y; }
double cross(Point o, Point a, Point b) {
    return (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y);
}
int btw(Point &x, Point &a, Point &b) { return sig(dot(x, a, b)); }
double dis(Point a, Point b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

double cos(Point o, Point a, Point b) {
    return dot(o, a, b) / dis(o, a) / dis(o, b);
}

int jarvis(Point *p, int n, int *ch) {
    static int d, i, o, s, l, t;
    for (d = i = 0; i < n; i++)
        if (p[i] < p[d]) d = i;
    l = s = *ch = d;
    d = 1;
    do {
        o = l;
        for (i = 0; i < n; i++)
            if ((t = sig(cross(p[o], p[l], p[i]))) > 0 ||
                (t == 0 && btw(p[l], p[o], p[i]) <= 0))
                l = i;
        ch[d++] = l;
    } while (l != s);
    return d - 1;
}

int main() {
    memset(ang, 0, sizeof(ang));
    memset(ans, 0, sizeof(ans));
    int n, xx, yy;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &xx, &yy);
        P[i].set(xx, yy);
    }
    if (n == 2) {
        puts("0.5");
        puts("0.5");
    } else {
        int m = jarvis(P, n, ch);
        double sum = 0;

        if (m == 2) {
            ans[ch[0]] = 0.5;
            ans[ch[1]] = 0.5;
        } else {
            for (int i = 0; i < m; i++) {
                ang[ch[i]] = PI - acos(cos(P[ch[i]], P[ch[(i - 1 + m) % m]],
                                           P[ch[(i + 1) % m]]));
            }
            for (int i = 0; i < n; i++) {
                ans[i] = ang[i] / 2. / PI;
            }
        }
        for (int i = 0; i < n; i++) {
            printf("%.20f\n", ans[i]);
        }
    }
    return 0;
}

Example test case(s):
input: 2
0 0
1 1

output: 0.5
0.5
Language: C++

#include <cstdio>

const int MAXN = 1E5 + 10;

int n, m, Q;
int a[MAXN];
int b[MAXN], id[MAXN];
bool vis[MAXN];
int cnt[MAXN];

int main() {
    scanf("%d%d", &n, &m);
    scanf("%d", &Q);
    for (int i = 1; i <= Q; ++i) scanf("%d", &a[i]);
    for (int k = 0, j = Q; j > 0; --j)
        if (!vis[a[j]]) b[++k] = a[j], vis[a[j]] = true;
    for (int j = m, i = m; i > 0; --i)
        if (!vis[i]) b[j--] = i;
    for (int i = 1; i <= m; ++i) id[b[i]] = i;

    bool flag = true;
    cnt[0] = n;
    for (int i = Q; i > 0; --i) {
        int t = id[a[i]];
        if (cnt[t - 1] > 0) {
            --cnt[t - 1];
            ++cnt[t];
            vis[t] = true;
        } else if (!vis[t]) {
            flag = false;
            break;
        }
    }

    int l;
    for (l = 0; cnt[l] == 0; ++l)
        ;
    for (int i = l + 1; i < m; ++i) flag &= b[i] < b[i + 1];
    puts(flag ? "Yes" : "No");
    return 0;
}

Example test case(s):
input: 2 2
3
2 1 2

output: Yes
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main() {
    int a, b;
    char S;
    while (true) {
        cin >> a >> S >> b;
        if (S == '+') cout << a + b << endl;
        if (S == '-') cout << a - b << endl;
        if (S == '*') cout << a * b << endl;
        if (S == '/') cout << a / b << endl;
        if (S == '?') break;
    }
}

Example test case(s):
input: 1 + 2
56 - 18
13 * 2
100 / 10
27 + 81
0 ? 0

output: 3
38
26
10
108
Language: C++

#include <iostream>
#include <vector>
using namespace std;
void A(void);
void B(void);
void C(void);
void D(void);

int main(void) { B(); }

void B(void) {
    long long int x, sum;
    cin >> x;
    int i;
    sum = 100;
    for (i = 0; sum < x; ++i) {
        sum += sum / 100;
    }
    cout << i << endl;
}

Example test case(s):
input: 103

output: 3
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void) {
    int n, a[100], b[100], sum = 0;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        cin >> b[i];
        if (a[i] - b[i] > 0) {
            sum += a[i] - b[i];
        }
    }
    cout << sum << endl;
}

Example test case(s):
input: 3
10 2 5
6 3 4

output: 5
Language: C++

#include <iostream>

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = h2 * 60 + m2 - (h1 * 60 + m1);

    cout << ans - k << endl;

    return 0;
}

Example test case(s):
input: 10 0 15 0 30

output: 270
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    string s;
    cin >> s;
    for (char i = 'a'; i <= 'z'; i++) {
        int a = 0;
        for (int j = 0; j < s.size(); j++) {
            if (i == s.at(j)) {
                a++;
            }
        }
        if (a == 0) {
            cout << i << endl;
            break;
        }
        if (i == 'z') {
            cout << "None" << endl;
            break;
        }
    }
}

Example test case(s):
input: atcoderregularcontest

output: b
Language: C++

#include <iostream>

using namespace std;

int main() {
    int a;
    cin >> a;
    cout << (a + (a * a) + (a * a * a)) << endl;

    return 0;
}

Example test case(s):
input: 2

output: 14
Language: C++

#include <cmath>
#include <iostream>
using namespace std;

int main() {
    int N = 0;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    int m = A[0];
    int M = A[0];
    for (int i = 0; i < N; i++) {
        if (A[i] < m) m = A[i];
        if (A[i] > M) M = A[i];
    }

    cout << M - m << endl;

    return 0;
}

Example test case(s):
input: 4
1 4 6 3

output: 5
Language: C++

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int L, N;

int main() {
    cin >> N >> L;
    string S[N];
    rep(i, N) cin >> S[i];
    sort(S, S + N);
    rep(i, N) cout << S[i];
    cout << endl;
}

Example test case(s):
input: 3 3
dxx
axx
cxx

output: axxcxxdxx
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int v[26] = {};
    for (int i = 0; i < n; i++) v[s[i] - 'a']++;
    string ans = "Yes";
    for (int i = 0; i < 26; i++) {
        if (v[i] % 2 != 0) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Example test case(s):
input: abaccaba

output: Yes
Language: C++

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

const int MAX_N = 4000;

typedef long long ll;

const ll LINF = 1LL << 60;

ll wis[MAX_N], wsums[MAX_N + 1], dp[MAX_N][MAX_N + 1];
int ks[MAX_N][MAX_N + 1];

int main() {
    int n;
    cin >> n;

    wsums[0] = 0;
    for (int i = 0; i < n; i++) {
        cin >> wis[i];
        wsums[i + 1] = wsums[i] + wis[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) dp[i][j] = LINF, ks[i][j] = -1;
        dp[i][i + 1] = 0;
        ks[i][i + 1] = i;
    }

    for (int l = 2; l <= n; l++)
        for (int i = 0, j = l; j <= n; i++, j++) {
            ll mind = LINF;
            ll wsum = wsums[j] - wsums[i];
            int mink = -1;
            for (int k = ks[i][j - 1]; k <= ks[i + 1][j]; k++) {
                ll d = dp[i][k] + dp[k][j] + wsum;
                if (mind > d) mind = d, mink = k;
            }
            dp[i][j] = mind;
            ks[i][j] = mink;
        }

    printf("%lld\n", dp[0][n]);
    return 0;
}

Example test case(s):
input: 3
1 2 3

output: 9
Language: C++

#include <iostream>
#include <queue>

using namespace std;

struct task {
    string name;
    int time;
};

int main() {
    int n, q;
    int elaps = 0;
    queue<task> Q;

    cin >> n >> q;

    for (int i = 0; i < n; i++) {
        task tmp;
        cin >> tmp.name >> tmp.time;
        Q.push(tmp);
    }

    while (!Q.empty()) {
        task p = Q.front();
        Q.pop();
        if (p.time <= q) {
            elaps += p.time;
            cout << p.name << " " << elaps << endl;
        } else {
            p.time -= q;
            elaps += q;
            Q.push(p);
        }
    }
    return 0;
}

Example test case(s):
input: 5 100
p1 150
p2 80
p3 200
p4 350
p5 20

output: p2 180
p5 400
p1 450
p3 550
p4 800
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
const int maxn = 200000 + 10;
const int INF = int(1e8);
int maps[maxn];
int num[maxn];
int main() {
    int n;
    while (~scanf("%d", &n)) {
        for (int i = 1; i <= n; i++) {
            scanf("%d", &maps[i]);
            num[i] = maps[i];
        }
        sort(maps + 1, maps + n + 1);
        int m = n / 2;
        for (int i = 1; i <= n; i++) {
            if (num[i] <= maps[m])
                printf("%d\n", maps[m + 1]);
            else
                printf("%d\n", maps[m]);
        }
    }
    return 0;
}

Example test case(s):
input: 4
2 4 4 3

output: 4
3
3
4
Language: C++

#include <math.h>
#include <stdio.h>

#include <iostream>
#include <string>

using namespace std;

int main() {
    int a, t = 0, h = 0, lt, lh, tt, hh, l;
    cin >> a;
    string taro, hana;
    for (int i = 0; i < a; ++i) {
        cin >> taro >> hana;
        lt = taro.length();
        lh = hana.length();
        if (lt > lh) {
            l = lt;
        } else {
            l = lh;
        }
        tt = 0;
        hh = 0;

        if (taro > hana) {
            t = t + 3;
        } else if (hana > taro) {
            h = h + 3;
        } else if (hana == taro) {
            h = h + 1;
            t = t + 1;
        }
    }
    cout << t << " " << h << endl;

    return 0;
}

Example test case(s):
input: 3
cat dog
fish fish
lion tiger

output: 1 7
Language: C++

#include <iostream>
#include <string>

using namespace std;

int mul(const string& str, int& idx) {
    int res = str[idx] - '0';
    while (idx + 1 < str.size() && str[idx + 1] == '*') {
        idx += 2;
        res *= str[idx] - '0';
    }
    return res;
}

int add(const string& str, int& idx) {
    int res = mul(str, idx);
    while (idx + 1 < str.size() && str[idx + 1] == '+') {
        idx += 2;
        res += mul(str, idx);
    }
    return res;
}

int bob(const string& str, int& idx) {
    int res = str[idx] - '0';
    while (idx + 1 < str.size()) {
        if (str[idx + 1] == '+')
            res += str[idx + 2] - '0';
        else
            res *= str[idx + 2] - '0';
        idx += 2;
    }
    return res;
}

int main() {
    string s;
    int d;
    while (cin >> s >> d) {
        int idx = 0;
        int a = add(s, idx);
        idx = 0;
        int b = bob(s, idx);
        if (a == d) {
            cout << (b == d ? "U" : "M") << endl;
        } else {
            cout << (b == d ? "L" : "I") << endl;
        }
    }
}

Example test case(s):
input: 1+2*3+4
11

output: M
Language: C++

#include <iostream>
using namespace std;
int main(void) {
    unsigned long n;
    cin >> n;
    bool flg = false;
    if (n < 4) {
        cout << "No" << endl;
    } else {
        for (int i = 0; i <= (n / 4); i++) {
            for (int j = 0; j <= (n / 7); j++) {
                if ((i * 4 + j * 7) == n) {
                    flg = true;
                    break;
                }
            }
            if (flg) break;
        }
        if (flg) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Example test case(s):
input: 11

output: Yes
Language: C++

#include <bitset>
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main() {
    string source = "";
    cin >> source;

    if (source.length() > 10 || source.length() < 1) {
        return -1;
    }

    int max_i = static_cast<int>(pow(2, source.length() - 1));

    double sum = 0;

    for (int i = 0; i < max_i; ++i) {
        bitset<100> plus(i);

        double number = 0;

        string working = source;
        while (plus.any()) {
            int i = 0;
            while (!plus[i]) ++i;
            sum += atof(working.substr(0, i + 1).c_str());
            plus >>= i + 1;
            working = working.substr(i + 1);
        }
        sum += atof(working.c_str());
    }

    cout.precision(0);
    cout << fixed << sum << endl;

    return 0;
}

Example test case(s):
input: 125

output: 176
Language: C++

#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n + 1;

    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0)
            enqueue(u);
        else
            printf("%s %d\n", u.name, elaps);
    }

    return 0;
}

Example test case(s):
input: 5 100
p1 150
p2 80
p3 200
p4 350
p5 20

output: p2 180
p5 400
p1 450
p3 550
p4 800
Language: C++

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    return 0;
}

Example test case(s):
input: 3

output: 180
Language: C++

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a;
    cin >> a;
    int sum = 0;
    int s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = n - 1; i > n - a - 1; i--) {
        sum += s[i];
    }
    cout << sum << endl;
    return 0;
}

Example test case(s):
input: 5 3
1 2 3 4 5

output: 12
Language: C++

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define rp(i, c) rep(i, (c).size())
#define fr(i, c) \
    for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define dbg(x) cerr << #x << " = " << (x) << endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;

bool seg[][7] = {
    {0, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1},
    {1, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0},

    {1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 0, 1}, {0, 1, 0, 0, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 1, 1, 1, 1}};

int main() {
    int n, t;
    bool st[7];
    while (cin >> n, ~n) {
        rep(i, 7) st[i] = 0;
        rep(i, n) {
            cin >> t;
            char ans[8] = {0};
            rep(i, 7) {
                ans[i] = st[i] ^ seg[t][i] ? '1' : '0';
                st[i] = seg[t][i];
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Example test case(s):
input: 3
0
5
1
1
0
-1

output: 0111111
1010010
1101011
0111111
Language: C++

#include <iostream>
#include <map>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, std::vector<long long> T, long long M,
           std::vector<long long> P, std::vector<long long> X) {
    REP(i, M) {
        long long ans = 0;
        REP(j, N) {
            if (j == P[i] - 1)
                ans += X[i];
            else
                ans += T[j];
        }
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    std::vector<long long> T(N);
    REP(i, N) cin >> T[i];
    long long M;
    cin >> M;
    std::vector<long long> P(M);
    std::vector<long long> X(M);
    REP(i, M) cin >> P[i] >> X[i];
    solve(N, std::move(T), M, std::move(P), std::move(X));
    return 0;
}

Example test case(s):
input: 3
2 1 4
2
1 1
2 3

output: 6
9
Language: C++

#include <iostream>

int main() {
    int h, w, hh, ww;
    std::cin >> h >> w >> hh >> ww;
    std::cout << (h - hh) * (w - ww) << '\n';
    return 0;
}

Example test case(s):
input: 3 2
2 1

output: 1
Language: C++

#include <iostream>
using namespace std;
int main(void) {
    long long int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << "\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }
}

Example test case(s):
input: 2 16

output: 9
Language: C++

#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>

using namespace std;

long long a[200000];
int ind_a[200000];
int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        ind_a[a[i] - 1] = i;
    }

    set<int> used_inds;
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        long long left_border;
        long long right_border;
        long long cur_ind = ind_a[i];
        auto left_it = used_inds.lower_bound(cur_ind);
        auto right_it = used_inds.lower_bound(cur_ind + 1);

        if (left_it == used_inds.begin()) {
            left_border = -1;
        } else {
            if (left_it == used_inds.end() || *left_it > cur_ind) {
                left_it--;
            }
            left_border = *left_it;
        }
        if (right_it == used_inds.end()) {
            right_border = N;
        } else {
            right_border = *right_it;
        }
        ans += (cur_ind - left_border) * (right_border - cur_ind) *
               ((long long)i + 1);

        used_inds.insert(cur_ind);
    }

    cout << ans << endl;
    return 0;
}

Example test case(s):
input: 3
2 1 3

output: 9
Language: Go

package main

import (
	"fmt"
	"sort"
)

func main() {
	in := make([]int, 3)
	fmt.Scan(&in[0], &in[1], &in[2])
	sort.Ints(in)

	fmt.Println(in[2]*10 + in[1] + in[0])
}


Example test case(s):
input: 1 5 2

output: 53
Language: Go

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	arr := scanArrayInt()
	a, b := arr[0], arr[1]
	tap := 0
	consent := 1
	for consent < b {
		consent = consent + a - 1
		tap++
	}
	fmt.Println(tap)
}

func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}


Example test case(s):
input: 4 10

output: 3
Language: Go

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	n, q := getInt(), getInt()

	fw := FenwickTree(n)
	for i := 0; i < n; i++ {
		a := getInt()
		fw.Add(i, a)
	}

	for i := 0; i < q; i++ {
		t := getInt()
		if t == 0 {
			p, x := getInt(), getInt()
			fw.Add(p, x)
		} else {
			l, r := getInt(), getInt()
			out(fw.Sum(l, r))
		}

	}

}

type BIT struct {
	n    int
	data []int
}

func FenwickTree(n int) *BIT {
	var ret BIT
	ret.n = n
	ret.data = make([]int, n)
	return &ret
}

func (b *BIT) Add(p, x int) {
	p++
	for p <= b.n {
		b.data[p-1] += x
		p += p & -p
	}
}

func (b *BIT) Sum(l, r int) int {
	return b.sum(r) - b.sum(l)
}

func (b *BIT) sum(r int) int {
	s := 0
	for r > 0 {
		s += b.data[r-1]
		r -= r & -r
	}
	return s
}


Example test case(s):
input: 5 5
1 2 3 4 5
1 0 5
1 2 4
0 3 10
1 0 5
1 0 3

output: 15
7
25
6
Language: Go

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 {
			fmt.Fprint(wr, " ")
		}
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	c := scanInts(n)

	ans := 0
	sort.Ints(c)

	for i := 0; i < n; i++ {
		ans = (ans + (n+1-i)*c[i]%mod) % mod
	}

	fmt.Println(ans * modpow(4, n-1) % mod)
}

const mod = 1000000007

func modpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return res
}


Example test case(s):
input: 1
1000000000

output: 999999993
Language: Go

package main

import "fmt"

func main() {
	var day int
	fmt.Scan(&day)

	switch day {
	case 25:
		fmt.Println("Christmas")
	case 24:
		fmt.Println("Christmas Eve")
	case 23:
		fmt.Println("Christmas Eve Eve")
	case 22:
		fmt.Println("Christmas Eve Eve Eve")
	}
}


Example test case(s):
input: 25

output: Christmas