akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

typedef long double ldouble;

const ll MAXN = 1000001;

int n, sum, h[101];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> h[i];
    }
    sum += h[1];
    for(int i = 2; i <= n; i++){
        if(h[i] > h[i - 1]) sum += h[i] - h[i - 1];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;

template<typename T>
struct edge {
    int src, to;
    T cost;

    edge() {}
    edge(int src, int to, T cost): src(src), to(to), cost(cost) {}
};

template<typename T>
using Graph = vector<vector<edge<T>>>;

template<typename T>
struct LowLink {
    const int inf = 1000000000;
    int sz;
    std::vector<int> pre, low;
    std::vector<bool> sel;
    std::vector<std::pair<int, int>> bridge;
    std::vector<int> articulation;

    LowLink(const Graph<T> &g) {
        sz = g.size();
        pre.resize(sz, inf);
        low.resize(sz, inf);
        sel.resize(sz, false);
        int cnt = 0;
        dfs(g, 0, -1, cnt);
    }

    void dfs(const Graph<T> &g, int now, int prev, int &cnt) {
        if(pre[now] != inf) {
            low[prev] = min(low[prev], pre[now]);
            return;
        }
        pre[now] = cnt;
        low[now] = cnt;
        cnt++;
        for(int i=0;i<(int)(g[now].size());++i) {
            int nxt = g[now][i].to;
            //if g is an undirected graph
            if(nxt == prev) continue;
            dfs(g, nxt, now, cnt);
        }
        if(prev != -1) low[prev] = min(low[prev], low[now]);
        if(prev != -1 && pre[prev] < low[now]) {
            bridge.emplace_back(make_pair(prev, now));
        }
    }

    void get_articulation(const Graph<T> &g, int now, int prev) {
        sel[now] = true;
        int art = 0;
        for(int i=0;i<(int)(g[now].size());++i) {
            int nxt = g[now][i].to;
            //cout << now << ":" << nxt << endl;
            if(sel[nxt]) continue;
            // if g is an undirected graph
            if(nxt == prev) continue;
            if(now == 0 || pre[now] <= low[nxt]) art++;
            get_articulation(g, nxt, now);
        }
        if((now == 0 && art >= 2) || (now != 0 && art >= 1)) articulation.push_back(now);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    int n, m; cin >> n >> m;
    Graph<int> g(n);
    REP(i, m) {
        int u, v; cin >> u >> v;
        g[u].push_back(edge<int>(u, v, 1));
        g[v].push_back(edge<int>(v, u, 1));
    }

    LowLink<int> link(g);
    // link.get_articulation(g, 0, -1);
    
/*     cout << "low" << endl;
    for(const auto &e: link.low) {
        cout << e << endl;
    }
    cout << "pre" << endl;
    for(const auto &e: link.pre) {
        cout << e << endl;
    }
    cout << "art" << endl; */

    for(auto &e: link.bridge) {
        if(e.first > e.second) swap(e.first, e.second);
    }
    sort(link.bridge.begin(), link.bridge.end());
    for(const auto &e: link.bridge) {
        cout << e.first << " " << e.second << endl;
    }
}





Measured memory_bytes: 5804
#include <bits/stdc++.h>

using namespace std;

int main(){
		int n;
		cin>>n;
		vector<int> p(100);
		for(int i = 1; i<10; i++){
			for(int j = i; j<10; j++){
				p[i*j] = 1;
				}
			}
		if(p[n]==1)cout<<"Yes";
		else cout<<"No";	
	
		return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {

            // ABC079C
            var ABCD = Console.ReadLine().ToCharArray().Select(x => int.Parse(x.ToString())).ToArray();

            // ３ビット分の総当たりを実施したい
            for (int i = 0; i < (1 << 3); i++)
            {

                long calc = ABCD[0];
                string str = ABCD[0].ToString();
                for (int j = 0; j < 3; j++)
                {
                    if ((i & (1 << j)) != 0)
                    {
                        calc += ABCD[j + 1];
                        str += "+" + ABCD[j + 1].ToString();
                    }
                    else
                    {
                        calc -= ABCD[j + 1];
                        str += "-" + ABCD[j + 1].ToString();
                    }
                }

                if (calc == 7)
                {
                    Console.WriteLine(str + "=7");
                    return;
                }
            }






            Console.ReadKey();
        }



        #region MyRegion

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        /// <summary>
        /// 空白区切の数値を取得する
        /// </summary>
        /// <returns>The read split int.</returns>
        public static int[] ReadSplitInt()
        {
            return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        /// <summary>
        /// 空白区切の数値を取得
        /// </summary>
        /// <returns>The read split long.</returns>
        public static long[] ReadSplitLong()
        {
            return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }


        public static int[][] ReadSplitIntLines(int n)
        {
            return Enumerable.Range(0, n).Select(x => ReadSplitInt()).ToArray();
        }

        public static long[][] ReadSplitLongLines(int n)
        {
            return Enumerable.Range(0, n).Select(x => ReadSplitLong()).ToArray();
        }

        public static long[][] ReadSplitLongLines(long n)
        {
            var ret = new List<long[]>();
            for (long i = 0; i < n; i++)
            {
                ret.Add(ReadSplitLong().ToArray());
            }

            return ret.ToArray();
        }

        #endregion

    }
}


Measured memory_bytes: 11348
import sys

n = int(input())
Tn = list(map(int, sys.stdin.readline().rstrip().split()))
m = int(input())
px = [[0,0] for i in range(m)]
for i in range(m):
  px[i] = list(map(int, input().split()))

sm = sum(Tn)
for i in range(m):
  print(sm-Tn[px[i][0]-1]+px[i][1])


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


const double PI=3.141592653589;

ll N ;
vector<pair<ll,ll> >xy;


// inp1,inp2
ld calangle(pair<ll,ll> inp){
    ld angle = (ld)((inp.first)) /  sqrt((ld)(inp.first*inp.first + inp.second*inp.second));
    angle = acos(angle);
    if(inp.second < 0) angle = 2.0 * PI - angle;
    return angle;
}

bool func(pair<ll,ll> a, pair<ll,ll> b){
    return calangle(a) <= calangle(b);
}

ld cal(ll a, ll b){
    pair<ll, ll> ans = mp(0,0);
    
    for(ll i = a; i <= b ; i ++){
        ans.first += xy[i].first;
        ans.second += xy[i].second;
    }
    
    ld ret = sqrt((ld)(ans.first * ans.first + ans.second * ans.second));
    
    return ret;
    
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin >> N ;
    rep(i, N){
        ll x,y;
        cin >> x >> y;
        xy.pb(mp(x,y));
    }
    sort(all(xy), func);
    
    rep(i, N){
        xy.pb(xy[i]);
    }
    
    //    cerr << "-------------------" << endl;
    //    rep(i, xy.size()){
    //        cerr << xy[i].first << " " << xy[i].second << "::" << calangle(xy[i])<< endl;
    //    }
    //    cerr << "-------------------" << endl;
    
    ld ans = 0.0L;
    
    for(int i = 0; i < xy.size(); i++){
        for(int j = i; j < xy.size() and (j-i) < N; j++){
            ans = max(ans, cal(i,j));
        }
    }
    
    cout << fixed << setprecision(48) << ans << endl;
    return 0;
}




Measured memory_bytes: 384
#include <iostream>
#define inf 1e9

using namespace std;

int N;
int t[20][20];
int dp[1<<16];
int cost[1<<16][16];

int main(void)
{
  while(1){
    cin >> N;
    if(N == 0) break;

    for(int i = 0; i < N; i++){
      for(int j = 0; j < N+1; j++){
        cin >> t[i][j];
      }
    }

    int S = 1 << N;
    for(int i = 0; i < S; i++) dp[i] = inf;
    dp[0] = 0;

    for(int i = 0; i < S; i++){
      for(int j = 0; j < N; j++){
        int c = t[j][0];
        for(int k = 1; k <= N; k++){
          if(i & (1<<(k-1))){
            c = min(c, t[j][k]);
          }
        }
        cost[i][j] = c;
      }
    }

    for(int i = 0; i < S; i++){
        for(int k = 0; k < N; k++){
          if(i & (1 << k)) continue;
          dp[i | (1<<k)] = min(dp[i | (1<<k)], dp[i] + cost[i][k]);
        }
    }

    cout << dp[S-1] << endl;
  }

  return 0;
}



Measured memory_bytes: 7448
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  string S; cin>>S;
  int count=0;
  vi A(N+1),B(N+1);
  rep(i,0,N){
    A[i+1]=A[i];
    if(S[i]=='#') A[i+1]++;
  }
  REP(i,1,N){
    B[i]=B[i-1];
    if(S[N-i]=='.') B[i]++;
  }
  int ans=A[0]+B[N];
  REP(i,1,N){
    ans=min(ans,A[i]+B[N-i]);
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define ll long long

using namespace std;
char mat[605][605];
int n;

bool check(int a, int b) {
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (mat[i + a][j + b] != mat[j + a][i + b]) return false;
    return true;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            char c;
            cin >> c;
            mat[i][j] = mat[i + n][j] = mat[i][j + n] = mat[i + n][j + n] = c;
        }
    }
    int a = 0, b = 0;
    int ans = 0;
    for (a = 0; a < n; ++a) {
        if (check(a, b)) ans += n - a;
    }
    a = 0;
    for (b = 1; b < n; ++b) {
        if (check(a, b)) ans += n - b;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc148
{
    class Program
    {
        static void Main(string[] args)
        {
           // Console.SetIn(new StreamReader("input.txt"));
            solve_abc148A();
        }
        public static void solve_abc148C()
        {

        }

        public static void solve_abc148B()
        {

        }

        public static void solve_abc148A()
        {
            int a  = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());

            if ((a == 1 && b == 2) || (a == 2 &&  b == 1))
            {
                Console.WriteLine(3);
            }
            else if ((a == 1 && b == 3) || (a == 3 && b == 1))
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(1);
            }


        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

class dice{
    private:
    int s[6];
    int top;
    int bottom;
    int r_side;
    int l_side;
    int face;
    int rev;

    public:
    dice(){
        top = 0;
        bottom = 5;
        r_side = 2;
        l_side = 3;
        face = 1;
        rev = 4;
        s[0] = 1;
        s[1] = 2;
        s[2] = 3;
        s[3] = 4;
        s[4] = 5;
        s[5] = 6;
    }

    dice(int a[5]){
        top = 0;
        bottom = 5;
        r_side = 2;
        l_side = 3;
        face = 1;
        rev = 4;
        REP(i, 6) s[i] = a[i];
    }

    dice(int x, int y, int z, int u, int v, int w){
        top = 0;
        bottom = 5;
        r_side = 2;
        l_side = 3;
        face = 1;
        rev = 4;
        s[0] = x;
        s[1] = y;
        s[2] = z;
        s[3] = u;
        s[4] = v;
        s[5] = w;
    }

    int get_top() {
        return s[top];
    }

    int get_bottom(){
        return s[bottom];
    }

    int get_r_side(){
        return s[r_side];
    }

    int get_l_side(){
        return s[l_side];
    }

    int get_face(){
        return s[face];
    }

    int get_rev(){
        return s[rev];
    }

    int set_top(int i) {
        top = i;
        bottom = 5 - top;
        r_side = (i+1)%5;
        l_side = 5 - r_side;
        face = (i+2)%5;
        rev = 5 - face;
        return s[top];
    }

    int rotate_r(int i) {
        while(i<0)
            i+=4;
        i %= 4;
        REP(j, i){
            int temp = face;
            face = r_side;
            r_side = rev;
            rev = l_side;
            l_side = temp;
        }
        return s[top];
    }

    int roll_r(int i) {
        while(i<0)
            i+=4;
        i %= 4;
        REP(j, i){
            int temp = top;
            top = l_side;
            l_side = bottom;
            bottom = r_side;
            r_side = temp;
        }
        return s[top];
    }

    int roll_f(int i){
        while(i<0)
            i+=4;
        i %= 4;
        REP(j, i){
            int temp = top;
            top = face;
            face = bottom;
            bottom = rev;
            rev = temp;
        }
        return s[top];
    }

};


int main() {
    int in[6];
    REP(i, 6) cin >> in[i];
    dice d = dice(in);
    string roll;
    cin >> roll;
    while(roll.size() != 0){
        string order = roll.substr(0, 1);
        if(order == "E")
            d.roll_r(1);
        else if(order == "S")
            d.roll_f(-1);
        else if(order == "N")
            d.roll_f(1);
        else if(order == "W")
            d.roll_r(-1);
        roll = roll.substr(1);
    }
    cout << d.get_top() << endl;
    return 0;
}

Measured memory_bytes: 1216
N, K = map(int, input().split())
A = list(map(int, input().split()))
inf = 10**9 + 7

tmp = 0
for i in range(0, N-1):
    for j in range(i+1, N):
        if A[i] > A[j]:
            tmp += 1

#print(tmp )

tmp%= inf
ans = (K+1)*K//2 % inf
ans = ans * tmp  
ans %= inf

#print(ans)
x = len(list(set(A)))
#print(x)

a = tmp * K % inf
b = (x*(x-1)//2) % inf
c = (K*(K-1)//2) % inf
d = a + b * c
e = d% inf
#print(e)

#print(A * K)

w = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            w += 1
#print(w)

a = tmp * K % inf
b = w % inf
c = (K*(K-1)//2) % inf
d = a + b * c
e = d% inf
print(e)

Measured memory_bytes: 3188
M;X[100][4],Y[100][4],P[100];long long C(o,i,a,j,b,k){return (X[a][j]-X[o][i])*(Y[b][k]-Y[o][i])-(Y[a][j]-Y[o][i])*(X[b][k]-X[o][i]);}PL(a,i,b,j){int i2=(i+1)%4;return hypot(X[a][i]-X[b][j],Y[a][i]-Y[b][j])+hypot(X[a][i2]-X[b][j],Y[a][i2]-Y[b][j])<hypot(X[a][i]-X[a][i2],Y[a][i]-Y[a][i2])+1e-9;}CL(a,i,b,j){int i2=(i+1)%4,j2=(j+1)%4;return PL(a,i,b,j)||PL(a,i,b,j2)||PL(b,j,a,i)||PL(b,j,a,i2)||C(a,i,a,i2,b,j)*C(a,i,a,i2,b,j2)<0&&C(b,j,b,j2,a,i)*C(b,j,b,j2,a,i2)<0;}II(a,b,i){int j,r=1;for(j=0;j<4;j++)if(C(b,i,a,j,a,(j+1)%4)>0)r=0;return r;}CI(a,b){int i,j;for(i=0;i<4;i++)for(j=0;j<4;j++)if(CL(a,i,b,j))return 1;for(i=0;i<4;i++)if(II(a,b,i)||II(b,a,i))return 1;return 0;}PW(m){int i;P[m]=0;for(i=0;i<M;i++)if(P[i]&&CI(m,i))PW(i);}main(){int N,i,j,c;for(;scanf("%d",&N),N;){for(;N--;){scanf("%d",&M);for(i=0;i<M;i++){for(j=0;j<4;j++)scanf("%d%d",&X[i][j],&Y[i][j]);P[i]=1;}c=0;for(i=0;i<M;i++){if(P[i]){PW(i);c++;}}printf("%d\n",c);}}exit(0);}

Measured memory_bytes: 424
// ACPC_AIZUDAI_DROPOUT
// coder : naan

#include <bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long K;
    cin >> K;
    vector<vector<unsigned long>> magictable{{1, 2, 1}, {2, 0, 0}, {1, 0, 0}};
    auto g = [&magictable](unsigned long N, unsigned long M) -> unsigned long{
        vector<vector<unsigned long>> grundy_table{{2, 2}};
        for(unsigned long i = M, j = 0; i; i >>= 1){
            grundy_table.emplace_back(2);
            grundy_table.back()[i & 1] = magictable[grundy_table[j][~i & 1]][grundy_table[j][0]];
            grundy_table.back()[~i & 1] = magictable[grundy_table[j + 1][i & 1]][grundy_table[j][0]];
            ++j;
        }
        return grundy_table[64 - __builtin_clzl(M / N)][N & 1];
    };
    unsigned long ans{0};
    for(unsigned long _ = 0, n, m; _ < K; ++_){
        cin >> n >> m;
        auto t = g(n, m);
        ans ^= t;
    }
    puts(ans ? "mo3tthi" : "tubuann");
    /*for(unsigned long i = 1; i <= K; ++i){
        vector<unsigned long> v(i);
        v.back() = 0;
        for(unsigned long j = i; --j; ){
            auto t = (j * 2 <= i) ? v[j * 2 - 1] : 100;
            if(min(v[j], t) == 0 && max(v[j], t) == 1)v[j - 1] = 2;
            else if(v[j] * t)v[j - 1] = 0;
            else v[j - 1] = 1;
        }
        for(const auto& j : v)cout << j << " ";cout << endl;
    }*/
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<n;i++)

int abs(int a,int b){
    if(a>b) return a-b;
    else return b-a;
}
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    cout << (abs(x,a)>abs(x,b)?'B':'A') << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <set>
#include <iostream>
using namespace std;

typedef long long ll;

// sortして挿入をO(logN), 中央値を求めるのをO(1)でできるデータ構造
// set (multiset) を二本もって左半分と右半分に分ける
struct MedianList {
  const ll INF = 10e10;
  multiset<ll> left, right;

  double median() { 
    ll l = *(--left.end());
    ll r = *right.begin();
    if (left.size() > right.size()) return l;
    else if (left.size() < right.size()) return r;
    // left.size() == right.size()
    return (l+r)/2;
  }

  ll getLeft() { 
    auto it = left.end();
    --it;
    return *it;
  }
  ll getRight() { 
    auto it = right.begin();
    return *it;
  }

  void insert(ll x) { 
    if (right.size() == 0) {
      left.insert(x);
    }
    else {
      ll r = getRight();
      if (x < r) left.insert(x);
      else right.insert(x);
    }
    int nl = left.size();
    int nr = right.size();
    while (nl-nr > 1) {
      auto it = left.end();
      --it;
      right.insert(*it);
      left.erase(it);
      nl = left.size();
      nr = right.size();
    }
    while (nr-nl > 1) {
      auto it = right.begin();
      left.insert(*it);
      right.erase(it);
      nl = left.size();
      nr = right.size();
    }
    // cerr << "[l]";
    // for (auto it = left.begin(); it != left.end(); ++it) {
    //   cerr << " " << (*it);
    // }
    // cerr << endl;
  }
};

int main() {
  int q;
  cin >> q;
  MedianList ml;
  int n = 0;
  ll suma = 0;
  ll sumb = 0;
  for (int i = 0; i < q; ++i) {
    int type;
    cin >> type;
    if (type == 1) {
      ll a, b;
      cin >> a >> b;
      sumb += b;
      if (ml.left.size() > 0) {
        ll l = ml.getLeft();
        ll r = ml.getRight();
        if (a < l) { suma += l-a; }
        if (a > r) { suma += a-r; }
      }
      ml.insert(a);
      ml.insert(a);
      // cerr << a << " " << b << " " << suma << endl;
    }
    else {
      cout << ml.getLeft() << " " << suma+sumb << endl;
      // 答えを出力する
    }
  }
}



Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

void solve(long N, vector<long> A) {
  vector<long> count(N, 0);
  rep(i, N)
    count[A[i] - 1]++;

  ll total = accumulate(count.cbegin(), count.cend(), 0LL, [](long a, long i){return a + (i * (i - 1) / 2);});

  rep(i, N) {
    cout << total - (count[A[i] - 1]) + 1 << endl;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<long> A(N);
  for(long i = 0 ; i < N ; i++){
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const int MAXN = 60;

int n;
double A[ MAXN ];

int main()
{
	cin >> n;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
	}
	sort( A, A + n );
	reverse( A, A + n );
	DFOR( i, n - 1, 1 )
	{
		A[ i - 1 ] = ( A[ i ] + A[ i - 1 ] ) / 2;
	}
	
	cout << A[ 0 ] << "\n";
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
int n,a[222222];
LL ans,INVs[200010],fac[200010],inv[200010],INV[200010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
int main(){
	fac[0]=1;
	FOR(i,1,100000) fac[i]=fac[i-1]*i%MO;
	FOR(i,1,100000) INV[i]=pw(i,MO-2);
	FOR(i,1,100000) INVs[i]=(INVs[i-1]+INV[i])%MO;
	cin>>n;
	FOR(i,1,n) getint(a[i]);
	FOR(i,1,n-1) a[i]=a[i+1]-a[i];
	FOR(i,1,n-1){
		(ans+=INVs[i]*a[i])%=MO;
	}
	ans=ans*fac[n-1]%MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B;
  char c;
  cin >> A >> c >> B;

  // ここにプログラムを追記
  if( c == '+'){
    cout << A + B <<endl;
  }else{
    cout << A - B <<endl;
  }
}
  



Measured memory_bytes: 256
no=int(input())
s=list(map(int,input().split()))
a=[0]
a.append(abs(s[1]-s[0]))
for i in range(2,no):
    a.append(min(abs((s[i]-s[i-1]))+a[i-1],abs((s[i]-s[i-2]))+a[i-2]))
print(a[-1])

Measured memory_bytes: 13928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();

		long x = Math.min(b-1, n);

		System.out.println(((a * x) / b) - (a * (x / b))) ;
	}
}

Measured memory_bytes: 27084
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int i, ans = 0, cnt = 0;
    for (i = 0; i < n; i++) {
        while(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
            i++;
        }
        ans = max(ans, cnt);
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i32; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut sum = 0;
    let mut dv = vec![0i32; n + 2];
    for i in 0..n + 1 {
        let d = (if i == n { 0 } else { av[i] } - if i == 0 { 0 } else { av[i - 1] }).abs();
        sum += d;
        dv[i + 1] = d;
    }
    for i in 0..n {
        println!(
            "{}",
            sum - (dv[i + 1] + dv[i + 2])
                + (if i == n - 1 { 0 } else { av[i + 1] } - if i == 0 { 0 } else { av[i - 1] })
                    .abs()
        );
    }
}


Measured memory_bytes: 5244
#include <iostream>
using namespace std;
int main(void){
    int n, q, ans = 0;
    cin >> n >> q;
    for(int i=1;i<=n-1;i++){
        int p;
        cin >> p;
        if(q == i || (i == n-1 && p == i+1)){
            ans++;
        }else{
            q = p;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
Alist=list(map(int,input().split()))
ans=0
for i in range(N):
  if Alist[i]%2==0:
    if Alist[i]%3!=0 and Alist[i]%5!=0:
      ans=1
      break
print("APPROVED"*(1+(-1)*ans)+"DENIED"*ans)

Measured memory_bytes: 9036
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int V = sc.nextInt(); // 頂点数
			int E = sc.nextInt(); // 辺数
			int INF = Integer.MAX_VALUE;

			int[][] dis = new int[V][V];
			for(int i=0; i<V; i++) {
				for(int j=0; j<V; j++) {
					if(i == j) dis[i][j] = 0;
					else dis[i][j] = INF;
				}
			}
			for(int i=0; i<E; i++) {
				int s = sc.nextInt();
				int t = sc.nextInt();
				int d = sc.nextInt();
				dis[s][t] = d;
			}
			boolean negative = false;
			for(int k=0; k<V; k++) {
				for(int i=0; i<V; i++) {
					for(int j=0; j<V; j++) {
						if(dis[i][k] < INF && dis[k][j] < INF) {
							dis[i][j] = Math.min(dis[i][j], dis[i][k]+dis[k][j]);
						}
					}
					if(dis[i][i] < 0)	negative = true;
				}
			}
			
			if(negative) {
				System.out.println("NEGATIVE CYCLE");
				return;
			}
			for(int i=0; i<V; i++) {
				for(int j=0; j<V-1; j++) {
					System.out.print((dis[i][j]>=INF? "INF":dis[i][j]) + " ");
				}
				System.out.println(dis[i][V-1]>=INF? "INF":dis[i][V-1]);
			}
			
		}
	}

}







Measured memory_bytes: 61332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
 
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if(a > b) {
        cout << 0 << endl;
        return 0;
    }
    if(n < 2 && b - a != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll k = b - a;
    ll ans = (n - 2) * k + 1;
    cout << ans << endl;
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
// use std::collections::BinaryHeap;

fn main() {
  let n = read::<i64>();
  let mut a_vec = vec![];
  let mut total = 0;
  let mut subsc = 0;
  let mut ans = 100000000000;

  for _ in 0..n {
    let a = read::<i64>();
    a_vec.push(a);
    total += a;
  }

  for i in 0..n - 1 {
    subsc += a_vec[i as usize];
    total -= a_vec[i as usize];
    ans = min(ans, (total - subsc).abs());
  }

  println!("{}", ans);
}


Measured memory_bytes: 6524
h,n = map(int,input().split())

dg = 10**5

ba = []
for _ in [0]*n:
    a,b = map(int,input().split())
    if a >= h:
        a = h
    ba.append(b*dg+a)
ba.sort()

d = [10**9]*(h+1)

d[0] = 0

for i in range(1,h+1):
    for e in ba:
        a,b = e%dg,e//dg
        if i<=a:
            if d[i] > b:
                d[i] = b
        else:
            if d[i] > d[i-a]+b:
                d[i] = d[i-a]+b

print(d[-1])

Measured memory_bytes: 41708
import math
from operator import mul
from functools import reduce


n, m, k = map(int, input().split())
mod = 998244353


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, n+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


ans = 0
for i in range(k+1):
    ans += m*cmb(n-1, i, mod)*pow(m-1, n-1-i, mod)%mod
    ans %= mod

print(ans)

Measured memory_bytes: 33212
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

ll gcd(ll a,ll b) {
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}
int main() {
    string S;
    cin>>S;
    string ans="Yes";
    int south=0;
    int north=0;
    int east=0;
    int west=0;
    for(int i=0;i<S.length();i++) {
        if(S[i]==('S'))south++;
        if(S[i]==('N'))north++;
        if(S[i]==('W'))west++;
        if(S[i]==('E'))east++;
    }
    if(south>0&&north<=0) ans="No";
    if(north>0&&south<=0) ans="No";
    if(east>0&&west<=0) ans="No";
    if(west>0&&east<=0) ans="No";
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
    int n; cin >> n;
    vector<ld> v(n); cin >> v;
    vector<ld> x = v;
    FOR(i, 1, n) {
        REP(j, i) {
            ld dr = v[i] + v[j];
            ld dy = v[i] - v[j];
            ld dx = sqrt(dr * dr - dy * dy);
            x[i] = max(x[i], x[j]+dx);
        }
    }
    ld ans = 0;
    REP(i, n) {
        ans = max(ans, x[i] + v[i]);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;


vector<int> factors(int M){
  vector<int> ans;
  for (int i=1;i*i<=M;i++){
    if (M%i==0){
      ans.push_back(i);
      ans.push_back(M/i);
    }
  }
  return ans;
}


int main(){
  int N, M;cin>>N>>M;
  vector<int> ans=factors(M);
  int res=1;
  int K=ans.size();
  for (int i=0;i<K;i++){
    if (ans[i]<=M/N){
      res=max(res,ans[i]);
    }
  }
  
  cout << res<< endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    int d = log2(n);
    if(n == (1 << d)){
        cout << "No" << endl;
        return 0;
    }
    else cout << "Yes" << endl;

    int r = n % 4;
    if(r == 0){
        FOR(i, 1, n-1){
            cout << i << " " << i+1 << endl;
            cout << i+n << " " << i+n+1 << endl;
        }
        cout << n-1 << " " << n+1 << endl;
        cout << n << " " << n-1 << endl;
        cout << 2*n <<  " " << ((n^(n-1))-1+n) << endl;
        return 0;
    }
    if(r == 1){
        FOR(i, 1, n-2){
            cout << i << " " << i+1 << endl;
            cout << i+n << " " << i+n+1 << endl;
        }
        cout << n-2 << " " << n+1 << endl;
        cout << n-1 << " " << n << endl;
        cout << n << " " << 1 << endl;        
        cout << 1 << " " << 2*n-1 << endl;        
        cout << 2*n-1 << " " << 2*n << endl;
        return 0;
    }
    if(r == 2){
        FOR(i, 1, n-3){
            cout << i << " " << i+1 << endl;
            cout << i+n << " " << i+n+1 << endl;
        }
        cout << n-3 << " " << n+1 << endl; 
        cout << n-1 << " " << n-2 << endl;        
        cout << n << " " << n-2 << endl;        
        cout << n-2 << " " << 2 << endl;        
        cout << 2 << " " << 2*n << endl;        
        cout << 2*n-1 << " " << 3 << endl;        
        cout << 2*n-1 << " " << 2*n-2 << endl;
        return 0;
    }
    if(r == 3){
        FOR(i, 1, n){
            cout << i << " " << i+1 << endl;
            cout << i+n << " " << i+n+1 << endl;
        }
        cout << n << " " << n+1 << endl;
        return 0;
    }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  
  if(N%2 == 0) {
    cout << N << " " << N << " " << N/2 << endl;
    return 0;
  }
  if(N == 3) {
    cout << 2 << " " << 2 << " " << 3 << endl;
    return 0;
  }
  
  for(int h=(int)(N/4)+1; h<3501; h++) 
  for(int n=h; n<3501; n++) 
  for(int w=n; w<3501; w++) {
    if(N*(h*n+n*w+w*h) == 4*h*n*w) {
      cout << h << " " << n << " " << w << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;

int n;
int constexpr maxn = 402;
int a[maxn];
int dp[maxn][maxn];
int s[maxn];

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
}

int rets(int l, int r) {
    return s[r] - s[l - 1];
}

int cost(int l, int r) {
    if(l == r) return 0;
    if(dp[l][r] != -1) return dp[l][r];

    dp[l][r] = numeric_limits<int>::max();
    for(int i = l + 1; i <= r; i++) {
        int x = rets(l, i - 1) + rets(i, r) + cost(l, i - 1) + cost(i, r);
        dp[l][r] = min(dp[l][r], x);
    }
    return dp[l][r];
}

decltype(0) main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    read_input();
    for(int i = 0; i < maxn; i++)
        for(int j = 0; j < maxn; j++) dp[i][j] = -1;

    cout << cost(1, n) << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s.at(i);
  int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  rep(i, h){
    rep(j, w){
      if(s.at(i).at(j) == '#'){
        bool f = false;
        rep(k, 4){
          int ni = i + dy[k], nj = j + dx[k];
          if(nj < 0 || w <= nj || ni < 0 || h <= ni) continue;
          if(s.at(ni).at(nj) == '#') f = true;
        }
        if(f == false){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 212;
const int maxs = 112345;
const int MOD = 1e9 + 7;

int dp[maxn][maxs];
int x, s[maxn], n, ans;

inline int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

inline int mul(int a, int b) {
  return ll(a) * b % MOD;
}

int main() {
  scanf("%d%d", &n, &x);
  FOR(i, 1, n) scanf("%d", s + i);
  sort(s + 1, s + n + 1, greater<>());
  dp[0][x] = 1;
  FOR(i, 1, n) REP(j, x + 1) {
    dp[i][j] = add(dp[i][j], mul(dp[i - 1][j], n - i));
    dp[i][j % s[i]] = add(dp[i][j % s[i]], dp[i - 1][j]);
  }
  REP(i, x + 1) ans = add(ans, mul(dp[n][i], i));
  printf("%d", ans);
}


Measured memory_bytes: 89728
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {
    int X,A,B;
    cin >> X >> A >> B;

    if (A >= B)cout << "delicious" << endl;
    else if(B-A<=X)cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
long long n,m,l,A[123][123],B[123][123],C[123][123];
int main(){
	cin>>n>>m>>l;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>A[i][j];
		}
	}
	for(int j=0;j<m;j++){
		for(int k=0;k<l;k++){
			cin>>B[j][k];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			for(int k=0;k<l;k++){
				C[i][k]+=(A[i][j]*B[j][k]);
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int k=0;k<l;k++){
			if(k==(l-1)){
				cout<<C[i][k];
			}
			else{
				cout<<C[i][k]<<" ";
			}
		}
		cout<<endl;
	}
}



Measured memory_bytes: 3416
// g++ -std=gnu++1y -O2 xxx.cpp

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int K,N; cin>>K>>N;
    vector<int> An(N);
    rep(i,N) cin>>An[i];

    vector<int> dist(N+1);
    rep(i,N-1) dist[i] = An[i+1]-An[i];
    dist[N] = (An[0]) + (K-An[N-1]);
    
    sort(dist.begin(),dist.end());

    cout << accumulate(dist.begin(), prev(dist.end()), 0) << endl;

    return 0;
}

Measured memory_bytes: 1920
A,B,C,X,Y = map(int,input().split())

if X>Y:
    print(min( A*X+B*Y , 2*C*X , 2*C*Y+A*(X-Y)))
else:
    print(min( A*X+B*Y , 2*C*Y , 2*C*X+B*(Y-X)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;

int main() {
 
  int A,B ;
  cin >>A>>B ;
  int c;
  if(B==1){
    cout<< 0 <<endl;
  }else{
   c = (B-A+(A-2))/(A-1);
  cout << c+1 << endl;
  }
}

Measured memory_bytes: 256
import itertools
n, a, b, c =map(int, input().split())
ans = float("inf")
take = [int(input()) for i in range(n)]

for pattern in itertools.product(range(4), repeat=n):
    abc = [0]*3
    mp=0
    for i in range(n):
      if pattern[i]==3:
        continue
      else:
        if abc[pattern[i]] != 0:
          mp+=10
        abc[pattern[i]]+=take[i]
    
    mp+=abs(a-abc[0])
    mp+=abs(b-abc[1])
    mp+=abs(c-abc[2])
    for i in range(3):
      if abc[i]==0:
        mp=float("inf")
        break
    ans = min(ans, mp)
    
print(ans)


Measured memory_bytes: 74596
local H, W = io.read("n","n")
local N = io.read("n")
local A = {}
for i=1,N do
    A[i] = io.read("n")
end
local dir = 1
local i,j = 1,1
local c = 1
local p = {}
for k=1,H*W do
    p[j] = c
    A[c] = A[c] - 1
    if A[c] == 0 then
        c = c + 1
    end
    j = j + dir
    if j > W or j <= 0 then
        print(table.concat(p, " "))
        i = i + 1
        dir = -1 * dir
        j = j + dir
    end
end


Measured memory_bytes: 1144
L,R = map(int,input().split())

left = L % 2019
c = 2019 - left
if L + c <= R:
    ans = 0
else:
    ans = 2020
    right = R % 2019
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            ans = min((i*j)%2019,ans)
print(ans)

    



Measured memory_bytes: 41708
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		for(int i=0; i<S.length(); i++) {
			System.out.print("x");
		}
		System.out.println();

		sc.close();
	}
}

Measured memory_bytes: 21716
N,Y=map(int, input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
  for j in range(N+1-i):
    sum=0
    sum+=10000*i
    sum+=5000*j
    sum+=1000*(N-i-j)
    if Y==sum:
      x=i
      y=j
      z=N-i-j
      break
print(str(x)+' '+str(y)+' '+str(z))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};


bool vis[107][107];
int dis[107][107];

struct nod{
	int x, y, d;
	nod(int x_, int y_, int d_){
		x = x_;
		y = y_;
		d = d_;
	}
};

bool ok(int x, int y, int n, int m){
	return 0 <= x && x < n && 0 <= y && y < m;
}

int shortestPathBinaryMatrix(vector<vector<int>>& g) {
	clr(dis,0);
	int n = (int)g.size();
	int m = (int)g[0].size();
	
	queue<nod> q;
	q.push(nod(0,0,1));
	vis[0][0] = true;
	dis[0][0] = 1;
	while(!q.empty()){
		int x = q.front().x;
		int y = q.front().y;
		int d = q.front().d;
		q.pop();
		for(int k = 0; k < 8; k++){
			int a = x + dx[k];
			int b = y + dy[k];
			if(ok(a,b,n,m) && !vis[a][b] && g[a][b] == 0){
				vis[a][b] = true;
				dis[a][b] = d + 1;
				q.push(nod(a,b,d+1));
			}
		}
	}
	if(dis[n-1][n-1] != 0)
		return dis[n-1][n-1];
    return -1;
}
   

int main()
{	
	
	int n; cin>> n;
	string s; cin>>s;
	int cont = 0;
	for(int i = 0; i < n; i++){
		if(i < n && i + 1 < n && i + 2 < n && s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
			cont += 1;
			i = i + 2;
		}
	}
	cout<<cont;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007


int main(){
    int N; cin >> N;
    bool f = false;
    while(N--){
        int a; cin >> a;
        if(a%2) f = true;
    }
    if(f) cout << "first" << endl;
    else cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll lb = 0, ub = 1e9;
    
    vector<ll> accum(n+1, 0);
    IFOR(i, 1, n)
        accum[i] = accum[i-1] + a[i-1];

    ll ans = 0;
    ll half, sumx, cnt;
    while(ub - lb >= 1){
        half = (lb + ub) / 2;
        sumx = 0;
        cnt = 0;
        REP(i, n){
            int idx = n - i - 1;
            ll rest = half - a[idx];
            auto pos = lower_bound(a.begin(), a.begin()+idx+1, rest);
            int pos_idx = distance(a.begin(), pos);
            if(idx < pos_idx)
                continue;
            sumx += 2*(accum[idx+1] - accum[pos_idx]) + 2*(idx-pos_idx)*a[idx];
            cnt += 2*(idx-pos_idx) + 1;
        }
        if(cnt >= m)
            lb = half;
        else
            ub = half;

        if(ub - lb == 1)
            break;
    }
    ans = sumx - (cnt - m) * lb;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int l = a + b, r = c + d;

  if (l > r) {
    cout << "Left" << endl;
  } else if (l < r) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256