akhauriyash/Code-Regression huggingface dataset:
// Problem : E - Sequence Sum
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, x, m;
int ans, cnt, sum[N];
int vis[N];

signed main()
{
    //File("");
    n = gi <int> (), x = gi <int> (), m = gi <int> ();
    if (n <= 1000000)
    {
    	int kk = x;
    	for (int i = 1; i <= n; i+=1)
    		ans += kk % m, kk = kk * kk % m;
    	printf("%lld\n", ans);
    	return 0;
    }
    vis[x] = 1;
    int now = x * x % m;
    sum[1] = x, cnt = 1;
    while (!vis[now]) 
    	++cnt, sum[cnt] = sum[cnt - 1] + now, vis[now] = cnt, now = now * now % m;
    int len = cnt + 1 - vis[now], qd = vis[now];
    if (n <= qd)
    {
    	int kk = x;
    	for (int i = 1; i <= n; i+=1)
    		ans += kk % m, kk = kk * kk % m;
    	printf("%lld\n", ans);
    	return 0;
    }
    int tmp = sum[cnt] - sum[qd - 1];
    ans = sum[qd - 1];
    n -= (qd - 1);
    int cs = n / len, ys = n % len;
    //cout << cs << ' ' << ys << endl;
    cout << ans + tmp * cs + sum[qd + ys - 1] - sum[qd - 1] << endl;
    //cout << len << ' ' << qd << endl;
    return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && a != c) || (b == c && a != b) || (a == c && a != b)) {
        cout << "Yes";
    }else {
        cout << "No";
    }
    return 0;
} 

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
def int_(num_str):
    return int(num_str) - 1

N, M = map(int, input().split())
ablist = [tuple(map(int_, input().split())) for _ in range(M)]
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j, ab in enumerate(ablist):
        if i == j:
            continue
        uf.union(*ab)
    if uf.group_count() > 1:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll N; cin >> N;
    string S,T; cin >> S >> T;
    string ans = "";
    rep(i,N){
        ans += S[i];
        ans += T[i];
    }
    print(ans);
    return 0;
}

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

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; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;
const int MOD = 1000000007;
char table [30][30];
int d[100][100];
int bfs(int x,int y);
typedef pair<int , int> P;
int w,h;

int main(){
        cin >> h >> w;

    
    int d[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> table[i][j];
        }
    }

   

    int maxv=0;
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            
            if(table[i][j]!='#' && maxv < bfs(i,j)) maxv = bfs(i,j);
        }
    }

    cout << maxv << endl;
}


int bfs(int x , int y){
    queue<P> que;
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j] = INF;
        }
    }

   

    d[x][y] = 0;//スタート地点の距離=0
    que.push(P(x,y));//スタート地点をキューに入れる

    while(que.size()){
        P p= que.front(); que.pop(); //キューの取り出し
    for(int i=0;i<4;i++){
        int nx = p.first + dx[i];
        int ny = p.second + dy[i];

        if( 0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF && table[nx][ny] != '#'){
            que.push(P(nx,ny));
            d[nx][ny] = d[p.first][p.second] + 1;
        
        }

    }

    }
    int max=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(d[i][j] != INF && max < d[i][j]){
                 max=d[i][j];
                 }
        }
    }

    return max;
}



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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n],s=0LL;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		a[i]-=(long long)i+1LL;
	}
	sort(a,a+n);
	long long b=a[n/2],ans1=0LL,ans2=0LL,ans3=0LL;
	for (int i = 0; i < n; ++i)
	{
		ans1+=abs(a[i]-b);
	}
	for (int i = 0; i < n; ++i)
	{
		ans2+=abs(a[i]-b-1LL);
	}
	for (int i = 0; i < n; ++i)
	{
		ans3+=abs(a[i]-b+1LL);
	}
	cout<<min({ans1,ans2,ans3})<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B;
  cin >> A >> B;
  if (A > 8 or B > 8) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[0] + [-1] * (L+3) for _ in range(N+3)]
