akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    ll n,m;cin>>n>>m;
    ll x[m],y[m];rep(i,0,m-1)cin>>x[i]>>y[i];
    bool ans[n+1];rep(i,1,n)ans[i]=false;
    ans[1]=true;
    ll ball[n+1];rep(i,1,n)ball[i]=1;
    rep(i,0,m-1){
        if(ball[x[i]]==1){
            if(ans[x[i]]){
                ans[y[i]]=true;
            }else{
                if(!ans[y[i]]){
                    ans[y[i]]=false;
                }else{
                    ans[y[i]]=true;
                }
            }
            ans[x[i]]=false;
        }else{
            if(ans[x[i]]){
                ans[x[i]]=true;
                ans[y[i]]=true;
            }
        }
        ball[x[i]]--;
        ball[y[i]]++;
    }
    ll c=0;
    rep(i,1,n){
        if(ans[i]){
            c++;
            //cout<<i<<endl;
        }
    }
    cout<<c<<endl;
    
    return 0;
}



Measured memory_bytes: 2688
n, k = map(int,input().split())
x_l = list(map(int,input().split()))

ans = float('inf')
for i in range(n-k+1):
    if x_l[i] * x_l[i+k-1] < 0:
        tmp = min(abs(x_l[i]), abs(x_l[i+k-1])) * 2 + max(abs(x_l[i]), abs(x_l[i+k-1]))
    elif x_l[i] < 0:
        tmp = abs(x_l[i])
    else:
        tmp = abs(x_l[i+k-1])
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 14384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
   int n, k;
   cin >> n >> k;
   vector<int> p(n);
   rep(i,n) cin >> p.at(i);

   sort(all(p));
   int sum=0;
   for(int i=0; i<k; i++){
       sum += p.at(i);
   }
   cout << sum << endl;

}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var K = sc.ReadInt();
        var T = sc.ReadInt();
        var A = sc.ReadIntArray(T);
        if (K == 1)
        {
            Console.WriteLine(K - 1);
            return;
        }
        var max = A.Max();
        var others = A.Sum() - max;
        var ans = Math.Max(0, max - 1 - others);
        Console.WriteLine(ans);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main (){
  int a,b,i;

  scanf("%d %d",&a,&b);

  if(a>b){
    for(i=1;i<=a;i++){
      printf("%d",b);
    }
  }
  else if(a<b){
    for(i=1;i<=b;i++){
      printf("%d",a);
    }
  }
  else{
    for(i=1;i<=b;i++){
      printf("%d",a);
    }
  }
}

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

const int N = (int)1e5;

char s[N+5];

int main() {
    int n; scanf("%d", &n);
    scanf("%s", s);
    int res = 1;
    for (int i=1; s[i]; i++) if (s[i-1] != s[i]) res += 1;
    printf("%d\n", res);
    return 0;
}


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

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    string out = "No";
    if (s[2] == s[3] && s[4] == s[5]) out = "Yes";
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3580
penki = input().split()

if penki[0] == penki[1] and penki[1] == penki[2]:
    print(1)

elif penki[0] == penki[1] and penki[1] != penki[2]:
    print(2)
    
elif penki[0] != penki[1] and penki[1] == penki[2]:
    print(2)

elif penki[0] != penki[1] and penki[0] == penki[2]:
    print(2)
    
else:
    print(3)


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int d, t, s;  cin >> d >> t >> s;
    if(d > t*s)  cout << "No" << endl;
    else         cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3656
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::collections::HashSet;

fn main() {
    input!(n: usize, vs: [usize; n]);

    let mut set = HashSet::new();
    for &v in &vs {
        if set.contains(&v) {
            set.remove(&v);
        } else {
            set.insert(v);
        }
    }

    println!("{}", set.len());
}


Measured memory_bytes: 8444
n, m = list(map(int, input().split()))
pss = [list(input().split()) for _ in range(m)]

dic = {}
for p, s in pss:
    if p not in dic:
        dic[p] = (0, 0)
    ac, wa = dic[p]
    if ac == 0 and s == 'AC':
        dic[p] = (ac + 1, wa)
    elif ac == 0 and s == 'WA':
        dic[p] = (ac, wa + 1)

