akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
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 REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n, k;
string s;

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

  scan(n); scan(s); scan(k);
//  vint s(n);
  REP(i, n){
    if(s[i]!=s[k-1]){ s[i]='*'; }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
from string import ascii_lowercase
from bisect import bisect_left


def main():
    word = stdin.readline().rstrip()
    if word == ascii_lowercase[::-1]:
        print(-1)
        return

    spam = sorted(list(set(ascii_lowercase) - set(word)))
    if 1 <= len(spam):
        print(word + spam[0])
        return

    rword = word[::-1]
    tmp = []
    for x in rword:
        if len(tmp) != 0 and x < sorted(tmp)[-1]:
            idx = bisect_left(tmp, x)
            print(word[:-len(tmp) - 1] + sorted(tmp)[idx])
            return
        tmp.append(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
S = {}
(gets.to_i).times do 
  key = gets.chomp
    if S.key?(key)
        S[key] += 1 
    else 
        S.store(key, 1)
    end
end

max = S.values.max
 S.keep_if {|_, v| v == max}
puts S.keys.sort

Measured memory_bytes: 36456
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

int ans[100005];
int last[100005];
main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, x, m;
	cin>>n>>x>>m;
	ans[1]=x;
	last[x]=1;
	int ind1=-1;
	int ind2=-1;
	
	for(int i=2; i<=100004; i++){
		ans[i]=(ans[i-1]*ans[i-1])%m;
		if(last[ans[i]]!=0){
			ind1=last[ans[i]];
			ind2=i;
			break;
		}
		last[ans[i]]=i;
	}
	for(int i=2; i<=100004; i++){
		ans[i]=(ans[i-1]*ans[i-1])%m;
	}
	int ans1=0;
	for(int i=1; i<ind1; i++){
		ans1+=ans[i];
	}
	
	if(n<ind1){
		int ans2=0;
		for(int i=1; i<=n; i++){
			ans2+=ans[i];
		}
		cout<<ans2;
		return 0;
	}
	int ans2=0;
	for(int i=ind1; i<ind2; i++){
		ans2+=ans[i];
	}
	
	
	int cyc=(n-ind1+1)/(ind2-ind1);
	int rem=(n-ind1+1)%(ind2-ind1);
	int val=ans[ind1];
	
	int ans3=0;
	while(rem!=0){
		rem--;
		ans3+=val;
		val=(val*val)%m;
	
	}
	cout<<ans1+cyc*ans2+ans3;
	return 0;
}

Measured memory_bytes: 5152
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
vector<ll> add(vector<ll> &v,ll a){
    rep(i,0,v.size())Min(a,v[i]^a);
    if(a>0)v.push_back(a);
    return v;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;cin>>t;
    rep(_,0,t){
        int n;cin>>n;
        ll a[n];
        rep(i,0,n)cin>>a[i];
        string s;cin>>s;
        vector<ll> v;
        bool bo=false;
        rrep(i,n-1,0){
            int m=v.size();
            add(v,a[i]);
            if(s[i]=='1'&&v.size()>m){
                bo=true;
                break;
            }
        }
        if(bo)cout<<1<<endl;
        else cout<<0<<endl;
    }
}


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

int64_t powmod(int64_t n, int64_t p, int64_t m) {
	if (p == 0) {
		return 1;
	}
	else if (p % 2 == 0) {
		int64_t t = powmod(n, p / 2, m);
		return t * t % m;
	}
	return n * powmod(n, p - 1, m) % m;
}

int64_t cmod(int64_t n, int64_t a, int64_t m) {
	int64_t x = 1;
	int64_t y = 1;
	for (int64_t i = 0; i < a; i++) {
		x *= n - i;
		x %= m;
		y *= i + 1;
		y %= m;
	}
	//return y;
	//return x;
	//return powmod(y, m - 2, m);
	int64_t res;
	res = x * powmod(y, m - 2, m) % m;
	return res;
}

int main() {
	/*
	int s, t;
	cin >> s >> t;
	uint64_t m = 1000000007;
	cout << cmod(s, t, m) << endl;
	*/
	
	int64_t n, a, b;
	cin >> n >> a >> b;
	int64_t m = 1000000007;
	int64_t ans = powmod(2, n, m) - 1;
	ans -= cmod(n, a, m);
	ans %= m;
	if (ans < 0) ans += m;
	ans -= cmod(n, b, m);
	ans %= m;
	if (ans < 0) ans += m;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
const int N = 1e3+5,M = 1e6+5;
const int inf = 1e18;
int w[N],val[N];
ll good[100005];

main() {
    ios::sync_with_stdio(0);
    int n,W;
    cin >> n >> W;
    //good[0] = 1;
    for (int i = 1; i <= n; i++)
        cin >> w[i] >> val[i];
    for (int i = 1; i <= n; i++)
        for (int j = W;j >= 0;j--)
            if (w[i] + j <= W)
                good[j + w[i]] = max(good[j + w[i]],good[j] + val[i]);
    ll ans = 0;
    for (int i = 1; i <= W; i++)
        ans = max(ans,good[i]);
        cout << ans;
}


Measured memory_bytes: 4360
n, m = map(int, input().split())
eg = [[] for _ in range(n + 1)]

al = [0] * m
bl = [0] * m

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

ans = 0
for i in range(m):
    x, y = al[i], bl[i]
    q = [1]
    seen = {1}
    while len(q) > 0:
        v = q.pop()
        for t in eg[v]:
            if t in seen:
                continue
            elif (v == x and t == y) or (v == y and t == x):
                continue
            q.append(t)
            seen.add(t)
    if len(seen) != n:
        ans += 1
print(ans)


Measured memory_bytes: 68120
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!(usize;n);

    if a.into_iter().any(|e| e%2==1) {
        println!("first");
    } else {
        println!("second");
    }
}


Measured memory_bytes: 8572
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int shrine = scanner.nextInt();
        final int temple = scanner.nextInt();
        final int startPoint = scanner.nextInt();
        final List<Long> shrines = new ArrayList<>();
        final List<Long> temples = new ArrayList<>();

        for (int i = 0; i < shrine; i++) {
            shrines.add(scanner.nextLong());
        }

        for (int i = 0; i < temple; i++) {
            temples.add(scanner.nextLong());
        }

        for (int i = 0; i < startPoint; i++) {
            final long point = scanner.nextLong();
            int sp = Collections.binarySearch(shrines, point);
            final List<Long> candidateShrines = new ArrayList<>();
            if (sp >= 0) {
                candidateShrines.add(0L);
            } else {
                sp = -(sp + 1);
                if (sp != 0) {
                    candidateShrines.add(shrines.get(sp - 1) - point);
                }

                if (sp != shrines.size()) {
                    candidateShrines.add(shrines.get(sp) - point);
                }
            }

            int tp = Collections.binarySearch(temples, point);
            final List<Long> candidateTemples = new ArrayList<>();
            if (tp >= 0) {
                candidateShrines.add(0L);
            } else {
                tp = -(tp + 1);
                if (tp != 0) {
                    candidateTemples.add(temples.get(tp - 1) - point);
                }

                if (tp != temples.size()) {
                    candidateTemples.add(temples.get(tp) - point);
                }
            }

            final List<Long> candidateAnswers = new ArrayList<>();
            for (final Long candidateShrine : candidateShrines) {
                for (final Long candidateTemple : candidateTemples) {
                    candidateAnswers.add(calc(candidateShrine, candidateTemple));
                }
            }

            Collections.sort(candidateAnswers);
            System.out.println(candidateAnswers.get(0));
        }
    }

    private static long calc(final long a, final long b) {
        if (a<0&&b>0 || a>0&&b<0) {
            final long aa = Math.abs(a);
            final long ab = Math.abs(b);

            return Math.min(aa, ab) * 2 + Math.max(aa, ab);
        } else {
            return Math.max(Math.abs(a), Math.abs(b));
        }
    }
}


