akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; 
int a[2000005],n,k;
double ans,num;
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++)
	    cin>>a[i];
    for(int i=1;i<=k;i++)
	    num+=a[i];
    ans=num;
    for(int i=2;i<n;i++)
    {
	    num-=a[i-1];
	    num+=a[i+k-1];
	    ans=max(ans,num);
	}
	printf("%10.12f",(ans+k)/2);
	return 0;
}

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

int A, B, C;

int main() {
    cin >> A >> B >> C;
    cout << min({C, (B / A)}) << endl;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1


n,m=map(int,input().split())
p=list(map(int,input().split()))
ans=0
uf=UnionFind(n+1)
for i in range(m):
    x,y=map(int,input().split())
    uf.unite(x,y)
for i in range(n):
    if uf.is_same(i+1,p[i]):
        ans+=1
print(ans)

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

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

int n, q;
int seg[1 << 21];

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

  cin >> n >> q;
  n = (1 << (32 - __builtin_clz(n)));
  for (int i = 0; i < q; i++) {
    int a, v;
    cin >> a >> v;
    a = a - 1 + n - 1;
    seg[a] += v;
    while (a > 0) {
      a = (a - 1) / 2;
      seg[a] = max(seg[2 * a + 1], seg[2 * a + 2]);
    }
    int p = 0;
    while (p < n - 1) {
      if (seg[2 * p + 1] >= seg[2 * p + 2]) p = 2 * p + 1;
      else p = 2 * p + 2;
    }
    cout << p - (n - 1) + 1 << " " << seg[0] << endl;
  }

  return 0;
}


Measured memory_bytes: 10996
#include <iostream>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int i=0; i<=K; i++)
    for (int j=0; j<=K; j++) {
      int k = S - i - j;
      if (k >= 0 && k <= K) {
        count++;
      }
    }
  cout << count << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
int n, a[223456];
int b[2234567];
int ans;
signed main() {
	cin >> n;
	for0(i, n) { cin >> a[i]; b[a[i]]++; }
	for0(i, n) {
		if (a[i] == 1 && b[1] > 1)continue;
		else if (a[i] != 1 && (b[1] > 0 || b[a[i]] > 1))continue;
		bool b1 = 1;
		for1(j, sqrt(a[i])) if (j > 1 && a[i] % j == 0) {
			if (b[j] || b[a[i] / j]) { b1 = 0; break; }
		}
		if (b1)ans++;
	}
	puts(ans);
}

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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int S, W;
    cin >> S >> W;
    if(S <= W){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
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;}
//------------------------------------------------------------------------------