dp[0] = [0] * (L+4)

for w in range(L+1):
    for i in range(1, N+1):
        dp[i][w] = max(dp[i-1][w], dp[i-1][w - W[i-1]] + V[i-1]
                       ) if w - W[i-1] >= 0 else dp[i-1][w]
#print(*dp, sep='\n')
print(dp[N][L])


Measured memory_bytes: 142616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;



int main() {
  ll n,z,w;
  cin>>n>>z>>w;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll ans;

  if (n==1){
    ans=abs(w-a[0]);
    cout<<ans;
    return 0;
  }
  else{
  ll last=a[n-1];
  ll last2=a[n-2];

  ll ans1=abs(w-last);
  ll ans2=abs(last-last2);
  ans=max(ans1,ans2);
  cout<<ans;
}
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
#define int long long
const int mod = 1e9 + 7;

const int N = 1e6 + 5;

int n, q, sum[N], total[N], ways;

string s;
bool used[N];
vector<int> vec;

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    cin >> s;
    s = "+" + s;
    for(int i = 1; i <= n; i++) {
        if(s[i] == 'M')
            sum[i] = 1;
        sum[i] += sum[i - 1];
        if(s[i] == 'C')
            total[i] = 1;
        total[i] += total[i - 1];
        if(s[i] == 'D')
            vec.pb(i);
    }
    cin >> q;
    while(q--) {
        int k;
        cin >> k;
        if(vec.size() == 0) {
            cout << "0\n";
            continue;
        }
        ways = 0;
        long long sumb = 0, sumc = 0;
        int l = vec[0], r = l;
        for(int i = 0; i < vec.size(); i++) {
            while(l < vec[i]) {
                if(s[l] == 'C')
                    sumc--;
                if(s[l] == 'M')
                    sumb -= sumc;
                l++;
            }
            while(r - l < k && r <= n) {
                if(s[r] == 'C') {
                    sumb += sum[r] - sum[l - 1];
                    sumc++;
                }
                r++;
            }
            ways += sumb;
            //cout << l << " " << r << " " << sumb << "\n";
        }
        cout << ways << "\n";
    }
}



Measured memory_bytes: 26816
import sys
import itertools
sys.setrecursionlimit(10000)
def resolve():
    N = int(input())
    A1 = list(map(int, input().split(" ")))
    A2 = list(map(int, input().split(" ")))
    maxcnt = 0
    for downpoint in range(N):
        cnt = sum(A1[:downpoint+1]) + sum(A2[downpoint:])
        maxcnt = max(maxcnt, cnt)
    print(maxcnt)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38384
// 2020-08-16 20:54:52
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

using Edge = pair<int, ld>; // to, e
void answer() {
  int n, m;
  cin >> n >> m;
  vector<vector<Edge> > G(n);
  vector<ld> E(n, -1);
  rep(i, m) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    G[s].emplace_back(Edge(t, -1));
  }
  E[n-1] = 0;
  REPCM(i, n-2, 0) {
    ld e = 0;
    for(auto& edge : G[i]) {
      edge.second = E[edge.first] + 1;
      e += edge.second;
    }
    E[i] = e / ld(G[i].size());
  }
  ld ans = E[0];
  REPCM(i, n-2, 0) if(G[i].size() > 1) {
    vector<ld> E2 = E;
    ld maxe = -1;
    for(auto& edge : G[i]) chmax(maxe, edge.second);
    E2[i] = (E[i] * ld(G[i].size()) - maxe) / ld(G[i].size()-1);
    REPCM(j, i-1, 0) {
      ld e = 0;
      for(auto& edge : G[j]) {
        e += E2[edge.first] + 1;
      }
      E2[j] = e / ld(G[j].size());
    }
    chmin(ans, E2[0]);
  }
  cout << fixed << setprecision(10) << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main() {
  int A, B, C, D, L, R;

  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;

  if (L < R) {
    cout << "Right" << endl;
  }

  else if (L == R) {
    cout << "Balanced" << endl;
  }

  else {
    cout << "Left" << endl;
  }
}



