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

#define REP(type, i, n) for (type i = 0; i < (n); ++i)
#define MAX(a, b) (a > b ? a : b)

int main(void) {
  long N; cin >> N;
  vector<long> o(100000, 0);
  vector<long> e(100000, 0);
  REP(long, i, N) {
    long v; cin >> v;
    if (i%2 == 0) o.at(v-1)++;
    else e.at(v-1)++;
  }
  auto o1 = max_element(o.begin(), o.end());
  auto e1 = max_element(e.begin(), e.end());
  auto oi = distance(o.begin(), o1);
  auto ei = distance(e.begin(), e1);
  if (oi == ei) {
    long to1 = *o1;
    long te1 = *e1;
    o.at(oi) = 0; e.at(ei) = 0;
    long o2 = *max_element(o.begin(), o.end());
    long e2 = *max_element(e.begin(), e.end());
    cout << N-MAX(to1+e2, o2+te1) << endl;
  } else cout << N-(*o1)-(*e1) << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

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

  min = a;
  max = a;

  if (b > max) max = b;
  if (b < min) min = b;

  if (c > max) max = c;
  if (c < min) min = c;

  printf("%d %d\n", min, max);

  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>
#define N 200000
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {
	int i, j, n, R[N];

	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d", &R[i]);
	}

	int maxv = -1000000000;
	int minv = R[0];
 	
	for(i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	printf("%d\n", maxv);

	return 0;
}




Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans=0;

    ans = b / c;
    if(a == 0)
        ans += 1;
    else if(a % c ==0)
        ans -= a/c - 1;
    else
        ans -= a/c;

    cout << ans << endl;

}


Measured memory_bytes: 3620
/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

vector<int>v;
int n,mn;
unordered_map<int,bool>dp;

bool solve(int k)
{
//    assert(k>=0);

    if(k<mn) return false;

//    if(binary_search(ALL(v),k)) return true;

    if(dp.count(k))
        return dp[k];

    bool ok = false;

    for(int i=0; i<n; i++)
    {
        if(v[i]>k)
            break;

        if(solve(k-v[i])==false)
        {
            ok = true;
            break;
        }
    }

    return dp[k] = ok;
}

int main()
{
    optimizeIO();

//    WRITE;

    int k;
    cin>>n>>k;

    mn = INT_MAX;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
        mn = min(mn,v[i]);
    }

    if(solve(k))
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;

    return 0;
}

