akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>A>>B;
    cout<<A+B/2<<endl;
}


Measured memory_bytes: 256
import collections
w=input()
words=[a for a in w]
c=collections.Counter(words)
values,counts=zip(*c.most_common())
count=0
for n in counts:
    if n%2==1:
        print('No')
        break
    else:
        count+=1
        continue

if count==len(values):
    print('Yes')
else:
    pass

Measured memory_bytes: 3828
import Data.List
import Data.Ord
import Data.Ratio

main = do
  [a,b,c,d,e,f] <- map read . words <$> getLine
  let (s, w) = swater a b c d e f
  putStrLn (show (w+s) ++ " " ++ show s)

swater a b c d e f = maximumBy (comparing (\(s,w) -> s%(s+w))) cand
  where
    cand = [(s, w) | ai<-[0..30], bi<-[0..30], ci<-[0..100], di<-[0..100],
                     let w = ai*a*100 + bi*b*100, let s = ci*c + di*d,
                     w>0, s+w<=f, e*w >= s*100]

Measured memory_bytes: 24444
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>
 
//#define int long long
 
#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define endl '\n'
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
mt19937 mrand(random_device{}());
 
double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
	
void solve();
void scan();
 
signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	int k; cin >> k;
	double h = (double)k / 3;
	cout << h * h * h << endl;
    return;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
struct p{
	int x;
	int y;
	int cnt;
};

int maps[1000][1000]={};
char map[1000][1000]={};
bool mapb[1000][1000]={},used[1000][1000]={};

int main(){
	queue<p> m;
	p f;
	p v;
	int h,w,n,i,j,z,sp=1,mv[4][2]={{0,-1},{1,0},{0,1},{-1,0}},count=0;
	char u,math[10]="123456789";
	cin>>h>>w>>n;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>u;
			for(z=0;z<9;z++){
				if(u==math[z]){
					maps[i][j]=z+1;
					mapb[i][j]=true;
				}
			}
			map[i][j]=u;
			if(u=='S'){
				f.x=j;
				f.y=i;
				f.cnt=0;
				m.push(f);
			}
		}
	}
	while(1){
		f=m.front();
		m.pop();
		if(used[f.y][f.x]==true){
			continue;
		}
		else{
			used[f.y][f.x]=true;
		}
		if(mapb[f.y][f.x]==true&&maps[f.y][f.x]<=sp){
			mapb[f.y][f.x]=false;
			count++;
			sp++;
			memset(used,0,sizeof(used));
			while(!m.empty()){
				m.pop();
			}
			m.push(f);
			used[f.y][f.x]=true;
			if(count==n){
				break;
			}
		}
		for(i=0;i<4;i++){
			if(map[f.y+mv[i][1]][f.x+mv[i][0]]!='X'&&(f.x+mv[i][0])>=0&&(f.x+mv[i][0])<w&&(f.y+mv[i][1])>=0&&(f.y+mv[i][1])<h){
				v.x=f.x+mv[i][0];
				v.y=f.y+mv[i][1];
				v.cnt=f.cnt+1;
				m.push(v);
			}
		}
	}
	cout<<f.cnt<<endl;
	return 0;
}

Measured memory_bytes: 6428
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    s = (ns() for _ in range(n))

    ans = len(set(s))
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 31712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