Measured memory_bytes: 123360
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
l = k.bit_length()
vs = [0]*(l)
for i in range(l):
    tmp = sum((item&(1<<i)) for item in a)
    if n*(1<<i) >= 2*tmp:
        vs[i] = n*(1<<i) - 2*tmp
ans = 0
tmp = 0
for i in range(l-1, -1, -1):
    if (k>>i)&1:
        ans = max(ans, tmp+sum(vs[:i]))
        tmp += vs[i]
ans = max(ans, tmp)
print(ans+sum(a))

Measured memory_bytes: 87248
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1007;


ll LCS(string x,string y){
	ll xs,ys;
	xs=x.size();ys=y.size();
	ll dp[xs+1][ys+1];
	FOR(i,0,xs+1)FOR(j,0,ys+1)dp[i][j]=0;
	FOR(i,0,xs+1){
		FOR(j,0,ys+1){
			if(i==0||j==0)dp[i][j]=0;
			else{
				if(x[i-1]==y[j-1])dp[i][j]=dp[i-1][j-1]+1;
				else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	return dp[xs][ys];
}



int main(){
	ll n;
	cin>>n;
	FOR(i,0,n){
		string x,y;
		cin>>x>>y;
		cout<<LCS(x,y)<<endl;
	}
}


Measured memory_bytes: 10932
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}


signed main()
{
    int N, K;
    int g = 0;
    int maxv = 0;

    cin >> N >> K;
    rep(i, 0, N) {
        int a; cin >> a;
        g = __gcd(g, a);
        chmax(maxv, a);
    }

    if (K % g == 0 && K <= maxv) {
        cout << ("POSSIBLE") << endl;
    } else {
        cout << ("IMPOSSIBLE") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	int ans = 1;
	for(int i = 0; i < n; i++) ans *= (k - 1);
	ans /= (k - 1);
	ans *= k;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  long x,a[2000],dp[2000][2000],ans=0,cnt,n;
  scanf("%ld %ld",&n,&x);
  for(long i=0;i<n;i++){
    scanf("%ld",&a[i]);
    dp[0][i]=a[i];
    ans+=a[i];
  }
  for(long i=1;i<n;i++){
    cnt=0;
    for(long j=0;j<n;j++){
      dp[i][j]=min(dp[i-1][j],a[(j+i)%n]);
      cnt+=dp[i][j];
    }
    if(ans>cnt+x*i)
      ans=cnt+x*i;
  }
  printf("%ld\n",ans);
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,m,k;
    cin >> n >> m >> k;
    int a[n],b[m];
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i)a[i]+=a[i-1];
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
        if(i)b[i]+=b[i-1];
    }
    int j=0,ans=0;
    for(int i=n-1;i>=0;i--){
        if(a[i]>k)continue;
        while(j<m and k-a[i]>=b[j])j++;
        ans=max(ans,i+1+j);
    }
    j=0;
    while(j<m and b[j]<=k)j++;
    ans=max(ans,j);
    cout << ans;
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

struct bipartiteGraph{
  int L, R;
  vector<vector<int>> adj;
  bipartiteGraph(int L, int R) : L(L), R(R), adj(L+R) { }
  void add_edge(int u, int v) {
    adj[u].push_back(v+L);
    adj[v+L].push_back(u);
  }
  int maximum_matching() {
    vector<int> level(L), mate(L+R, -1);

    function<bool(void)> levelize = [&]() { // BFS
      queue<int> Q;
      for (int u = 0; u < L; ++u) {
        level[u] = -1;
        if (mate[u] < 0) {
          level[u] = 0;
          Q.push(u);
        }
      }
      while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        for (int w: adj[u]) {
          int v = mate[w];
          if (v < 0) return true;
          if (level[v] < 0) {
            level[v] = level[u] + 1;
            Q.push(v);
          }
        }
      }
      return false;
    };
    function<bool(int)> augment = [&](int u) { // DFS
      for (int w: adj[u]) {
        int v = mate[w];
        if (v < 0 || (level[v] > level[u] && augment(v))) {
          mate[u] = w;
          mate[w] = u;
          return true;
        }
      }
      return false;
    };
    int match = 0;
    while (levelize())
      for (int u = 0; u < L; ++u)
        if (mate[u] < 0 && augment(u))
          ++match;
    return match;
  }
};


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  vll a(N),b(N),c(N),d(N);
  for(ll i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
  for(ll i=0;i<N;i++){
    cin>>c[i]>>d[i];
  }
  bipartiteGraph g(N,N);
  for(ll i=0;i<N;i++){
    for(ll j=0;j<N;j++){
      if(a[i]<c[j]&&b[i]<d[j]){
        g.add_edge(i,j);
      }
    }
  }
  cout<<g.maximum_matching()<<endl;
  return 0;
}


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

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

int N,M;
vector<int> Ys[101100];

int P[101010],Y[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>P[i]>>Y[i];
		Ys[P[i]].push_back(Y[i]);
	}
	
	FOR(i,100001) sort(ALL(Ys[i]));
	FOR(i,M) {
		x=lower_bound(ALL(Ys[P[i]]),Y[i])-Ys[P[i]].begin()+1;
		_P("%06d%06d\n",P[i],x);
	}
	
}


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


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    int num[3] = {0};
    string v[3];
    rep(i, 3)
    {
        cin >> v[i];
    }
    int cur = 0;
    while (true)
    {
        if (num[cur] == v[cur].size())
        {
            cout << (char)('A' + cur) << endl;
            return 0;
        }
        num[cur]++;
        cur = v[cur][num[cur] - 1] - 'a';
    }
    return 0;
}


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