int dp[515151];
signed main() {
    fill(ALL(dp),INFLL);
    int n,m;
    cin>>n>>m;
    vi c(m);
    cin>>c;
    dp[0]=0;
    REP(i,m) {
        REP(j,n) {
            if(dp[j]==-1) continue;
            dp[j+c[i]]=min(dp[j+c[i]],dp[j]+1);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 7120
<?php
$map = range('a', 'z');
fscanf(STDIN, '%d', $num);

$ans = '';

while ($num > 0) {
    $num--;
    $now = $num % 26;
    $ans = $map[$now] . $ans;
    $num = floor($num / 26);
}

echo $ans;

Measured memory_bytes: 16152
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<queue>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

long long dp[101][21];

int main(){
	int n;
	cin>>n;
	
	rep(i,101)rep(j,21)dp[i][j]=0;
	
	int hand[100];
	rep(i,n){
		cin>>hand[i];
	}
	
	dp[0][hand[0]]=1;
	reps(i,1,n-1){
		rep(j,20+1){
			int pls = j+hand[i];
			int mns = j-hand[i];
			
			if(pls<=20) dp[i][pls] += dp[i-1][j];
			if(mns>=0) dp[i][mns] += dp[i-1][j];
		}
	}
	
	printf("%lld\n", dp[n-2][hand[n-1]]);
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int a,b, ans;
  cin >> a >> b;
  
  ans = ((a + b)/2);
  
  if(abs(ans - a) == abs(ans - b))
    cout << to_string(ans);
  else {
    cout << "IMPOSSIBLE";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vector<vector<tuple<ll, ll, ll>>> path; ll goal = 0; vector<tuple<ll,ll,ll>> path2;
vll dis;
//***********//
void dijkstra(ll s) {
	priority_queue<pll> PQ;
	vl D(N), color(N);
	for (ll i = 0; i < N; i++) {
		D[i] = INF;
		color[i] = 0;
	}
	D[s] = 0;
	PQ.push(make_pair(0, s));
	color[0] = 1;
	ll q = -1;
	while (!PQ.empty()) {
		pll f = PQ.top();
		PQ.pop();
		ll u = f.second;
		color[u] = 2;
		if (D[u] < f.first * q) {
			continue;
		}
		for (ll j = 0; j < path[u].size(); j++) {
			ll v = get<0>(path[u][j]);
			if (color[v] == 2) {
				continue;
			}
			if (D[v] > D[u] + get<1>(path[u][j])) {
				D[v] = D[u] + get<1>(path[u][j]);
				color[v] = 1;
				PQ.push(make_pair(D[v] * q, v));
			}
		}
	}
	for (ll j = 0; j < N; j++) {
		dis[s].push_back(D[j]);
		//cout << (D[j] == INF ? -1 : D[j]) << endl;
	}
}
int main() {
	cin >> N >> M;
	path.resize(N);
	flag.resize(M*2);
	dis.resize(N);
	for (i = 0; i < M; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		path[a].push_back(make_tuple(b, c, i));
		path[b].push_back(make_tuple(a, c, i));
		path2.push_back(make_tuple(a, b, c));
		path2.push_back(make_tuple(a, b, c));
	}
	for (i = 0; i < N; i++) {
		dijkstra(i);
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			for (k = 0; k < M*2; k++) {
				ll s = get<0>(path2[k]);
				ll t = get<1>(path2[k]);
				ll c = get<2>(path2[k]);
				if (dis[i][s] + c + dis[t][j] == dis[i][j]) flag[k] = 1;
			}
		}
	}
	for (i = 0; i < M*2; i+=2) {
		if (flag[i] == 0 && flag[i+1] == 0) ans++;
	}
	cout << ans;
}


Measured memory_bytes: 512
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var H = myconv(input[0],4)[0];
  var W = myconv(input[0],4)[1];
  input.shift();
  for(var i = 0; i < H; i++){
    input[i] = myconv(input[i],6);
  }
  for(var i = 0; i < H; i++){
    for(var j = 0; j < W; j++){
      if(input[i][j] == "."){
        //123
        //4.5
        //678
        var count = 0;
        try{
        var hidariue = input[i-1][j-1];
        if(hidariue == "#"){count++;}
        }catch(e){}
        try{
        var ue = input[i-1][j];
        if(ue == "#"){count++;}
        }catch(e){}
        try{
        var migiue = input[i-1][j+1];
        if(migiue == "#"){count++;}
          }catch(e){}
        try{
        var hidari = input[i][j-1];
        if(hidari == "#"){count++;}
          }catch(e){}
        try{
        var migi = input[i][j+1];
        if(migi == "#"){count++;}
          }catch(e){}
        try{
        var hidarishita = input[i+1][j-1];
        if(hidarishita == "#"){count++;}
          }catch(e){}
        try{
        var shita = input[i+1][j];
        if(shita == "#"){count++;}
          }catch(e){}
        try{
        var migishita = input[i+1][j+1];
        if(migishita == "#"){count++;}
          }catch(e){}
        input[i][j] = count;
      }
    }
  }
  for(var i = 0; i < H; i++){
    input[i] = input[i].join("");
  }
  myout(input.join("\n"));
}

Main(myin());


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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> check(m+1);
  rep(i, n) {
    int K, A;
    cin >> K;
    rep(j, K) {
      cin >> A;
      check[A]++;
    }
  }
  int cnt = 0;
  rep(i, m+1) {
    if (check[i] == n) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i,n) for(ul i=0;i<n;i++)

ul L, R, N, M, Q;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> Q;
    P LR[M];
    auto pq = vector<P> (Q, make_pair(0, 0));
    ul ans[Q];
    auto train_table = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));
    auto cum = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));
    REP(itr, M) {
      cin >> LR[itr].first >> LR[itr].second;
      train_table[LR[itr].first][LR[itr].second] ++;
    } 
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j){
        cum[i][j] = cum[i][j-1] + train_table[i][j];
      }
    }


    REP(itr, Q) {
      cin >> pq[itr].first >> pq[itr].second;
      ans[itr] = 0;
    }

    for (ul itr = 0; itr < Q ; ++itr) {
      for(ul j = pq[itr].first; j <= pq[itr].second; ++j) {
        ans[itr] += cum[j][pq[itr].second];
      } 
    }

    REP(itr, Q) cout << ans[itr] << endl;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	final int A = Integer.parseInt(str);
    	str = br.readLine();
    	final int B = Integer.parseInt(str);
    	str = br.readLine();
    	final int C = Integer.parseInt(str);
    	str = br.readLine();
    	final int D = Integer.parseInt(str);
    	str = br.readLine();
    	final int E = Integer.parseInt(str);
    	str = br.readLine();
    	
    	final int K = Integer.parseInt(str);
    	
    	boolean communicationAvailable = false;
    	
    	if (E - A <= K) {
    		communicationAvailable = true;
    	}
    	
    	if (communicationAvailable) {
    		System.out.println("Yay!");
    	} else {
    		System.out.println(":(");
    	}
    }
}