dic = {k:dic[k] for k in dic if dic[k][0] == 1}

ac = sum(dic[k][0] for k in dic)
wa = sum(dic[k][1] for k in dic)
print(ac, wa)


Measured memory_bytes: 51560
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		int n = in.nextInt();
		p = new Pair[n];
		for(int i = 0; i < n; i++) {
			p[i] = new Pair(i, in.nextInt());
		}
		Arrays.sort(p);
		int left = 0;
		int right = n - 1;
		int ans = right;
		while(left <= right) {
			int mid = (left + right) / 2;
			if(check(mid)) {
				ans = mid;
				right = mid - 1;
			} else {
				left = mid + 1;
			}
		}
		System.out.println(n - ans);
	}
	
	Pair[] p;
	boolean check(int s) {
		long size = p[s].a;
		for(int i = 0; i < s; i++) {
			size += p[i].a;
		}
		for(int i = s + 1; i < p.length; i++) {
			if(size * 2 < p[i].a) return false;
			size += p[i].a;
		}
		return true;
	}
}

class Pair implements Comparable<Pair>{
	int i, a;
	Pair(int i, int a) {
		this.i = i;
		this.a = a;
	}
	@Override
	public int compareTo(Pair o) {
		return a - o.a;
	}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

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

#define LENG 100000

typedef struct pp{

  char name[11];

  int time;

}P;

P Q[LENG];

int head = 0; 
int tail = 0;
int n;

void enqueue(P x){

  Q[tail] = x;

  if((tail + 1) == n)
    tail = 0;
  else
    tail++;
    
}

P dequeue(){

  P x;

  x = Q[head];

  if((head + 1) == n)
    head = 0;
  else
    head++;

  return x;

}


int main(){

  int i, q, alltime, count;
  P data;

  alltime = 0;
  count = 0;

  scanf("%d %d", &n, &q);

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

    scanf("%s %d", Q[i].name, &Q[i].time);

  }

  while(count != n){

    data = dequeue();

    if(data.time <= q){

      alltime += data.time;

      printf("%s %d\n", data.name, alltime);
      
      count++;

    }

    else{

      alltime += q;

      data.time -= q;

      enqueue(data);

    }

  }
  