/**
1 4
3

2 4
2 3

2 5
2 3

2 7
2 3

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}





Measured memory_bytes: 11976
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
int main() {
    ll N;
    cin>>N;
    vi A(N),B(N),C(N);
    REP(i,N)cin>>A[i];
    REP(i,N)cin>>B[i];
    REP(i,N)cin>>C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    //vector<vi> dp(2,vi(N));
    ll ind1=0,ind2=0;
    REP(i,N){
        while(A[ind1]<B[i]&&ind1<N)ind1++;
        //dp[0][i]=N-ind1;
        while(B[i]>=C[ind2]&&ind2<N)ind2++;
        //dp[1][i]=N-ind2;
        //cout<<i<<","<<ind1<<","<<ind2<<endl;
        ans+=ind1*(N-ind2);
    }
    cout<<ans<<endl;
    
    REP(i,N)
    return 0;
}

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

using namespace std;

vector< int > nums;

template< typename T >
struct SegmentTree
{
  vector< T > seg, add;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, 0);
    add.assign(2 * sz - 1, 0);
  }

  T merge(T a, T b)
  {
    return (a + b);
  }

  void set(int k, int x)
  {
    seg[k + sz - 1] = x;
  }

  void build()
  {
    for(int k = sz - 2; k >= 0; k--) {
      seg[k] = merge(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }

  T rmq(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) return (seg[k] + add[k] * (nums[r] - nums[l]));
    return (merge(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
                  rmq(a, b, 2 * k + 2, (l + r) >> 1, r)) +
            (add[k] * (min(nums[r], nums[b]) - max(nums[l], nums[a]))));
  }

  T rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, sz));
  }

  void rangeadd(int a, int b, T x, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      add[k] += x;
      return;
    }
    rangeadd(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    rangeadd(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    seg[k] += x * (min(nums[r], nums[b]) - max(nums[a], nums[l]));
  }

  void rangeadd(int a, int b, T x)
  {
    rangeadd(a, b, x, 0, 0, sz);
  }
};

using int64 = long long;

int main()
{
  int N, M, Q;
  int A[100000], B[100000], C[100000];
  int X[100000], Y[100000];
  int64 Z[100000];
  int L[100000], R[100000];

  scanf("%d %d %d", &N, &M, &Q);

  for(int i = 0; i < M; i++) {
    scanf("%d %d %d", &A[i], &B[i], &C[i]);
    --A[i];
    nums.emplace_back(A[i]);
    nums.emplace_back(B[i]);
  }

  for(int i = 0; i < Q; i++) {
    scanf("%d %d %lld", &X[i], &Y[i], &Z[i]);
    --X[i];
    L[i] = 0, R[i] = M - 1;
    nums.emplace_back(X[i]);
    nums.emplace_back(Y[i]);
  }
  sort(begin(nums), end(nums));
  nums.erase(unique(begin(nums), end(nums)), end(nums));

  for(int i = 0; i < M; i++) {
    A[i] = lower_bound(begin(nums), end(nums), A[i]) - begin(nums);
    B[i] = lower_bound(begin(nums), end(nums), B[i]) - begin(nums);
  }
  for(int i = 0; i < Q; i++) {
    X[i] = lower_bound(begin(nums), end(nums), X[i]) - begin(nums);
    Y[i] = lower_bound(begin(nums), end(nums), Y[i]) - begin(nums);
  }

  vector< int > order(M);
  iota(begin(order), end(order), 0);
  sort(begin(order), end(order), [&](int a, int b)
  {
    return (C[a] < C[b]);
  });

  for(int i = 0; i < 19; i++) {
    vector< pair< int, int > > mid(Q);
    for(int j = 0; j < Q; j++) {
      mid[j] = {(L[j] + R[j]) / 2, j};
    }
    sort(begin(mid), end(mid));
    int tail = 0;
    SegmentTree< int64 > tree(nums.size());
    for(int j = 0; j < M; j++) {
      tree.rangeadd(A[order[j]], B[order[j]], 1);
      while(tail < Q && mid[tail].first == j) {
        const int idx = mid[tail].second;
        if(tree.rmq(X[idx], Y[idx]) >= Z[idx]) R[idx] = j;
        else L[idx] = j + 1;
        ++tail;
      }
    }
  }

  for(int i = 0; i < Q; i++) {
    printf("%d\n", C[order[L[i]]]);
  }
}

Measured memory_bytes: 25484
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std

struct robot {
    int x, l, first, last;
    bool operator<(const robot &another) const {
        return last < another.last;  //年齢を比較
    };
};

void solve() {
    int n;
    std::cin >> n;
    std::vector<robot> robots(n);
    for(auto &&p : robots) {
        std::cin >> p.x >> p.l;
        p.first = std::max(0, p.x - p.l);
        p.last = std::min((int)1e9, p.x + p.l);
    }
    std::sort(robots.begin(), robots.end());
    int cnt = 0;
    int pos = 0;
    rep(i, n) {
        if(pos <= robots[i].first) {
            cnt++;
            pos = robots[i].last;
        }
    }
    std::cout << cnt << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

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

int main(){
	int H, W, i, j;
	cin >> H >> W;
	char S[H][W];
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			cin >> S[i][j];
		}
	}
	
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			if(S[i][j]=='#'){
				int count=0;
				if(i!=0){
					if(S[i-1][j]=='#')	count++;
				}
				if(i!=H-1){
					if(S[i+1][j]=='#')	count++;
				}
				if(j!=0){
					if(S[i][j-1]=='#')	count++;
				}
				if(j!=W-1){
					if(S[i][j+1]=='#')	count++;
				}
				
				if(count==0){
					cout << "No" << endl;
				return 0;
				}
			}
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] NL=cin.ArrayInt(2,0);
        int ans=0;
        int N=NL[0];
        int L=NL[1];
        int min=99999;
        int min_i=0;
        int sum=0;
        int[] apple=new int[N];
        for(int i=0;i<N;i++)
        {
            apple[i]=i+L;
            sum+=apple[i];
            if(Math.Abs(apple[i])<min){min=Math.Abs(apple[i]);min_i=i;}
        }
        ans=sum-apple[min_i];
      Console.WriteLine("{0}",ans);
        
    }
}



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;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int X;
bool isPrime[100005];
vector<int> primes;
void sieve(){
    memset(isPrime, 1, sizeof isPrime);
    for (int i = 2; i <= 100003; i++) {
        if(isPrime[i]){
            primes.push_back(i);
            if((long long) i*i <= 100003L)
                for (ll j = i*i; j <= 100003L; j+=i)
                    isPrime[j] = false;
        }
    }
}
int main(){
    scanf("%d", &X);
    sieve();
    printf("%d", *lower_bound(primes.begin(), primes.end(), X));
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n; float s=0; float p;
	float arr[n];
	for(i=0; i<n; i++)
	{ cin>>arr[i];
	}
	for(i=0; i<n; i++)
	{
		s+=1/arr[i];
	}
	p=1/s;
	cout<<p;
	
}
	

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger; 

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends

//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
              int r= int_v(read());
              double d=(double)22/7;
              d*=2*r;
              out.write(d+"\n");
              out.flush();
	        		 
	}
	       
	          
}

	    

	
  





Measured memory_bytes: 36628
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

const COMMAX int64 = 100001
const MOD int64 = 1000000007

var fac [COMMAX]int64
var finv [COMMAX]int64
var inv [COMMAX]int64

// テーブル作成
func COMinit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := int64(2); i < COMMAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

// 二項係数nCk
func COM(n, k int64) int64 {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	COMinit()

	n, k := int64(nextInt()), int64(nextInt())
	a := nextInts(int(n))
	sort.Sort(sort.IntSlice(a))

	ans := int64(0)
	for i := 0; i < int(n)-1; i++ {
		fac := COM(n, k)
		if fac -= COM(int64(i+1), k); fac < 0 {
			fac += MOD
		}
		if fac -= COM(n-int64(i+1), k); fac < 0 {
			fac += MOD
		}
		ans = (ans + fac*int64(a[i+1]-a[i])) % MOD
	}

	puts(ans)
}


Measured memory_bytes: 6656
def fact(n):
    ret = 1
    MOD = 10**9 + 7
    for i in range(1, n + 1):
        ret = ret * i % MOD
    return ret


N, M = map(int, input().split())
MOD = 10**9 + 7
diff = abs(N - M)


if diff == 0:
    ans = (fact(N) * fact(M)) * 2
elif diff == 1:
    ans = fact(N) * fact(M)
else:
    ans = 0


ans %= MOD
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int n;
  cin>>n;
  if(n<=999)
    cout<<"ABC"<<endl;
  else
    cout<<"ABD"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans = 1, ans2 = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		int a;
		scanf("%d", &a);
		if (a & 1) ans *= 3, ans2 *= 1; else ans *= 3, ans2 *= 2;
	}
	cout << ans - ans2 << endl;
}


Measured memory_bytes: 256
a,b,c =map(int,input().split())
k= int(input())
while((k>0) and a>=b):
    b=b*2
    k-=1
while((k>0) and b>=c):
    c=c*2
    k-=1
if b>a and c>b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
l = list(input())

s = [0 for i in range(len(l))]
ss = [0 for i in range(len(l))]
co = 1
for i in range(len(l)):
    if l[i] == 'R':
        s[i] = co
        co += 1
    else:
        co = 1

co = 1
for i in range(len(l)-1,-1,-1):
    if l[i] == "L":
        ss[i] = co
        co += 1
    else:
        co = 1


su = [0 for i in range(len(l))]

for i in range(0,len(l)-1):
    if s[i+1] == 0:
        su[i] += -(-s[i]//2)
        su[i+1] += s[i]//2

for i in range(len(l)-1,0,-1):
    if ss[i-1] == 0:
        su[i] += -(-ss[i]//2)
        su[i-1] += ss[i]//2

print(jo(su))





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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int x; std::cin >> x;
    std::cout << (x >= 30 ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3692
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
long long mod = 1e9 + 7;
const int N = 3e5 + 500;

long long n, m, u, v, k, t, q, a, h;

pair <string, int> rest[N];

pair < pair <string, int>, int> srt[N];

int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> n;
   for (int i = 1; i <= n; ++i) {
      cin >> rest[i].first >> rest[i].second;
      rest[i].second *= -1;
      srt[i] = make_pair(make_pair(rest[i].first, rest[i].second), i);
   }
   
   sort(srt + 1, srt + 1 + n);
   
   for (int i = 1; i <= n; ++i) {
      cout << srt[i].second << '\n';
   }
   
}






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

int main() {
  int ans = 0;

  int N;
  cin >> N;
  
  int A;
  vector<int> vec(N);
  
  for(int i = 0; i < N; i++){
    cin >> A;
    vec.at(i) = A;
  }
  
  sort(vec.begin(), vec.end());
  int min = vec.at(0);
  reverse(vec.begin(), vec.end());
  int max = vec.at(0);
  
  cout << max- min;
  
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;

vector<bool> sieve_of_eratosthenes(int n) {
    vector<bool> is_prime(n, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; (long long)i * i < n; ++ i)
        if (is_prime[i])
            for (int k = 2 * i; k < n; k += i)
                is_prime[k] = false;
    return is_prime;
}

constexpr uint64_t prime = 1000000009;
constexpr uint64_t base = 10007;
uint64_t rolling_hash_push(uint64_t hash, char c) {
    return (hash * base + c) % prime;
}
uint64_t rolling_hash_shift(uint64_t hash, uint64_t k) {
    uint64_t e = base;
    for (; k; k >>= 1) {
        if (k & 1) hash = hash * e % prime;
        e = e * e % prime;
    }
    return hash;
}
template <class Iterator>
vector<uint64_t> rolling_hash_prepare(Iterator first, Iterator last) {
    vector<uint64_t> hash(last - first + 1);
    REP (i, last - first) {
        hash[i + 1] = rolling_hash_push(hash[i], *(first + i));
    }
    return hash;
}
uint64_t rolling_hash_range(vector<uint64_t> const & hash, int l, int r) {
    return hash[r] - rolling_hash_shift(hash[l], r - l);
}

template <class Iterator>
vector<bool> make_is_good_array(Iterator first, Iterator last) {
    int n = last - first;
    auto is_prime = sieve_of_eratosthenes(n + 1);
    auto hash = rolling_hash_prepare(first, last);
    vector<bool> p(n + 1, true);
    uint64_t h = 0;
    uint64_t shift = 1;
    REP3 (l, 1, n + 1) {
        h = rolling_hash_push(h, *(first + l - 1));
        shift = rolling_hash_push(shift, 0);
        uint64_t h1 = h;
        for (int r = 2 * l; r <= n; r += l) {
            h1 = (h1 * shift + h) % prime;
            if (h1 != hash[r]) break;
            p[r] = false;
        }
    }
    return p;
}

pair<int, int> solve(string const & w) {
    int n = w.length();
    if (count(ALL(w), w[0]) == n) {
        return make_pair(n, 1);  // w has only one letter
    }

    // m = 1
    auto is_good = make_is_good_array(ALL(w));
    if (is_good[n]) {
        return make_pair(1, 1);
    }

    // m = 2
    auto is_good_rev = make_is_good_array(w.rbegin(), w.rend());
    int cnt = 0;
    REP3 (i, 1, n) {
        cnt += is_good[i] and is_good_rev[n - i];
    }
    if (cnt) {
        return make_pair(2, cnt);
    }

    // m = 3
    REP3 (i, 1, n) if (is_good[i]) {
        auto is_good_shifted = make_is_good_array(w.begin() + i, w.end());
        REP (j, n - i) {
            cnt += is_good_shifted[j] and is_good_rev[n - j];
        }
    }
    assert (cnt);
    return make_pair(3, cnt);
}

int main() {
    string w; cin >> w;
    int m, cnt; tie(m, cnt) = solve(w);
    cout << m << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4800
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		sc.close();
		System.out.print(T/A *B);		
	}
}

Measured memory_bytes: 22612
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// template<class... Args>
// auto create(size_t n, Args&&... args) {
// 	if constexpr(sizeof...(args) == 1)
// 		return vector(n, args...);
// 	else
// 		return vector(n, create(args...));
// }

// template<typename... T>
// void read(T&... args) {
// 	((cin >> args), ...);
// }

// template<typename... T>
// void write(T&&... args) {
// 	((cout << args), ...);
// }

void solve() {
	char a;
	cin >> a;
	if(a >= 'A' && a <= 'Z') {
		cout << "A";
	} else {
		cout << "a";
	}
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	solve();
	return 0;
}


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new List<int[]>();
            for (int i = 0; i < n; i++)
            {
                var r = ReadSplit();
                var ar = new int[3];
                ar[0] = r[0].Int();
                ar[1] = r[1].Int();
                ar[2] = r[2].Int();
                l.Add(ar);
            }

            var dp = new int[100010][];
            var INF = -1;
            for (int i = 0; i < dp.Length; i++)
            {
                dp[i] = new int[3];
                for (int j = 0; j < 3; j++)
                {
                    dp[i][j] = INF;
                }
            }

            for (int i = 0; i < 3; i++)
            {
                dp[0][i] = 0;
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        if (j == k) continue;
                        ChangekMax(ref dp[i + 1][k], dp[i][j] + l[i][k]);
                    }
                }
            }

            WriteRead(dp[n].Max());
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 29356
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans=sum(b)
for i in range(n-1):
    if(a[i+1]-a[i]==1):
        ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll A[200010], B[200010], bsum[200010];

int main() {
	int N, M;
	ll K;
	cin >> N >> M >> K;
	for(int i=0; i<N; ++i) cin >> A[i];
	bsum[0]=0;
	int ans=0;
	for(int i=0; i<M; ++i){
		cin >> B[i];
		bsum[i+1]=bsum[i]+B[i];
		if(bsum[i+1]<=K) ++ans;
	}
	ll res=K;
	for(int i=0; i<N; ++i){
		res -= A[i];
		if(res<0) break;
		int ok=0, ng=M+1;
		while(ok+1<ng){
			int mid=(ok+ng)/2;
			if(bsum[mid]<=res) ok=mid;
			else ng=mid;
		}
		ans=max(ans, i+1+ok);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

void solve() {
  long N, X;
  cin >> N >> X;
  vector<long> m(N);
  rep (i, N) cin >> m[i];

  long result = 0;

  long minimum = 100000;
  rep (i, N) {
    minimum = min(minimum, m[i]);
    X -= m[i];
    result ++;
  }

  result += X / minimum;

  cout << result << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d;
    cin>>n>>d;
    int x=2*d+1;
    int y=n/x + (n%x!=0);
    cout<<y<<endl;
    return 0;
    
}



Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = gets.to_i
puts a[K - 1]

Measured memory_bytes: 1788
N = int(input())
h = list(map(int, input().split()))
f_h = [0 for i in range(N)]
judge = [False if f_h[i] != h[i] else True for i in range(N)]

ct = 0
while False in judge:
    flg = 0
    for i in range(N):
        if judge[i] is False:
            if i == N-1:
                f_h[i] += 1
                ct += 1
                if f_h[i] == h[i]:
                    judge[i] = True
            else:
                flg = 1
                f_h[i] += 1
                if f_h[i] == h[i]:
                    judge[i] = True
        else:
            if flg == 1:
                ct += 1
                flg = 0
            else:
                pass
print(ct)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    int N, Q;
    string S;
    //vector<tuple<int, int, int, int>> question;
    vector<pair<int, int>> question;
    cin >> N >> Q >> S;

    rep(i, 0, Q){
        int l, r;
        cin >> l >> r;
        question.push_back(make_pair(l, r));
    }
    int ans[100010] = {0};
    rep(i, 1, N+1){
        if ((S[i - 1] == 'A') && (S[i] == 'C')){
            ans[i + 1] = ans[i] + 1;
        }else{
            ans[i + 1] = ans[i];
        }
    }
    rep(i, 0, Q){
        int dif = ans[question[i].first];
        cout << ans[question[i].second] - dif << endl;
    }

    return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string n;
  cin >> n;
  ll ans = 0;
  ll tmp = 0;
  REP(i,n.length()){
    if(n[i]=='A'||n[i]=='T'||n[i]=='G'||n[i]=='C') tmp++;
    else {
      CHMAX(ans,tmp);
      tmp = 0;
    }
  }
  CHMAX(ans,tmp);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    vector <long> a(n);
    for(long i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<long>());
    vector <unsigned long long> dp(n,0);
    long cnt = 0;
    for(long i = 0; i < n; i++){
        //cout << i << endl;
        if(i==0){
            dp[i]++;
            cnt++;
            if(cnt>=(n-1))break;
        }else{
            dp[i]++;
            cnt++;
            if(cnt>=(n-1))break;
            dp[i]++;
            cnt++;
            if(cnt>=(n-1))break;
        }
    }
    unsigned long long ans = 0;
    for(unsigned long long i = 0; i < dp.size(); i++){
        ans += a[i]*dp[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6368
a,b,c,x,y=map(int,input().split())

ans=0
ans+=min(x,y)*min(a+b,2*c)
x,y=x-min(x,y),y-min(x,y)

ans+=x*min(a,2*c)
ans+=y*min(b,2*c)

print(ans)

Measured memory_bytes: 3064
import sys

def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b,a%b)

def lcm(a,b):
	return a*b/gcd(a,b)

for s in sys.stdin:
	i = map(int,s.split())
	print gcd(*i), lcm(*i)

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


const int MAXN = 1e5+100;
int a[MAXN];
int main()
{
    int b,c,d;
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)    scanf("%d",a+i);
    sort(a,a+N);
    long long area=0,pre=-1;
    int i=N-1;
    while(i>=1)
    {
        if(a[i]==a[i-1]){
            if(pre==-1) pre=a[i];
            else{area=a[i]*pre;break;}
            i-=2;
        }else i--;
    }
    cout<<area<<endl;
    return 0;
}


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

int main()
{


	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;
	
	

	if (0 > (W - (x + r)) || 0 > (H - (y + r)) || 0 > (x-r) || 0 > (y-r))
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1156
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import math
import sys


def calc_p(a, b, c):
    u = {a, b, c}
    if len(u) == 3:
        return 6
    if len(u) == 2:
        return 3
    if len(u) == 1:
        return 1
    else:
        raise


def std_in():
    return sys.stdin.readline().strip()


def _main():
    N = int(std_in())
    fn = [0] * (N + 1)
    if N == 1:
        x_max = 1
    else:
        x_max = int(math.sqrt(N - 2)) - 1

    n2 = [i**2 for i in range(1, x_max + 1)]

    ij = [[0 for _ in range(1, x_max + 1)] for _ in range(1, x_max + 1)]
    for i in range(x_max):
        for j in range(i, x_max):
            ij[i][j] = (i+1) * (j+1)

    for x in range(1, x_max + 1):
        y_min = x
        x2 = n2[x-1]
        for y in range(y_min, x_max + 1):
            z_min = y
            y2 = n2[y-1]
            xy = ij[x-1][y-1]
            tmp_n = x2 + xy + y2
            if tmp_n > N:
                break
            for z in range(z_min, x_max + 1):
                z2 = n2[z-1]
                yz = ij[y-1][z-1]
                zx = ij[x-1][z-1]
                n = tmp_n + z2 + yz + zx
                if n > N:
                    break
                fn[n] += calc_p(x, y, z)

    for i in range(1, N + 1):
        print(fn[i])


if __name__ == "__main__":
    _main()


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

using namespace std;

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //ifstream cin("input.in");
   //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long A,B,C;
    cin>>A>>B>>C;
    if(A==B && B==C && !(A%2))
        cout<<-1;
    else{
        long M=0;
        while(!(A%2) && !(B%2) && !(C%2)){
            M++;
            long X=A/2;
            long Y=B/2;
            long Z=C/2;
            A=Y+Z;
            B=X+Z;
            C=X+Y;
        }
        cout<<M;
    }
    return 0;
}   

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

int main() {
    int n;
    cin>>n;
    
    int a[n+2];
    a[0]=0;
    a[n+1]=0;
    for(int i=1; i<n+1; i++){
        cin>>a[i];
    }
    int cost_all=0;
    int cost_i;
    for(int i=0; i<n+1; i++){
        cost_all += abs(a[i]-a[i+1]);
    }
    
    for(int i=1; i<n+1; i++){
        cost_i = cost_all-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]);
        cout<<cost_i<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i, j, k ,n,m,l,f;

	cin >> n;
	cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define X first
#define Y second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=1e9+7;
const ll MAXN=1e6+5;
const ll inf=1e18;

vector<ll > fact(MAXN);

ll pwr(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll inv(ll a){
    return pwr(a,mod-2);
}

long long binomial_coefficient(int n, int k) {
    return ((((fact[n] * inv(fact[k])) % mod) * inv(fact[n - k])) % mod);
}

int main()
{
    fastio;
    ll n,k;
    cin>>n>>k;
    vector<ll > a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    a[0]=-inf;
    sort(a.begin(),a.end());
    fact[0]=fact[1]=1;
    for(int i=2;i<=n;i++) fact[i]=(i*fact[i-1])%mod;
    vector<ll > l(n+1),r(n+1);
    l[1]=a[1]%mod;
    for(int i=2;i<=n;i++) l[i]=(a[i]+l[i-1])%mod;
    r[n]=a[n];
    for(int i=n-1;i>0;i--) r[i]=(a[i]+r[i+1])%mod;
    ll sum=0;
    for(int i=k-2;i<=n-2;i++){
        ll b=binomial_coefficient(i,k-2);
        ll c=r[i+2]-l[n-i-1];
        sum=(sum+((b*c)%mod))%mod;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 10496
#include<iostream>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
    int in_num, a, b, ans, now=0;
    int sta[1000];
    char s[100];
    string number;

    while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        b = sta[now];
        now--;
        a = sta[now];
        ans = a+b;
        sta[now] = ans;
    } else if ( s[0] == '-' ){
        b = sta[now];
        now--;
        a = sta[now];
        ans = a-b;
        sta[now] = ans;
    } else if ( s[0] == '*' ){
        b = sta[now];
        now--;
        a = sta[now];
        ans = a*b;
        sta[now] = ans;
    } else {
        number = s;
        in_num = atoi(s);
        now++;
        sta[now] = in_num;
    }
  }
    

    ans = sta[now];
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3280
// C - Write and Erase

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

unordered_map<int, bool> memo;

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

	int ans = 0;
	int A;
	for (int i=0; i<N; i++) {
		cin >> A;
		if (memo[A]) {
			ans--;
			memo[A] = false;
		} else {
			ans++;
			memo[A] = true;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4388
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
M_x = max(x)
m_y = min(y)
if M_x < m_y and M_x < Y and m_y > X:
  print('No War')
else:
  print('War')

Measured memory_bytes: 3060
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<int> _prime;
vector<int> build_prime_table(int max) {
	vector<int> table = vector<int>(max + 1, -1);
	table[0] = 0;
	table[1] = 0;
	table[2] = 1;
	for (int i = 3; i <= max; i++) {
		if (i % 2 == 0) { table[i] = 0; continue; }
		if (table[i] != -1)continue;
		table[i] = 1;
		for (int j = i + i; j <= max; j += i) {
			table[j] = 0;
		}
	}
	return table;
}

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}


vector<long long> comb = vector<long long>(100 * 100, -1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}

struct cell {
	int Number, x, y;
};

int main() {
	int H, W, D; cin >> H >> W >> D;
	auto grid = vector<cell>(H*W);
	for (size_t i = 0; i < H; i++) {
		for (size_t j = 0; j < W; j++) {
			cin >> grid[i*W + j].Number;
			--grid[i*W + j].Number;
			grid[i*W + j].x = j;
			grid[i*W + j].y = i;
		}
	}
	sort(grid.begin(), grid.end(), [](cell a, cell b) {return a.Number < b.Number; });
	//系列を作る。0系列からD-1系列まで
	auto series = vector<vector<int>>(D);
	for (size_t i = 0; i < D; i++) series[i].push_back(0);
	for (size_t i = D; i < H*W; i++) {
		series[i % D].push_back(series[i% D][i/ D - 1] + abs(grid[i - D].x - grid[i].x) + abs(grid[i - D].y - grid[i].y));
	}
	int Q; cin >> Q; int l, r;
	for (size_t i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << series[(r - 1) % D][(r - 1) / D] - series[(l - 1) % D][(l - 1) / D] << endl;
	}
}

Measured memory_bytes: 6528