Measured memory_bytes: 24532
from itertools import accumulate
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

cnt0 = [0] * m
cnt1 = [0] * m
for i in range(n-1):
    cnt0[a[i+1]] += (a[i+1] - a[i]) % m - 1
    if (a[i] + 1) % m <= a[i+1]:
        cnt1[(a[i]+1) % m] += 1
        cnt1[a[i+1]] -= 1
    else:
        cnt1[(a[i]+1) % m] += 1
        cnt1[0] += 1
        cnt1[a[i+1]] -= 1
cnt1 = list(accumulate(cnt1))
ans = float('inf')
tmp = 0
for i in range(n-1):
    tmp += min((a[i+1] - a[i]) % m, a[i+1] + 1)
ans = tmp
for i in range(m-1):
    tmp += cnt0[i] - cnt1[i]
    ans = min(ans, tmp)
print(ans)



Measured memory_bytes: 91776
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

void dfs(int cur, int par, const vector<vi> &g, vi &d) {
  int cur_d = d[cur];
  for (const auto el : g[cur]) {
    if (par == el)
      continue;
    d[el] = cur_d + 1;
    dfs(el, cur, g, d);
  }
}

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

  int n;
  cin >> n;
  vector<vi> g(n);
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vi d(n);
  d[0] = 1;
  dfs(0, -1, g, d);
  int ma = 0, mai;
  REP(i, n) {
    if (d[i] > ma) {
      chmax(ma, d[i]);
      mai = i;
    }
  }

  d[mai] = 1;
  dfs(mai, -1, g, d);
  int diam = 0;
  REP(i, n) { chmax(diam, d[i]); }

  if (diam % 3 == 2) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }

  return 0;
}


Measured memory_bytes: 27648
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    s = list(input())
    k = int(input())
    k -= 1

    d1 = defaultdict(list)
    for i, c in enumerate(s):
        d1[c].append(i)
    d2 = sorted(d1.items())

    lens = len(s)
    for d2e in d2:
        subs = set()
        subs.add(d2e[0])
        for d2ee in d2e[1]:
            end = min(lens + 1, d2ee + k + 2)
            for i1 in range(d2ee+1, end):
                subs.add("".join(s[d2ee:i1]))
        if len(subs) > k:
            subsl = list(subs)
            subsl.sort()
            print(subsl[k])
            sys.exit()
        else:
            k -= len(subs)

if __name__ == '__main__':
    main()

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

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

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

}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, k = map(int, input().split())

    if a >= k:
        print(k)
    else:
        res = a
        k -= a
        if b >= k:
            print(res)
        else:
            k -= b
            res -= k
            print(res)


