akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=1e5+5;
int n,m,v,p,a[N],ans,sum;

signed main(){
	read(n,m,v,p);
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+1+n,greater<int>());
	ans=p;sum=a[p];
	for(int i=p+1;i<=n;i++){
		if(a[i]+m>=a[p]&&(a[i]+m)*(i-p)-sum>=m*(v-n+i-p)) ans++;
		else break;
		sum+=a[i];
	}
	write(ans);
}

Measured memory_bytes: 4420
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
result = p[:x] + q[:y] + r
result = sorted(result, reverse=True)
print(sum(result[:x+y]))

Measured memory_bytes: 22720
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> ans;

signed main(){
  int k,q;cin>>k>>q;
  vector<int> d(k);
  for(int i=0;i<k;i++)cin>>d[i];
  while(q--){
    int n,x,m;cin>>n>>x>>m;n--;
    int a=0;
    for(int i=0;i<k;i++)a+=(d[i]%m?d[i]%m:m);
    a*=n/k;
    a+=x%m;
    for(int i=0;i<n%k;i++)a+=(d[i]%m?d[i]%m:m);
    ans.push_back(n-a/m);
  }
  for(int p:ans)cout<<p<<endl;
}


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

typedef long long ll;

const int inf = 100000;

int main() {
    string s;
    int ans = inf;
    cin >> s;
    set<char>v;
    for (int i = 0; i < s.size(); i++) {
        v.insert(s[i]);
    }

    for (auto itr = s.begin(); itr != s.end(); itr++) {
        int Max = 0;
        int last = 0;
        int cnt = 0;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == *itr) {
                last = j;
                Max = max(Max, cnt); 
                cnt = 0;
            } else {
                cnt++;
            }
        }
        Max = max((int)s.size()-last-1, Max); 
        ans = min(ans, Max);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, M; cin >> N >> M;
    vector<bool> ac(N+1);
    vector<int> wa(N+1);
    for(int i=0; i<N+1; i++){
        ac.at(i) = false;
        wa.at(i) = 0;
    }

    int ac_sum = 0;
    int wa_sum = 0;

    for(int i=0; i<M; i++){
        int ques; cin >> ques;
        string acorwa; cin >> acorwa;

        if(ac.at(ques) == true){
            continue;
        }
        
        if(acorwa == "WA"){
            wa.at(ques)++;
        }else if(acorwa == "AC"){
            ac.at(ques) = true;
            ac_sum++;
            wa_sum += wa.at(ques);
        }

    }

    cout << ac_sum << ' ' << wa_sum << endl;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  while (cin >> n, n)
  {
    vector<int> a(n);
    for (auto &e : a)
      cin >> e;
    sort(a.begin(), a.end());
    int ans = 1e9;
    for (int i = 0; i < n - 1; ++i)
      ans = min(ans, abs(a[i] - a[i + 1]));
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3132
package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()

	c := make([]cake, n)

	for i := 0; i < n; i++ {
		x,y,z := scanInt(), scanInt(), scanInt()
		c[i] = cake{x,y,z}
	}

	ans := 0

	bitExhaustiveSearch(3, func(a []bool) {
		b := []int{1,1,1}
		for i := 0; i < 3; i++ {
			if a[i] {
				b[i] *= -1
			}
		}

		d := make([]int,n)
		for i := 0; i < n; i++ {
			d[i] = b[0]*c[i].x+b[1]*c[i].y+b[2]*c[i].z
		}

		sort.Ints(d)

		sum := 0
		for i := 0; i < m; i++ {
			sum += d[n-1-i]
		}
		ans = max(ans, sum)
	})

	fmt.Fprintln(wr, ans)

}

type cake struct {
	x,y,z int
}

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = true } else { a[j] = false }
		}
		fn(a)
	}
}


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

int maxtime(int t) {
    return (t + 9) / 10 * 10;
}

int realtime(int t) {
    return maxtime(t) - t;
}

int main() {
    int a, b, c, d, e;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e);

    int total = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
    int real = max({realtime(a), realtime(b), realtime(c), realtime(d), realtime(e)});

     printf("%d", total - real);

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int x, y;
    cin >> x >> y;
    
    cout << fixed << setprecision(20);

    cout << x + y / 2 << endl;

}


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

typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// i枚目でj枚が表になる確率tot[i][j]
// i+1枚目が表の場合 tot[i+1][j+1] += tot[i]*p[i+1];
// i+1枚目が裏の場合 tot[i+1][j] += tot[i]*(1-p[i+1])

int N;
vector<double> pi;
vector<vector<double>> tot;

int main() {
  cin >> N;
  pi = vector<double>(N);
  tot = vector<vector<double>>(N+1,vector<double>(N+1,0));
  for (int i=0;i<N;i++){
    cin >> pi.at(i);
  }

  tot.at(0).at(0) = 1.0;

  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      tot.at(i+1).at(j+1) += tot.at(i).at(j)*pi.at(i);
      tot.at(i+1).at(j) += tot.at(i).at(j)*(1.0 -pi.at(i));
    }
  }
  
  double ans = 0.0;
  for (int i=N/2+1;i<N+1;i++){
    ans += tot.at(N).at(i);
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70784
n, a, b, c, d = map(int, input().split())
S = input()
if c < d:
    if "##" in S[a-1:d]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:d+1].find("...")
    if f != -1 and ("##" not in S[a-1:c]):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3572
import sys
readline = sys.stdin.readline

def main():
  N, M, K = map(int, readline().split())
  p = 998244353

  cnt = 0
  c = 1
  for i in range(K+1):
    cnt += c * M * pow(M-1, N-1-i, p)
    cnt %= p
    c *= (N - i - 1) * pow(i+1, p-2, p)
    c %= p
  print(cnt)

if __name__ == '__main__':
  main()

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std ;
int main() {
 char a,b,c,d ;
 string f="Yes" ;
 cin>>a>>b>>c>>d ;
 if(a==b&&a==c||b==c&&b==d) {
   cout<< f ;
 }


 else {
    cout<<"No" ;
 }
}


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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  rep(i,n){
    if(s[i] == "AC") ++a;
    if(s[i] == "WA") ++b;
    if(s[i] == "TLE") ++c;
    if(s[i] == "RE") ++d;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  return 0;
}


Measured memory_bytes: 6420
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	a := make([]int, n)
	cas := make([]int, n)
	odd := make([]int, n)

	casenum := 1
	oddnum := 1
	for i := 0; i < n; i++ {
		a[i] = nextInt()

		if a[i]%2 == 1 {
			odd[i] = 1
		} else {
			odd[i] = 2
		}
		cas[i] = 3

		casenum *= cas[i]
		oddnum *= odd[i]
	}

	fmt.Println(casenum - oddnum)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;
using ll = long long;

struct UnionFind {
private:
	vector<int> uf;
	size_t sz;

public:
	UnionFind(size_t Size) {
		uf.assign(Size, -1);
		sz = Size;
	}

	int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -uf[find(x)]; }
	int size() { return sz; }

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) { return; }
		--sz;

		if (uf[y] < uf[x]) { swap(x, y); }
		uf[x] += uf[y];
		uf[y] = x;
	}
};

int main() {
	const int sz = 1e5;
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	UnionFind uf(sz * 2);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
		--x[i];
		--y[i];
		uf.unite(x[i], y[i] + sz);
	}

	vector<ll> cx(sz * 2, 0), cy(sz * 2, 0);
	for (int i = 0; i < sz * 2; ++i) {
		if (i < sz) { cx[uf.find(i)] += 1; }
		else { cy[uf.find(i)] += 1; }
	}

	ll sum = 0;
	for (int i = 0; i < sz * 2; ++i) {
		sum += cx[i] * cy[i];
	}
	cout << sum - N << endl;

	return 0;
}

Measured memory_bytes: 4992
import numpy as np

H, W = map(int, input().split())
G = []
for _ in range(H):
    G.append([1 if x == '.' else 0 for x in input()])
G = np.array(G)
HWOnes = np.ones_like(G)

North = np.cumsum(np.ones_like(G), axis=0)
North *= (1 - G)
North = np.maximum.accumulate(North, axis=0) * G

South = np.cumsum(np.ones_like(G), axis=0)
South *= np.flipud(1 - G)
South = np.maximum.accumulate(South, axis=0)
South = (H - np.flipud(South)) * G