Measured memory_bytes: 256
def resolve():
    X, K, D = [int(i) for i in input().split()]
    if abs(X) > K * D:
        print(abs(X) - K * D)
        return
    else:
        if K % 2 == (abs(X) // D) % 2:
            print(abs(abs(X) - D * (abs(X) // D)))
        else:
            print(abs(abs(X) - D * ((abs(X) // D) + 1)))

resolve()


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

int n, m, k, ans=0;
vector<string>a;

int main(){
	cin >> n >> m >> k;
	for (int i=0;i<n;i++){
		string s;
		cin >> s;
		a.push_back(s);
	}
	for (int maskr=0;maskr<(1<<n);maskr++){
		for (int maskc=0;maskc<(1<<m);maskc++){
			vector<string>b=a;
			for (int i=0;i<n;i++){
				if (maskr&(1<<i)){
					for (int j=0;j<m;j++) b[i][j]='R';
				}
			}
			for (int j=0;j<m;j++){
				if (maskc&(1<<j)){
					for (int i=0;i<n;i++) b[i][j]='R';
				}
			}
			int cnt=0;
			for (int i=0;i<n;i++){
				for (int j=0;j<m;j++){
					if (b[i][j]=='#') cnt++;
				}
			}
			if (cnt==k) ans++;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl A(N, 0);
  REP(i, K) {
    ll d;
    cin >> d;
    REP(j, d) {
      ll a;
      cin >> a;
      A[a - 1]++;
    }
  }
  ll ans = 0;
  REP(i, N) if (A[i] == 0) ans++;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int q;
  cin >> q;
  while (q--) {
    int k;
    cin >> k;
    ll ans = 0;
    int l = 0;
    bool flag = true;
    while (s[l] != 'D') {
      l++;
      if (l == n) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      cout << 0 << endl;
      continue;
    }
    int r = l;
    ll m_cnt = 0, c_cnt = 0, add = 0;
    while (r < n && r - l < k) {
      if (s[r] == 'M') {
        m_cnt++;
      }
      if (s[r] == 'C') {
        add += m_cnt;
        c_cnt++;
      }
      r++;
    }
    while (l < n) {
      if (s[l] == 'D') {
        ans += add;
      }
      if (s[l] == 'M') {
        m_cnt--;
        add -= c_cnt;
      }
      if (s[l] == 'C') {
        c_cnt--;
      }
      if (r <= n - 1) {
        if (s[r] == 'M') {
          m_cnt++;
        }
        if (s[r] == 'C') {
          c_cnt++;
          add += m_cnt;
        }
        r++;
      }
      l++;
    }
    cout << ans << endl;
  }
  
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;

ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;

  ll arr[n + 5];
  map<ll, ll> par;
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    par[arr[i]]++;
  }

  for (ll i = 1; i <= m; i++) {
    ll b, c;
    cin >> b >> c;

    while (b) {
      auto it = par.begin();
      if (it->first >= c)
        break;

      if (it->second <= b) {
        b -= it->second;
        par[c] += it->second;
        par.erase(it);
      } else {
        par.begin()->second -= b;
        par[c] += b;
        break;
      }
    }
  }

  ll res = 0;
  for (auto &it : par) {

    res += it.first * it.second;
  }

  cout << res << en;

  return 0;
}

Measured memory_bytes: 7296
//
//  main.cpp
//  test
//
//  Created by hayato-m on 2016/03/16.
//  Copyright ?? 2016??´ Hayato MAKI. All rights reserved.
//

#include <iostream>
#include "algorithm"
using namespace std;



int main() {
    int n;
    cin >> n;
    int R[n];
    int i = 0;
    bool flag = true;
    int c = 0;
    int temp;
    
    
    for (int i = 0; i < n; i++){
        cin >> R[i];
    }
    
    while(flag){
        flag = false;
        for (int j = n-1; j > i; j--){
            if (R[j]<R[j-1]){
                temp = R[j];
                R[j] = R[j-1];
                R[j-1] = temp;
                flag = true;
                c++;
            }
        }
        i++;
    }

    
    for(int j=0; j<n; j++){
        cout << R[j];
        if (j<n-1){
            cout << " ";
        }
    }
    cout << endl << c << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}
LL sq(LL x)
{
    return x * x;
}
LL truth(LL rem, LL i, LL j, LL k)
{
    LL ans = sq(k) + (i + j) * k;
    return rem - ans;
}

LL cal(LL n)
{
    LL root = sqrt(n) + 1;
    LL cnt = 0;
    LL i, j, k, t;
    for (i = 1; i <= root; i++)
    {
        //debug(i);
        for (j = 1; j <= root; j++)
        {

            //debug(j);
            LL till_now = sq(i) + sq(j) + i * j;
            if (till_now > n)
            {
                continue;
            }
            LL rem = n - till_now;
            LL lb = 1, ub = root;
            LL mid, pos = -1;
            //debug(rem);
            LL y = 0;
            while (lb <= ub)
            {
                y++;
                mid = (lb + ub) / 2;
                LL check = truth(rem, i, j, mid);
                // debug(mid);
                // debug(check);
                if (check == 0)
                {
                    //cout<<"found "<<i<<" "<<j<<" "<<mid<<endl;
                    cnt++;
                    break;
                }
                else if (check > 0)
                {
                    lb = mid + 1;
                }
                else
                {
                    ub = mid - 1;
                }
                // if(y==3)
                // {
                //     break;
                // }
            }
        }
        //part;
    }
    return cnt;
}
int main()
{
    fastinput;
    LL n, i, j, k, t, temp, tc;
    cin >> n;
    LL ans = 0;
    for(i=1;i<=n;i++)
    {
        //debug(i);
        LL add=cal(i);
        //debug(i);
       // debug(add);
       // ans+=add;
        //part;
        cout<<add<<endl;

    }
    //cout<<ans<<endl;
    //LL check = cal(11);

    return 0;
}


Measured memory_bytes: 3696
#include <iostream>

#define BLACK 1
#define WHITE 2

using namespace std;

int main(){

	int d[13][3]={
		{1,-1,1},
		{0,-1,1},
		{-1,-1,1},
		{-1,0,1},
		{-1,1,1},
		{0,1,1},
		{-1,1,0},
		{0,1,0},
		{1,1,0},
		{1,0,0},
		{1,0,1},
		{0,0,1},
		{1,1,1},
	};

	int data[10][10][10];
	int height[10][10];

	int n,m,p;

	while(cin>>n>>m>>p){
		if(n==0 && m==0&&p==0)break;

		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					data[i][j][k]=0;
				}
				height[i][j]=0;
			}
		}
		int returnFlag=0;

		for(int i=0;i<p;i++){
			int x,y;
			cin>>x>>y;
			data[x][y][height[x][y]]=i%2+1;
			height[x][y]++;



			if(returnFlag==1)continue;
			for(x=1;x<=n;x++){
				for(y=1;y<=n;y++){
					for(int z=0;z<=height[x][y];z++){
						if(data[x][y][z]==0)continue;
						for(int j=0;j<13;j++){
							int nowX = x;
							int nowY = y;
							int nowZ = z;
							int now = data[x][y][z];
							int cnt=1;
							while(1){
								nowX += d[j][0];
								nowY += d[j][1];
								nowZ += d[j][2];

								if(now == data[nowX][nowY][nowZ]){
									cnt++;
								}
								else{
									break;
								}
							}
							if(cnt>=m){
								if(now==BLACK){
									cout<<"Black "<<i+1<<endl;
								}
								else{
									cout<<"White "<<i+1<<endl;
								}
								returnFlag=1;
								break;
							}
						}
						if(returnFlag==1)break;
					}
					if(returnFlag==1)break;
				}
				if(returnFlag==1)break;
			}
				

		}

		if(returnFlag==0){
			cout<<"Draw"<<endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1168
n,m = map(int, input().split())

ac_count = 0
ac_status = [False]*n
pn_count = 0
wa_count = [0]*n
for i in range(m):
    p,s = input().split()

    if(s == 'AC'):
        if(ac_status[int(p)-1] == False):
            ac_status[int(p)-1] = True
            ac_count = ac_count + 1
            pn_count = pn_count + wa_count[int(p)-1]
    if(s == 'WA'):
        wa_count[int(p)-1] = wa_count[int(p)-1] + 1

print(ac_count, pn_count)

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long int ll;

int N;
vector<int> A;

int main() {
    cin >> N;

	int p = 0;
	int sum = 0;
	for(int i=0; i<N; i++) {
		int x;
		cin >> x;
		A.push_back(x);
		sum += abs(x-p);
		p = x;
	}
	sum += abs(p);

	for(int i=0; i<N; i++) {
		int ans;
		int current = A[i];
		int pre = (i==0 ? 0 : A[i-1]);
		int post = (i==N-1 ? 0 : A[i+1]);

		if ( (current>pre && current<post) ||  (current < pre && current > post) ) {
			ans = sum;
		}else{
			ans = sum - 2 * min(abs(pre-current), abs(post-current));
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 1784
#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    string t;
    int a = 0;

    cin >> s >> t;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) a++;
    }

    cout << a << 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 contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> G(n+1);
  vector<int> miti(n+1, -1);
  vector<int> from(n+1, -1);
  queue<int> que;
  rep(i, m) {
    int a, b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
    // cout << a << " = " << b << endl;
  }
  miti[1] = 0;
  que.push(1);
  while (!que.empty()) {
    int v = que.front();
    // cout << "v : " << v << endl;
    que.pop();

    for(int nv: G[v]) {
      // cout << v << " -> " << nv << endl;
      if (miti[nv] != -1) continue;

      miti[nv] = miti[v] + 1;
      from[nv] = v;
      que.push(nv);
    }
  }
  
  for(int i = 2; i <= n; i++) {
      if (miti[i] == -1) {
          cout << "No";
          return 0;
      }
  }
  cout << "Yes" << endl;
  for(int i = 2; i <= n; i++) {
    // cout << i << ": " << miti[i] << " from " << from[i] << endl;
    cout << from[i] << endl;
  };
}


Measured memory_bytes: 10568
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
ll d1[2] = { 1,-1 };
ll d2[2] = { 1,-1 };
ll d3[2] = { 1,-1 };
int main() {
	int n, m; cin >> n >> m;
	ll x[1000],y[1000],z[1000];
	rep(i, n) {
		cin >> x[i]>>y[i]>>z[i];
	}
	ll ma = 0;
	rep(aa, 2) {
		rep(ab, 2) {
			rep(ac, 2) {
				vector<ll> v;
				rep(i, n) {
					v.push_back(x[i] * d1[aa] + y[i] * d2[ab] + z[i] * d3[ac]);
				}
				sort(v.begin(), v.end(), greater<ll>());
				ll sum = 0;
				rep(i, m) {
					sum += v[i];
				}
				ma = max(ma, sum);
			}
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
int main(){
	int n;
	int a, b;
	int A[101];
	int **arr = NULL;
	scanf("%d", &n);	
	arr = new int*[n];
	for (int i = 0; i < n; i++){
		arr[i] = new int[n];
	}
	for (int i = 0; i < n; i++){		
		scanf("%d%d", &a, &b);
		for (int j = 0; j < b; j++){
			scanf("%d",&A[j]);
			arr[a-1][A[j]-1] = 1;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (j == n - 1){
				if (arr[i][j] == 1){
					printf("1");
				}
				else {
					printf("0");
				}
			}
			else {
				if (arr[i][j] == 1){
					printf("1 ");
				}
				else {
					printf("0 ");
				}
			}
		}
		printf("\n");
	}
	for (int i = 0; i < n; i++){
		delete[](arr[i]);
	}
	delete[](arr);
	return 0;
}


Measured memory_bytes: 2720
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <map>
using namespace std;
int main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	int ans=C-(A-B);
	if(ans<0)
	{
		ans=0;
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
	string S; cin >> S;
	long beki3[100010], mod=1000000007;
	beki3[0]=1;
	for(int i=1; i<100010; ++i) beki3[i]=(beki3[i-1]*3)%mod;
	int A=0, C=0, H=0, AllH=0;
	for(int i=0; i<S.size(); ++i){
	    if(S[i]=='C') ++C;
	    if(S[i]=='?') ++AllH;
	}
	long ans=0;
	for(int i=0; i<S.size(); ++i){
	    if(S[i]=='A') ++A;
	    else if(S[i]=='C') --C;
	    else if(S[i]=='?'){
	        ans=(ans+beki3[AllH-1]*A*C)%mod;
	        if(AllH>1) ans=(ans+beki3[AllH-2]*(H*C+A*(AllH-H-1)))%mod;
	        if(AllH>2) ans=(ans+beki3[AllH-3]*H*(AllH-H-1))%mod;
	        ++H;
	    }
	    else{
	        ans=(ans+beki3[AllH]*A*C)%mod;
	        if(AllH>0) ans=(ans+beki3[AllH-1]*(H*C+A*(AllH-H)))%mod;
	        if(AllH>1) ans=(ans+beki3[AllH-2]*H*(AllH-H))%mod;
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    double d;
    cin>>n>>d;
    ll m=0;
    double k,l;
    double res,r;
    for(ll i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        r=sqrt(pow(a,2) + pow(b,2));
        //cout<<r<<" ";
        if(r<=d)
        {
            m++;
        }
    }
    cout<<m;
}
 

Measured memory_bytes: 3792
#include <iostream>
using namespace std;

int main(void){
    int i;
    int x;
    for(i = 1; i <= 10000; i++){
        cin >> x;
        cout << "Case " << i << ": " << x << endl;
        if(x == 0){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111




	void solve(){


		ini(n);
		int morty[n];
		int tmp = 0;
		FOR(i,0,n){
			in(morty[i]);
			tmp+=morty[i];
		}
		if(tmp%((n*(n+1))/2))return out("NO");
		tmp = tmp/((n*(n+1))/2);
		FOR(i,0,n){
			int tmp1 = morty[(i+1)%n]-morty[i];
			tmp1*=-1;tmp1+=tmp;
			if(tmp1<0 or tmp1%n)return out("NO");
		}
		out("YES");
		


	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#define abs(x) ((x) > 0 ? (x) : -(x))
#define min(x, y) ((x) > (y) ? (y) : (x))

int
main(int argc, char *argv[])
{
  int n, l[8], a, b, c;
  scanf("%d %d %d %d", &n, &a, &b, &c);
  for(int i = 0; i < n; ++i) scanf("%d", &l[i]);

  int d = 1 << 2*n;

  int length[3], cost, ans = 1000000000; int k; int temp;

  for(int i = 1; i < d; ++i){
    k = 0;
    for(int j = 0; j < 3; ++j) length[j] = 0;
    cost = 0;
    temp = i;
    while(temp > 0){
      if(temp % 4 != 0){
	if(length[temp % 4 - 1] != 0) cost += 10;
	length[temp % 4 - 1] += l[k];
      }
      temp /= 4;
      k++;
    }
    
    cost += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2]);
    if(ans > cost && length[0]*length[1]*length[2] != 0){
      ans = cost;
    }
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

void rec(int d, long long val, vector<long long> &all) {
    // 格納
    all.push_back(val);

    // 10 桁だったらそれ以上やらずに打ち切り
    if (d == 10) return;

    // 次の桁へ進む処理
    for (int j = -1; j <= 1; ++j) {
        int add = (val % 10) + j;
        if (add >= 0 && add<= 9) rec(d+1, val*10+add, all);
    }
}

int main() {
    int K;
    cin >> K;
    vector<long long> all;
    for (int v = 1; v < 10; ++v) rec(1, v, all);

    // 小さい順に並び替える
    sort(all.begin(), all.end());

    // K 番目
    cout << all[K-1] << endl;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = (int)1e5 + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e13;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int dp[3005][3005];
pii par[3005][3005];
string a, b;

int main ()
{
    cin >> a >> b;
    for (int i = 1; i <= sz(a); ++i)
    {
        for (int j = 1; j <= sz(b); ++j)
        {
            if (dp[i - 1][j] >= dp[i][j])
            {
                par[i][j] = {i - 1, j};
                dp[i][j] = dp[i - 1][j];
            }
            if (dp[i][j - 1] >= dp[i][j])
            {
                par[i][j] = {i, j - 1};
                dp[i][j] = dp[i][j - 1];
            }
            if (a[i - 1] == b[j - 1] && dp[i - 1][j - 1] + 1 >= dp[i][j])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                par[i][j] = {i - 1, j - 1};
            }
        }
    }
    pii p = {sz(a), sz(b)};
    string res;
    while (p.fi > 0 && p.se > 0)
    {
        pii p2 = par[p.fi][p.se];
        if (p2.fi == p.fi - 1 && p2.se == p.se - 1) res += a[p2.fi];
        p = p2;
    }
    reverse (whole(res));
    cout << res << "\n";
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];
	vector<ll> tmp(N+1);
	vector<ll> S;
	tmp[0] = 0;
	REP(i, N) tmp[i+1] = tmp[i]+a[i];
	REP(i, N){
		for(int j=i+1;j<N+1;j++){
			S.push_back(tmp[j]-tmp[i]);
		}
	}
	sort(S.begin(), S.end());

	/*
	REP(i, S.size()) cout << S[i] << " ";
	cout << endl;
	*/

	ll M = S.size();
	ll bin[M][60];
	REP(i, M){
		ll t = S[i];
		REP(j, 60){
			bin[i][j] = t%2;
			t /= 2;
		}
	}

	/*
	REP(i, S.size()){
		REP(j, 5){
			cout << bin[i][j] << " ";
		}
		cout << endl;
	}
	*/

	vector<ll> res(60, 0);
	REP(j, 60){
		int k = 59 - j;
		ll ss = 0;
		REP(i, M) ss+=bin[i][k];
		if(ss>=K){
			res[k] = 1;
			REP(i, k){
				REP(l, M){
					if (bin[l][i]==1){
						bin[l][i] = bin[l][k];
					}
				}
			}
		}
	}

	ll ans = 0;
	ll bai = 1;
	REP(i, 60){
		ans += (res[i]*bai);
		bai *= 2;
	}
	cout << ans << endl;

	/*
	cout << endl;
	REP(i, S.size()){
		REP(j, 5){
			cout << bin[i][j] << " ";
		}
		cout << endl;
	}
	*/

    return 0;
}

Measured memory_bytes: 239088
import java.util.Scanner;

/**
 * @author : gaurav.ss
 * @since : 16/02/20
 **/
 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int a=in.nextInt();
        int b=in.nextInt();
        int c=in.nextInt();
        if(a==b && a!=c){
            System.out.println("Yes");
        }else
            if(a==c && a!=b){
                System.out.println("Yes");
            }else
                if(b==c && b!=a){
                    System.out.println("Yes");
                }
                else
                    System.out.println("No");
    }
}


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

int main(){
  string s,t;
  cin>>s>>t;
  vector<int>S_d(s.size(),0);
  vector<int>T_d(t.size(),0);

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  string ans = "Yes";
  string tmp;

  if(s.at(0)-t.at(t.size()-1)>=0){
    ans = "No";
  if(s.at(s.size()-1)==t.at(t.size()-1)&&s.size()<t.size()){
    ans = "Yes";
  }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	_, _ = fmt.Scan(&a, &b, &k)
	max := a
	if max < b {
		max = b
	}
	count := 0
	ans := 0
	for i := max; max > 0; i-- {
		if count >= k {
			break
		}
		if a % i == 0 && b % i == 0 {
			count++
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    ll p[A], q[B], r[C];
    REP (i, A) {
        cin >> p[i];
    }
    REP (i, B) {
        cin >> q[i];
    }
    REP (i, C) {
        cin >> r[i];
    }
    sort(p, p+A, greater<int>());
    sort(q, q+B, greater<int>());
    sort(r, r+C, greater<int>());

    ll picked_p[X];
    REP (i, X) {
        picked_p[i] = p[i];
    }
    ll picked_q[Y];
    REP (i, Y) {
        picked_q[i] = q[i];
    }

    ll merge[X+Y];
    for (int i = 0; i < X; i++) {
        merge[i] = picked_p[i];
    }
    for (int i = X; i < X+Y; i++) {
        merge[i] = picked_q[i-X];
    }

    sort(merge, merge+X+Y);
    int count = 0;
    for (int i = 0; i < X+Y; i++) {
        if (merge[i] < r[count]) {
            merge[i] = r[count];
            count++;
            if (count >= C) {
                break;
            }
        }
    }
    ll ans = 0;
    REP (i, X+Y) {
        ans += merge[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5376
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          String[] s = ReadLine().Split(' ').ToArray();
          int[] a = ReadLine().Split(' ').Select(int.Parse).ToArray();
          String u = ReadLine();
          if(s[0] == u) a[0] -= 1;
          else a[1] -= 1;
          WriteLine(a[0] + " " + a[1]);
      }
   }
}

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

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];
    int ans = 0;
    rep(i, N) {
        ans += B[A[i] - 1];
        if (i > 0 && (A[i] - A[i - 1]) == 1) {
            ans += C[A[i - 1] - 1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cp(const void*a,const void*b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int n,k;
    char s[20];
    scanf("%d %s %d",&n,s,&k);
    char moji[2];
    moji[0]=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]!=moji[0]) s[i]='*';
    }
    printf("%s\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll n;
    cin >> n;
    vl a(n + 1), b(n + 1), prefix(n + 2), suffix(n + 2);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        ++b[a[i]];
    }
    for(int i = 1; i <= n; ++i) {
        prefix[i] = prefix[i - 1] + (b[i] * (b[i] - 1)) / 2;
    }
    suffix[n] = (b[n] * (b[n] - 1)) / 2;
    for(int i = n - 1; i >= 1; --i) {
        suffix[i] = suffix[i + 1] + (b[i] * (b[i] - 1)) / 2;
    }
    ll ans;
    for(int i = 1; i <= n; ++i) {
//        cout << "pref:" << prefix[i - 1] << "suff:" << suffix[i + 1] << "\n";
        ans = prefix[a[i] - 1] + suffix[a[i] + 1];
        ans += ((b[a[i]] - 2) * (b[a[i]] - 1)) / 2;
        cout << ans << "\n";
    }
}


Measured memory_bytes: 8832
import math
n = int(input())
ans = 0
if n < 100:
    for i in range(1, n//2):
        if n % i == 0:
            if (n // i) - 1 > i:
                ans += (n // i) - 1
    print(ans)
else:
    for i in range(1, math.ceil(n**(1/2))):
        if n % i == 0:
            if (n // i) - 1 > i:
                ans += (n // i) - 1
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>s;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(), s.end());
	cout << s[s.size() - 1] - s[0] << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc154/tasks/abc154_b
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

fn main() {
    input! {
        s: chars
    };
    println!("{}", join!(s.into_iter().map(|_| 'x').collect::<Vec<_>>(), ""));
}


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);

  sort(S.begin(), S.end());

  for (int i = 0; i < N; i++) {
    cout << S.at(i);
  }
  cout << "\n";
}

Measured memory_bytes: 256