if __name__ == '__main__':
    resolve()


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


using namespace std;

#define re return
#define sz(a) (int)a.size()
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 0; i < int(n); i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<long long, long long> pll;
typedef long double ld;
typedef unsigned long long ull;
const ll mod = int(1e9) + 7;


ll x[100001];
vii adj[100001];

ll mini,maxi;

int n,m;

struct UnionFind
{
    vi depth,parent;

    UnionFind(int N)
    {
        depth.assign(N,0);
        parent.assign(N,0);
        fill(parent.begin(),parent.end(),0);
    }

    int findParent(int i)
    {
        if(parent[i]==i)
            return i;
        return parent[i]=findParent(parent[i]);
    }
    void join(int i,int j)
    {
        i=findParent(i);
        j=findParent(j);

        if(i==j)
            return;
        if(depth[i]<depth[j])
            swap(i,j);

        parent[j]=i;
        depth[i]=max(depth[i],depth[j]+1);
    }

};


bool done[100001];
bool dfs(int i,ll y)
{
    if(done[i])
        return y==x[i];

    mini=min(y,mini);
    maxi=max(y,maxi);
    x[i]=y;

    done[i]=1;

    for(auto v:adj[i])
    {
        if(!dfs(v.first,y+v.second))
            return false;
    }

    return true;
}



int main()
{
    //iostream::sync_with_stdio(0), cin.tie(0);
    cin>>n>>m;
    int i=0;
    forn(i,m)
    {
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        adj[a].push_back(mk(b,c));
        adj[b].push_back(mk(a,-c));
    }


    forn(i,n)
    {
        if(!done[i])
        {
            if(!dfs(i,0))
            {
                cout<<"No";
                return 0;
            }

        }

    }

        cout<<"Yes";

}


Measured memory_bytes: 11520
#include <stdio.h>
#include <math.h>

#define MAX 8
#define square(n) (n)*(n)

int main(void)
{
  int N;
  int xy[MAX][2];
  int i,j;
  double sum_each_len=0;
  double ave_len=0;

  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d %d",&xy[i][0],&xy[i][1]);

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      sum_each_len += sqrt(square(xy[i][0]-xy[j][0])+square(xy[i][1]-xy[j][1]));
    }
  }
  
  if(N>2)ave_len = sum_each_len * 2 / N;
  else ave_len = sum_each_len;
  printf("%lf\n",ave_len);

  return 0;
}



Measured memory_bytes: 128
/*input
10 4
40 10 20 70 80 10 20 70 80 60
*/
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author masterbios
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CLinovaAndKingdom solver = new CLinovaAndKingdom();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLinovaAndKingdom {
       

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            int a[] = new int[n];
            int dp[] = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            Arrays.fill(dp, (int) 1e9);
            dp[0] = 0;
            for (int i = 1; i < n; i++) {
                for (int j = 1; j <= k; j++) {
                    if (i >= j) {
                        dp[i] = min(dp[i], dp[i - j] + Math.abs(a[i] - a[i - j]));
                    }
                }
            }
            out.println(dp[n - 1]);

        }

        public int max(int ...a) {
            int max = Integer.MIN_VALUE;
            for (int i : a) max = Math.max(max, i);
            return max;
        }

        public int min(int ...a) {
            int min = Integer.MAX_VALUE;
            for (int i : a) min = Math.min(min, i);
            return min;
        }

    }

    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.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 93968
N,A,B,C,D=map(int,input().split())
S='.'+input() # 便宜上，S[0]='.'とし，問題文の1-initialに合わせる

if D<C:
    f=False
    for i in range(B-1,D):
        if S[i:i+3]=='...':
            f=True
else:
    f=True

if f:
    for i in range(A+1,C-1):
        if S[i:i+2]=='##':
            f=False
    for i in range(B+1,D-1):
        if S[i:i+2]=='##':
            f=False

print('Yes' if f else 'No')