void solve(){
    int x[3];
    for(int i = 0; i < 3; i++){
        cin >> x[i];
    }
    sort(x, x+3);
    for(int i = 0; i < 3; i++){
        cout << x[i];
        if(i < 2){
            cout << " ";
        }
    }
    cout << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    char a;
    int b,c;
    cin  >> b;
    cin >> a >> c;
    if(a=='+'){
        cout << b+c;
    }else{
        cout << b-c;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) REPI(i, 0, n)
#define REPI(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)

#define SZ(x) ((int)(x).size())


using ll = long long;
using uint = unsigned int;
using namespace std;

int main()
{
    uint A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int taka_turn, ao_turn, temp;
    temp = C % B == 0 ? 0 : 1;
    taka_turn = C / B + temp;
    temp = A % D == 0 ? 0 : 1;
    ao_turn = A / D + temp;
    if (taka_turn <= ao_turn)
    {
        cout << "Yes" << endl;
    } 
    else 
    {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a, C[9];
  for(int i = 0; i < 9; ++i) C[i] = 0;
  for(int i = 0; i < N; ++i){
    cin >> a;
    ++C[min(8,a/400)];
  }
  int s = 0;
  for(int i = 0; i < 8; ++i){
    if(C[i]) ++s;
  }
  cout << max(s,1) << " " << s+C[8] << endl;;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
//ll num[ten52];
priority_queue<ll> pq;          //decreasing

int main(void)
{
    long long int m,n,i,j,sum=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        pq.push(m);
    }
    sum+=pq.top();
    pq.pop();
    for(i=2;i<n;i++)
    {
        sum+=pq.top();
        if(i%2==1)
            pq.pop();
    }
    cout<<sum;
    return 0;
}





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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int mod = 1e9+7;
    
    long long a = modpow(10,n,mod);
    long long b = modpow(9,n,mod);
    long long c = modpow(9,n,mod);
    long long d = modpow(8,n,mod);
    long long ans = a-b-c+d;
    ans %= mod;
    cout << (ans+mod)%mod << endl;
}

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

using namespace std;

int main()
{
   
  ll n,k;
  cin>>n>>k;
  vector<ll> v(n);
  for(ll i=0;i<n;i++)
  cin>>v[i];
  sort(v.begin(),v.end());
  ll sum=0;
  for(ll i=0;i<n-k;i++)
   sum=sum+v[i];
   cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 1792
n, m = map(int, input().split())
h = list(map(int, input().split()))

a = [0] * m
b = [0] * m
d = [0] * n

for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    if h[a[i]] < h[b[i]]:
        d[a[i]] = 1
    elif h[a[i]] == h[b[i]]:
        d[a[i]] = 1
        d[b[i]] = 1
    else:
        d[b[i]] = 1

ans = 0

for i in range(n):
    if d[i] == 0:
        ans += 1
#print(d)
print(ans)


Measured memory_bytes: 87584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b;
  cin >> a >> b;
  if (a == b) {
    REP(i, a) { cout << a; }
    cout << endl;
  } else if (a < b) {
    REP(i, b) { cout << a; }
    cout << endl;
  } else {
    REP(i, a) { cout << b; }
    cout << endl;
  }
}

Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
	set<int> s;
	for (int i = 0; i < 3; ++i) {
		int c;
		cin >> c;
		s.insert(c);
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N,M = parseMap(split(readline()))
A = parseMap(split(readline()))
sum_A = sum(A)
ans = 0 
for a in A
    if  a >= sum_A / 4M 
        ans += 1
    end
end

println(ans >= M ? "Yes" :  "No")

Measured memory_bytes: 112420
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	long long n,i,j,ans[2]={0};
	cin>>n;
	long long a[n];
	for(i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	j=0;
	for(i=n-1;i>=1;i--){
		if(a[i]==a[i-1]){
			ans[j]=a[i];
			i--;
			j++;
		}
		if(j==2) break;
	}
	cout<<ans[0]*ans[1]<<endl;
	return 0;
}



Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author neuivn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            long[] arr = new long[3 * N];
            for (int i = 0; i < 3 * N; ++i) {
                arr[i] = in.nextLong();
            }
            Arrays.sort(arr);
            int a = 0;
            int b = arr.length - 1;
            int c = arr.length - 2;
            long res = 0L;
            for (int q = 0; q < N; ++q) {
                res += arr[c];
                ++a;
                b -= 2;
                c -= 2;
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}



Measured memory_bytes: 58976
li = []
while True:
    h, w = [int(i) for i in input().split()]
    if h == 0 & w == 0:
        break
    else:
        li.append([h, w])
    
for i, j in li:
    for k in range(i):
        if k == 0 or k == i - 1:
            print("#" * j, end = "")
            print()
        else:
            print("#" + "." * (j - 2) + "#", end = "")
            print()
    print()


Measured memory_bytes: 5636
from collections import deque

n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

#BFS実行部分
while d:
    v = d.popleft()
    for i in graph[v]:
        if dist[i] != -1:
            continue
        dist[i] = v
        d.append(i)

if -1 in dist:
    print("No")
else:
    print("Yes")
ans = dist[2:]
print(*ans, sep="\n")


Measured memory_bytes: 36536
#include<stdio.h>

int main() {
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if ((x < r) || (y < r) || (W - x < r) || (H - y < r)) {
		printf("No\n");
	}
	else printf("Yes\n");

	return 0;
}


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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<int> a(N+1, 0);
	rep(i, N) cin >> a[i+1];

	vector<int> b(N+1, 0);
	for(int i = N; i >= 1; i--){
		if(a[i] == b[i]) {
			b[i] = 0;
			continue;
		}

 		for(int j = 1; j * j <= i; j++){
			if(i % j == 0){
				if(j * j == i){
					b[j] ^= 1;
					// cout << i << "," << j << endl;
				}else{
					b[j] ^= 1;
					b[i / j] ^= 1;

					// cout << i << "," << j << endl;
					// cout << i << "," << i /j << endl;
				}
			}
		}

		b[i] = 1;
	}

	int cnt = 0;
	vector<int> c;
	for(int i = 1; i <= N; i++){
		if(b[i] == 1){
			cnt++;
			c.push_back(i);
		}
	}

	cout << cnt << endl;
	if(cnt > 0){
		cout << c[0];
	}

	for(int i = 1; i < cnt; i++){
		cout << " " << c[i];
	}

	cout << endl;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	string s;
	cin >> s;
	int b = -1;
	int e = -1;

	for(int i=0; i<s.size(); i++){
		if(b == -1 && s[i] == 'A'){
			b = i;
		}
		if(s[i] == 'Z') e = i;
	}
	cout << e - b + 1 << endl;
	
	return 0;
}


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

int main()
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); ++i)
	{
		bool flag = false;
		if (i % 2 == 0 && (S[i] == 'R' || S[i] == 'U' || S[i] == 'D'))
		{
			flag = true;
		}

		if (i % 2 == 1 && (S[i] == 'L' || S[i] == 'U' || S[i] == 'D'))
		{
			flag = true;
		}

		if (!flag)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<int,vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    ll N,A,B;
    cin >> N >> A >> B;
    ll ans;
    
    if(abs(A-B)%2==0) ans = abs(A-B)/2;
    else{
        if(A-1 < N-B){
            ans = A-1;
            B -= A-1;
            ans++;
            B--;
            A = 0;
            ans += abs(B-A)/2;
        }else{
            ans = N-B;
            A += N-B;
            ans++;
            A++;
            B = N;
            ans += abs(B-A)/2;
        }
    }
    
    out(ans);

    
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int num;
	cin >> num;
	int a[num];

	for(int i=0; i<num; ++i) cin >> a[i];

	int min = a[0];
	int max = 0;

	for(int i=0; i<num; ++i){
		if(min > a[i]) min = a[i];
		else if(max < a[i]) max = a[i];
	}
	
	cout << max - min;

	return 0;

}




Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