West = np.cumsum(np.ones_like(G), axis=1)
West *= (1 - G)
West = np.maximum.accumulate(West, axis=1) * G

East = np.cumsum(np.ones_like(G), axis=1)
East *= np.fliplr(1 - G)
East = np.maximum.accumulate(East, axis=1)
East = (W - np.fliplr(East)) * G

print(np.amax(South - North + East - West - 1))


Measured memory_bytes: 284976
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll a, b;
  cin >> a >> b;

  if((a + b) % 2 == 0){
    cout << (a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
a = list(map(int, input().split()))
b = input()
c = True
for i in range(a[0]):
    try:
        if 0 <= int(b[i]) <= 9:
            pass
    except:
        c = False
if b[a[0]] == "-":
    pass
else:
    c = False
for i in range(a[1]):
    try:
        if 0 <= int(b[i + a[0] + 1]) <= 9:
            pass
    except:
        c = False
if len(b) != a[0] + a[1] + 1:
    c = False
if c == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	
	
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		long num = s.nextLong();
		
		long sum = 0;
		for (long i = 1; i <= num; i++) {
			if (i % 3 != 0 && i%5 != 0) {
				sum += i;
			}
			
		}
		
		System.out.println(sum);

	}
}

Measured memory_bytes: 35756
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    string s;
    int K;
    cin >> s >> K;
    int t = s.size();
    priority_queue<string, vector<string>, greater<string>> pq;
    set<string> spq;
    for (int i = 0; i < t; i++){
        for (int j = 1; (j <= t - i && j <= 5); j++){
            string l = s.substr(i, j);
            if (!spq.count(l)){
                pq.push(l);
                spq.insert(l);
                /*
                if (pq.size() > 6){
                    vector<string> a(5);
                    for (int i = 0; i < 5; i++){
                        a.at(i) = pq.top();
                        pq.pop();
                    }
                    pq.pop();
                    for (int i = 0; i < 5; i++){
                        pq.push(a.at(i));
                    }
                }
                 */
            }
        }
    }
    /*
    int h = pq.size();
    for (int i = 0; i < h; i++){
        string z = pq.top();
        pq.pop();
        cout << z << endl;
    }
     */
    for (int i = 0; i < K - 1; i++){
        pq.pop();
    }
    string z = pq.top();
    cout << z << endl;
}

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

namespace AOJ1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            int b;
            int S;
            int P;

            string[] str =Console.ReadLine().Split(' ');
            a=int.Parse(str[0]);//" "の手前
            b=int.Parse(str[1]);//" "の後
            
            S = a * b;
            P = (a + b) * 2;
            Console.WriteLine(S + " " + P);
        }
        //string[] str = Console.ReadLine().Split(' ');
        ////String.SplitメソッドとはStringクラスメソッドの一つで、文字列を指定した区切り文字で分割し配列に格納する場合に使う

        //int a = int.Parse(str[0]);
        //int b = int.Parse(str[1]);

        //Console.WriteLine(a* b + " " + (a + b) * 2);
    }
}



Measured memory_bytes: 13880
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
		try{
			root:
			while(true){
				String st;
				int count = 0;
				int[][] map = new int[14][14];
				while(true){
					st = sc.readLine();
					if(st==null)
						break root;
					if(!st.isEmpty())
						break;
					}
			for(int i=1; i<=12; i++){
				for(int j=1; j<=12; j++)
					map[i][j]=st.charAt(j-1)-'0';
				st = sc.readLine();
				}
			for(int i=1; i<=12; i++)
				for(int j=1; j<=12; j++)
					if(map[i][j]!=0){
						count++;
						erase(map, i, j);
						}
			System.out.println(count);
			}
		}catch(Exception e){
			System.out.println("Error");
			}
		}
	private static void erase(int[][] map, int i, int j){
		if(map[i][j]==0)
			return;
		map[i][j]=0;
		erase(map,i,j+1);
		erase(map,i+1,j);
		erase(map,i-1,j);
		erase(map,i,j-1);
		}
}

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