Measured memory_bytes: 3636
# C問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l.sort()

  a=l[n//2-1]
  b=l[n//2]

  return b-a

print(main())


Measured memory_bytes: 16544
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int K, X;
	cin >> K >> X;
	
	puts([&] {
		return 500 * K >= X;
	}() ? "Yes": "No");
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
  int A;
  int a[4];
  cin >> A;
  for(int i=3;i>=0;--i){
    a[i] = A%10;
    A = A/10;
  }
  if(a[0]+a[1]+a[2]+a[3] == 7){
    cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=7" <<endl;
  }else if(a[0]+a[1]+a[2]-a[3] == 7){
    cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=7" <<endl;
  }else if(a[0]+a[1]-a[2]+a[3] == 7){
    cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=7" <<endl;
  }else if(a[0]-a[1]+a[2]+a[3] == 7){
    cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=7" <<endl;
  }else if(a[0]+a[1]-a[2]-a[3] == 7){
    cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=7" <<endl;
  }else if(a[0]-a[1]+a[2]-a[3] == 7){
    cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=7" <<endl;
  }else if(a[0]-a[1]-a[2]+a[3] == 7){
    cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=7" <<endl;
  }else if(a[0]-a[1]-a[2]-a[3] == 7){
    cout << a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=7" <<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<stack>
#include<queue>
#include<stdlib.h>
#include<string.h>
#include<vector>
#define LL long long
#define  long long
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const double INF=1e9+7;
int Find[10000];
int find(int x) {return Find[x]==x?x:Find[x]=find(Find[x]);}
int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int cnt=0;
    int m=__gcd(a,b);
    for(int i=m;i>=1;i--)
    {
        if(m%i==0)
        {
            cnt++;
        }
        if(cnt==k)
        {
            printf("%d\n",i);return 0;
        }
    }
    //printf("%d\n",__gcd(a,b));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cctype>
#include<cstdio>
#include <string>
#include<algorithm>
using namespace std;
int main(){
    
    while(true){
    string s;
    cin>>s;
    if(s=="-")break;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int j;
        cin>>j;
        s=s.substr(j)+s.substr(0,j);
        
        
    }
    cout<<s<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3244
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int x,Ans = 0;
  for(int i = 0; i < N; i++){
    cin >> x;
    if(x <= K-x) Ans += 2*x;
    else Ans += 2*(K-x);
  }
  printf("%d\n",Ans);
  return 0;
}


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

using namespace std;

bool Solve(const vector<int>& order, const vector<vector<bool>>& edges) {
  int from = 1;
  for (int to : order) {
    if (!edges[from][to]) {
      return false;
    }
    from = to;
  }
  return true;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> edges(N+1, vector<bool>(N+1));
  for (int m = 0; m < M; ++m) {
    int a, b;
    cin >> a >> b;
    edges[a][b] = true;
    edges[b][a] = true;
  }
  vector<int> order(N-1);
  for (int n = 2; n <= N; ++n) {
    order[n-2] = n;
  }
  int result = 0;
  do {
    if (Solve(order, edges)) {
      ++result;
    }
  } while (next_permutation(order.begin(), order.end()));
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
//using atcorder.DataStructure;
namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }


    public class Test
    {
        public static void Run()
        {
            Input input=new Input(' ');
            input.ReadLine();
            int N = input.Next<int>();
            int M = input.Next<int>();
            int C = input.Next<int>();
            input.ReadLine();
            List<int> B = new List<int>();
            for (int i = 0; i < M; i++) B.Add(input.Next<int>());
            List<List<int>> A = new List<List<int>>();
            for (int i = 0; i < N; i++) {
                List<int> _A = new List<int>();
                input.ReadLine();
                for (int j = 0; j < M;j++){
                    _A.Add(input.Next<int>());
                }
                A.Add(new List<int>(_A));
            }
            int count = 0;
            for (int i = 0; i < N;i++){
                int n = 0;
                for (int j = 0; j < M; j++)
                {
                    n += A[i][j] * B[j];
                }
                n += C;
                if (n > 0) count++;
            }
            Console.WriteLine(count);
        }
    }







    public class Input
    {
        int arg;
        int length;
        string s;
        string[] ss;
        char sep;
        public Input(char _sep = '\0')
        {
            sep = _sep;
        }
        public void ReadLine()
        {
            s = Console.ReadLine();
            if (sep != '\0') ss = s.Split(sep);
            else
            {
                ss = new string[1];
                ss[0] = s;
            }
            arg = 0;
            length = ss.Length;
        }
        public T Next<T>()
        {
            if (arg == length) throw new IndexOutOfRangeException();
            return (T)Convert.ChangeType(ss[arg++], typeof(T));
        }
        public void SetSeparater(char _sep)
        {
            sep = _sep;
        }
    }
}


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

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

  int count=1;
  for (int i = 0; i < N; i++) {
    if (i == 0){
        count*=K;
    }
    else{
        count*=(K-1);
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4040, mod = 1'000'000'007;
int n, m, K;
int f[2][maxn + 1], nf[2][maxn + 1];
void add(int &a, int b){
	a += b;
	if(a >= mod) a -= mod;
}
int main(){
	cin >> n >> m >> K;
	f[0][0] = 1;
	int ans = 0;
	for(int i = 0; i < maxn; i++){
		for(int j = 0; j < 2; j++) for(int k = 0; k < maxn; k++) nf[j][k] = 0;
		for(int j = 0; j < 2; j++) for(int k = 0; k < maxn; k++){
			if(f[j][k]){
				add(nf[0][k], f[j][k]);
				add(nf[0][k+1], mod - f[j][k]);
				add(nf[1][k+1], f[j][k]);
				add(nf[1][min(k+K, maxn)], mod - f[j][k]);
			}
		}
		for(int j = 0; j < 2; j++) for(int k = 1; k < maxn; k++) add(nf[j][k], nf[j][k-1]);
		for(int j = 0; j < 2; j++) for(int k = 0; k < maxn; k++) f[j][k] = nf[j][k];
		for(int k = 0; k < maxn; k++){
			if(f[1][k]){
				int sn = k, sm = (i + 1) * (K - 1) - k;
				if(sn <= n && (sn % (K - 1)) == (n % (K - 1)) && sm <= m - 1 && (sm % (K - 1)) == ((m - 1) % (K - 1))){
					add(ans, f[1][k]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

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

    // initialize constructor
    vector<ll> leaves(N+1);
    vector<ll> notleaves(N+1);
    vector<ll> minimum(N+1);
    vector<ll> maximum(N+1);
    
    rep(i, 0, N+1) cin >> leaves[i];

    // get range (condition from leaves)
    maximum[N] = leaves.back();
    minimum[N] = leaves.back();
    rrep(i, N, 0)
    {
        maximum[i] = maximum[i+1] + leaves[i];
        minimum[i] = (minimum[i+1] + leaves[i]+1)>>1;
    }

    // pvec(maximum);
    // pvec(minimum);

    // count not leaves (condition from tree)
    ll sup = 1;
    rep(i, 0, N+1)
    {
        if (sup < minimum[i])
        {
            cout << -1 << endl;
            return 0;
        }

        ll now = min(sup, maximum[i]);
        notleaves[i] = now - leaves[i];

        sup = notleaves[i]*2;
    }
    notleaves[N] = 0;

    // count ans
    ll res =0;
    rep(i, 0, N+1)
        res += leaves[i] + notleaves[i];

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6368
#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 M, D;
	cin >> M >> D;

	int ans = 0;
	for(int i = 1; i <= M; i++){
		for(int j = 1; j <= D; j++){
			int j1 = j % 10;
			int j10 = j / 10;

			if(j1 <= 1 || j10 <= 1) continue;
			if(j1 * j10 == i) ans++;
		}
	}

	cout << ans << endl;
}


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

using namespace std;
typedef long long LL;
const double pi = acos(-1.0);
const double eps = 1e-7;
const LL N = 100010;

LL T,n,m,i,j,k,a[N]={0},t,ans=0;

int main()
{
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&t);
        if(t)a[t-1]++;
        a[t]++;
        a[t+1]++;
    }
    for(i=0;i<N-1;i++){
        ans=max(ans,a[i]);
    }
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		String s = stdIn.next();

		int num = 0;

		for(int i = 0; i < 4; i++)
		{
			if(s.charAt(i) == '+')
			{
				num++;
			}
			else
			{
				num--;
			}
		}

		System.out.println(num);

	}

}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

const ll MAX_N = 3000;
ll N;
double prob[MAX_N];
double dp[MAX_N + 1][MAX_N + 1] = {};
int main(){
  cin >> N;
  REP(i, N){
    cin >> prob[i];
  }
  dp[0][0] = 1.0;
  REP(i, N){
    dp[i + 1][0] = 1.0;
    REP(j, i + 1){
      dp[i + 1][j + 1] = dp[i][j + 1] * (1 - prob[i]) + dp[i][j] * prob[i];
      //printf("dp[%lld][%lld] = %.10f\n", i+1, j+1,dp[i+1][j+1]);
    }
  }
  printf("%.10f\n", dp[N][(N + 1) / 2]);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 3010
int n, a[N];
vector<int> A[N];
int p[N];
bool win[N];

bool cmp(int x, int y) {
	return a[x] < a[y];
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	for (int i = 1; i < n; i ++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		A[x].pb(y);
		A[y].pb(x);
	}
	for (int i = 0; i < n; i ++) p[i] = i;
	sort(p, p+n, cmp);
	for (int i = 0; i < n; i ++) {
		int x = p[i];
		bool F = 0;
		for (vector<int>::iterator j = A[x].begin(); j != A[x].end(); j ++)
			if (a[*j] < a[x] && !win[*j]) F = true;
		win[x] = F;
	}
	vector<int> S;
	for (int i = 0; i < n; i ++)
		if (win[i]) S.pb(i+1);
	for (int i = 0; i < (int) S.size(); i ++)
		printf ("%d%c", S[i], i==(int)S.size()-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
  
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 2060
#include <stdio.h>
int main(){
  int a,b,k,ans = 0;
  int i = 100;
  scanf("%d %d %d", &a,&b,&k);
  while (k>0) {
    if (a % i == 0 && b % i == 0) {
      ans = i;
      k -= 1;
    }
    i -= 1;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n; cin >> n;
  if (n == 7 or n == 5 or n == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int  d, g, p[10], c[10];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> d >> g;
  FOR(i, 0, d) cin >> p[i] >> c[i];
  int ans = iinf;
  FOR(i, 0, 1<<d){
    int gg = g, cnt= 0;
    vi v;
    FOR(j, 0, d){
      if(i & (1<<j)){
        cnt += p[j];
        gg -= c[j] + p[j] * (j + 1) * 100;
      }else{
        v.pb(j);
      }
    }
    reverse(rng(v));
    each(itr, v){
      int s = (*itr + 1) * 100;
      FOR(j, 0, p[*itr]){
        if(gg <= 0) break;
        gg -= s;
        cnt++;
      }
    }
    mins(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < N; i++)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M];
  REP(i, M) {
    cin >> a[i];
    cin >> b[i];
  }

  vector<int> ans(N, 0);
  REP(i, M) {
    ans[a[i] - 1]++;
    ans[b[i] - 1]++;
  }

  REP(i, N) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<random>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

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

    int n, m;
    cin >> n >> m;
    vector<ll> r;

    for (int i = 1; i * i <= m; i++) {
        if (!(m % i)) {
            r.push_back(i);
            if (i * i != m) {
                r.push_back(m / i);
            }
        }
    }
    
    rSORT(r, [](int a, int b) {return a > b; });
    for (ll i : r) {
        if (i * n <= m) {
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<stdio.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
	int n;
	cin>>n;
	if(n==0)cout<<1<<endl;
	else{
		if(n==1){
			cout<<2<<endl;
		}
		else{
			if(n==2){
				cout<<1<<endl;
			}
			else{
				cout<<0<<endl;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 3112
N = int(input())
a = [int(input()) for _ in range(N)]

a.sort()

sum = 1
now = a[0]
for i in range(1,N):
    if now < a[i]:
        sum += 1
        now = a[i]

    elif now == a[i]:
        now = a[i]

    else:
        break

print(sum)

Measured memory_bytes: 3064
// E - Double Factorial
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve(ll N){
	if(N%2) return 0;
	ll n = N/2, m = log(n)/log(5);
	ll ans = 0;
	for(ll w=5, i=0; i<m; ++i, w*=5) ans += n/w;
	return ans;
}

int main(){
	ll N; cin>>N;
	cout<< solve(N) <<endl;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::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<_>>()
    };
}

const P: i64 = 1000000007;

fn main() {
    let (n, m) = get!(i64, i64);

    let xs = get!(String).split_whitespace().map(|n| n.parse::<i64>().unwrap()).collect::<Vec<_>>();
    let ys = get!(String).split_whitespace().map(|n| n.parse::<i64>().unwrap()).collect::<Vec<_>>();

    let mut x = 0;
    let mut y = 0;
    for i in 0..n-1 { x = (x + (xs[(i+1) as usize] - xs[i as usize]) * (i+1) % P * (n-i-1)) % P; }
    for i in 0..m-1 { y = (y + (ys[(i+1) as usize] - ys[i as usize]) * (i+1) % P * (m-i-1)) % P; }
    println!("{}", x * y % P);
}

Measured memory_bytes: 11512
#include<iostream>
using namespace std;
int main(){
 int H,W,i,j;
	while(cin>>H>>W){
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<W;i++){
			cout<<'#';
		}
		cout<<endl;
		for(i=0;i<H-2;i++){
			cout<<'#';
			for(j=0;j<W-2;j++){
				cout<<'.';
			}
			cout<<'#'<<endl;
		}
		for(i=0;i<W;i++){
		cout<<'#';
		}cout<<endl;
		cout<<endl;
	}
return 0;
}

Measured memory_bytes: 1152
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio

    int n,k;
    cin >> n >> k;
    
    if(k==1) {
    cout << n;
    return 0;
    }
    
    int ans=0;
    while(n>0) {
        ans++;
        n/=k;
    }
    
    cout << ans ;
    
    return 0;
    
}

Measured memory_bytes: 8832
n = int(input())
a = list(map(int, input().split()))
s=0
b=[]
su=0
for i in range(1,n):
    su+=a[-i]
    b.append(su)
for j in range(2,n+1):
    s+=a[-j]*b[j-2]
    s%=(10**9+7)
print(s)


Measured memory_bytes: 31540
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = tuple(map(int,input().split()))

dp = [False] + [True]*k
for i in range(1,k+1):
    judge = False
    for j in range(n):
        if i-a[j] >= 0 and not dp[i-a[j]]:
            judge = True
    dp[i] = judge

if dp[k]:
    print('First')
else:
    print('Second')

Measured memory_bytes: 42220
#include <cstdio>
#include <cstring>
using namespace std;

const int S = 7400000;
bool flower[S];

int main() {
    int N, M;
    while(1) {
        scanf("%d%d", &M, &N);
        if(!M) break;
        memset(flower, false, sizeof(flower));

        int k = M;
        for(int i=0; i<N; i++) {
            while(flower[k]) k++;
            for(int x=k; x<S; x+=k) {
                flower[x] = true;
            }
        }

        while(flower[k]) k++;
        printf("%d\n", k);
    }
    return 0;
}


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

int main()
{
	int e;
	string t;
	cin>>t;
	e=t.size();
	for(int i=0; i<t.size(); i++)
	{
		if(t[i]=='B')
			for(int j=i-1; j>=0; j--)
				if(t[j]!='B')
				{
					t[j]='B';	
					break;
				}

	}

	for(int i=0; i<t.size(); i++)
	{
		if(t[i]!='B')
		{
			e++;
			t[e]=t[i];
			t[i]=' ';
		}
		
	}
	
	for(int i=0; i<=e; i++) 
		if(t[i]=='1' || t[i]=='0')
			cout<<t[i];
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int countDivisors(int n){
	int count = 0;
	for(int i=1; i<=n; i++){
		if(n%i==0) count++;
	}
	return count;
}

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

	int n;
	cin >> n;

	int ans = 0;
	for(int i=1; i<=n; i+=2){
		if(countDivisors(i)==8) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3576