  return 0;

}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	string s;
	cin >> s;
	string now = "";
	vector<string> v;

	rep(i, s.size()) {
		if(i < s.size()-1 && s[i] == 'B' && s[i+1] == 'C') {
			now += 'Y';
			i++;
		} else if(s[i] == 'A') {
			now += 'X';
		} else {
			v.push_back(now);
			now = "";
		}
	}
	v.push_back(now);

	int ans = 0;
	for(string x : v) {
		int cnt = 0;
		rep(i, x.size()) {
			if(x[i] == 'Y') {
				ans += i - cnt;
				cnt++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11708
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(intmax_t, A, B);

    const auto MAX = 1e5;
    reps(i, 1, MAX) {
        if (intmax_t(i * 0.08) == A && intmax_t(i * 0.1) == B) {
            return output(i), 0;
        }
    }

    output(-1);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  long long N,D;
  long long X[200000], Y[200000];
  int Ten = 0;
  
  cin >> N >> D;
  for (int i = 0; i < N; i++)
  {
    cin >> X[i] >> Y[i];
    
    if ((X[i]*X[i])+(Y[i]*Y[i]) <= D*D)
    {
      Ten++;
    }
  }
  
  cout << Ten << endl;
  
}

Measured memory_bytes: 6680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
int main()
{
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans;
	if (b <= n)	ans = ll(double(a) / double(b)*double(b - 1));
	else {
		ans = ll(double(a) / double(b)*double(n));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3160
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline


def main():
    N = int(input())
    en = [[] for _ in range(N)]
    on = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        if w % 2:
            on[u - 1].append(v - 1)
            on[v - 1].append(u - 1)
        else:
            en[u - 1].append(v - 1)
            en[v - 1].append(u - 1)

    color = [-1] * N
    stack = [(0, -1, 0)]
    while stack:
        node, parent, col = stack.pop()
        if color[node] >= 0:
            continue
        color[node] = col
        for k in en[node]:
            if k != parent:
                stack.append((k, node, col))
        for k in on[node]:
            if k != parent:
                stack.append((k, node, (col + 1) % 2))

    print(*color, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 71344
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

int main() {
    int N;
    cin >> N;
    int a = 1;
    int b = 1;
    vector<int> v;
    v.push_back(1);
    rep(i, 0, 7) {
        a *= 6;
        b *= 9;
        if(a < 100000) {
            v.push_back(a);
        }
        if(b < 100000) {
            v.push_back(b);
        }
    }
    vector<int> dp(1000000, 100000);
    dp[0]=0;
    rep(i, 0, N) {
        for(auto tv : v) {
            dp[i + tv] = min(dp[i + tv], dp[i] + 1);
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 4096
#include <cstdio>

using namespace std;

char reply[10];
int test(int i)
{
    printf("%d\n", i);
    fflush(stdout);
    scanf("%s", reply);
    switch(reply[0])
    {
        case 'V': return 0;
        case 'F': return 1;
        case 'M': return 2;
    }
}
int n;
int findm(int low, int high)
{
    return (low+high)/2;
}
int seat[100000];

int main()
{
    int l, h;
    int mid;
    int cnt = 20;

    scanf("%d", &n);
    seat[0] = seat[n] = test(0);
    if(seat[0]==0) return 0;
    l=0;h=n;

    while(l<h && cnt>0)
    {
        mid = (l+h)/2;
        seat[mid] = test(mid);
        if(seat[mid]==0) return 0;
        if(((mid-l)%2==0 && seat[mid]==seat[l]) || ((mid-l)%2==1 && seat[mid]!=seat[l]))
            l = mid;
        else h = mid;
        cnt--;
    }

    return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, K, Ans = 0, A = 0, B = 0, x = 0;//Nボール、K位置
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
      cin >> x;
      A = x*2;
      B = (K-x)*2;
        if (A < B) {
          Ans += A;
        }else{
          Ans += B;
        }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 3560
n=int(input())
b=list(map(int,input().split()))
k=[]
if n>2:
    for i in range(n-2):
        if i==0:k.append(b[i])
        k.append(min(b[i],b[i+1]))
    k.append(b[-1])
else:k.append(b[-1]*2)
print(sum(k))

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

int main()
{
  int a, b;

  cin >> a >> b;

  if (a > b) {
    cout << "a > b" << endl;
  } else if (a < b) {
    cout << "a < b" << endl;
  } else {
    cout << "a == b" << endl;
  }

  return 0;
}


Measured memory_bytes: 3088
n = int(input())

if n == 1:
    print(1)
elif n == 2:
    print(2)
else:
    for x in range(1,n):
        tmp = (1+x)*x//2
        if tmp >= n:
            l = x
            break

    d = tmp - n
    for x in range(1,l+1):
        if x != d:
            print(x)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,d=0;
    cin>>k>>a>>b;
    for(a;a<=b;a++)
    {
        if(a%k==0)
        {
            d++;
            break;
        }
    }
    if(d>0)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int main() {
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  if (b == 'C') cout << 'G' << endl;
  if (b == 'G') cout << 'C' << endl;
  if (b == 'T') cout << 'A' << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
#define M 0x000fffff
#define NIL (-1)
#define L 14
 
char H[M][L]; /* Hash Table */
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return -1;
}
 
/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){ return key%M; }
int h2(int key){ return key%L; }
 
int find(char str[]){
  int key = (int)(getKey(str)&0x7fffffff);
  return (H[h1(key)][h2(key)]=='\0'?0:1);
}
 
int insert(char str[]){
  int key = (int)(getKey(str)&0x7fffffff);
  H[h1(key)][h2(key)] = 't';
  return 0;
}
 
int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
     
    scanf("%d", &n);
     
    for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
     
    if ( com[0] == 'i' ){
        insert(str);
    } else {
        if (find(str)){
        printf("yes\n");
        } else {
        printf("no\n");
        }
    }
    }
 
    return 0;
}


Measured memory_bytes: 16056
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long a[200005];
int main()
{
	int n;
	scanf("%d",&n);
	long long tot1=0,tot2=0;
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]),tot1+=a[i],tot2+=a[i]*a[i]%mod;
	tot1%=mod;
	tot2%=mod;
	long long ans=tot1*tot1%mod;
	ans=(ans-tot2)%mod+mod;
	printf("%lld\n",ans*500000004%mod);
	return 0;
}

Measured memory_bytes: 5328
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
  int N,max = 0,cnt=0;
  cin >> N;
  int H[N];
  for(int i = 0;i < N;i++){
    cin >> H[i];
  }
  for(int i = 0;i < N-1;i++){
    if(H[i] >= H[i+1]){
      cnt++;
    }else{
      cnt=0;
    }
    if(max < cnt){
      max = cnt;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

const int INF = 1001001001;

int f(string s, string t){
  int res = 0;
  REP(i, t.size()) {
    if(s[i] != t[i]) res++;
  }
  return res;
}

int main() {
  string s, t;
  cin>>s>>t;
  int ans = INF;
  
  REPo(i, s.size()-t.size()) {
    string ss = s.substr(i, t.size());
    int tmp = f(ss, t);
    chmin(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] L = new Integer[N];
		for(int i = 0;i < N;i++){
			L[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int cnt = 0;
		Arrays.asList(L).sort(Comparator.reverseOrder());;
		for(int i = 0;i < N-2;i++){
			for(int j = i+1;j < N-1;j++){
				for(int k = j+1;k < N;k++){
					if(L[i]+L[j] > L[k]
							&& L[j] + L[k] > L[i]
							&& L[k] + L[i] > L[j]){
						cnt++;
					}else{
						break;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

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

int main(){
	ll n;
	ll now=100,ans=0;
	cin>>n;
	while(1){
		now+=now/100;
		ans++;
		if(now>=n){
			cout<<ans<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
a, b, c = map(int, input().split())
t = 0
p = 0
p = min(b, c)
b -= p
c -= p
t += p * 2
p = min(a, c)
a -= p
c -= p
t += p
t += 1 if c != 0 else 0
t += b
print(t)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<math.h>
using namespace std;
long long MOD = 1e9+7;
long long ans,left,n,lef;
char a[3][1000];
int main()
{
    cin>>n;
    for (int i = 1; i <= n; i++) cin>>a[1][i];
    for (int i = 1; i <= n; i++) cin>>a[2][i];
    if (n==1) {
        cout<<3<<endl;
        return 0;
    }
    if (n==2){
        cout<<6<<endl;
        return 0;
    }
    lef = 0;
    ans = 3;
    int i = 1;
    while (i<=n){
        if (a[1][i]==a[2][i]&&lef==1) {

            ans=(ans*2);
          // cout<<i<<" "<<ans<<endl;
            lef = 1;
            i++;
            continue;
        }
        if (a[1][i]==a[2][i]&&lef==0){
            lef = 1;
         //   cout<<i<<" "<<ans<<endl;
            i++;
            continue;
        }
        if (a[1][i]==a[2][i]&&lef==2){
            lef = 1;
        //    cout<<i<<" "<<ans<<endl;
           // ans=(ans*2);
            i++;
            continue;
        }
        if (a[1][i]!=a[2][i]&&lef==0||lef==1){
            ans = (ans*2);
          //  cout<<i<<" "<<ans<<endl;
            lef = 2;
            i+=2;
            continue;
        }
        if (a[1][i]!=a[2][i]&&lef==2){
            lef = 2;

             ans = (ans*3);
           //  cout<<i<<" "<<ans<<endl;
            i+=2;
            continue;
        }
    }
    cout<<ans%MOD<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ITP1_11_A {
    class Dice {
        private int[] _dice;

        public int Top {
            get {
                return _dice[0];
            }
        }

        public Dice(int[] dice) {
            _dice = dice;
        }

        public void Move(string dir) {
            foreach (var d in dir) {
                Move(d);
            }
        }

        public void Move(char dir) {
            switch (dir) {
                case 'E':
                    Replace(0, 3, 5, 2);
                    break;
                case 'W':
                    Replace(0, 2, 5, 3);
                    break;
                case 'N':
                    Replace(0, 1, 5, 4);
                    break;
                case 'S':
                    Replace(0, 4, 5, 1);
                    break;
            }
        }

        private void Replace(int a,int b,int c,int d) {
            int temp = _dice[a];
            _dice[a] = _dice[b];
            _dice[b] = _dice[c];
            _dice[c] = _dice[d];
            _dice[d] = temp;
        }
    }

    class Program {
        static void Main(string[] args) {
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            string dir = Console.ReadLine();
            Dice dice = new Dice(nums);
            dice.Move(dir);
            Console.WriteLine(dice.Top);
        }
    }
}

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

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> choco(h);
    rep(j, h) cin >> choco[j];

    int ans = INF;
    rep(bit, (1 << (h - 1))) {
        int cnt = __builtin_popcount(bit);
        bool ok = true;
        vi cum(h + 1, 0);
        vi cusum(h + 1, 0);

        rep(x, w) {
            if (!ok) break;

            auto init = [&]() {
                rep(z, h) {
                    if (choco[z].at(x) == '1')
                        cum[z + 1] = cum[z] + 1;
                    else
                        cum[z + 1] = cum[z];
                }
            };
            init();
            rep(y, h + 1) cusum[y] += cum[y];

            int pre = 0;
            int curr = 0;
            rep(y, h) {
                curr = y + 1;
                if (y > 0 and (bit >> (y - 1) & 1))
                    pre = y;

                int num = cum[curr] - cum[pre];
                if (num > k) {
                    ok = false;
                    break;
                }

                int cunum = cusum[curr] - cusum[pre];
                if (cunum > k) {
                    cnt++;
                    copy(all(cum), cusum.begin());
                    break;
                }
            }
        }
        if (ok) chmin(ans, cnt);
    }

    out(ans);
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;
string large_al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small_al = "abcdefghijklmnopqrstuvwxyz";
using Graph = vector<vector<int>>;
using i64 = int64_t;

int main() {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") {
    cono;
  }
  else {
    coyes;
  }

  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n;
  cin>>n;
  map<string,int> m;
  for(int i=1;i<=n;i++)
  {
    string s;
    cin>>s;
    m[s]++;
  }
  cout<<"AC x "<<m["AC"]<<endl;
  cout<<"WA x "<<m["WA"]<<endl;
  cout<<"TLE x "<<m["TLE"]<<endl;
  cout<<"RE x "<<m["RE"]<<endl;
  return 0;
}


Measured memory_bytes: 3652
import java.util.*;
 
public class Main {
  public static void main(String[] args ) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> forbidden = new ArrayList<Integer>();
    int X = sc.nextInt();
    int f = sc.nextInt();
    for (int i=0;i<f;i++) {
      int j = sc.nextInt();
      forbidden.add(j);
    }
   
    int i = 0;
    int tf = 1;
	
    for (int h=0; h<100; h++) {
        for (int j=0;j<f;j++) {
            if (forbidden.get(j) == X-i) {
              tf = 0;
            }
        } if (tf == 1) {
          System.out.println(X-i);
          break;
        } else {
          tf = 1;
          for (int k=0;k<f;k++) {
            if (forbidden.get(k) == X+i) {
              tf = 0;
            }
          } if (tf == 1) {
            System.out.println(X+i);
            break;
          } else {
            i = i+1;
            tf = 1;
          }
        }
    }
    
  }
}

Measured memory_bytes: 27244
// E - Hopscotch Addict

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

using Idx = int;
using Step = int;

struct Node {
	vector<int> neighbors;
	bool visited[3];

	Node() {
		visited[0] = false;
		visited[1] = false;
		visited[2] = false;
	}
};

int N, M, S, T;
Node nodes[100000];

int bfs(int start, int goal) {
	nodes[start].visited[0] = true;

	queue<pair<Idx, Step>> search_queue;
	search_queue.push(make_pair(start, 0));

	while(!search_queue.empty()) {
		pair<Idx, Step> current = search_queue.front();
		search_queue.pop();

		int idx = current.first;
		int step = current.second;
		//cout << idx + 1 << " (" << step << ")" << endl; // **** debug ****

		if (idx == T && step % 3 == 0) {
			return step / 3;
		}

		int next_r = (step + 1) % 3;
		for (int next_idx : nodes[idx].neighbors) {
			if (nodes[next_idx].visited[next_r]) {
				continue; // 探索済みならキューに入れない
			}

			nodes[next_idx].visited[next_r] = true;
			search_queue.push(make_pair(next_idx, step + 1));
		}
	}

	return -1;
}

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

	int u, v;
	for (int i=0; i<M; i++) {
		cin >> u >> v;
		u--;
		v--;
		nodes[u].neighbors.push_back(v);
	}

	cin >> S >> T;
	S--;
	T--;

	int ans = bfs(S, T);

	cout << ans << endl;

	return 0;
}

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

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            int n = NextInt();
            bool[] s = new bool[13], h = new bool[13], c = new bool[13], d = new bool[13];

            for (int i = 0; i < n; i++) {

                string[] temp = NextStrings();
                string card = temp[0];
                int num = int.Parse(temp[1]);

                switch (card) {
                    case "S":
                        s[num - 1] = true;
                        break;
                    case "H":
                        h[num - 1] = true;
                        break;
                    case "C":
                        c[num - 1] = true;
                        break;
                    case "D":
                        d[num - 1] = true;
                        break;
                }
                
            }

            for (int i = 0; i < 13; i++) {
                if (s[i] == false) Println("S " + (i + 1));
            }
            for (int i = 0; i < 13; i++) {
                if (h[i] == false) Println("H " + (i + 1));
            }
            for (int i = 0; i < 13; i++) {
                if (c[i] == false) Println("C " + (i + 1));
            }
            for (int i = 0; i < 13; i++) {
                if (d[i] == false) Println("D " + (i + 1));
            }

        }

        public static void Print (Object o) {
            Console.Write(o);
        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

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

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

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }

        public static double NextDouble () {
            return double.Parse(Console.ReadLine());
        }

    }
}



Measured memory_bytes: 15924
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=2e5+10;

int n;
char a[maxn];
int nxt[maxn][26];
int dp[maxn];
int last;

void dfs(int p)
{
	if (p>n) 
	{
		printf("a\n");
		return;
	}
	for(int i=0;i<26;i++)
	{
		if (nxt[p][i]==-1)
		{
			printf("%c",i+'a');
			return;
		}
		if (dp[p]==dp[nxt[p][i]+1]+1)
		{
			printf("%c",i+'a');
			dfs(nxt[p][i]+1);
			return;
		}
	}
}

int main() 
{
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=0;i<26;i++)
	{
		last=-1;
		for(int j=n;j>=1;j--)
		{
			if (a[j]-'a'==i) last=j;
			nxt[j][i]=last;
		}
	}
	
	dp[n+1]=1;
	for(int i=n;i>=1;i--)
	{
		dp[i]=n+1;
		for(int j=0;j<26;j++)
		{
			if (nxt[i][j]==-1) 
			{
				dp[i]=1;
				break;
			}
			dp[i]=min(dp[i],dp[nxt[i][j]+1]+1);
		}
	}
	
	dfs(1);
	printf("\n");
	return 0;
}

Measured memory_bytes: 21504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				for (int i = 0; i < 26; i++)
				{
					char[] c = s.ToCharArray();
					for (int j = 0; j < c.Length; j++)
					{
						if (c[j] >= 'a' && c[j] <= 'z')
							c[j] = c[j] == 'z' ? 'a' : (char)(c[j] + 1);
					}
					s = new string(c);
					if (s.Contains("the") || s.Contains("this") || s.Contains("that"))
						Console.WriteLine(s);
				}
			}
		}
	}
}

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

using ll = long long int;
const int MAX_N = (int)(100 + 5);

ll n, w, weight[MAX_N], value[MAX_N];

map<ll, vector<ll>> cnt;
vector<vector<ll>> combs(0);
ll ans = 0;

void produce(auto itr, vector<ll> part) {
  if (itr != cnt.end()) {
    auto itrp = next(itr, 1);
    for (int i = 0; i <= itr->second.size(); ++i) {
      vector<ll> tmppart = part;
      tmppart.push_back(i);
      produce(itrp, tmppart);
    }
  }
  else {
    combs.push_back(part);
  }
}

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &w);
  for (int i = 0; i < n; ++i) {scanf("%lld %lld", &weight[i], &value[i]);}
  for (int i = 0; i < n; ++i) {cnt[weight[i]].push_back(value[i]);}

  for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
    sort(itr->second.begin(), itr->second.end(), greater<ll>());
  }

  auto itr = cnt.begin();
  vector<ll> tmp(0);
  produce(itr, tmp);

  for (int k = 0; k < combs.size(); ++k) {
    vector<ll> x = combs[k];
    ll candans = 0;
    ll candweight = 0;
    for (int j = 0; j < x.size(); ++j) {
      auto titr = next(itr, j);
      vector<ll> tmpweight = titr->second;
      candweight += titr->first * x[j];
      for (int i = 0; i < x[j]; ++i) {
        candans += tmpweight[i];
      }
    }

    if (candweight <= w) {
      ans = max(ans, candans);

    }
  }

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

  return 0;
}

Measured memory_bytes: 32936
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    double D = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            D += sqrt(pow(x[i]-x[j],2) + pow(y[i]-y[j],2));
        }
    }

    printf("%.8lf\n", 2*D/N);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int cnt[10005];
int po[200005];
main() {
	
	int n, p;
	cin>>n>>p;
	po[0]=1;
	for(int i=1; i<200005; i++){
		po[i]=(po[i-1]*10)%p;
	}
	string s;
	cin>>s;
	if(p==2){
		int ans=0;
		for(int i=0; i<s.size(); i++){
			if(((s[i]-'0'))%2==0){
				ans+=(i+1);
			}
		}
		cout<<ans;
		return 0;
	}
	if(p==5){
		int ans=0;
		for(int i=0; i<s.size(); i++){
			if(((s[i]-'0'))%5==0){
				ans+=(i+1);
			}
		}
		cout<<ans;
		return 0;
	}
	int ans=0;
	int curr=0;
	cnt[0]=1;
	for(int i=s.size()-1; i>=0; i--){
		curr=((curr)+(s[i]-'0')*po[s.size()-1-i])%p;
		ans+=cnt[curr];
		
		cnt[curr]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5328
n=int(input())
q=[input().split()+[i]for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
p=sorted(sorted( q ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
for s,t,r in p:
    print(r+1)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <climits>
#include <string>
#include <vector>

using namespace std;

int main () {
    long long n = 0, k = 0;
    cin >> n >> k;
    vector<long long> candle(n);
    for (int i=0; i<n; i++) {
        cin >> candle.at(i);
    }
    int zero = lower_bound(candle.begin(), candle.end(), 0) - candle.begin();
    long long mini = (n - zero >= k) ? candle.at(zero-1+k) : LLONG_MAX;
    for (int i=0; i<zero; i++) {
        if (zero - i > k) continue;
        if (zero - i == k) mini = min(abs(candle.at(i)), mini);
        if (k + i - 1 > n-1) break;
        mini = min(abs(candle.at(i)) + abs(candle.at(k + i - 1)) + min(abs(candle.at(i)), abs(candle.at(k+i-1))), mini);
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ll n;cin>>n;
    ll a=1,b=1;
    for(int i=0; i<n; i++){
        ll x,y;cin>>x>>y;
        ll mul = max((a+x-1)/x,(b+y-1)/y);
        a=mul*x,b=mul*y;
    }
    cout<<a+b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, x; cin >> a >> b >> c >> x;
    int res = 0;
    rep(i, a + 1){
        rep(j, b + 1){
            rep(k, c + 1){
                int cur = 500 * i + 100 * j + 50 * k;
                if(cur == x){
                    res++;
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256