akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define PI acos(-1)

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

}

int main()
{
    textIO();
    fastIO();

    long long a, b, h, m;
    cin >> a >> b >> h >> m;

    double hdeg = (h*30)+(m*0.5);
    double mdeg = (m*6);
    double degdiff = min(abs(mdeg-hdeg), abs(hdeg-mdeg));
    double ans = sqrt((a*a)+(b*b)-(2*a*b*cos((PI*degdiff)/180)));

    cout << fixed << setprecision(9) << ans << '\n';

    return 0;
}


Measured memory_bytes: 4244
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class ATakahashiCalendar {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int m,d,ans=0;
        in>>m>>d;
        Fr(i,m){
            Fr(j,d){
                if(i==(j/10)*(j%10)&&(j/10)>1&&(j%10)>1) ++ans;
            }
        }
        out<<ans<<endl;
    }
};

int main() {
    ATakahashiCalendar solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
struct knife
{
	int ai;
	bool f;
}m[2000018];
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int N,H,ans;
bool cmp(knife x,knife y)
{
	return x.ai>y.ai;//返回伤害最大的刀 
}
int main()
{
	N=read();H=read();
	for(int i=1;i<=N;i++)
	   {m[i].ai=read();
	   	m[i+N].ai=read();
	    m[i+N].f=true;}   //我们把每把刀看作是可以无限扔的和只能扔一次的两把刀，存进去 
	sort(m+1,m+1+N*2,cmp);//排序，便于取 
	int ans=0;    //ans
	for(int i=1;i<=2*N;i++) //枚举2*N把刀 
	   {if(m[i].f)     //接下来贪心，如果刀可以飞出去就废掉，同时加上伤害 
		  {ans++;
		   H-=m[i].ai;}
	    else{int u=H%m[i].ai;//如果碰到第一把无限次飞而且伤害最高的就无限砍 
		     ans+=H/m[i].ai;//一直砍到没血，记录ans+ 
	         if(u)ans++;
		  	 H=-1;}
	      if(H<=0){cout<<ans;return 0;}//如果没血了就输出 
	   }
}


/*
  AtCoder Regular Contest 089  
  D - Katana Thrower
  当你突然遇到一个怪物时，你正在外出散步。 
  幸运的是，你有N卡塔娜（剑），武士刀1，武士刀2，...，武士刀N
  并可以以任何顺序执行以下两种攻击：
  1.挥舞你的武士刀之一。 当你使用武士刀i（1≤i≤N）时，怪物会受到ai点伤害同样的武士刀可以使用任何次数。
  2.扔你的一个武士刀。 当你把怪物卡塔纳i（1≤i≤N）扔到怪物身上时，它会受到bi的伤害，而你失去了武士刀。
    也就是说，你不能再使用或扔掉那个武士刀。
  当它获得的总伤害是H点或更多时，怪物将消失。 
  至少需要多少次攻击才能彻底消失？
*/

Measured memory_bytes: 1792
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	a := make([]int, n+1)
	a[0] = 0
	for i := 1; i <= n; i++ {
		a[i] = sc.ReadInt()
	}

	totalTableHeight := 0
	for i := 1; i <= n; i++ {
		tableHeight := Max(0, a[i-1]-a[i])
		a[i] += tableHeight
		totalTableHeight += tableHeight
	}

	fmt.Println(totalTableHeight)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 5868
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;
char D[26];

void solve() {
	cin >> S;
	N = sz(S);
	if(N != 26) {
		rep(i, 0, N) {
			D[S[i] - 'a'] = 1;
		}
		rep(i, 0, 26) {
			if(!D[i]) {
				S += char('a' + i);
				break;
			}
		}
		cout << S << "\n";
	}
	else {
		D[S[25] - 'a'] = 1;
		rer(i, 25, 0) {
			if(S[i] < S[i + 1]) {
				rep(j, 0, 26) {
					if(D[j] && S[i] - 'a' < j) {
						S = S.substr(0, i) + char('a' + j);
						break;
					}
				}
				cout << S << "\n";
				return;
			}
			D[S[i] - 'a'] = 1;
		}
		cout << -1 << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main ()
{
	int a, b;
	cin >> a >> b;
	cout << "a";
	if(a > b)
		cout << " > ";
	else if(a < b)
		cout << " < ";
	else
		cout << " == ";
	cout << "b" << endl;
	return 0;
} 


Measured memory_bytes: 3124
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  int cnt = 0, prev = 0;
  for (int i = 0; i < N; ++i) {
    int h; cin >> h;
    if (prev <= h) {
      prev = h;
      ++cnt;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3600
# coding: utf-8

# In[95]:


N = int(input())


# In[96]:


third_letter = "C"


# In[97]:


a = int(N / 1000)
b = N % 999


# In[99]:


letter_ascii = ord(third_letter) + a


# In[100]:


letter = chr(letter_ascii)


# In[101]:


output = "AB" + letter


# In[102]:


print(output)



Measured memory_bytes: 2940
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int n,x;
		int cnt = 1;
		Scanner sc = new Scanner(in);
		ArrayList<Integer> l = new ArrayList<Integer>();
		ArrayList<Integer> d = new ArrayList<Integer>();
		n = sc.nextInt();
		x = sc.nextInt();
		d.add(0);
		for (int i = 1; i <= n; ++i){
			l.add(sc.nextInt());
			d.add(d.get(i - 1) + l.get(i - 1));
			if(d.get(i) <= x){
				++cnt;
			}
			// out.println(d.get(i));
		}
		out.println(cnt);
	}
}


Measured memory_bytes: 23252
/*
		  		    _oo0oo_
	               08888888o
			       88" . "88
			       (| -_- |)
			       0\  =  /0
			     ___/'---'\___
		       .' \\|     |// '.
		      / \\|||  :  |||// \
		     / _||||| -:= |||||- \
		    |   | \\\  -  /// |   |
		    | \_|  ''\---/''  |_/ |
		    \  .-\__  '-'   __/-. /
	      ___'. .'  /--.--\  '. .'___
       .== '<  '.___\_<|>_/___.' >' "".
      | | :  '- \'.;'\ _ /';.'/ - ' : | |
      \  \ '_.   \_ __\ / __ _/  ._' /  /
  ====='-.____'.___ \____/ ___.-'___.-'=====
                   '=---='

          ~~~~~~~~~~~~~~~~~~~~~~~~~~~

            佛祖保佑      永无BUG
*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int d=s.length();
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
		{
			d=i;
			break;
		}
	}
	for(int i=d+1;i<s.length();i++)
	{
		if(s[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}




int main()
{ 

  IOS;

ll n;cin>>n;

vl a(n);

ll ans=1e18;
ll k=0,s=0;
for(int i=0;i<n;i++){
  cin>>a[i];
  s+=a[i];
 // ans=min({ans,abs(2*k)})
}

for(int i=0;i<n;i++){
k+=a[i];
ans=min(ans,abs(2*k-s));
}

cout<<ans<<endl;



return 0;
 
}



Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  int g;
  cin >>g;
  int a,b;
  cin >>a >>b;
  if(g==1){cout << "Hello World" << endl;}else{cout << a+b << endl;}
}

Measured memory_bytes: 3544
def solve():
    s = input()
    
    len_s = len(s)
    for i in range(len_s - 1):
        c = s[i:i + 2]
        if c[0] == c[1]:
            print(i + 1, i + 2)
            exit()
    for i in range(len_s - 2):
        c = s[i:i + 3]
        if c[0] == c[-1]:
            print(i + 1, i + 3)
            exit()
    print(-1, -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=998244353;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;cin >> a >> b >> c >> d;
    ll u=c-a+1,v=d-b+1;
    vector<vector<ll>> dp(u+1,vector<ll>(v+1));
    dp[0][0]=1;
    for(ll i=1;i<=u;i++){
        (dp[i][0]+=dp[i-1][0]*b%mod)%=mod;
    }
    for(ll i=1;i<=v;i++){
        (dp[0][i]+=dp[0][i-1]*a%mod)%=mod;
    }
    for(ll i=1;i<=u;i++){
        for(ll j=1;j<=v;j++){
            (dp[i][j]+=dp[i-1][j]*(j+b)%mod+dp[i][j-1]*(i+a)%mod)%=mod;
            (dp[i][j]+=mod-dp[i-1][j-1]*(i-1+a)%mod*(j-1+b)%mod)%=mod;
        }
    }
    cout << dp[u-1][v-1] << endl;
}

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

int main() {
	int n; cin >> n;
	int k; cin >> k;
	string x; cin >> x;
	vector<char> s;
	for (int i = 0; i < n; i++) {
		
		s.push_back(x[i]);
	}
	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	}
	else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	}
	else{
		s[k - 1] = 'c';
	}
	x = ("");
	for (int i = 0; i < n; i++) {
		x.push_back(s[i]);
		
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      int K = nextInt();
      int X = nextInt();
      int Y = nextInt();
      myout(X * Math.min(N, K) + Math.max(0, N - K) * Y);
	}
	//Method addition frame start


  
	//Method addition frame end
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int X;
    cin >> X;

    cout << (2199 - X) / 200 << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>

int main()
{
  int i, n;
  char str[100000 + 1];
  scanf("%s", str);
  n = strlen(str);
  for (i = 0; i < n; i += 2) {
    putchar(str[i]);
  }
  puts("");
  
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    int i,j,k,l,r,x,y; string s;
    bool exit = false;
    int N;
    cin>>N;
    vector <ll> A(N);
    FOR(i,N){
        cin>>A[i];
    }
    sort(ALL(A),greater<ll>());
    ll ret=0;
    if(N%2==0){
        FOR(i,N/2){
            if(i==N/2-1){
                ret+=A[i];
            }else{
                ret+=2*A[i];
            }
        }
        FOR(i,N/2){
            if(i==0){
                ret-=A[i+N/2];
            }else{
                ret-=A[i+N/2]*2;
            }
        }
        cout<<ret<<endl;
        return;
    }
    else{
        ll cand1=0;
        ll cand2=0;
        FOR(i,N/2){
            cand1+=2*A[i];
        }
        FOR(i,N/2+1){
            if(i==0 or i==1){
                cand1-=A[i+N/2];
            }else{
                cand1-=A[i+N/2]*2;
            }
        }



        FOR(i,N/2){
            cand2 -= 2*A[i+N/2+1];
        }
        FOR(i,N/2+1){
            if( i==N/2 or i==N/2-1 ){
                cand2+=A[i];
            }else{
                cand2+=A[i]*2;
            }
        }

        ret = max(cand1,cand2);
        cout<<ret<<endl;
        return;
    }
    /*cin>>N;
    vector<ll> V((N+1)*(N+1));
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;


vector<int> ans(200005,0);
void dfs(const Graph &G, int v, int p=-1) {

    for (int c : G[v]) {
        if (c == p) continue;
        ans[c] += ans[v];
        dfs(G,c,v);
    }

}

int main() {
    int N,Q; cin >> N >> Q;

    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
      }

    for (int i = 0; i < Q; ++i) {
            int p, x;
            cin >> p >> x;
            --p;
            ans[p]+=x;
    }

    int root = 0;
    dfs(G, root, 0);

    for (int i=0;i<N;i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 26624
N = int(input())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

void printb(ll n) {
    rep(i, 32) {
        if (n & 1ll<<31) cout<<1;
        else cout<<0;
        n = n<<1;
    }
    cout<<endl;
}

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

    ll n;
    cin>>n;
    printb(n);
    printb(~n);
    printb(n<<1);
    printb(n>>1);
}


Measured memory_bytes: 3232
//#include <bits/stdc++.h>
//
//using namespace std;
//
//#define int long long
//#define endl '\n'
//#define maxn 100010
//const int MOD = 1000000007;
//
//vector<int> r[maxn];
//
//void solve() {
//    int n, m, k, q;
//    cin >> n >> m >> k >> q;
//
//    for (int i = 0; i < k; i++) {
//        int a, b;
//        cin >> a >> b;
//
//        r[a].push_back(b);
//    }
//    vector<int> nice;
//    for (int i = 0; i < q; i++) {
//        int tp;
//        cin >> tp;
//        nice.push_back(tp);
//    }
//    int ct = 0, ans = 0;
//    for (auto &row:r)sort(row.begin(), row.end());
//    for (int row = 1; row <= n; row++) {
//        if (ct == k)break;
//        if (row == 1) {
//            if (r[row].empty()) {
//                ans++;
//            } else ans += r[row].back(), ct += r[row].size();
//            continue;
//        }
//
//    }
//    cout << ans - 1 << endl;
//}
//
//int32_t main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr);
//
//    int t = 1;
////    cin >> t;
//
//    while (t--)
//        solve();
//    return 0;
//}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, s1 = 0, s2 = 0;
    cin >> n;

    vector<int> v(3 * n);
    for (int i = 0; i < 3 * n; ++i) cin >> v[i];
    priority_queue<int, vector<int>, greater<int>> pq1;
    priority_queue<int> pq2;
    for (int i = 0; i < n; i++)pq1.push(v[i]), s1 += v[i];
    for (int i = 0; i < n; i++)pq2.push(v[2 * n + i]), s2 += v[2 * n + i];
    vector<int> pre(n + 1), suff(n + 1);
    pre[0] = s1, suff[n] = s2;
    for (int i = 0; i < n; i++) {
        int idx = n + i;
        if (v[idx] > pq1.top())
            s1 += v[idx] - pq1.top(), pq1.pop(), pq1.push(v[idx]);
        pre[i + 1] = s1;
    }
    for (int i = 0; i < n; i++) {
        int idx = 2 * n - i - 1;
        if (v[idx] < pq2.top())
            s2 += v[idx] - pq2.top(), pq2.pop(), pq2.push(v[idx]);
        suff[n - i - 1] = s2;
    }
    int ans = LLONG_MIN;
    for (int i = 0; i <= n; i++)ans = max(ans, pre[i] - suff[i]);
    cout << ans << endl;
}

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

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

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 5876
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 50000
#define INF 0x3f3f3f3f
int main(){
	int a=read(),b=read();
	if(a%2==0||b%2==0) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,m,a[N];

int main(){
    read2i(n,m);
    lp(i,1,m) readi(a[i]);
    sort(a+1, a+1+m);
    multiset<int> st;
    lp(i,1,m-1) st.insert(a[i+1] - a[i]);
    --n;
    while(n and st.size()) st.erase(st.find(*st.rbegin())), --n;
    ll ans = 0;
    for(int i : st) ans += i;
    cout <<ans;
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


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

int main() {
    for(int N, M; cin >> N >> M, N + M != 0; ) {
    vector<int> H(N + 1);
    vector<int> W(M + 1);
    H[0] = W[0] = 0;
    for(int i = 1; i <= N; i++) {
        int k; cin >> k;
        H[i] = H[i - 1] + k;
    }
    for(int i = 1; i <= M; i++) {
        int k; cin >> k;
        W[i] = W[i - 1] + k;
    }
    vector<int> A;
    for(int i = 0; i < (int)H.size(); i++) {
        for(int j = i + 1; j < (int)H.size(); j++) {
            A.push_back(H[j] - H[i]);
        }
    }
    vector<int> B;
    for(int i = 0; i < (int)W.size(); i++) {
        for(int j = i + 1; j < (int)W.size(); j++) {
            B.push_back(W[j] - W[i]);
        }
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int res = 0;
    for(int i = 0; i < (int)A.size(); i++) {
        res += upper_bound(B.begin(), B.end(), A[i]) - lower_bound(B.begin(), B.end(), A[i]);
    }
    cout << res << endl;
    }
}

Measured memory_bytes: 21424
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int x,y;
    cin>>x>>y;
    int a=x*2;
    if(y<a)
    {
        cout<<"No"<<endl;
    }
    else
    {
        if(a==y)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        for(int i=1; i<=x; i++)
        {
            a+=2;
            if(a==y)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
import sys

(x, n) = list(map(int, input().split()))
arr = list(map(int, input().split()))

if(len(arr) == 0):
    print(x)
    sys.exit()

if(not(x in arr)):
    print(x)
    sys.exit()

i = 1
while True:
    if(not (x - i in arr)):
        print(x - i)
        sys.exit()
    
    if(not (x + i in arr)):
        print(x + i)
        sys.exit()
    i += 1


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll mat[3005][3005], dp[3005][3005][4] ;
ll r, c ;

ll check(ll row, ll col, ll val)
{
    if (dp[row][col][val] != -1) return dp[row][col][val] ;
    ll ans = 0 ;

    if (row < r) {
        ans = max(ans, check(row + 1, col, 0)) ;
        if (val < 3) {
            ans = max(ans, mat[row][col] + check(row + 1, col, 0)) ;
        }
    }
    if (col < c) {
        ans = max(ans, check(row, col + 1, val)) ;
        if (val < 3) {
            ans = max(ans, mat[row][col] + check(row, col + 1, val + 1)) ;
        }
    }
    return dp[row][col][val] = ans ;
}

int main()
{
    ll k, r1, c1, v ;
    cin >> r >> c >> k ;

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            mat[i][j] = 0 ;
            dp[i][j][0] = -1, dp[i][j][1] = -1, dp[i][j][2] = -1, dp[i][j][3] = -1 ;
        }
    }

    for (int i = 0; i < k; i++) {
        scanf("%lld %lld %lld", &r1, &c1, &v) ;
        mat[r1 - 1][c1 - 1] = v ;
    }

    cout << check(0, 0, 0) ;

    return 0 ;
}


Measured memory_bytes: 356260
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
def main():
    alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
    'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

    c = input().strip()

    print(alphabet[alphabet.index(c) + 1])


main()

Measured memory_bytes: 8964
import math
N=int(input())

def isPrime(n):
  for k in range(2,int(math.sqrt(n))+2):
    if n%k==0:
      return False
  else:
    return True

plist=[]
p=1
while(len(plist)<N):
  p+=10
  if isPrime(p):
    plist.append(p)
    
print(*plist)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mx,mn,sum;
int main(){
	ll k;
	cin>>k;
	for(int i=1; i<=k; i++){
		for(int j=i+1; j<=k; j++){
			if(i%2==0&&j%2!=0) ans++;
			else if(i%2!=0 && j%2==0) ans++;
		}
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
Module Module1

    Sub Main()

        Dim N As Integer = Console.ReadLine
        Dim bunsi As Integer

        If N Mod 2 = 0 Then
            bunsi = N \ 2
        Else
            bunsi = (N + 1) \ 2
        End If

        Console.WriteLine((bunsi / N).ToString("0.0000000000"))
        'Console.Read()

    End Sub

End Module


Measured memory_bytes: 13268
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i=0;i<=25;i++){
      for(int j=0;j<=25;j++){
        if(n==4*i+7*j){
          System.out.println("Yes");
          return ;
        }
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long


signed main(){
  int n,m;
  cin >> n >> m;
  int x,c[n], a[n][m];
  cin >> x;
  vector<int> v(n);
  LOOP(i,n){
    cin >> c[i];
    LOOP(j,m){
      cin >> a[i][j];
    }
    v[i] = i;
  }
  int mincost = INF;
  for (int bit = 0; bit < (1<<n); ++bit) {
    int exp[12] = {};
    int cost = 0;
    LOOP(i,n){
      if(bit & (1<<i)){
        cost += c[i];
        LOOP(j,m){
          exp[j] += a[i][j];
        }
      }
    }
    bool f = false;
    LOOP(i,m){
      if(exp[i] < x){
        f = true;
        break;
      }
    }

    if(f==false){
      mincost = min(mincost, cost);
    }
  }
  if(mincost==INF){
    cout << -1;
  }else{
    cout << mincost << endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define int long long 

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

	int current = 1;
	int count = 0;
	while(current < b) {
		current--;
		current += a;
		count++;
	}
	cout << count << endl;
}

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

using namespace std;

const int N = 1e5+100;
int n, m, h[N];
vector<int> g[N];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d %d", &n, &m);
	
	for (int i = 1; i <= n; i++)
		scanf("%d", &h[i]);

	for (int i = 0; i < m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int ans = 0;

	for (int i = 1; i <= n; i++){
		bool good = true;
		for (int j = 0; j < (int)g[i].size(); j++){
			int adj = g[i][j];
			if (h[adj] >= h[i])
				good = false;
		}
		ans += good;
	}

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

	return 0;
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			A();
		}

		public static void A()
		{
			Scanner cin = new Scanner();
			int a = cin.NextInt();
			int b = cin.NextInt();
			int c = cin.NextInt();
			if ((a < c && c < b)
				|| (b < c && c < a)) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}


		public static void B()
		{
			Scanner cin = new Scanner();
			int n = cin.NextInt();
			string s = cin.Next();
			int k = cin.NextInt();

			char t = s[k - 1];
			string ss = "";
			for (int i = 0; i < n; ++i) {
				if (s[i] == k) {
					ss += s[i];
				} else {
					ss += "*";
				}
			}

			Console.WriteLine(ss);
		}



	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{
	public int n = 0;
	public int[] x;
	public int[] y;
	public double area = 0.0;
	
	public static int count = 0;
	public static Scanner scan;
	Main(){}
	
	Main(int _n){
		n = _n;
		x = new int[n];
		y = new int[n];
	}
	
	public boolean process(){
		if( n <= 0 ){ return false; }
		for( int i = 0; i < n; i++ ){
			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
		}
		for( int i = 1; i < n-1; i++ ){
			area += ((x[i+1]-x[0])*(y[i]-y[0]) - (x[i]-x[0])*(y[i+1]-y[0])) / 2.0;
		}
		System.out.println(count + " " + area);
		return true;
	}
	
	public static void main(String[] args){
		scan = new Scanner(System.in);
		for( count = 1; new Main(scan.nextInt()).process(); count++ );
		return;
	}
}

Measured memory_bytes: 20988
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
int main()
{
  int t,n,k,l,r,tt,i;
  ll res;
  vector<int> e;
  vector<P> p;
  decltype(e)::iterator it;
  cin >> t;
  for(tt=0;tt<t;tt++){
    cin >> n;
    res=0;
    e.clear();
    p.clear();
    for(i=0;i<n;i++){
      cin >> k >> l >> r;
      res+=r;
      p.emplace_back(l-r,k-1);
    }
    sort(p.begin(),p.end(),greater<P>());
    for(i=0;i<n;i++){
      if(p[i].first<=0)
        break;
      e.push_back(i);
    }
    for(i=0;i<n;i++){
      if(p[i].first<=0)
        break;
      it=upper_bound(e.begin(),e.end(),p[i].second);
      if(it==e.begin()){
        continue;
      }
      e.erase(prev(it));
      res+=p[i].first;
    }
    e.clear();
    for(i=n-1;i>=0;i--){
      if(p[i].first>=0)
        break;
      e.push_back(i);
    }
    for(i=n-1;i>=0;i--){
      if(p[i].first>=0)
        break;
      it=upper_bound(e.begin(),e.end(),p[i].second+1,greater<int>());
      if(it==e.begin()){
        res+=p[i].first;
        continue;
      }
      e.erase(prev(it));
    }
    cout << res << endl;
  }
  return 0;
}

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

int main()
{
    string b, ans;
    cin >> b;
    if (b == "A")
        ans = "T";
    else if (b == "T")
        ans = "A";
    else if (b == "C")
        ans = "G";
    else if (b == "G")
        ans = "C";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int a = 0, b = 0;
string s;

int main() {
    cin >> s;
    REP(i, s.length()) {
        a += (i & 1) == (s[i] == '0');
        b += (i & 1) != (s[i] == '0');
    }
    cout << min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 512
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split())
a = [int(c) for c in input().split()]
b = [c//2 for c in a]
g = reduce(lcm_base, b, 1)
G = reduce(lcm_base, a, 1)
if M<g:
  print(0)
  import sys
  sys.exit()
m = a[0]&-a[0]
for i in range(N):
  if m != a[i]&(-a[i]):
    print(0)
    break
else:
  n = (M-g)//G
  print(n+1)

Measured memory_bytes: 16232
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = inintl()

A = [0] + A + [0]

s = 0

for i in range(n+1):
    s += abs(A[i] - A[i+1])

for i in range(1,n+1):
    print(s+abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i+1] - A[i])))


Measured memory_bytes: 20540
#include <algorithm>
#include<stdio.h>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

int main(void) {
  int n;
  for(;scanf("%d",&n)>0;){
    VI a(n);
    REP(i,0,n)scanf("%d",&a[i]);
    sort(a.begin(),a.end());
    int b=0;
    REP(i,0,n)b+=(n-i)*a[i];
    printf("%d\n",b);
  }
}



Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<int> L(n);
    for (int &l : L) cin >> l;
    int ans = pow(3, n);
    int only_odd = 1;
    for (int i = 0; i < n; i++) {
        only_odd *= (L[i] % 2) ? 1 : 2;
    }
    cout << ans - only_odd << '\n';
}


Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n , m;
  	cin >> n >> m;
    int x = min(n , m);
  	int y = max(n , m);
  	for(int i = 0 ; i < y ; i++)
      cout << x ;
  
 	return 0; 
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
a = 10
b = 0
x = np.zeros((10, 10, ))
for i in range(1,n+1):
  while (i // a != 0):
    a = a * 10
  c = (i * 10) // a
  d = i % 10
  x[c][d] += 1

for i in range(0,10):
  for j in range(0,10):
    b += int(x[i][j] * x[j][i])
print(b)

Measured memory_bytes: 12420
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

long long sosuu(long long number)
{
    long long i;
    for(i = 2;i <= (long long)sqrt(number);++i){
        if(i == number){
            return 1;
        }
        if(number%i == 0){
            return 0;
        }
    }
    return 1;
}

int main()
{
    long long a,b;
    long long i,j,k;
    cin >> a >> b;
    long long max,min,tmp;
    if(b > a){
        max = b; min = a;
    }else{
        max = a; min = b;
    }
    while(max%min){
        tmp = max%min;
        max = min;
        min = tmp;
    }
    long long saidaikouyaku = min;
    long long ans = 0;
    for(i = 1;i <= sqrt(saidaikouyaku);++i){
        if(saidaikouyaku%i){
            continue;
        }else{
            ans += sosuu(i);
            if(saidaikouyaku != 1){
                ans += sosuu(saidaikouyaku/i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php


[$S] = fscanf(STDIN, "%s");
[$T] = fscanf(STDIN, "%s");

$S = str_split($S);
$T = str_split($T);
$ans = 0;
foreach($S as $key=>$value){
    if($value !== $T[$key]){
        $ans++;
    }
}
echo $ans;

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

int main(){
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for(int x=0; x<=K; x++) for(int y=0; y<=K; y++){
        int z = S-x-y;
        if(0 <= z && z <= K) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(reader.readLine());
        long max = (long) Math.sqrt(n);
        long sum = 0;
        // n = i * (m + 1)    (ただし 1 <= i < m)
        for (long i = 1; i <= max; i++) {
            if (n % i == 0) {
                long m = n / i - 1;
                if (i < m) {
                    sum += m;
                }
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

if A.count{|a| a == 0} > 0 || A.count{|a| a < 0}.even? then
  puts A.inject(0){|r, a| r + a.abs}
else
  puts A.inject(0){|r, a| r + a.abs} - 2 * A.min_by{|a| a.abs}.abs
end


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

ll mypow(ll x, ll n){
  if(n == 0)
    return 1;
 
  if(n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  ll mod0 = n / k;
  if(k == 1){
    ans = mypow(n, 3);
    cout << ans << endl;
    return 0;
  }
  if(k % 2 == 0){
    if(n % k >= k / 2){
      ans = mypow(mod0, 3) + mypow(mod0 + 1, 3);
    }else {
      ans = 2 * mypow(mod0, 3);
    }
    cout << ans << endl;
  }else {
    ans = mypow(mod0, 3);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
console.log((args=>{
  const s = args.trim();
  const N = s.length-1;
  let x = 0;
  for ( let i = 0, j = N; i < j; i++, j-- ) {
    while ( s[i] !== s[j] ) {
      if ( s[i] === 'x' ) x++,i++;
      else if ( s[j] === 'x' ) x++,j--;
      else return '-1';
    }
  }
  return `${x}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 32520
#include <stdio.h>
 
int main(void) {
	int a,b,sum;
	scanf("%d %d",&a,&b);
	sum=a+b;
	if(a%3==0)
		printf("Possible\n");
	else if(b%3==0)
		printf("Possible\n");
	else if(sum%3==0)
		printf("Possible\n");
	else
		printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int g[120000];
int i,j,n,t;

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&g[i]);
	for (i=1;i<=n;i=j+1,t++)
	{
		for (j=i;(j<=n) && (g[i]==g[j]);j++);
		if (g[i]>g[j]) for (;(j<=n) && (g[j+1]<=g[j]);j++);
		else for (;(j<=n) && (g[j+1]>=g[j]);j++);
	}
	printf("%d",t);
	return 0;
}

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

int main(){
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if (x == 3){
        ans += 100000;
    }
    else if (x == 2){
        ans += 200000;
    }
    else if (x == 1){
        ans += 300000;
    }

    if (y == 3){
        ans += 100000;
    }
    else if (y == 2){
        ans += 200000;
    }
    else if (y == 1){
        ans += 300000;
    }

    if (x == 1 && y == 1){
        ans += 400000;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
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 SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            out.println(a[n - 1] - a[0]);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 22740