int main(void){
    // Your code here!
    string c;
    cin >> c;
    if (c == "ABC") cout << "ARC";
    else cout << "ABC";
}


Measured memory_bytes: 3128
n,k=map(int,input().split())
a=[int(i) for i in input().split()]

m=40
f=[0]*m
b=False
ans=0
for i in a:
    for j in range(m):
        f[j]+=i>>j&1
for i in range(m)[::-1]:
    if f[i]>n//2:
        ans+=f[i]*2**i
        if k>>i&1:
            b=True
    else:
        if b or k>>i&1:
            ans+=(n-f[i])*2**i
        else:
            ans+=f[i]*2**i
print(ans)

Measured memory_bytes: 14700
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	string res = "No";
	if (n % 2 == 0)
	{
		if (s.substr(0, n / 2) == s.substr(n / 2, n / 2))
		{
			res = "Yes";
		}
	}

	println(res);
}


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

int main(){
    int n, b, c, d, f;
    int house[5][4][11];
    for(int i = 1;i < 5;++i){
       for(int o = 1;o < 4;++o){
         for(int p = 1;p < 11;++p){
          house[i][o][p] = 0;
         }
       }
     }
     cin >> n;
     for(int u = 0;u < n;++u){
        cin >> b >> c >> d >> f;
        house[b][c][d] += f;          
      } 
       for(int i = 1;i < 5;++i){
         if(i != 1){
           cout << "####################" << endl;
         }
        for(int o = 1;o < 4;++o){
         for(int p = 1;p < 11;++p){
          cout << " " << house[i][o][p];
          if(p == 10) cout << endl;
         }
       }
     }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N;cin>>N;
  ll a[N];
  ll i,j;
  rep(i,N) cin>>a[i];
  ll cnt=0;
  rep(i,N-2){
    if(a[i+1]<a[i] and a[i+1]<a[i+2]) continue;
    else if(a[i+1]>a[i] and a[i+1]>a[i+2]) continue;
    else cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
    int n; 
    cin >> n;
    int i = 1;
    while(1){
        if(i>n)break;
        while(1){//3の倍数か判断する部分からxの値を増やす部分を増やす機構に移動させるためだけのwhile
            int x = i;
            if(x%3==0){
                cout << " " << i;
                break;
            }
            while(1){
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
                if(x==0)break;
            }
            break;
        }
        i++;
    }
    cout << endl;
    return 0;   
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		
		String output = "No";
		
		while(N>=0) {
			if(N%4 == 0) {
				output = "Yes";
			}
			N = N-7;
		}
		
		System.out.println(output);
	}

}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/fenwicktree>

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	
	atcoder::fenwick_tree<ll> ft(N);
	REP(i, N) {
		int a;
		scanf("%d", &a);
		ft.add(i, a);
	}
	
	while (Q--) {
		int q, a, b;
		scanf("%d %d %d", &q, &a, &b);
		if (q == 0) ft.add(a, b);
		else printf("%lld\n", ft.sum(a, b));
	}
	
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 105; i <= n; i += 2) {
        int k = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) k++;
        }
        if (k == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

typedef long long ll;

int main()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<ll> x(m);
    for (int i = 0; i < m; i++) {
        std::cin >> x[i];
    }

    std::sort(x.begin(), x.end());

    std::vector<ll> xs(m - 1);
    for (int i = 0; i < m - 1; i++) {
        xs[i] = x[i + 1] - x[i];
    }

    std::sort(xs.begin(), xs.end(), std::greater<ll>());

    int ans = 0;
    for (int i = n - 1; i < m - 1; i++) {
        ans += xs[i];
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
   long A,B,K;
   scanf("%ld %ld %ld",&A,&B,&K);
   if(A>=K){
      A -=K;
   }else if(A+B<K){
      A=0;
      B=0;
   }else{
      B -=K;
      B +=A;
      A=0;
   }
   printf("%ld %ld",A,B);
   return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int count = 0;
  char a;
  for(int i = 0; i < N; i++) {
    cin >> a;
    if(a == 'R') count++;
  }
  if(count > N - count)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);

    // pre
    std::vector<int> prime, mip(1e6 + 1); mip[0] = mip[1] = -1;
    for(int i = 2; i < mip.size(); i++) {
        if(mip[i] == 0) {
            mip[i] = i;
            prime.push_back(i);
        }
        
        for(int j = 0; j < prime.size() and prime[j] <= mip[i] and i * prime[j] <= mip.size(); j++) {
            mip[i * prime[j]] = prime[j];
        }
    }

    auto pfact = [&](int x) {
        std::vector<std::pair<int, int>> vec;
        while(x > 1) {
            if(vec.empty() or vec.back().first != mip[x]) {
                vec.push_back({mip[x], 1});
            } else {
                vec.back().second++;
            }
            x /= mip[x];
        }
        return vec;
    };

	std::vector<bool> setwise(n);
	for(int i = n - 1, g = 0; i >= 0; i--) {		
		g = std::gcd(g, a[i]);
		if(g == 1) setwise[i] = true;
	}

	std::vector<bool> pairwise(n);
	std::vector<int> lcm(1e6 + 1);
	for(int i = n - 1; i >= 0; i--) {
		auto vec = pfact(a[i]);

		bool flag = true;
		for(auto v: vec) flag &= (lcm[v.first] == 0);
		for(auto v: vec) lcm[v.first] = std::max(lcm[v.first], v.second);
		pairwise[i] = flag;
	}

	bool flag = true;
	for(bool v: pairwise) flag &= v;
	if(flag) {
		printf("pairwise coprime\n");
		return 0;
	}
	if(setwise[0]) {
		printf("setwise coprime\n");
		return 0;
	}
	printf("not coprime\n");
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int a[N];
  int flag=1;
  int cnt;
  
  for(int i=0; i<N; ++i)	cin >> a[i];
  
  while(flag){
    for(int i=0; i<N; ++i){
      if(a[i]%2 == 1){
        flag = 0;
      	break;
      }
      else{
      	a[i] = a[i] / 2;
      }
    }
    if(flag!=0)	cnt++;
    else break;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
n, l = map(int, input().split())

aji = [l + i for i in range(n)]

# 0が含まれるか
if 0 in aji:
  print(sum(aji))

# 正の数か
elif sum(aji) > 0:
  print(sum(aji[1:]))
  
else:
  print(sum(aji[:-1]))



Measured memory_bytes: 2940
k = int(input())
a = list(map(int, input().split()))
#そのラウンドで落ちるマックスはa[i]-1人、残る人数は最小でa[i]
#a[i-1] <= 2 でなくてはいけない。
#そのラウンドが終わるごとに人数がa[i]の倍数になっていると考えると分かりやすい
#最大を考える場合は、そのラウンドで毎回毎回max人数落ちてると考えればいい
#最小を考える場合は、そのラウンドで毎回毎回min人数落ちていると考える

if a[-1] > 2:
    print(-1)
    exit()
ans_min = 2
ans_max = 2
a.reverse()
for i in range(k):
    if ans_max % a[i] != a[i] - 1:
        ans_max += (a[i] - 1) - (ans_max % a[i])
    if ans_min % a[i] != 0:
        ans_min += a[i] - ans_min % a[i]
a.reverse()
sim_max = ans_max
sim_min = ans_min
for i in range(k):
    sim_max = sim_max - sim_max % a[i]
    sim_min = sim_min - sim_min % a[i]
if sim_max == sim_min == 2:
    print("{} {}".format(ans_min, ans_max))
else:
    print(-1)

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define PRINTARR(a,b) for(int i=0;(a+i)!=(b);i++){cout << *(a+i) << " ";}PN();
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

typedef pair<int, int> PII;
typedef tuple<int, int, int> T3I;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
char s[MAX_N];

int main()
{
    scanf("%s", s);
    if(strncmp(s, "YAKI", 4) == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

vector<int> color;

void dfs(const vector<vector<pair<int, int>>>& G, int cur, int pre, int c) {
	color[cur] = c;

	for (auto to : G[cur]) {
		if (to.first == pre) {
			continue;
		}
		if (to.second & 1) {
			dfs(G, to.first, cur, 1 - c);
		}
		else {
			dfs(G, to.first, cur, c);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int N;
	cin >> N;

	vector<vector<pair<int, int>>> G(N);

	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		G[u].push_back(make_pair(v, w));
		G[v].push_back(make_pair(u, w));
	}

	color.assign(N, 0);

	dfs(G, 0, -1, 1);

	for (auto c : color) {
		cout << c << endl;
	}

	return 0;
}

Measured memory_bytes: 9728
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
bool ok(int a,int b,int c)
{
    return (a<b&&b<c)||(a>b&&b>c);
}
int main()
{
    int n;
    cin>>n;
    int p[n],cnt=0;
    REP(i,n)cin>>p[i];
    REP(i,n-2)
    {
        if(ok(p[i],p[i+1],p[i+2]))
        {
            // cout<<p[i]<<" "<<p[i+1]<<" "<<p[i+2]<<endl;
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    float Ans = 0;
    cin >> N;    
    vector<pair<double, string> > Pochi(N);
    for(int i = 0;i < N;i++){
        double a;
        string b;
        cin >> a >> b;
        Pochi[i] = make_pair(a,b); 
    }
    for(int i = 0;i < N;i++){
        if(Pochi[i].second == "JPY"){
            Ans += Pochi[i].first;
        }else{
            Ans += Pochi[i].first * 380000.0;
        }
    }
    cout << Ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll  long long 
#define dl long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second


int main ()
{
	
	ll n;
	cin>>n;
	vector<ll>brr(n+1,0);


	for (ll i = 1 ;i<=n;i++)
	{  
        for (ll j = 0;j<=n;j+=i)
        {
        	brr[j]++;

        }
	}

       ll ans=0;
	   for (int  i = 1 ;i<=n;i++)
		{
            ans+= (ll)i * (ll) brr[i];
		}

		cout<<ans<<endl;
	
	return 0;

}

Measured memory_bytes: 81360
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
int _lcm(int a, int b);
int _lcm(int a, int b) {
	return( (int)( (long)(a * b) / (long)_gcd(a, b) ));
}
	
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion

//131 C-Anti-Division

int main(void) {
	ll  a, b, cnt = 0;
	ll c, d;
	
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	a -= 1;
	ll cc, dd,cd,ans;

	cc = b / c - a / c;
	dd = b / d - a / d;

	//gcd--------------------
	ll r, tmp, tc, td; 

    tc = c; td = d;
	if (tc < td) { tmp = tc; tc = td; td = tmp; }
//	printf("tc: %lld td:%lld\n",c,d);
	r = tc % td;
	while (r) {
		if (!r) break;
		tc = td; td = r;
		r = tc % td;
	}
//	printf("gcd: %lld\n", td);
	//lcm
	cd = (c * d) / td;

	//--------------------------





//	cd = _lcm(c, d);

//	printf("lcm:%lld\n", cd);
	cd = b / cd - a / cd;
	ans = b - a;
	ans -= ((cc + dd) - cd);
//	printf("cc:%lld dd:%lld cd:%lld ans:%lld\n", cc, dd, cd, ans);

	printf("%lld \n",ans);
	return 0;
}





Measured memory_bytes: 2148
#include<stdio.h>

int n;
int i;
int j;
int x;

char c;
int hoge[4][13];

main(){
	scanf("%d",&n);
	for(i=0; i<2*n; i++){
		scanf("%c %d",&c,&x);
		switch(c){
			case 'S':hoge[0][x-1]=x;
			break;
			case 'H':hoge[1][x-1]=x;
			break;
			case 'C':hoge[2][x-1]=x;
			break;
			case 'D':hoge[3][x-1]=x;
			break;
		}
	}
	for(i=0; i<4; i++){
		for(j=0; j<13; j++){
			if(hoge[i][j]== 0){
					switch(i){
						case 0:printf("S %d\n",j+1);
						break;
						case 1:printf("H %d\n",j+1);
						break;
						case 2:printf("C %d\n",j+1);
						break;
						case 3:printf("D %d\n",j+1);
						break;
					}
			}
		}
	}
return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int a, b;
	char s;
	for (int i = 0;;++i) {
		std::cin >> a >> s >> b;
		if (s == '?')
			break;
		if (s == '+') {
			std::cout << a + b << std::endl;
		}
		else if (s == '-') {
			std::cout << a - b << std::endl;
		}
		else if (s == '*') {
			std::cout << a * b << std::endl;
		}
		else if (s == '/') {
			std::cout << a / b << std::endl;
		}
	}

	return 0;
}


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

int main() {
int N;
  cin>>N;
  int A=N%10;
  if(A==3){
    cout<<"bon"<<endl;
  }
  if(A==0||A==1||A==6||A==8){
    cout<<"pon"<<endl;
  }
  if(A==2||A==4||A==5||A==7||A==9){
    cout<<"hon"<<endl;
  }
}


Measured memory_bytes: 3632
#include<stdio.h>
int main ()
  {
    int a,b,c;
    scanf("%d %d",&a,&b);
    c=a*b;
    if(0<a)
      { 
        if(a<10)
      { 
        if(0<b)
          { 
            if(b<10)
              printf("%d",c);
            else
              printf("-1");
          }
          else
            printf("-1");
      }
    else
      { 
        printf("-1");
      }
      }
  else
    printf("-1");
  return 0;
  }


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

int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;
  int A,B,C;
  A=X;
  B=Y;
  C=Z;
  int tmp;
  tmp=A;
  A=B;
  B=tmp;
  tmp=A;
  A=C;
  C=tmp;
  cout << A << " "  << B << " " << C << endl;
  
}


Measured memory_bytes: 256
////////////////////////////////////////////////////////////////
//
//    (☝ ՞ਊ ՞)☝ << Be accept!!
//
//    C++ format for competitive professional v1.0
//
//    need gcc & boost::c++
//
////////////////////////////////////////////////////////////////
//#define BOOST
#define CGCC
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
#ifdef CGCC
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
int setup(void) { // set
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return 0;
}
int lenght(char *str) { // getcharlengh
  int i = 0;
  while (str[i]) {
    i++;
  }
  return i;
}
int gcd(long long a, long long b) {
  if (a < b)
    return gcd(b, a);
  long long r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
int iinput(void) {
  int a = 0;
  cin >> a;
  return a;
}
int dinput(void) {
  double a = 0;
  cin >> a;
  return a;
}
string sinput(void) {
  string a = "";
  cin >> a;
  return a;
}
int kuriup(double a) {
  int b = int(a);
  if (a != b) {
    return b + 1;
  } else {
    return b;
  }
}
int kuridown(double a) {
  int b = int(a);
  return b;
}
int sisyagonyu(double a){
  int b =int(a);
  double c=a-b;
  if(c >= 0.5){
      return b+1;
    }else{
      return b;
    }
}
int run(void);
int main(){
  setup();
  run();
  return 0;
}
int run(void){

  int n;
  cin>>n;
  double sum=0;
  vector<int> x(n);
  rep(i,n){
    cin>>x[i];
    sum+=x[i];
  }
  sum/=double(n);
  sum=sisyagonyu(sum);

  int ans=0;
  rep(i,n){
    ans+=(x[i]-sum)*(x[i]-sum);
  }

  cout<<ans<<endl;

  return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
ll m;
ll a[maxn], acc[maxn];

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

  cin>>n>>m;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a,a+n);
  for (int i=0; i<n; i++) {
    acc[i+1] = acc[i] + a[i];
  }

  ll lo = 0;
  ll hi = 1e12;
  ll cnt = 0; ll tot = 0;
  while (hi - lo > 1) {

    ll g = (lo+hi)/2;

    cnt = 0; tot = 0;

    for (int i=0; i<n; i++) {
      int j = std::lower_bound(a,a+n,g-a[i]) - a;
      ll R = n-j;
      cnt += R;
      tot += acc[n]-acc[j] + a[i]*R;
    }

    
    
    if (cnt>=m) {
      lo = g;
    } else {
      hi = g;
    }
  }


  ll ans = tot - (cnt-m)*lo;
  cout<<ans<<endl;
  
  return 0;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
// #define ll long long
#define pb push_back
#define mp make_pair
#define ll unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
typedef vector<vector<ll> > mat;
#define nl "\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size() 

vll a[2001];
ll nlvl[2001];
void bfs(ll s,ll n ) {
	bool vis[n+1]={};
	vis[s]=1;
	queue<ll> q;
	q.push(s);
	ll lvl[n+1]={};
	while(!q.empty()) {
		ll p = q.front();
		q.pop();
		for(auto i:a[p]) {
			if(!vis[i]) {
				vis[i]=1; lvl[i] = lvl[p]+1;
				q.push(i);
			}
		}
	}
	// cout << s << ": " ;
	rep(n+1) {
		if(!i) continue;
		// cout << lvl[i] << " " ;
		nlvl[lvl[i]]++; 
	}
	// cout << nl ;
}

void solve() {
	ll n ,x , y ; cin>>n>>x>>y ;
	rep(n) {
		a[i].pb(i+1); a[i+1].pb(i);
	}
	a[x].pb(y); a[y].pb(x);

	rep(n+1) if(!i) continue; else bfs(i,n);
	for(ll i=1;i<n;++i) cout << nlvl[i]/2 << nl ;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll t=1;
	// cin>>t;
	rep(t) {
		solve() ; 
	}
	return 0;
}

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

int main() {
    int64_t N;
    cin >> N;

    string ans;

    while (N) {
        N--;
        ans += 'a' + N % 26;
        N /= 26;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
    int a,b,c,x;
    
    scanf("%d%d%d",&a,&b,&c);
    while(a>b || b>c){
    if(a>b){
        x=a;
        a=b;
        b=x;
    }else if(b>c){
        x=b;
        b=c;
        c=x;
    }
    }

    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define input(v,n) for(int i=0;i<n;i++)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //

int n,m;

void test() {

    cin >> n;
    cout << M_PI*2*n;
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif

    int T = 1;
    
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 3796
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  rep(i, h) cin >> s[i];
  rep(i, w + 2) cout << '#';
  cout << endl;
  rep(i, h) { cout << '#' << s[i] << '#' << endl; }
  rep(i, w + 2) cout << '#';
  cout << endl;
  return 0;
}


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

int main() {
  int N;
  int K;
  string str1;
  cin >> N >> K;
  cin >> str1;
  
  for (int i = 0; i < N; i++) {
    if (K-1 == i){
    if (str1.at(i) == 'A') {
    cout << "a";
  }
  if (str1.at(i) == 'a') {
    cout << "A" ;
  }
  if (str1.at(i) == 'B') {
    cout << "b";
  }
  if (str1.at(i) == 'b') {
    cout << "B";
  }
  if (str1.at(i) == 'C') {
    cout << "c";
  }
  if (str1.at(i) == 'c') {
    cout << "C";
  }
      
               }
    else{
      cout << str1.at(i);
        }
  }
}


Measured memory_bytes: 384
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
int power(int a,int b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}


int32_t main()
{
    IOS
    
    
        int a,b;
        cin>>a>>b;
        if(b==1)
        {
            cout<<0;
            return 0;
        }
        int count=0;
        int temp=1;
        for(int i=1;i<=100;++i)
        {
            temp=temp+a-1;
            if(temp>=b)
            {
                cout<<i;
                return 0;
            }
        }

}

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

int main()
{
	  long long int n;
	  cin>>n;
	  long long int a[n],ans[n];
	  long long int imu=0,imran=0;
	  for (int i=0;i<n;i++){
        cin>>a[i];
        imu+=a[i];
        if(i%2==1){
            imran+=a[i];
        }
	  }
	  ans[0]=imu/2-imran;
	  cout<<ans[0]*2<<" ";
	  for(int i=1;i<n;i++){
        ans[i]=a[i-1]-ans[i-1];
        cout<<ans[i]*2;
        if(i!=n-1){
            cout<<" ";
        }
	  }
	  cout<<endl;
}


Measured memory_bytes: 2816
#include <stdio.h>
int main()
{
    int a;
    int i;
 
    i = 0;
    do{
        scanf("%d", &a);
  
        if (a != 0){
            i = i + 1;
            printf("Case %d: %d\n",i, a);
        }
  
     }while (a != 0);
  
    return 0;
}

Measured memory_bytes: 1676