# 2018 Multi-University Training Contest 2

## Game

``````#include <stdio.h>
int main()
{
for (int n; ~scanf("%d", &n);)
printf("Yes\n");
}
``````

## Swaps and Inversions

``````#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll merge_sort(ll *b, ll *e)
{
if (e - b < 2)
return 0;
ll *m = b + (e - b) / 2, ans = merge_sort(b, m) + merge_sort(m, e);
for (ll *i = b, *j = m; i < m && j < e; ++i)
for (; j < e && *j < *i; ++j)
ans += m - i;
return inplace_merge(b, m, e), ans;
}
ll n, x, y, a[100009];
int main()
{
while (~scanf("%lld%lld%lld", &n, &x, &y))
{
for (int i = 0; i < n; ++i)
scanf("%lld", &a[i]);
printf("%lld\n", merge_sort(a, a + n) * min(x, y));
}
}
``````

## Naive Operations

``````#include<bits/stdc++.h>
using namespace std;
typedef int ll;
int n,q,l,r,b[100009];
struct SegmentTree
{
struct Node
{
};
vector<Node> v;
int LAST,L,R;
SegmentTree(int n):LAST(n),v(2*n+1) {}
Node &lv(int l,int r)
{
return v[l+r|l!=r];
}
void push_down(Node &lc,Node &rc,Node &fa)
{
}
void build(ll b[],int l,int r)
{
if(l<r)
{
int m=l+(r-l)/2;
}
maintain(l,r);
}
void push_up(const Node &lc,const Node &rc,Node &fa)
{
fa.sum=lc.sum+rc.sum;
}
void maintain(int l,int r)
{
if(l<r)
{
int m=l+(r-l)/2;
{
push_down(lv(l,m),lv(m+1,r),lv(l,r));
maintain(l,m),maintain(m+1,r);
}
push_up(lv(l,m),lv(m+1,r),lv(l,r));
return;
}
}
Node ask(int l,int r,ll val=0,bool out=1)
{
else if(L<=l&&r<=R)v[0]=lv(l,r);
else
{
int m=l+(r-l)/2;
}
return v[0];
}
void add(int l,int r,ll val,bool out=1)
{
else
{
int m=l+(r-l)/2;
push_down(lv(l,m),lv(m+1,r),lv(l,r));
else maintain(l,m);
else maintain(m+1,r);
}
maintain(l,r);
}
};
int main()
{
while(~scanf("%d%d",&n,&q))
{
for(int i=1; i<=n; ++i)scanf("%d",&b[i]);
SegmentTree t(n);
t.build(b,1,n);
for(char s[9]; q--;)
{
scanf("%s%d%d",s,&l,&r);