akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int n,m;
int x,y;
int sb[23];
 
int main(){
	cin>>n>>m;
	bool flag = true;
	fill(sb,sb+20,-1);
	for(int i = 1; i <= m; i++){
		cin>>x>>y;
		if(sb[x] != y && sb[x] != -1) flag = false;
		if(n != 1 && x == 1 && y == 0) flag = false;
		sb[x] = y;
	}
	if(flag == true){
		int Out = 0;
		int i = 1;
		if(n >= 2 && sb[1] == -1) Out  = 1,i = 2;
		for(; i <= n; i++){
			if(sb[i] == -1) sb[i] = 0;
			Out = Out * 10 + sb[i];
		}
		cout<<Out<<endl;	
	}
	else cout<<"-1"<<endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int answer = 10000000;
  for(int i = 0;i < S.size() - 2;i++) {
    if(answer > abs((S.at(i) - '0') * 100 + (S.at(i + 1) - '0') * 10 + (S.at(i + 2) - '0') - 753)) {
      answer = abs((S.at(i) - '0') * 100 + (S.at(i + 1) - '0') * 10 + (S.at(i + 2) - '0') - 753);
    }
  }
  cout << answer << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<long long> a(N);
    long long sum = 0;
    rep(i, N) {
        cin >> a[i];
        a[i] -= (i + 1);
    }

    sort(a.begin(), a.end());
    long long b = a[a.size() / 2];
    long long ans = 0;
    rep(i, N) {
        ans += abs(a[i] - b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


class Compress:
    def __init__(self, ls):
        # 座標圧縮クラス(仮) #どうしたら使いやすくなるのか知らんけど
        self.i_to_orig = sorted(set(ls))
        self.orig_to_i = {}
        for i, zahyou in enumerate(self.i_to_orig):
            self.orig_to_i[zahyou] = i
        self.len = len(self.i_to_orig)

    def __len__(self):
        return len(self.i_to_orig)


N = read_a_int()
A, B = read_col(N)
A.sort()
B.sort()
if N & 1:
    print(B[N // 2] - A[N // 2] + 1)
else:
    l = (A[N // 2 - 1] + A[N // 2])
    r = (B[N // 2] + B[N // 2 - 1])
    print(abs(r - l) + 1)


# 偶数奇数でちょっとわけて考えよう
# Nが奇数なら→X[N//2]の候補の数

# 2つの領域の重なり方は3種類
# 1. 重なっていない
# 2. 一部重なっている
# 3. 完全に内包関係にある(ちょうどの場合も含む)

# 座標圧縮と前後ろから累積和で行けない？
# 一番lをXにしたときと一番rをXにしたとき,中央値の始まる端と終わる端がわかればよい

# 奇数の場合は


Measured memory_bytes: 121184
n, m = map(int,input().split())
a_mat = [input() for _ in range(n)]
b_mat = [input() for _ in range(m)]

contain = False
for i in range(n-m+1):
    for j in range(n-m+1):
        ok = True
        for k in range(m):
            if not ok:
                break
            for l in range(m):
                if a_mat[i+k][j+l] != b_mat[k][l]:
                    ok = False
                    break
        if ok:
            contain = True
            break
if contain:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,ts,tmp[55555],s,ans[55555];
bool ck(){
	int s=0;
	FOR(i,1,n) s+=ans[i];
	if (s%6!=0) return 0;
	if (n>100) return 1;
	int t=ans[1];
	FOR(i,2,n) t=__gcd(t,ans[i]);
	return (t==1);
}
int main(){
	srand(613);
	cin>>n;
	if (n==3) return puts("2 5 63"),0;
	ts=0;
	FOR(i,1,30000)
		if (i%2==0 || i%3==0) tmp[++ts]=i,s+=i;
	while (1){
		random_shuffle(tmp+1,tmp+ts+1);
		FOR(i,1,n) ans[i]=tmp[i];
		if (ck()) break;
	}
	
	FOR(i,1,n) printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int x,y,z;cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
src = list(map(int,input().split()))

ctr = Counter(src)
if len(ctr) == 1:
    print(N//2)
    exit()

odd = Counter([a for i,a in enumerate(src) if i%2])
even = Counter([a for i,a in enumerate(src) if i%2==0])

ev = even.most_common()[:2]
ans = N
for k,v in odd.most_common():
    k1,v1 = ev[0]
    if k != k1:
        ans = min(ans, N-v1-v)
    if len(ev) < 2: continue
    k2,v2 = ev[1]
    if k != k2:
        ans = min(ans, N-v2-v)
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0);
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    ll res = (ll) 2e18;
    for (int i = 0; i < 3; i++) {
        ll d = a[i] % 2;        
        for (int j = 0; j < 3; j++)
            if (j != i)
                d *= a[j];
        res = min(res, d);
    }
    cout << res << endl;
    return 0;
}


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

int main() {
int a;
  cin>>a;
  int b=a%10;
  if(b==0||b==1||b==6||b==8){cout<<"pon"<<endl;}
  else if(b==3){cout<<"bon"<<endl;}
  else{cout<<"hon"<<endl;}
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int S,h=0,m=0,s=0;
		S=sc.nextInt();
		h=S/3600;
		m=S%3600/60;
		s=S%3600%60;
		System.out.println(h+":"+m+":"+s);
		sc.close();
	}
}



Measured memory_bytes: 26220
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  string s;
  cin >> s;
  string ans;
  rep(i, s.size()) {
    if(s[i]=='0')
      ans+='0';
    else if(s[i]=='1')
      ans+='1';
    else if(ans.size()>0)
      ans.pop_back();
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

    int ans = 10000;
    for(int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if(t > T){
            continue;
        }
        if(c < ans){
            ans = c;
        }
    }

    if(ans == 10000){
        cout << "TLE" << endl; 
    }else{
        cout << ans << endl; 
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;

ll N, P;

void input() {
    cin >> N >> P;
//    N = 1, P = 111;
}

ll solve() {
    if (N == 1)
        return P;
    ll gcd = 1;
    ll p = P;
    for (ll k = 2; k * k <= P; k++) {
        ll c = 0;
        while (p % k == 0) {
            c++;
            p /= k;
        }
        gcd *= pow(k, c / N);
    }
    return gcd;
}


int main() {
    input();
    cout << solve() << endl;;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ (*istream_iterator<int>(cin))
#define eb emplace_back
#define em emplace

using namespace std;
const int mxn = 1e2+10;

vector<int> v(mxn);
stack<int> stk;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n = _;
    for(int i=1; i<=n; i++) v[i] = _;
    for(bool f=true; f;){
        f = false;
        for(int i=v.size()-1; i; i--) {
            if(v[i] == i) {
                stk.em(i);
                v.erase(v.begin()+i);
                f = true;
                break;
            }
        }
    }
    if(stk.size()<n) cout << -1;
    else for(; stk.size(); stk.pop())
        cout << stk.top() << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7;
int n,m,lr=0,ud=0,c1=0,c2=0,c3=0;
i64 k;
char s[1007][1007];
i64 pw(i64 a,i64 n){
	i64 v=1;
	for(;n;n>>=1,a=a*a%P)if(n&1)v=v*a%P;
	return v;
}
typedef i64 mat[2][2];
mat X,Y,tmp;
void mul(mat a,mat b){
	memcpy(tmp,a,sizeof(tmp));
	for(int i=0;i<2;++i)
	for(int j=0;j<2;++j)a[i][j]=(tmp[i][0]*b[0][j]+tmp[i][1]*b[1][j])%P;
}
i64 cal(int x,int y,int z){
	X[0][0]=X[1][1]=1;
	Y[0][0]=z,Y[0][1]=P-1;
	Y[1][1]=x;
	for(;k;k>>=1,mul(Y,Y))if(k&1)mul(X,Y);
	return (X[0][0]+X[0][1]*y)%P;
}
int main(){
	scanf("%d%d%lld",&n,&m,&k);
	if(!k--)return puts("1"),0;
	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		lr+=s[i][1]=='#'&&s[i][m]=='#';
		for(int j=1;j<=m;++j)if(s[i][j]=='#'){
			c1+=1;
			c2+=s[i][j-1]=='#';
			c3+=s[i-1][j]=='#';
		}
	}
	for(int i=1;i<=m;++i)ud+=s[1][i]=='#'&&s[n][i]=='#';
	printf("%lld\n",lr?(ud?1ll:cal(lr,c2,c1)):(ud?cal(ud,c3,c1):pw(c1,k)));
	return 0;
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
cnt = 0
cur = 0
for i in range(1,N):
    if A[i]!=A[i-1]:
        a = A[i-1]
        if i-cur>=a:
            cnt += i-cur-a
        else:
            cnt += i-cur
        cur = i
a = A[-1]
if N-cur>=a:
    cnt += N-cur-a
else:
    cnt += N-cur
print(cnt)

Measured memory_bytes: 14692
import java.util.*;

public class Main {
  /**
   * Iterate through each line of input.
   */
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int ans = 0;
    
    int[] p = new int[n];
    
    for(int i=0;i<p.length;i++) {
    	p[i] = sc.nextInt();
    }
    
    Arrays.sort(p);
    
    for(int i=0;i<k;i++) {
    	ans += p[i];
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 38888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1ULL << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1ULL << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1ULL << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    int dp[n][m];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            char ch;
            cin >> ch;
            dp[i][j] = (ch == '#') ? 0 : 1;
        }
    }
    for (int j = 1; j < m; ++j) dp[0][j] = (dp[0][j] == 1 && dp[0][j-1]) ? 1 : 0;
    for (int i = 1; i < n; ++i) dp[i][0] = (dp[i][0] == 1 && dp[i-1][0]) ? 1 : 0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j < m; ++j)
        {
            if (dp[i][j] == 0) continue;
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        }
    }
    cout << dp[n-1][m-1] << '\n';
    return 0;
}

Measured memory_bytes: 8064
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            StringBuilder sb = new StringBuilder();
            while (n > 0) {
                char c = (char) ((n - 1) % 26 + 'a');
                n = (n - 1) / 26;
                sb.append(c);
            }

            out.println(sb.reverse().toString());
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

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

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

    }

}

Measured memory_bytes: 34048
#include<iostream>
#include<algorithm>

using namespace std;

bool binarySearch(int *A, int length, int key){
  int left = 0, right = length;

  while(left < right){
    int mid = (left + right) / 2;

    if(key == A[mid]) return true;
    else if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return false;
}

int main(){

  int n, q, cnt = 0;
  int s[100000], t[50000];

  cin >> n;
  for(int i = 0;i < n;i++) cin >> s[i];
  cin >> q;
  for(int i = 0;i < q;i++) cin >> t[i];

  for(int i = 0;i < q;i++){
    if(binarySearch(s, n, t[i])) cnt++;
  }

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string S="ABC",s;
    ll n;
    cin>>n>>s;
    ll ans=0;
    rep(0,i,n){
        if(S==s.substr(i,3)){
            ++ans;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
#include <iterator>
using namespace std;
using VI = vector<int>;

int par[101010];
VI children[101010];
int find(int v) {
    if (v == par[v]) return v;
    return par[v] = find(par[v]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x != y) {
        par[x] = y;
    }
}

int main() {
    for (int i = 0; i < 101010; i++) {
        par[i] = i;
    }
    
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int l;
            cin >> l;
            children[l].push_back(i);
        }
    }
    
    for (int i = 0; i < 101010; i++) {
        if (children[i].size() > 1) {
            for (int j = 1; j < children[i].size(); j++) {
                unite(children[i].front(), children[i][j]);
            }
        }
    }
    
    for (int i = 0; i < 101010; i++) {
        find(i);
    }
    
    for (int i = 1; i < n; i++) {
        if (par[i] != par[0]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 5500
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)





int main() {
	ll n;
	in(n);
	double ans = 0;
	vector<double> x(n), y(n);
	vector<vector<double>> d(n, vector<double>(n-1));

	rep(i, 0, n) {
		in(x[i]);
		in(y[i]);
	}

	rep(i, 0, n) {
		rep(j, 0, n) {
			if (i != j) {
				ans += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2))/n;
			}
		}
	}
	cout << std::setprecision(15) << ans << endl;
	return 0;



}


Measured memory_bytes: 256
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  string s;
  cin>>s;
  for(auto i:s){
    if(i=='?') cout<<"D";
    else cout<<i;
  }
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 3900
//==========================================
// ABC130a
//
// 2019/08/21
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int x, a;
  cin >> x >> a;

  if (x < a) cout << "0" << endl;
  else if(a <= x) cout << "10" << endl; 

  return 0;
}

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

long long num[30];

int main()
{
	long long i,j,ans=0;
	string s;
	cin >> s;
	for(i=0;i<s.size();i++)
		num[s[i]-'a']++;
	for(i=0;i<s.size();i++)
		for(num[s[i]-'a']--,j=0;j<26;j++)
			if(j!=s[i]-'a') ans+=num[j];
	printf("%lld\n",ans+1);
} 

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

int main(){
  while(1){
    int d,e;
    cin>>d>>e;
    if(d==0 && e==0) break;
    double ans=1e9;
    for(int x=0;x <= d;x++){
      int y=d-x;
      double dist=sqrt((double)(y*y+x*x));
      ans=min(ans, abs(e-dist));
    }
    printf("%.3f\n",ans);
  }
  return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>

int main(void){
  int i, j;

  int h, w, a, b;
  scanf("%d%d%d%d", &h, &w, &a, &b);

  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      if(i < b ^ j < a == 1) printf("0");
      else printf("1");
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
int main(void){
    int X,ans;
    
    scanf("%d",&X);
    
    if(X<=599){
        ans=8;
    }else if(X<=799){
        ans=7;
    }else if(X<=999){
        ans=6;
    }else if(X<=1199){
        ans=5;
    }else if(X<=1399){
        ans=4;
    }else if(X<=1599){
        ans=3;
    }else if(X<=1799){
        ans=2;
    }else if(X<=1999){
        ans=1;
    }
    
    printf("%d",ans);
    
    return 0;
}

Measured memory_bytes: 2156
a,b,c,d,e,f = map(int,input().split())
a,b,e = 100*a,100*b,e/(100+e)
best = [max(0,(f//a)*a,(f//b)*b),0,0] #[sugarwater,sugar,concentration]

for n in range(f//a+1):
    na = n*a
    for m in range((f-na)//b+1):
        if n==m==0:
            continue
        mb = m*b
        for k in range((f-na-mb)//c+1):
            kc = k*c
            for l in range((f-na-mb-kc)//d+1):
                ld = l*d
                sugar = (kc+ld)
                sugarwater = (na+mb+kc+ld)
                if best[2] < sugar/sugarwater <= e:
                    best = [sugarwater,sugar,sugar/sugarwater]
                
best.pop()
print(*best)

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    int N;
    std::cin >> N;

    int res = 0;
    for(int i=0;i<N;++i){
        int l, r;
        std::cin >> l >> r;

        res += r - l + 1;
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

const int MAX_N = 202020;

vector<int> graph[MAX_N];
ll counter[MAX_N];
bool is_visited[MAX_N];

void dfs(int node, ll prev_cost) {
    counter[node] += prev_cost;
    is_visited[node] = true;
    for (int i = 0; i < graph[node].size(); ++i) {
        if (is_visited[graph[node][i]]) continue;
        dfs(graph[node][i], counter[node]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    int a, b;
    for (int i = 0; i < N - 1; ++i) {
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int p;
    ll x;
    for (int i = 0; i < Q; ++i) {
        cin >> p >> x;
        p--;
        counter[p] += x;
    }
    dfs(0, 0);
    for (int i = 0; i < N; ++i) {
        cout << counter[i] << " \n"[i == N - 1];
    }
    return 0;
}

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

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

    int N;
    vector<int> V1;
    vector<int> V2;
    int ab=0;
    int counter=0;
    int input;
  
    cin >> N;

    rep(i, N) 
    {
       cin >> input;
       V1.emplace_back(input);
       V2.emplace_back(input);
    }

    sort(V2.begin(), V2.end());

    rep(i, V1.size())
    {
        ab = abs(V1[i]-V2[i]);

        if(ab != 0) 
        {
            ++counter;
        }
    }

    if (counter <= 2)
    {
      puts("YES");
    }
     else
    {
       puts("NO");
    }

    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int64_t count = 0;
  bool loop_continue = true;
  while (loop_continue) {
    for (int64_t i = 0; i < N; ++i) {
      if (A[i] % 2 == 0) {
        A[i] /= 2;
      } else {
        loop_continue = false;
        break;
      }
    }
    if (loop_continue) {
      ++count;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back

using namespace std;

const int N = 16;

int n, m;
int dp[1 << N][N];
vector<int> G[N];
int w[N][N], sumv[1 << N], sume[1 << N][N];

inline void Add(int u, int v, int x){
	G[u].pb(v), w[u][v] = x;
}

inline void chkmax(int &x, int y){
	x = x > y ? x : y;
}

int main(){
	scanf("%d%d", &n, &m);
	int sumw = 0;
	For(i, 1, m){
		int u, v, x;
		scanf("%d%d%d", &u, &v, &x);
		sumw += x;
		Add(u, v, x), Add(v, u, x);
	}
	For(i, 0, (1 << n) - 1){
		For(j, 0, n) dp[i][j] = -1e9;
		For(j, 1, n){
			if(i & (1 << (j - 1))){
				for(int v : G[j]) if(i & (1 << (v - 1))) sumv[i] += w[j][v];
			}
			else{
				for(int v : G[j]) if(i & (1 << (v - 1))) sume[i][j] += w[j][v];
			}
		}
		sumv[i] >>= 1;
	}
	dp[1][1] = 0;
	For(i, 1, (1 << n) - 1)
		For(j, 1, n) if(i & (1 << (j - 1))){
			if(dp[i][j] == -1e9) continue;
			for(int k : G[j]) if(!(i & (1 << (k - 1)))) chkmax(dp[i | (1 << (k - 1))][k], dp[i][j] + w[j][k]);
			int S = ((1 << n) - 1) ^ i;
			for(int k = S; k; k = (k - 1) & S){
				int ret = sumv[k] + sume[k][j];
				chkmax(dp[i | k][j], dp[i][j] + ret);
			}
		}
	printf("%d\n", sumw - dp[(1 << n) - 1][n]);
	return 0;
}

Measured memory_bytes: 8448
def D_Megalomania():
    N = int(input())
    A = [0 for _ in range(N)]
    B = [[0,0] for _ in range(N)]
    for i in range(N):
        B[i][0] = i
        A[i], B[i][1] = map(int, input().split())

    B.sort(key=lambda x: x[1])
    output = "Yes"
    total_a = 0
    for i in range(N):
        total_a += A[B[i][0]]
        if total_a > B[i][1]:
            output = "No"
    print(output)

if __name__ == "__main__":
    D_Megalomania()

Measured memory_bytes: 45988
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        int num = 0;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String s = br.readLine();
            int x = Integer.parseInt(s);
            System.out.println(x * x * x);
        } catch (NumberFormatException e) {
        } catch (IOException e) {
        }
    }
}

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

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll s = b - a + 1LL;
    ll e = c * d / __gcd(c, d);

    ll x = (b) / c - (a + c - 1) / c;
    ll y = (b) / d - (a + d - 1) / d;
    ll z = (b) / e - (a + e - 1) / e;

    cout << s + z - x - y - 1LL << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

struct info {
    string S;
    int P;
    int index;
};

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

    vector<info> infoList(N);
    for (int i = 0; i < N; i++) {
        cin >> infoList[i].S >> infoList[i].P;
        infoList[i].index = i + 1;
    }

    sort(infoList.begin(), infoList.end(), [](const info& left, const info& right) {
        if (left.S == right.S) {
            return left.P > right.P;
        } else {
            return left.S < right.S;
        }
    });

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

    return 0;
}


Measured memory_bytes: 3256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int, K: int):
    ret = 0
    counts = [0] * (K + 1)
    for i in range(1, K + 1)[::-1]:
        c = K // i
        cnt = pow(c, N, MOD)
        j = 2
        while i * j <= K:
            cnt -= counts[i * j]
            j += 1
        ret += cnt * i
        ret %= MOD
        counts[i] = cnt
    #print(counts)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68464
N, M = list(map(int, input().split()))

pair = []
for i in range(M):
    a, b = list(map(int, input().split()))
    pair.append([b, a])

# bをキーにして昇順にソートする
pair.sort()

ans = 1
y, x = pair[0]

for i in range(1, M):
    b, a = pair[i]
    if y <= a:
        y = b
        ans += 1

print(ans)

Measured memory_bytes: 20548
N = int(input())
lst = []
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        lst.append([i, x-1, y])

ans = 0
for i in range(1 << N):
    chk = []
    for j in range(N):
        if ((i >> j) & 1):
            chk.append(1)
        else:
            chk.append(0)
    for a, x, y in lst:
        if ((i >> a) & chk[a]):
            if chk[x] ^ y:
                chk = [0] * N
                break
    ans = max(ans, sum(chk))

print(ans)


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	LL n, q;
	cin >> n >> q;
	LL s = 0;
	for (int i : range(q)) {
		LL a, b;
		cin >> a >> b;
		if (a == 0)cout << (s + b - 1) % n + 1 << endl;
		else s = (s + b) % n;
	}

	return 0;
}



Measured memory_bytes: 3204
import heapq
N, M = map(int, input().split())
*A, = map(int, input().split())

A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍
heapq.heapify(A)

while M>0:
    a = heapq.heappop(A)*(-1)
    heapq.heappush(A, -int(a/2))
    M -= 1

print(-sum(A))

Measured memory_bytes: 20052
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <stack>
#include <string.h>
#include <unordered_map>
using namespace std;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()

const ll MOD = (ll)(1e9 + 7);
const ll N = 5007;


ll powerf(ll a, ll b)
{
	ll ans = 1;
	while(b > 0)
	{
		if(b&1)
		{
			ans = (ans * a) % MOD;
		}
		a = (a * a) % MOD;
		b/=2;
	}
	return ans;
}

ll inv_modulo(ll a)
{
	return powerf(a, MOD-2);
}


int dp[N][N];

int main()
{
	FIO;

	int n;
	string str;
	cin >> n >> str;
	int mx = 0;
	
	for(int i=n; i>=0; i--)
	{
		for(int j=n; j>=0; j--)
		{
			if(i==n || j == n)
			{
				dp[i][j] = 0;
			}
			else if(str[i] == str[j])
			{
				dp[i][j] = min(j-i, dp[i+1][j+1]+1);
			}
			else
			{
				dp[i][j] = 0;
			}
			
			mx = max(mx, dp[i][j]);
		}
	}

	cout << mx << "\n";

	return 0;
	
}

Measured memory_bytes: 98048
import Data.Char
main = do
  xs <- map digitToInt <$> getLine :: IO [Int]
  print $ dfs xs []
  
dfs :: [Int] -> [Int] -> Int
dfs [] ys = sum ys
dfs (x:xs) [] = dfs xs [x]
dfs (x:xs) (y:ys) =
    dfs xs (x:y:ys) +  dfs xs ((x+10*y):ys)

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

int main() {
  int A;
  cin>>A;
  if(A<1200){
    cout<<"ABC"<<endl;
  }
  if(A>=1200 && A<2800){
    cout<<"ARC"<<endl;
  }
  if(A>=2800){
    cout<<"AGC"<<endl;
  }
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s;
    int d;
    cin >> s >> d;
    int n = s.size();
    vector<vector<int>> dp1(n+1,vector<int>(d,0)),dp2(n+1,vector<int>(d,0));
    dp1[0][0] = 1;
    for (int i = 0;i < n;++i) {
        int t = s[i]-'0';
        for (int j = 0;j < d;++j) {
            for (int k = 0;k < 10;++k) {
                (dp2[i+1][(j+k)%d] += dp2[i][j]) %= mod;
                if (k == t) dp1[i+1][(j+k)%d] += dp1[i][j];
                else if (k < t) (dp2[i+1][(j+k)%d] += dp1[i][j]) %= mod;
            }
        }
    }
    cout << (dp1[n][0]+dp2[n][0]-1+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 8832
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	fmt.Printf("%d\n", combination(n)+combination(m))
}

func combination(x int) int {
	if x < 2 {
		return 0
	}
	return x * (x - 1) / 2
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<int> hv(h), wv(w);
    rep(i,h) {
        int cnt = 0;
        rep(j,w) {
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == 0) hv[i]++;
    }
    rep(j,w) {
        int cnt = 0;
        rep(i,h) {
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == 0) wv[j]++;
    }
    rep(i,h){
        if (hv[i]) continue;
        rep(j,w) {
            if (wv[j]) continue;
            printf("%c", s[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

//素因数分解
vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    ll N = n;
    for (ll i = 2; i * i <= N; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i,0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        } 
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}

int main() {
    ll n; cin >> n;
    auto p = factorize(n);
    int ans = 0;
    for (auto x : p) {
        int a = x.second;
        // cout << a << endl;
        int sum = 0;
        int n = 1;
        while (true) {
            sum += n;
            if (a < sum) break;
            n++;
        }
        // cout << n << endl;
        ans += n-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vl a(n);
    FOR(i,0,n){
        cin>>a[i];
    }
    LL ans=0,mx=a[0];
    FOR(i,1,n){
        ans+=max(0LL,mx-a[i]);
        mx=max(mx,a[i]);
    }
    cout<<ans;

}


Measured memory_bytes: 4780
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
s = list(set(s))
n = len(s)
t.sort()
s.sort()
c = 0
for i in range(q):
    l = 0
    u = n - 1
    while u - l > 1:
        x = int((l + u) / 2)
        if t[i] > s[x]:
            l = x
        elif t[i] < s[x]:
            u = x
        else:
            break
    if t[i] == s[x]:
        c += 1
    elif t[i] == s[l]:
        c += 1
    elif u <= n - 1:
        if t[i] == s[u]:
            c += 1
print(int(c))



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

using namespace std;
#define BUF (1000)
#define ll long long 

int n;
int D[BUF];
int dcnt[13];
int used[25];
int ans;


void dfs(int d){
	int sm,bg;
	sm=D[d];
	bg=24-D[d];

	if(d==n+1){
		//count used!!!!
		int cnt=0;
		int index=0;
		int min = 1000;
		for(int i=0;i<=24;i++){
			
			if(used[i]==1){
				cnt=i-index;
				index = i;
				if(min>cnt) min = cnt;
			}
		}

//		cout << min << "calc\n";
		if(min==1000) return ;
		if(min>ans) ans = min;
		return;
	}

	if(used[sm]==0){

		used[sm]=1;

//		cout << d << sm << "\n";	
		dfs(d+1);
		used[sm]=0;
	}

	if(used[bg]==0){

//		cout << d << bg << "\n";	
		used[bg]=1;
		dfs(d+1);
		used[bg]=0;
	}

	if(used[bg]==1 && used[sm]==1) return;
}

int main(void){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> D[i];
		dcnt[D[i]]++;
	}

	for(int i=1;i<12;i++){
		if(dcnt[i]>2){ 
			cout << 0;
			return 0;
		}
	}

	if(dcnt[0]>0){
		cout << 0;
		return 0;
	}

	if(dcnt[12]>1){
		cout << 0;
		return 0;
	}

	if(n==1){
		int sm=D[1];
		int bg=24-sm;
		cout << sm;
		return 0;
	}


/*
	for(int i=0;i<12;i++){
		if(dcnt[i]==2){ 
			used[i]=1;
			used[24-i]=1;
		}
	}
*/
	//used[0]=1;
	used[24]=1;
	dfs(1);

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)x
#define lp(i,n) for(int i=0;i<(n);++i)

#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PIPII pair<int, pair<int, int> >
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int ans[400];

int main(){
  lp(i,400){
    ans[i]=-1;
  }
  ans[0]=0;
  int n;
  cin>>n;
  int maxi=0;
  lp(i,n){
    int s,l,p;
    cin>>s>>l>>p;
    for(int i=0;i<=399;i++){
      if(ans[i]!=-1){
	for(int j=i+s;j<=min(399,l+i);j++){
	  ans[j]=max(ans[j],ans[i]+p);
	}
      }
    }/*
    lp(i,20){
      cout<<ans[i]<<" ";
    }
    cout<<endl;*/
  }
  int q;
  cin>>q;
  vector<int> v;
  int check=0;
  lp(i,q){
    int hoge;
    cin>>hoge;
    v.push_back(ans[hoge]);
    if(ans[hoge]==-1){
      check=1;
    }
  }
  if(check==1) cout<<-1<<endl;
  else{
    lp(i,q){
      cout<<v[i]<<endl;
    }
  }
  
  return 0;
}



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

int main() {
  int n;
  scanf("%d", &n);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    ans += (i % 2 == 0 && a % 2 == 1);
  }

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

  return 0;
}

Measured memory_bytes: 3752
n = int(input())
a, b = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
f = len([i for i in p if i<=a])
s = len([i for i in p if a<i<=b])
t = len([i for i in p if b<i])
print(min(f,s,t))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<ll >    vecll;
typedef vector<string > vecstr;
////////////////////////////////////////////////
ll num(ll k, ll n, ll m){
  ll zero = 0;
  return max((ll)min((m - 2*k)/2, n + k),zero);
}
////////////////////////////////////////////////
int main()
{
  int n;
  cin >> n;
  vecint a(n,0);
  REP(i,n) cin >> a[i];
  sort(all(a));
  int cost = 0;
  int ans = 1e9;
  for(int i = a[0]; i <= a[n- 1]; i++){
    cost = 0;
    REP(j,n){
      cost += (a[j] - i)*(a[j] - i);
    }
    ans = min(cost, ans);
  }
  cout << ans << endl;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A!=B&&(B==C||B==A)) cout<<"Yes"<<endl;
  else if(B!=C&&(C==A||A==B)) cout<<"Yes"<<endl;
  else if((A==B||B==C)&&C!=A) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<double> vec(N+1, 0);
    for(int n=0; n<N; n++) {
        double p;
        cin >> p;
        p = (p*(p+1)/2)/p;
        vec[n+1] = vec[n]+p;
    }
    
    double mx=0;
    for(int n=0; n+K<=N; n++) {
        mx = max(mx, vec[n+K]-vec[n]);
    }
    cout << setprecision(15) << mx << endl;


    return 0;
    
}

Measured memory_bytes: 1792
n = gets.to_i
point = []
n.times {point << gets.split.map(&:to_i)}
fac = [1,1,2,6,24,120,720,5040,40320]

sum = 0.0

(0..n-1).to_a.permutation do |arr|
    (n-1).times do |i|
        sum += Math.sqrt((point[arr[i+1]][0] - point[arr[i]][0]) ** 2 + 
                         (point[arr[i+1]][1] - point[arr[i]][1]) ** 2)
    end
end

puts sum / fac[n]

Measured memory_bytes: 2172
#include <stdio.h>

int main(void)
{

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

    if((a >= b)&&(a >= c)) 
        d = a * 10 + b + c;
    else if((b >= a)&&(b >= c)) 
        d = b * 10 + a + c;
    else if((c >= a)&&(c >= b)) 
        d = c * 10 + a + b;

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

Measured memory_bytes: 128