int main(){
  ll x,k,d;
  cin>>x>>k>>d;
  if(x<0){
    x*=-1;
  }
  if(x/d>k){
    cout<<x-d*k<<endl;
    return 0;
  }
  k-=x/d;
  x%=d;
  k%=2;
  cout<<abs(x-k*d)<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
int V,E;
 
vector<int> G[10000];
vector<int> reverse_G[10000];
stack<int> S;
 
int topo_rank[10000];
bool check[10000];
 
void dfs(int node_id){
    check[node_id] = true;
 
    for(int i = 0; i < G[node_id].size(); i++){
        if(!check[G[node_id][i]])dfs(G[node_id][i]);
    }
    S.push(node_id);
}
 
void reverse_dfs(int node_id,int num){
    check[node_id] = true;
    topo_rank[node_id] = num;
 
    for(int i = 0; i < reverse_G[node_id].size(); i++){
        if(!check[reverse_G[node_id][i]])reverse_dfs(reverse_G[node_id][i],num);
    }
}
 
 
int main(){
 
    scanf("%d %d",&V,&E);
 
    for(int i = 0; i < V;i++)check[i] = false;
 
    int from,to;
 
    for(int loop = 0; loop < E; loop++){
        scanf("%d %d",&from,&to);
        G[from].push_back(to);
        reverse_G[to].push_back(from);
    }
 
    for(int i = 0; i < V;i++){
        if(!check[i])dfs(i);
    }
 
    int num = 0;
 
    for(int i = 0; i < V;i++)check[i] = false;
 
    while(!S.empty()){
        if(!check[S.top()])reverse_dfs(S.top(),num++);
        S.pop();
    }
 
    int Q,left,right;
    scanf("%d",&Q);
 
    for(int loop = 0; loop < Q; loop++){
        scanf("%d %d",&left,&right);
        if(topo_rank[left] == topo_rank[right]){
            printf("1\n");
        }else{
            printf("0\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 4872
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
const int N=200005;
struct qq
{
	int x,y,last;
}e[N*2];int num,last[N];
int X[N],Y[N];
void init (int x,int y)
{
	num++;
	e[num].x=x;e[num].y=y;
	e[num].last=last[x];
	last[x]=num;
}
int n,xx,yy;
int L[N],R[N],dep[N],fa[N];
void dfs (int x)
{
	L[x]=++num;
	for (int u=last[x];u!=-1;u=e[u].last)
	{
		int y=e[u].y;
		if (y==fa[x]) continue;
		fa[y]=x;dep[y]=dep[x]+1;
		dfs(y);
	}
	R[x]=num;
}
bool ok[N];
vector<int> vec[N];
bool vis[N];
int d[N];
void bfs ()
{
	memset(d,127,sizeof(d));
	memset(vis,false,sizeof(vis));
	vis[xx]=true;d[xx]=0;
	queue<int> q;q.push(xx);
	while (!q.empty())
	{
		int x=q.front();q.pop();
	//	printf("%d\n",x);
		int siz=vec[x].size();
		for (int i=0;i<siz;i++)
		{
			int y=vec[x][i];
			if (vis[y]) continue;
			if (d[y]>d[x]+1)
			{
				d[y]=d[x]+1;
				if (d[y]<dep[y]) 
				{
					vis[y]=true;
					q.push(y);
				}
			}
		}
	}
}
bool check (int x,int y)//这两个点是否可以由同一个点到达 
{
	if (dep[x]>dep[y]) swap(x,y);
	if (L[x]<=L[y]&&L[y]<=R[x])//在他子树里面
		return dep[y]-dep[x]>2;
	if (fa[x]==fa[y]) return false;
	return true;
}
int main()
{
	num=0;memset(last,-1,sizeof(last));
	scanf("%d%d%d",&n,&xx,&yy);
	for (int u=1;u<n;u++) scanf("%d%d",&X[u],&Y[u]);
	for (int u=1;u<n;u++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		init(x,y);init(y,x);
	}
	num=0;dfs(yy);
	/*for (int u=1;u<=n;u++) printf("%d ",dep[u]);
	printf("\n");*/
	memset(ok,false,sizeof(ok));
	for (int u=1;u<n;u++)
	{
		if (check(X[u],Y[u]))	{ok[X[u]]=true;ok[Y[u]]=true;}
		else vec[X[u]].push_back(Y[u]),vec[Y[u]].push_back(X[u]);
	}
	bfs();
	int ans=0;
	for (int u=1;u<=n;u++)
	{
		if (ok[u]&&vis[u])
		{
			printf("-1\n");
			return 0;
		}
		if (vis[u])	ans=max(ans,dep[u]*2);
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int n,m,x,b,c;
priority_queue<pair<int,int> > q;

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

    for (int i = 0; i < n; ++i) {
        scanf("%d", &x);
        q.push({-x, 1});
    }

    while(m--) {
        scanf("%d %d", &b, &c);
        
        int cur = 0;
        int last = -1;
        while(!q.empty() and cur < b and -q.top().first < c) {
            cur += q.top().second;
            last = q.top().first;
            q.pop();
        }
        
        if(cur > b) 
            q.push({last, cur - b});
        
        q.push({-c, min(b, cur)});
    }

    long long ans = 0;
    
    while(!q.empty()) {
        ans += -1ll*q.top().first * q.top().second;
        q.pop();
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>

int main () {
    int t, h, m, s ;
    
    std :: cin >> t ;
    
    h = t / 3600;
    m = (t % 3600) / 60 ;
    s = t % 60 ;
    
    std :: cout << h << ":" << m << ":" << s << std :: endl;
    
}


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

int main() {
  int a,b,c;
  int e;

  cin >> a >> b >> c;

  e = a-b;

  if(e<c) {
      cout << c-e << endl;
  }
  else {cout << 0  << endl;}

  return 0;
}


Measured memory_bytes: 384
def B():
    N = int(input())
    L = list(map(int, input().split()))
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                a, b, c = L[i], L[j], L[k]
                if len(set([a, b, c])) == 3 and not (a+b <= c or a+c <= b or b+c <= a):
                    count += 1
    return count
print(B())

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	string s;
	cin>>n>>k>>s;
	for (int i=0;i<s.size();i++)
		if (i+1==k) cout<<(char)(s[i]+32);
		else cout<<s[i];
	return 0;
}

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

int main() {
        int n;
        cin >> n;
        int h[n];
        for (int i = 0; i < n; ++i) {
                cin >> h[i];
        }
        int dp[n];
        dp[0] = 0;
        dp[1] = abs(h[0]-h[1]);
        for (int i = 2; i < n; ++i) {
                dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
        }
        cout << dp[n-1];
}

Measured memory_bytes: 4340
from collections import defaultdict as dd
import sys
input = sys.stdin.readline

N,K = map(int,input().split())

d = dd(int)
for i in range(N):
    a,b = map(int,input().split())
    d[a] += b

d = sorted(d.items())
for i,j in d:
    K -= j
    if K <= 0:
        print(i)
        break

Measured memory_bytes: 14940
n=int(input())
s_list=[input() for _ in range(n)]

samedic={}
for s in s_list:
    sorder=''.join(sorted(list(s)))
    if sorder in samedic:
        samedic[sorder]+=1
    else:
        samedic[sorder]=1

ans=0
for v in samedic.values():
    ans+=v*(v-1)//2
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rep3(i, m, n) for(ll i=m;i<=(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1000000000000000000

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = MOD;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

ll dp[100005][3];

void solve_abc_d() {
	ll n;

	cin >> n;
	V a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	rep(i, n - 1) {
		chmax(dp[i + 1][0], dp[i][1] + a[i + 1]);
		chmax(dp[i + 1][0], dp[i][2] + a[i + 1]);
		chmax(dp[i + 1][1], dp[i][0] + b[i + 1]);
		chmax(dp[i + 1][1], dp[i][2] + b[i + 1]);
		chmax(dp[i + 1][2], dp[i][0] + c[i + 1]);
		chmax(dp[i + 1][2], dp[i][1] + c[i + 1]);
	}

	ll l_ans = max(max(dp[n - 1][0], dp[n - 1][1]), dp[n-1][2]);

	cout << l_ans << "\n";

	return;
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 8004
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string w;
	cin >> w;
	map<char, int> M;

	for(int i=0; i<w.size(); i++){
		char c = w[i];
		if(M.count(c) == 0){
			M[c] = 1;
		}
		else{
			M[c]++;
		}
	}
	int ans = 0;
	for(auto itr = M.begin(); itr != M.end(); itr++){
		char c = itr->first;
		int  v = itr->second;
		if((v % 2) != 0){
			ans = 1;
			break;
		}
	}
	if(ans==1){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    string s;cin>>s;
    
    int count[127]={0};
    rep(i,127)count[i]=0;
    for(auto j:s){
        count[j]|=1;

    }
    
    if(count['W']==count['E'] && count['S']==count['N'])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}








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

using namespace std;
const int MAXN = 10000;

int F[MAXN];

inline int Root(int u) {
    return F[u] == u ? u : F[u] = Root(F[u]);
}

inline void Merge(int u, int v) {
    int root_u = Root(u);
    int root_v = Root(v);
    if (root_u != root_v) {
        F[root_u] = root_v;
    }
}

int main() {
    //ifstream cin("input.txt");
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        F[i] = i;
    }
    for (int i = 1; i <= q; i++) {
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 0)
            Merge(x, y);
        else
            cout << (Root(x) == Root(y)) << endl;
    }
    return 0;
}




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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    ll n;
    cin>>n;
    ll k = 2*n;
    ll m = -1;
    for(int i=1;i<=n;i++){
        if(i*(i+1)==k){
            m = i;
            break;
        }
        if(i*(i+1)>k) break;
    }
    if(m==-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << m+1 << endl;
    vector<vector<int>> v(m+1);
    int now = 1;
    for(int i=0;i<m+1;i++){
        int c=1;
        while(v[i].size()<m){
            v[i].push_back(now);
            v[i+c].push_back(now);
            now++;
            c++;
        }
    }
    for(int i=0;i<m+1;i++){
        cout << m << " ";
        for(auto j:v[i]){
            cout << j << " ";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 2304
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int x,c=0;
    cin >> x;
    for(int i=1;;i++){
        c+=i;
        if(x<=c){
            cout<<i;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	double n;
	double a[100];
	double co = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		co += a[i];
	}
	co /= n;
	double min = 1000000007;
	int ans;
	for (int j = 0; j < n; j++) {
		if (abs(co - a[j]) < min) {
			min = abs(co - a[j]);
			ans = j;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
	string S;
	cin >> S;
	int Q;
	cin >> Q;
	bool rev=false;
	string b, e;
	rep(i,Q){
		int T;
		cin >> T;
		if(T==1){
			if(rev==false) rev=true;
			else rev=false;
		}
		if(T==2){
			int F;
			cin >> F;
			string C;
			cin >> C;
			if(F==1&&rev==false) b+=C;
			else if(F==1&&rev==true) e+=C;
			else if(F==2&&rev==false) e+=C;
			else b+=C;
		}
	}
	string br=b, er=e, Sr=S;
	reverse(br.begin(),br.end());
	reverse(er.begin(),er.end());
	reverse(Sr.begin(),Sr.end());
	if(rev==false) cout << br+S+e << endl;
	else cout << er+Sr+b << endl;

	return 0;
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
const ll M=1e9+7;
int n;
ll dp[2020]; 
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	dp[0]=1;dp[1]=dp[2]=0;
	fo(i,3,n+1) fo(j,3,i+1)dp[i]=(dp[i]+dp[i-j])%M;
	cout<<dp[n]<<endl;
	return 0;
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  atcoder::dsu towns(N);
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    towns.merge(A, B);
  }
  int answer = towns.groups().size() - 1;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
    long long int max(long long int a,long long int b)
    {
      if(a>=b)
      return a;
      return b;
    }
int main()
{
 long long int n;
 cin>>n;
 vector<long long int>arr(n);
 for(int i=0;i<n;i++)
 cin>>arr[i];
 long long int mx=0;
 long long int ans=0;
 for(int i=0;i<n;i++)
 {
 mx=max(mx,arr[i]);
 ans=ans+(mx-arr[i]);
 }
 cout<<ans;
}

Measured memory_bytes: 4756
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int fact (int n) {
	if (n == 1) return 1;
	else return n * fact(n - 1);
}
int main(void)
{
	int n;
	cin >> n;
	double ans = 0;
	pair<double, double> p[n]; 
	rep (i, n) {
		cin >> p[i].first >> p[i].second;
	}
	rep (i, n - 1) {
		repp (j, i + 1, n) {
			double dy = (p[j].second - p[i].second);
			double dx = (p[j].first - p[i].first);
			ans += sqrt(dy * dy + dx * dx);
		}
	}
	ans *= 2.0 / (double)(n);
	printf("%lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, x, n);
    Cins(int, n, p);
    
    int ans = 0;
    for(int i = 1; i < 110; i ++){
        if(Contains(p, i)) continue;
        if(abs(i-x) < abs(ans-x)) ans = i;
    }
    Cout(ans);
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////

signed main()
{
	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("inputf.in","r",stdin);
	// 	freopen("outputf.in","w",stdout);
	// #endif
	int n,m;
	cin>>n>>m;
	pair<int,int> a[n];
	for(int i=0;i<n;++i)
	{
		int x,y;
		cin>>x>>y;
		a[i]={x,y};
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;++i)
	{
		int r=min(m,a[i].S);
		ans+=a[i].F*r;
		m-=r;
	}
	cout<<ans;
	
}

Measured memory_bytes: 1792
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

template<int jt> struct ModularInt {
	int x;
	ModularInt(int v = 0) {x = v; if(x >= jt || x < 0) {x %= jt; if(x < 0) x += jt;}}
	ModularInt(ll v) {x = v % jt; if(x < 0) x += jt;}
	operator int() const {return x;}
	friend inline ModularInt &operator+=(ModularInt &a, const ModularInt &b) {
		a.x += b.x;
		if(a.x >= jt) a.x -= jt;
		return a;
	}
	friend inline ModularInt operator+(ModularInt a, const ModularInt &b) {return a += b;}
	friend inline ModularInt &operator++(ModularInt &a) {return a += 1;}
	friend inline ModularInt &operator-=(ModularInt &a, const ModularInt &b) {
		a.x -= b.x;
		if(a.x < 0) a.x += jt;
		return a;
	}
	friend inline ModularInt operator-(ModularInt a, const ModularInt &b) {return a -= b;}
	friend inline ModularInt &operator--(ModularInt &a) {return a -= 1;}
	friend inline ModularInt &operator*=(ModularInt &a, const ModularInt &b) {
		a.x = (ll)a.x * b.x % jt;
		return a;
	}
	friend inline ModularInt operator*(ModularInt a, const ModularInt &b) {return a *= b;}
	static inline void exgcd(ll a, ll b, ll &x, ll &y) {
		if(!b) x = 1, y = 0;
		else exgcd(b, a % b, y, x), y -= a / b * x;
	}
	friend inline ModularInt inv(const ModularInt &a) {
		ll x, y; exgcd(a, jt, x, y);
		return x;
	}
	friend inline ModularInt operator/(const ModularInt &a, const ModularInt &b) {return a * inv(b);}
	friend inline ModularInt operator/=(ModularInt &a, const ModularInt &b) {return a = a / b;}
};
const int jt = 1000000007;
typedef ModularInt<jt> mint;

mint dp[4005][4005];
int n, m, k;

int main() {
	scanf("%d%d%d", &n, &m, &k);
	if(!n || !m) return 0 & puts("1");
	int lvl = (n + m - 1) / (k - 1);
	dp[0][0] = 1;
	mint ans = 0;
	cont(i, lvl) {
		loop(j, n + 1) {
			for(int t = 0; j + t <= n && t <= k - 1; t++) {
				dp[i][j + t] += dp[i - 1][j];
			}
		}
		loop(j, n + 1) {
			int t = i * (k - 1) - j;
			if(t <= m - 1 && j % (k - 1) == n % (k - 1) && t % (k - 1) == (m - 1) % (k - 1)) {
				ans += dp[i][j] - dp[i - 1][j];
			}
		}
	}
	printf("%d\n", int(ans));
	return 0;
}


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

const int MOD = 1000000007;
const int maxn = 1000005;
int fac[maxn], rev[maxn];
int n, ans, res;

inline int power(int x, int p) {
	int res = 1;
	while (p) {
		if (p&1) res = 1LL * res * x % MOD;
		x = 1LL * x * x % MOD; p >>= 1;
	}
	return res;
}

inline int C(int n, int m) {
	if (m < 0 || m > n) return 0;
	return 1LL * fac[n] * rev[m] % MOD * rev[n-m] % MOD;
}

int main() {
	scanf("%d", &n); n--;
	fac[0] = rev[0] = 1;
	rep (i, 1, maxn-1) {
		fac[i] = 1LL * fac[i-1] * i % MOD;
		rev[i] = power(fac[i], MOD - 2);
	}
	ans = 1LL * n * fac[n] % MOD;
	rep (i, 0, n-3) if (i <= n-2-i-1) {
		res = (res + 1LL * C(n-2-i-1, i) * (n-2-i) % MOD * fac[n-i-1] % MOD * fac[i]) % MOD;
		// printf("%d\n", res);
	}
	ans = (ans + MOD - res) % MOD;
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}

int main() {
  int64_t n, m, ans = 0;
  cin >> n >> m;
  if (n <= m/2) {
    ans += n;
    m -= n*2;
    ans += m/4;
  } else {
    ans += m/2;
  }
  cout << ans << endl;
}

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

int main() {
	int a,b,n,T,cas=0;
	cin>>n;
	a=n;
	int s=0;
	while(n) {
		s+=n%10;
		n/=10;
	}
	if(a%s==0) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::input;
use proconio::fastout;
use std::cmp::min;

#[fastout]
fn main() {
    const M: i32 = 998244353;
    input! {
        N: usize,
        K: usize,
        LR: [(usize, usize); K],
    }
    let mut dp = vec![0; N + 1];
    dp[0] = 1;
    dp[1] = M - 1;
    let mut x = 0;
    for i in 0..N {
        x = (x + dp[i]) % M;
        for &(L, R) in &LR {
            let l = min(i + L, N);
            let r = min(i + R + 1, N);
            dp[l] = (dp[l] + x) % M;
            dp[r] = (dp[r] + M - x) % M;
        }
    }
    println!("{}", x);
}


Measured memory_bytes: 2880