int main(){
    string S,T;
    int64_t ans = 10000,cnt = 0;
    cin >> S >> T;
    for (int64_t i = 0; i <= S.size()-T.size(); i++){
        for (int64_t j = i; j < i + T.size(); j++){
            if (S.at(j) != T.at(j-i)){
                cnt++;
            }
        }
        ans = min(ans,cnt);
        cnt = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    int ans = 0;
    forn (i, 0, n)
        if (i % 2 == 0 && a[i] % 2 == 1)
            ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
const int inf=(int)1e9;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
int dp[(1<<20)];
int a[20][20];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      for(int j=0;j<n+1;j++){
        cin>>a[i][j];
      }
    }
    for(int i=0;i<(1<<n);i++)dp[i]=inf;
    dp[0]=0;
    for(int i=0;i<(1<<n);i++){
      for(int bit=0;bit<n;bit++){
        if(i&(1<<bit))continue;
        int mincost=inf;
        for(int k=0;k<n;k++){
          if(i&(1<<k)){
            mincost=min(mincost,a[bit][k+1]);
          }
        }
        mincost=min(mincost,a[bit][0]);
        dp[i|(1<<bit)]=min(dp[i]+mincost,dp[i|(1<<bit)]);
      }
    }
    cout<<dp[(1<<n)-1]<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







Measured memory_bytes: 3376
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	static int n, a[];
	static long m, sum[];
	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		n = fs.nextInt(); m = fs.nextLong();
		a = fs.nextIntArray(n);
		rsort(a);
		sum = new long[n+1];
		for(int i=0;i<n;i++)sum[i+1] = sum[i] + a[i];
		//価値xの握手をm個作れるような、xの最大値を二分探索で求める
		int l = 0, r = INF;
		while(l+1<r) {
			int c = (l+r)/2;
			if(check(c)) l = c;
			else r = c;
		}
		System.out.println(culcSum(l));
	}
	
	//x以上になる物だけでm個つくる時の和の最大値
	static long culcSum(int x) {
		x ++;
		long cnt = 0;
		long s = 0;
		for(int i=0;i<n;i++) {
			int l = -1, r = n;
			while(l+1<r) {
				int c = (l+r)/2;
				if(a[i] + a[c] >= x)l = c;
				else r = c;
			}
			if(l<i)break;
			cnt += (l - i + 1) * 2 - 1;
			s += (((long)a[i] * (l-i+1) + (sum[l+1] - sum[i]))*2 - a[i] * 2);
		}
		long rem = m - cnt;
		s += (rem * (x-1));
		return s;
	}
	
	static boolean check(int x) {
		long cnt = 0;
		for(int i=0;i<n;i++) {
			int l = -1, r = n;
			while(l+1<r) {
				int c = (l+r)/2;
				if(a[i] + a[c] >= x)l = c;
				else r = c;
			}
			if(l<i)break;
			cnt += (l - i + 1) * 2 - 1;
		}
		if(cnt >= m)return true;
		else return false;
	}
	
	static void rsort(int x[]) {
		Arrays.sort(x);
		int len = x.length;
		for(int i=0;i<len/2;i++) {
			int tmp = x[i];
			x[i] = x[len-1-i];
			x[len-1-i] = tmp;
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 36508
#include<stdio.h>
#include<stdlib.h>


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;
Node root;

void insert(int );
void inorder(Node );
void preorder(Node );
int find(int ,Node );
int main(){
  int n,i;
  int k,m,s;
  char t[5];

  scanf("%d",&n);
  
  for(i=0 ; i<n ; i++){
    scanf("%s",t);
    if(t[0]== 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    if(t[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    if(t[0]=='f'){
      scanf("%d",&s);
      m = find(s,root);
      if(m==0)printf("no\n");
      else printf("yes\n");
    }
  }

  return 0;
}


void insert(int k){
  Node z;
  Node y = NULL;
  Node x = root;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL){//?????????insert??????????????????
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NULL)root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}


void inorder(Node T){
  if(T != NULL){
    inorder(T->left);
    printf(" %d",T->key);
    inorder(T->right);
  }
}


void preorder(Node T){
  if(T != NULL){
    printf(" %d",T->key);
    preorder(T->left);
    preorder(T->right);
  }
}

int find(int k,Node node){
  if(node == NULL){
    return 0;
  }
  if(node->key == k){
    return 1;
  }
  else if(node->key < k){
    return find(k , node->right);
  }
  else{
    return find(k , node->left);
  }
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a, b, c, d, ans1, ans2, ans3, ans4;
    cin >> a >> b >> c >> d;
    ans1 = a * c;
    ans2 = a * d;
    ans3 = b * c;
    ans4 = b * d;
    cout << max(max(ans1, ans2), max(ans3, ans4)) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
using namespace std;



int main(){
  bool is_prime[50001];
  is_prime[0]=false;is_prime[1]=false;
  for(int i=2;i<50001;i++)is_prime[i]=true;
  for(int i=2;i<=sqrt(50001);i++){
    if(is_prime[i]){
      for(int j=2;i*j<=50001;j++)is_prime[i*j]=false;
    }
  }


  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int cnt=0;

    for(int i=2;i<=n/2;i++){
      if(is_prime[i]){
        if(is_prime[n-i])cnt++;
      }
    }
    cout<<cnt<<endl;
  }
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define fix  cout<<std::fixed;
#define mk make_pair
#define mod 1000000007
#define time  cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
#define IOS             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{  
  ll n;cin>>n;
  ld sum=0;
  ld dp[n+1][n+1];
 memset(dp,0,sizeof(dp));
  for(int i=1;i<=n;i++)
  { ld b;  cin>>b;
    if(i==1)
        dp[1][0]=1-b,dp[1][1]=b;
    else
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)dp[i][j]=(1-b)*dp[i-1][j];

            else
                dp[i][j]=b*dp[i-1][j-1]+(1-b)*dp[i-1][j];
        }
    }

  }   

  for(int i=(n+1)/2;i<=n;i++)
    sum+=dp[n][i];
printf("%.12Lf",sum);
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    unordered_map<int,int> mp;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    rep(i,0,n) ++mp[a[i]];
    int pw = 1;
    int ans = 0;
    while(pw<=a[n-1]) pw*=2;
    for(int i=n-1;i>=0;--i) {
        if(mp[a[i]]>0) {
            --mp[a[i]];
            while(pw/2>a[i]) pw/=2;
            if(mp[pw-a[i]]>0) {
                --mp[pw-a[i]];
                ++ans;
            }
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 17652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

    rep(i,n){
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;
    rep(i,n){

        if(a[i]<=10e18/ans){
            ans *= a[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    if(ans>(ll)10e17){
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3984
from functools import reduce 
from operator import add
 
n = int(input())
arr = list(map(int, input().split()))
 
pt_a = 0
pt_b = 0
 
arr.sort(reverse=True)
 
for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num
 
print(pt_a - pt_b)

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

using namespace std;

int main()
{
	string s, p;
	
	cin >> s;
	cin >> p;
	
	string t = s + s.substr(0, p.size());
	//cout << t << endl;
	string::size_type loc = t.find(p, 0);
	if (loc != string::npos)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int h=0,i,j,k,l;
  int b[9][9],n;
  vector<int> o[9][9];
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<9;j++){
      for(k=0;k<9;k++){
	int tmp;
	cin>>tmp;
	o[k][j].push_back(tmp);
      }
    }
  }
  for(i=0;i<n;i++){
    memset(b,0,sizeof(b));
    for(j=0;j<9;j++){
      for(k=1;k<10;k++){
	int cnt=0;
	for(l=0;l<9;l++){
	  if(o[j][l][i]==k)
	    cnt++;
	}
	if(cnt>1){
	  for(l=0;l<9;l++){
	    if(o[j][l][i]==k)
	      b[j][l]=1;
	  }
	}
      }
      for(k=1;k<10;k++){
	int cnt=0;
	for(l=0;l<9;l++){
	  if(o[l][j][i]==k)
	    cnt++;
	}
	if(cnt>1){
	  for(l=0;l<9;l++){
	    if(o[l][j][i]==k)
	      b[l][j]=1;
	  }
	}
      }
      for(k=1;k<10;k++){
	int cnt=0;
	for(l=0;l<9;l++){
	  if(o[j%3*3+l%3][j/3*3+l/3][i]==k)
	    cnt++;
	}
	if(cnt>1){
	  for(l=0;l<9;l++){
	    if(o[j%3*3+l%3][j/3*3+l/3][i]==k)
	      b[j%3*3+l%3][j/3*3+l/3]=1;
	  }
	}
      }
    }
    if(h)
      cout<<endl;
    h=1;
    for(j=0;j<9;j++){
      for(k=0;k<9;k++){
	if(b[k][j])
	  cout<<"*";
	else
	  cout<<" ";
	cout<<o[k][j][i];
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#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 n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int smd = 0;
  rep(i, n) smd += d[i];
  int ans = smd * smd;
  rep(i, n) ans -= d[i] * d[i];
  ans /= 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

int main()
{
    int64_t a;
    std::cin>> a;

    int64_t b = a/ 2;

    if( a % 2 == 0 )
    {
        b -= 1;
    }
    std::cout<< b;
}




Measured memory_bytes: 256
from sys import exit

def reads():
  return [int(x) for x in input().split()]

(N, A) = reads()
x = reads()

d = dict()

d[0] = 1

for i in range(N):
  for (s, N) in list(d.items()):
    k = s + x[i] - A
    d[k] = d.get(k, 0) + N

print(d[0]-1)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll l[n],r[n];
    vector<ppll> w;
    vector<pll> v;
    ll num;
    rep(i,0,n){
        cin>>l[i]>>r[i];
        w.push_back({{r[i],l[i]},i});
        
    }
    
    
    
    sort(w.begin(),w.end());
    num=w[0].second;
    rep(i,0,n){
        if(i==num)continue;
        v.push_back({l[i],r[i]});
    }
    sort(v.begin(),v.end());
    ll rmi=w[0].first.first;
    ll lm=w[0].first.second;
    ll ans=0;
    ll rmi2=inf;
    ll lma2=0;
    rrep(i,n-2,1){
        ll nr=v[i].second,nl=v[i].first;
        rmi2=min(rmi2,nr);
        lma2=max(lma2,nl);
        ll nel=v[i-1].first;
        ll tl=max(lm,nel);
        //cout<<lma2<<" "<<rmi2<<endl;
        ans=max(ans,max((ll)0,rmi2-lma2+1)+max((ll)0,rmi-tl+1));
    }
    ll nr=v[0].second,nl=v[0].first;
    rmi2=min(rmi2,nr);
    lma2=max(lma2,nl);
    ll tl=lm;
    //cout<<lma2<<" "<<rmi2<<endl;
    ans=max(ans,max((ll)0,rmi2-lma2+1)+max((ll)0,rmi-tl+1));
    ll nuu;
    ll maa=0;
    rep(i,0,n){
        if(r[i]-l[i]+1>maa){
            maa=r[i]-l[i]+1;
            nuu=i;
        }
    }
    ll ttl=0,ttr=inf;
    rep(i,0,n){
        if(nuu==i)continue;
        ttl=max(ttl,l[i]);
        ttr=min(ttr,r[i]);
    }
    ans=max(ans,maa+max((ll)0,ttr-ttl+1));
    cout<<ans<<endl;
}


Measured memory_bytes: 8560
s = input()
q = int(input())
status = 1
top = []
bottom = []
for i in range(q):
    query = [i for i in input().split()]
    if query[0] == "1":
        status *= -1
    else:
        if (query[1] == "1" and status == 1) or (query[1] == "2" and status == -1):
            top.append(query[2])
        else:
            bottom.append(query[2])

tmp = "".join(top[::-1]) + s + "".join(bottom)
print(tmp if status == 1 else tmp[::-1])


Measured memory_bytes: 6268
k, s = gets.split.map &:to_i
cnt = 0
f = [s-k*2, 0].max
f.upto(k) do |x|
  ([s-x-k, f].max).upto(k) do |y|
    z = s - x - y
    cnt += 1 if z <= k && 0 <= z
  end
end
p cnt

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

vector<int> dp(100005,-1);
vector<vector<int>> g(100005);


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(){
  int n;
  cin>>n;
  vector<double> p(n);
  rep(i,n)cin>>p[i];
  double dp[n+1][n+2];
  rep(i,n+1)rep(j,n+1)dp[i][j]=0;
  dp[0][0]=1;
  rep(i,n){
    rep(j,n+1){
      dp[i+1][j]+=dp[i][j]*(1-p[i]);
      dp[i+1][j+1]+=dp[i][j]*(p[i]);
    //  cout<<dp[i+1][j+1]<<"i"<<i+1<<"j"<<j+1<<endl;
    //  cout<<dp[i+1][j]<<"i"<<i+1<<"j"<<j<<endl;
    }
  }
  double ans=0;
  rep(i,(n+1)/2){
    ans+=dp[n][n-i];
    
  }
cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 76448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int l,cnt=0;
    cin>>s;
    cin>>t;
    l=s.length();
    for(int i=0,j=0; i<l,j<t.length(); i++,j++)
    {
        if(s[i]!=t[j])
        {
            cnt++;
        }
    }
    cout<<cnt;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<ll> v(3);

  cin>>v[0]>>v[1]>>v[2];
  sortAl(v);
  cout<<v[2]*10+v[1]+v[0]<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


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

    int ans;
    ans = max(A, B);
    if(A!=B)
    cout << ans + ans - 1 << endl;
    else cout << A * 2 << endl;

}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 9)


# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, W = map(int, input().split())
    item = []
    dp = [[0] * (W + 1) for _ in range(N)]

    for i in range(N):
        w, v = map(int, input().split())
        item.append((w, v))

    for i in range(N):
        w, v = item[i]
        for j in range(W + 1):
            if j >= w:
                dp[i][j] = max(dp[i-1][j], dp[i - 1][j - w] + v)
            else:
                dp[i][j] =dp[i-1][j]

    print(dp[N-1][W])


if __name__ == "__main__":
    main()


Measured memory_bytes: 151612
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  int k;
  int cnt=0;
  cin>>a>>b>>c;
  cin>>k;
  while(b<=a){
    b*=2;
    cnt++;
  }
  while(c<=b){
    c*=2;
    cnt++;
  }
  if(cnt<=k){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return(0);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n;
    map<int, int> mp;
    cin >> n;
    REP(i, n){
        int a; cin >> a;
        mp[a]++;
    }
    int m; cin >> m;
    REP(i, m){
        int a; cin >> a;
        if(mp[a]) mp[a]--;
        else mp[a]++;
    }
    
    for(auto it=mp.begin(); it!=mp.end(); ++it){
        if(it->second) cout << it->first << endl;
    }
	return 0;
}


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

int main() {
  int A, B, C; cin >> A >> B >> C;
  int m = A%B; 
  if(m == 0) {cout << "NO" << endl; return 0;}
  int sum = m;
  
  rep(i,150){
    if(sum%B == C){ cout << "YES" << endl; return 0;}
    else sum +=m;
  }
  cout << "NO" << endl;
  return 0;
}

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

#define F(i,a,b) for(int i=a;i<=b;i++)
 
int a[100001]={0};
int n;
int r;
 
int main()
{
  
	cin>>n;
	F(i,1,n)cin>>a[i];
	
	F(i,0,n)r+=(abs(a[i]-a[i+1]));
	F(i,1,n)
	{
		int x;
		x=r-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
		cout<<x<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int k;

void input() {
  cin >> n >> k;
}

void solve() {
  string ans;

  while (n) {
    ans += n % k;

    n /= k;
  }

  cout << ans.size() << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();

  int t = 1;
//  cin >> t;

#ifdef _DEBUG
  t = 3;
#endif

  while (t--) {
    input();
    solve();
  }
}


Measured memory_bytes: 256
H, W = map(int, input().split())		# 5 7

M = list( input() for _ in range(H) )
A=[]
C=[]
r=0
c=W

#print(M)

for i in range(H):
	m = M[i]
	if "#" in m:
		A.append(m)
		r+=1

#print(r,c)
#print(A)

for j in range(c):
	for i in range(r):
		a = A[i][j]
		if a=='#': break
	else:
		C.append(j)

#print(C)

for r in A:
#	print(r)
	for c in range(len(r)):
		if not (c in C):
			print(r[c], end='')
	print('')

Measured memory_bytes: 4468
class Node:
    left = -1
    right = -1


def get_root_index(first: int, end: int) -> int:
    """inorder[first:end]の根のインデックスを取得する。
    根： inorder[first:end]を左部分木と右部分木に分割するノード
    """

    # inorder[first:end]の要素でpreorderの一番手前にあるものが、
    # inorder[first:end]を左部分木と右部分木に分割するノード。
    # そのインデックスを返す。
    for pre in preorder:
        for j in range(first, end):
            if pre == inorder[j]:
                return j


def get_root(first, end) -> int:
    """inorder[first:end]の根のノードを返す。
    """

    root_ix = get_root_index(first, end)
    if root_ix is not None:
        return inorder[root_ix]
    else:
        return -1


def set_nodes(first: int, end: int):
    root_ix = get_root_index(first, end)
    if first + 1 < root_ix:
        set_nodes(first, root_ix)
    if root_ix + 1 < end - 1:
        set_nodes(root_ix + 1, end)
    nodes[inorder[root_ix]].left = get_root(first, root_ix)
    nodes[inorder[root_ix]].right = get_root(root_ix + 1, end)


def set_postorder(node_id: int) -> None:
    """後行順巡回で得られる節の番号を保存する。

    Args:
        node_id (int): [description]
    """

    left = nodes[node_id].left
    if left != -1:
        set_postorder(left)

    right = nodes[node_id].right
    if right != -1:
        set_postorder(right)

    postorder.append(node_id)


N = int(input())
nodes = [Node() for i in range(N + 1)]
preorder = [int(i) for i in input().split()]
inorder = [int(i) for i in input().split()]

set_nodes(0, N)

postorder = []
set_postorder(get_root(0, N))
print(' '.join(map(str, postorder)))


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

namespace Welcome_to_AtCoder
{
    class Program
    {
        static void Main()
        {
            string[] bc = Console.ReadLine().Split(' ');
            int a = int.Parse(bc[0]);
            int b = int.Parse(bc[1]);
            if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) Console.WriteLine("Possible");
            else Console.WriteLine("Impossible");
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n=scan.nextInt();
		int a=0;

		int i=0;

		for(i=0; i<n; i++) {
			a=a+1+i;

			//System.out.println(a);
		}
		System.out.println(a);

	}

}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

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

struct Road
{
	int a, b, c;
};

int n, a, b, c;

int table[10][10];
Road roads[45];

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

		memset(table, 0, sizeof(int) * 100);

		rep(i, n)
		{
			cin >> roads[i].a >> roads[i].b >> roads[i].c;
		}

		//Warhsall-Floyd
		int t = 0;
		rep(i, 10)
		{
			rep(j, 10)
			{
				rep(k, n)
				{
					if((roads[k].a == i && roads[k].b == j) ||
					   (roads[k].a == j && roads[k].b == i))
					{
						table[i][j] = roads[k].c;
						if(t < max(i, j))
							t = max(i, j);
						break;
					}
					else if(i == j)
					{
						table[i][j] = 0;
					}
					else
					{
						table[i][j] = 100000;
					}
				}
			}
		}

		rep(k, t+1)
		{
			rep(i, t+1)
			{
				rep(j, t+1)
				{
					if(table[i][j] > table[i][k] + table[k][j])
					{
						table[i][j] = table[i][k] + table[k][j];
					}
				}
			}
		}

		int min_cost = 100000;
		int town = 0;
		rep(i, t+1)
		{
			int total = 0;
			rep(j, t+1)
			{
				total += table[i][j];
			}

			if(total < min_cost)
			{
				town = i;
				min_cost = total;
			}
		}

		printf("%d %d\n", town, min_cost);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    bool flg = true;
    INT(a);INT(b);
    string s; cin >> s;
    rep(i,a) if(s[i] == '-') flg = false;
    if(s[a] != '-') flg = false;
    FOR(i,a+1,a+b) if(s[i] == '-') flg = false;
    if(flg) Yes;
    else No;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by hkoba on 2018/01/08.
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // スペース区切りの整数の入力
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        // 奇数ならBorysの勝ち、偶数ならAliceの勝ち
        if ((b - a) % 2 == 0) {
            System.out.println("Alice");
        } else {
            System.out.println("Borys");
        }
    }
}


Measured memory_bytes: 21716