akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

constexpr int MAXN = 2e5 + 100;
constexpr int MOD = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if (x >= MOD)
    x -= MOD;
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0)
    x += MOD;
  return x;
}
int mul(int x, int y) {
  return 1ll * x * y % MOD;
}
int pw(int a, int k) {
  int r = 1;
  while (k > 0) {
    if (k % 2 == 1)
      r = mul(r, a);
    a = mul(a, a);
    k /= 2;
  }
  return r;
}
#define div asdfsafasdfs
int div(int x, int y) {
  return mul(x, pw(y, MOD - 2));
}

int N;
VI e[MAXN];

int fac[MAXN], inf[MAXN];

int dp[MAXN][2]; // 0 down, 1 up
int sz[MAXN];
void DFS(int x, int p) {
  for (int u : e[x]) {
    if (u == p)
      continue;
    DFS(u, x);
  }
  sz[x] = 1;
  dp[x][0] = 1;
  for (int u : e[x]) {
    if (u == p)
      continue;
    dp[x][0] = mul(dp[x][0], dp[u][0]);
    dp[x][0] = mul(dp[x][0], inf[sz[u]]);
    sz[x] += sz[u];
  }
  dp[x][0] = mul(dp[x][0], fac[sz[x] - 1]);
  debug("%d: %d\n", x, dp[x][0]);
}
int ans[MAXN];
void DFS2(int x, int p) {
  for (int u : e[x]) {
    if (u == p)
      continue;
    int t = div(dp[x][0], dp[u][0]);
    t = div(t, mul(fac[sz[x] - 1], mul(inf[sz[u]], inf[sz[x] - 1 - sz[u]])));
    debug("%d:   %d\n", u, t);
    if (p > 0) {
      t = mul(t, dp[x][1]);
      debug("%d:   %d (%d)\n", u, t, p);
      t = mul(t, mul(fac[N - sz[u] - 1], mul(inf[N - sz[x]], inf[sz[x] - sz[u] - 1])));
    }
    debug("%d:   %d\n", u, t);
    dp[u][1] = t;
    DFS2(u, x);
  }
  debug("%d  %d (%d)\n", x, dp[x][1], sz[x]);
  ans[x] = 1;
  for (int u : e[x]) {
    if (u == p)
      continue;
    ans[x] = mul(ans[x], dp[u][0]);
    ans[x] = mul(ans[x], inf[sz[u]]);
  }
  if (p > 0) {
    ans[x] = mul(ans[x], dp[x][1]);
    ans[x] = mul(ans[x], inf[N - sz[x]]);
  }
  ans[x] = mul(ans[x], fac[N - 1]);
}

int main() {
  fac[0] = 1;
  for (int i = 1; i < MAXN; i++)
    fac[i] = mul(fac[i - 1], i);
  inf[0] = 1;
  for (int i = 1; i < MAXN; i++)
    inf[i] = mul(inf[i - 1], pw(i, MOD - 2));

  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].PB(y);
    e[y].PB(x);
  }
  DFS(1, 0);
  DFS2(1, 0);
  for (int i = 1; i <= N; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 18548
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 5;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	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';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int binom[MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int getans(int n, int x) {
	int ans = 0;
	if (2 * n < x || x % 2 == 1) ans = 1;
	for (int i = n; i <= 2 * n - 1; i++) {
		if (i < x) update(ans, binom[n][i - n]);
		else {
			if ((i - x) % 2 == 0) continue;
			int cnt = (i - x + 1) / 2;
			if (2 * cnt >= n) continue;
			int rp = n - 2 * cnt, rs = i - 4 * cnt;
			if (rs >= rp && rs <= 2 * rp) update(ans, binom[rp][rs - rp]);
		}
	}
	return ans;
}
int main() {
	int n, x; read(n), read(x);
	for (int i = 0; i <= n; i++) {
		binom[i][0] = 1;
		for (int j = 1; j <= i; j++)
			binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % P;
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
		update(ans, 1ll * binom[n][i] * getans(n - i, x) % P);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 34176
INF = 1 << 29
def solve
  memo = [INF] * (1<<$n)
  memo[0] = 0
  (1<<$n).times do |bits|
    next if memo[bits] == INF
    $n.times do |i|
      next if bits | (1<<i) == bits
      nbits = bits | (1<<i)
      mint = 0
      (0..$n).each do |j|
        k = $stg[i][j][0]
        if k == 0 || bits | 1<<(k-1) == bits
          mint = memo[bits] + $stg[i][j][1]
          break
        end
      end
      memo[nbits] = mint if memo[nbits] > mint
    end
  end
  memo[(1<<$n)-1]
end

while $n = gets.to_i
  break if $n == 0
  $stg = $n.times.map{ gets.split.map(&:to_i) }
  $stg.map! do |s|
    h = {}
    s.each_with_index{ |t, i| h[i] = t }
    h.sort_by{|k, v| v}
  end
  p solve
end

Measured memory_bytes: 15836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] cities = new int[n+1];
		
		for (int i = 0; i < m; i++) {
			int v = sc.nextInt();
			int w = sc.nextInt();
			cities[v]++;
			cities[w]++;
		}
		
		for (int i = 1; i < cities.length; i++) {
			System.out.println(cities[i]);
		}
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int a,b,c,d;
    
    scanf("%d %d %d %d",&a,&b,&c,&d);
    
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
        printf("Yes");
    else
        printf("No");
}


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

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

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

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

// 注意: a と mod が互いに素である必要がある
template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    T modulo;
    std::vector<T> fact, inv_fact;

    Combinatorics(T max, T modulo) : modulo(modulo), fact(max + 1), inv_fact(max + 1) {
        fact[0] = 1;
        for(T i=1;i<=max;++i){
            fact[i] = i * fact[i - 1] % modulo;
        }

        inv_fact[max] = mod_inverse(fact[max], modulo);
        for(T i=max;i>0;--i){
            inv_fact[i - 1] = i * inv_fact[i] % modulo;
        }
    }

    T nPk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[n - k] % modulo;
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[k] % modulo * inv_fact[n - k] % modulo;
    }

    T nHk(T n, T k){
        if(n == 0 && k == 0){return 1;}
        return nCk(n + k - 1, k);
    }
};

constexpr ll MOD = 998244353;
ll N, M, K;
Combinatorics<ll> comb(200100, MOD);

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

  std::cin >> N >> M >> K;

  ll res = 0;

  for(int i=0;i<=K;++i){
      res += M * comb.nCk(N - 1, i) % MOD * mod_expt(M - 1, N - 1 - i, MOD) % MOD;
      if(res >= MOD){
          res -= MOD;
      }
  }

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


Measured memory_bytes: 6172
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        int N;
        vector<int> card(9);

        for(int i=0; i<9; i++){
            cin >> card.at(i);
        }
        
        cin >> N;
        vector<int> number(N);

        for(int i=0; i<N; i++){
            cin >> number.at(i);
        }

        vector<int> bingo(9);
        for(int i=0; i<9; i++){
            int j;
            bool judge = false;
            j = card.at(i);

            for(int i=0; i<N; i++){
                if(number.at(i)==j)
                    judge = true;
            }

            if(judge)
                bingo.at(i) = 1;
            else
                bingo.at(i) = 0;
        }

    if(bingo.at(0)+bingo.at(1)+bingo.at(2) == 3){
        cout << "Yes" <<endl;}
    else if(bingo.at(3)+bingo.at(4)+bingo.at(5) == 3){
        cout << "Yes" <<endl;}
    else if(bingo.at(6)+bingo.at(7)+bingo.at(8) == 3){
        cout << "Yes" <<endl;}
    else if(bingo.at(0)+bingo.at(3)+bingo.at(6) == 3){
        cout << "Yes" <<endl;}
    else if(bingo.at(1)+bingo.at(4)+bingo.at(7) == 3){
        cout << "Yes" <<endl;}
    else if(bingo.at(2)+bingo.at(5)+bingo.at(8) == 3){
        cout << "Yes" <<endl;}
    else if(bingo.at(0)+bingo.at(4)+bingo.at(8) == 3){
        cout << "Yes" <<endl;}
    else if(bingo.at(2)+bingo.at(4)+bingo.at(6) == 3){
        cout << "Yes" <<endl;}
    else{
        cout << "No" <<endl;}
    }

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().rstrip()

N, Q = map(int, input().split())
S = input()
li = [0]*(N+1)

for i in range(N):
    if S[i:i+2] == 'AC':
        li[i+1] = li[i] + 1
    else:
        li[i+1] = li[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(li[r-1] - li[l-1])

Measured memory_bytes: 6356
#include <cstdio>

const int MaxN = 200000 + 5;

int N;
int D[MaxN]; long long C[MaxN];

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d %lld", &D[i], &C[i]);
}

void solve() {
  long long ans = 0, r = 0;
  for (int i = 1; i <= N; ++i) {
    long long s = D[i] * C[i];
    ans += s / 9 + C[i];
    s %= 9;
    if (D[i] != 0 && s == 0) s = 9, ans--;
    r += s;
    if (r >= 10) {
      r -= 9;
      ans++;
    }
  }
  printf("%lld\n", ans - 1);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<limits.h>

using namespace std;

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int temp;
	for(int i = 1; i < 100000 && i > 0; i++) {
		if(a*i%b == c) {
			printf("YES");
			return 0;
		}
		//printf("%d\n" , temp);
	}
	
	printf("NO");
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
void solve() {
    cin >> n;

    if (n == 3) cout << "2 5 63" << endn;
    else if (n % 2 == 0) {
        int a[] = { 2,10,3,9,4,8,6,12 };
        rep(i, n) cout << a[i % 8] + 12 * (i / 8) << " ";
        cout << endn;
    }
    else {
        int a[] = { 6,2,10,3,9,4,8,12 };
        rep(i, n) cout << a[i % 8] + 12 * (i / 8) << " ";
        cout << endn;
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
long long combination(long n, long r, long long mod) {
  // nCrを返す　O(r)
  // 逆元はその場で対応
  if (n < r) swap(n, r);
  long long bunbo = 1;
  long cnt = r;
  while (0 < cnt) {
    bunbo *= cnt;
    cnt--;
  }
  if (bunbo == 0) return 1;
  long long bunsi = 1;
  cnt = 0;
  while (cnt < r) {
    bunsi *= (n - cnt);
    cnt++;
  }
  return bunsi / bunbo;
}
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  int N, P;
  cin >> N >> P;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  int even = 0;
  REP(i, N) if (A[i] % 2 == 0) even++;
  int odd = N - even;
  if (odd == 0) {
    if (P == 1) {
      cout << 0 << endl;
    } else {
      cout << longpow(2, N, (ll)MOD * (ll)100000000) << endl;
    }
    return 0;
  }
  cout << longpow(2, N - 1, (ll)MOD * (ll)100000000) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
signed main(){
    int n,t;
    cin >> n >> t;
    vec(a,n);
    int ans = 0;
    int yu = 0;
    REP(i,n){
        cin >> a[i];
        if(yu > a[i]){
            ans += a[i] + t - yu;
        }
        else{
            ans += t;
        }
        yu = a[i] + t;
    }
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    bool Lsearch = true; //Lを探している最中(Rの長さ計測中)
    int RLlength = 0;
    int Rlength = 0;
    int Llength = 0;
    int children[S.length()] = {};
    int Lposition = 0;

    for(int i=0; i<S.length(); i++){
        if(Lsearch){
            if(S[i]=='R'){
                RLlength++;
                Rlength++;
            }else if(S[i]=='L'){
                RLlength++;
                Llength++;
                Lsearch=false;
                Lposition=i;
            }
        }else{    
            //RL長測定完了
            if(S[i]=='R'){
                    if(RLlength%2==0){
                        //答え入力
                        children[Lposition] = RLlength/2;
                        children[Lposition-1] = RLlength/2;
                    }else{
                        if(Rlength%2==0){
                            children[Lposition] = RLlength/2+1;
                            children[Lposition-1] = RLlength/2;
                        }else{
                            children[Lposition] = RLlength/2;
                            children[Lposition-1] = RLlength/2+1;
                        }
                    }
                
                //変数初期化
                Lsearch=true;
                RLlength=1;
                Rlength=1;
                Llength=0;

            }else if(S[i]=='L'){
                RLlength++;
                Llength++;
            }
        }
    }
    //最後の1回分
    if(RLlength%2==0){
        //答え入力
        children[Lposition] = RLlength/2;
        children[Lposition-1] = RLlength/2;
    }else{
        if(RLlength%2==0){
            //答え入力
            children[Lposition] = RLlength/2;
            children[Lposition-1] = RLlength/2;
        }else{
            if(Rlength%2==0){
                children[Lposition] = RLlength/2+1;
                children[Lposition-1] = RLlength/2;
            }else{
                children[Lposition] = RLlength/2;
                children[Lposition-1] = RLlength/2+1;
            }
        }
    }


    
    for(int i=0; i<S.length(); i++){
        cout << children[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		//すぬけ君リスト
		boolean[] arrayGetSweets = new boolean[N];

		for (int i = 0; i < K; i++) {
			//お菓子iを持っている人数
			int d = sc.nextInt();
			for (int j = 0; j < d; j++) {
				//スイーツをもらったすぬけ君の番号
				int GetSweets = sc.nextInt();
				if (!arrayGetSweets[GetSweets - 1]) {
					arrayGetSweets[GetSweets - 1] = true;
				}
			}
		}
		sc.close();

		//お菓子を貰っていない人数をカウント
		int count = 0;
		for (boolean bool : arrayGetSweets) {
			if (!bool) {
				count++;
			}
		}
		System.out.println(count);

	}

}


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

int digit(ll n){
  int i=0;
  while(n!=0){
    n/=10;
    i++;
  }
  return i;
}

int main(){
  int i,j,cnt=0;
  ll n;
  cin>>n;
  n++;
  ll a=n/(ll)round(pow(10,digit(n)-1));
  cout<<a-1+9*(digit(n)-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,b,ans=0,x;
	scanf("%d %d",&n,&b);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x>=b)ans++;
	}
	printf("%d",ans);
}


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

using namespace std;
#define int long long
const int N = 2e5 + 5;
int a[N], cnt[N];
int32_t main() {
    int n; cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], cnt[a[i]]++;
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += cnt[i] * (cnt[i] - 1) / 2;
    for (int i = 1; i <= n; i++) {
        ans -= cnt[a[i]] - 1;
        cout << ans << "\n";
        ans += cnt[a[i]] - 1;
    }
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

using ld = long double;
int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K; cin >> N >> K;
    vec<lint> p_list(N);
    range(i, 0, N) cin >> p_list.at(i);
    lint res = 0, cur = 0;
    range(i, 0, K) cur += p_list.at(i);
    res = cur;
    range(i, K, N) {
        cur += p_list.at(i);
        cur -= p_list.at(i - K);
        res = max(cur, res);
    }
    cout << (ld)(res + K) / 2 << "\n";
}


Measured memory_bytes: 1792
/*Problem B : Common Raccoon vs Monster*/
#include<stdio.h>

int main(void)
{
    int H,N,i;

    scanf("%d %d", &H,&N);

    int attack;
    int sum = 0;

    for(i = 1; i <= N; i++)
    {
        scanf("%d", &attack);
        sum = sum + attack;
    }

    if(sum >= H)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	ll n, m, d;
	cin >> n >> m >> d;
	double ans = ((d > 0 ? 2.0 : 1.0) * (n-d) / n) *  (m-1) / (1.0*n);
	printf("%.10f\n", ans);
	return 0;
}

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

using namespace std;

int count(int n) {
	int res = 0;
  	while(n) {
      	res++;
      	n /= 10;
    }
  	return res;
}

int main() {
  	int n;
  	cin >> n;
  	int res = 0;
  	for (int i = 1; i <= n; i++) {
      	res += count(i) % 2;
    }
  	cout << res;
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

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

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N];
set<int> g[N];
queue<int> q;
bool u[N];
set<pii> st;	
int sum[N];
vector<pii> bb[N];

void no() {
	puts("NO");
	exit(0);
}

int main() {
	megaRandom();
	scanf("%d", &n);
	for(int i= 1; i <= n; i ++)
		scanf("%d", &a[i]);
	for(int i = 1, x, y; i < n; i ++) {
		scanf("%d%d", &x, &y);
		g[x].insert(y);
		g[y].insert(x);
	}
	for(int i= 1; i <= n; i ++) {
		sum[i] = 2 * a[i];
		if(sz(g[i]) == 1)
			sum[i] = a[i];
		st.insert(mp(sz(g[i]), i));
	}
	while(sz(st) > 0) {
		int x = st.begin() -> S;
		st.erase(st.begin());
		assert(sz(g[x]) == 1);	
		int to = *g[x].begin();
		//cout << "x: " << x << " to: " << to << " cost: " << sum[x] << "\n";
		bb[x].pb(mp(to, sum[x]));
		bb[to].pb(mp(x, sum[x]));
		sum[to] -= sum[x];
		sum[x] = 0;
		if(sum[to] < 0)
			no();
		st.erase(mp(sz(g[to]), to));
		g[x].erase(to);
		g[to].erase(x);
		if(sz(g[to]))
			st.insert(mp(sz(g[to]), to));
	}
	for(int i = 1; i <= n; i ++) {
	    if(sum[i] != 0)
	    	no();
		for(auto to : bb[i]) 
			if(to.S > a[i])
				no();		
	}
		
	
	puts("YES");
	return 0;  
}


Measured memory_bytes: 88192
import math
X = int(input())
 
if X == 2:
  print(2)
  exit()
  
hajime = X
 
#if hajime % 2 == 0:
#  hajime += 1
#checkMax = math.ceil(math.sqrt(hajime))
for i in range(hajime, 1000000):
  goseisu = False
  for j in range(2, hajime):
    if i % j == 0:
      goseisu = True
      break
  if not goseisu:
    print(i)
    exit()

Measured memory_bytes: 3060
#include <stdio.h>

// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
//


int main(int argc, char **argv) {
    int n = get_uint();
    int G[100][100] = {};
    for(int i = 0; i < n; ++i) {
        int u = get_uint() - 1;
        int k = get_uint();
        for(int j = 0; j < k; ++j) G[u][get_uint() - 1] = 1;
    }
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j) {
            put_uint(G[i][j]);
            putchar_unlocked(j == n - 1 ? '\n' : ' ');
        }
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
void solve(long long L, long long R){
  ll n,ans = 10000000;
  for (ll i = L; i < R;i++) {
    for (ll j = i+1; j <= R; j++) {
      n = ((i%2019)*(j%2019))%2019;
      ans = min(ans,n);
      if(ans == 0)break;
    }
    if(ans == 0)break;
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    solve(L, R);
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}

typedef pair<int,int>   ii;

int t[N];

int upd(int p,int v)    {
    for(; p < N ; p += p & -p)
        add(t[p],v);
    return  1;
}
int get(int p)  {
    int ans = 0;
    for(; p > 0 ; p -= p & -p)
        add(ans,t[p]);

    return  ans;
}

int x[N];
int y[N];

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

    int n;  cin >> n;
    int m;  cin >> m;

    for(int i = 0 ; i < n ; ++i)    cin >> x[i];
    for(int j = 0 ; j < m ; ++j)    cin >> y[j];

    vector<ii>  vec;
    vector<int> val;

    for(int i = 0 ; i < n ; ++i)    {
        int j = lower_bound(y,y + m,x[i]) - y;

        if (j == 0) continue;
        if (j == m) continue;

        vec.pb(x[i] - y[j - 1],y[j] - x[i]);
        val.pb(y[j] - x[i]);
    }
    sort(all(val)); val.erase(unique(all(val)),val.end());
    sort(all(vec),[&](ii  a,ii  b)  {
        if (a.X != b.X) return  a.X < b.X;
        if (a.X == b.X) return  a.Y > b.Y;
    });

    vec.erase(unique(all(vec)),vec.end());
    upd(1,1);

    for(ii  T : vec)    {
        int i = upper_bound(all(val),T.Y) - val.begin();
        upd(i + 1,get(i));
    }
    cout << get(sz(val) + 1) << endl;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    int S = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        S += a[i];
    }
    int T = 0;
    if(S%N == 0 || S%N < N/2) T = S/N;
    else T = S/N + 1;
    int ans = 0;
    for(int i = 0; i < N; i++) ans += (a[i]-T)*(a[i]-T);
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<ll> a(n);
	rep(i, n)scanf("%lld", &a[i]);
	map<ll, ll> m;
	rep(i, n) ++m[i + a[i]];
	ll ans = 0;
	rep(i, n) {
		ans += m[i - a[i]];
	}
	printf("%lld\n", ans);


	Please AC;
}


Measured memory_bytes: 27548
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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 dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<Pii> br(m);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        br[i] = mp(b, a);
    }
    sort(all(br));
    int ans = 0, t = 0;
    rep(i, 0, m) {
        if (t <= br[i].second) {
            ans++;
            t = br[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main(){







long long int N,K;
cin>>N>>K;
long long int A[N];
for(int i=0;i<N;i++)cin>>A[i];
bool dp[K+1];
for(int i=0;i<K+1;i++)dp[i]=false;


for(int i=0;i<=K;i++)for(int j=0;j<N;j++){
if(i>=A[j]&&!dp[i-A[j]])dp[i]=true;
}

if(dp[K])cout<<"First";
else cout<<"Second";

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll n,k;
    cin>>n>>k;
    ll v[n];
    for(i=0;i<n;i++){
        cin>>v[i];
    }
    ll ans=0;
    for(i=-1;i<n;i++){
        for(j=i+1;j<=n;j++){
            vector<ll> v1;
            ll tmp=0;
            for(ll l=0;l<n;l++){
                if(l<=i||l>=j) {
                    v1.pb(v[l]);
                    tmp+=v[l];
                }
            }
            sort(v1.begin(),v1.end());
            if(i+1+n-j<=k){
                ans=max(ans,tmp);
                for(ll l=0;l<k-(i+1+n-j);l++){
                    if(l>=v1.size()) break;
                    tmp-=v1[l];
                    ans=max(ans,tmp);
                }
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a[5],i,g,t,p,r[5];
	while(1){
		g=p=t=0;
		scanf("%d",&a[0]);
		if(a[0]==0){
			break;
		}
		scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4]);
		for(i=0;i<5;i++){
			switch(a[i]){
			case 1:
				g++;
				break;
			case 2:
				t++;
				break;
			case 3:
				p++;
				break;
			}
		}
		if((g!=0&&t!=0&&p!=0)||g==5||t==5||p==5){
			for(i=0;i<5;i++){
				r[i]=3;
			}
		}else if(g==0){
			for(i=0;i<5;i++){
				if(a[i]==2){
					r[i]=1;
				}else{
					r[i]=2;
				}
			}
		}else if(t==0){
			for(i=0;i<5;i++){
				if(a[i]==3){
					r[i]=1;
				}else{
					r[i]=2;
				}
			}
		}else{
			for(i=0;i<5;i++){
				if(a[i]==1){
					r[i]=1;
				}else{
					r[i]=2;
				}
			}
		}
		for(i=0;i<5;i++){
			printf("%d\n",r[i]);
		}
	}
	return 0;
}

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

int main(){
  int i=0,OL,EL,nO=0,nE=0;
  char O[60];
  char E[60];

  scanf("%s",O);
  OL = strlen(O);
  scanf("%s",E);
  EL = strlen(E);

  for(i=0;i<OL+EL;i++){
    if(i%2==0){
      printf("%c",O[nO++]);
    }else{
      printf("%c",E[nE++]);
    }
  }printf("\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    long n,n_;
    long long base[15];
    long long ans[15];
    cin >> n;
    n_ = n;
    base[0]=26;
    for(int i=1;i<13;i++){
        base[i]= base[i-1] + std::pow((long long)26,i+1);
    }
    int max = 0;
    rep(i,13){
        if(base[i] < n){max=i+1;}
    }
    max++;
    rep(i,max){
        ans[i] = n % 26;
        if(ans[i]==0) ans[i]=26;
        n-=ans[i];
        n/=26;
    }
    string str_ans="";
    for(int i=max-1;i>=0;i--){
       str_ans += ('a' + ans[i]-1);
    }
    cout << str_ans << endl;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int MAXN = 10000001;
#define ll long long 

class TaskD {
private:
	Debugger debugger;
	vector<int> lp;
	void prepare(){
		lp.assign(MAXN, -1);
		for(int i = 2; i < MAXN; i++){
			if(lp[i] == -1)
			for(int j = i; j < MAXN; j += i){
				if(lp[j] == -1){
					lp[j] = i;
				}
			}
		}
	}

	ll get(int n){
		ll ans = 1;
		int curr = 0;
		int last = lp[n];
		while(n > 1){
			if(lp[n] == last){
				curr++;
			}else{
				ans *= (1 + curr);
				curr = 1;
				last = lp[n];
			}
			n /= lp[n];
		}
		ans *= (1 + curr);
		return ans;
	}

public:
	void solveOne(int it){
		prepare();
		int n;
		cin >> n;
		ll ans = 0;
		for(int i = 1; i <= n; i++){
			ans += (ll)i*get(i);
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskD solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 42200
import numpy
import itertools
import math

n = int(input())
town_list = []
for i in range(n):
	x, y = map(int, input().split())
	town_list.append([x, y])

pattern_list = list(itertools.permutations(town_list, n))

a = int(math.factorial(n))

sum = 0
for j in range(a):
	for k in range(n-1):
		# sum += numpy.linalg.norm(pattern_list[j][k+1] - pattern_list[j][k])
		x1 = pattern_list[j][k][0]
		x2 = pattern_list[j][k+1][0]
		y1 = pattern_list[j][k][1]
		y2 = pattern_list[j][k+1][1]
		sum += math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)

print(sum/a)

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

long long n;
string s;
map<long long, long long> mp;

long long solve();

int main() {
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  reverse(s.begin(), s.end());
  long long res = 0, now = 0, ten = 1;
  mp[0] = 1;
  for (int i = 0; i < n; ++i) {
    now += (s[i] - '0') * ten;
    ten *= 10;
    ten %= 2019;
    now %= 2019;
    res += mp[now];
    ++mp[now];
  }
  return res;
}

Measured memory_bytes: 3808
#include <cstdio>
#include <iostream>
#include <queue>
#define N 303
using namespace std;
int n,m,a[N][N],ban[N],cnt[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1,x;j<=m;++j){
			scanf("%d",&x);
			a[i][x]=m+1-j;
		}
	int ans=n;
    for(int i=1;i<=m;++i){
    	for(int j=1;j<=m;++j)cnt[j]=0;
    	for(int j=1;j<=n;++j){
    		int tmp=0;
    	    for(int k=1;k<=m;++k)
    	        if(!ban[k] && a[j][k]>a[j][tmp])tmp=k;
    	    ++cnt[tmp];
    	}
    	int tmp=0;
    	for(int j=1;j<=m;++j)
    	    if(cnt[j]>cnt[tmp])tmp=j;
    	ans=min(ans,cnt[tmp]);
    	ban[tmp]=1;
    }
    printf("%d",ans);
}

Measured memory_bytes: 640
#[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 p = get!(usize; n);

    let mut vec = vec![0; n+1];
    let mut mx = 0;
    for e in p {
        vec[e] = vec[e-1] + 1;
        mx = max!(mx, vec[e]);
    }
    println!("{}", n-mx);
}


Measured memory_bytes: 12668
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		while(true) {
			int count = 0;
			int n = sc.nextInt();
			int x = sc.nextInt();

			if(n == 0 && x == 0) {break;}

			for(int i = 1; i <= n; i++) {
				for(int j = 1; j <= n; j++) {
					for(int k = 1; k <= n; k++) {
						if(i + j + k == x) {
							if(i != j && i != k && j != k) {
								count++;
							}
						}
					}
				}
			}
			System.out.println(count / 6);
		}
		sc.close();
	}
}


Measured memory_bytes: 26716
#include <bits/stdc++.h>   
using namespace std;
#define N 1000000
#define REP(i, n) for(int i=0; i<n; i++)
int a,b,c,d;
int x;
int main(void){
    cin>>x;
    d=x%10;x=x/10;
    c=x%10;x=x/10;
    b=x%10;
    a=x/10;
    int ans=a;
    char can[]={'0','0','0'};
    REP(i,2){
        REP(j,2){
            REP(k,2){
                ans=a;
                if(i==0){
                   ans+=b; 
                 }else{
                   ans-=b;
                }
                if(j==0){
                   ans+=c; 
                }else{
                   ans-=c; 
                }
                if(k==0){
                   ans+=d;
                }else{
                   ans-=d; 
                }
                if(ans==7){
                    if(i==0){
                     can[0]='+';
                     }else{
                      can[0]='-';
                     }
                     if(j==0){
                          can[1]='+';
                     }else{
                        can[1]='-';
                        }
                     if(k==0){
                      can[2]='+'; 
                      }else{
                      can[2]='-';
                      }
                    break;
                }
            }
        }
    }
    
    cout<<a<<can[0]<<b<<can[1]<<c<<can[2]<<d<<"=7"<<endl;
}


Measured memory_bytes: 256
## coding: UTF-8
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

#print(N, D)

ans = "No"
renzoku = 0

for i in range(N):
    if(D[i][0] == D[i][1]):
        renzoku += 1
        if(renzoku >= 3):
            ans = "Yes"
    else:
        renzoku = 0

print(ans)





Measured memory_bytes: 62492
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int N, P[10], R[26]; string S;
int main() {
	cin >> N >> S;
	for(int i = 0; i < S.size(); i += 2) R[S[i] - 97]++;
	for(int i = 0; i < 26; i++) P[R[i]]++;
	int ret = -1;
	for(int i = 1; i < 10; i++) {
		if(P[i] != 0) ret++;
	}
	if(P[1] != 0) ret += P[1] * 2 - 1;
	for(int i = 2; i < 10; i++) {
		if(P[i] != 0) {
			ret += min(P[i] * 2 + 3, P[i] * 4 - 1);
		}
	}
	printf("%d\n", ret);
	return 0;
}

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

int main(){
    long long int n,cc=0;
    cin>>n;
    vector<long long int>a(n);
    vector<long long int>b(n);
    vector<long long int>c(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n;i++) cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        long long int ia=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        long long int ic=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        cc+=ia*ic;
    }
    cout<<cc;
}


Measured memory_bytes: 2560
N = gets.to_i
A = (1..2).map { gets.split.map &:to_i }

$memo = {}
def max_candy(i, j)
  if i<0 or j<0
    return 0
  end

  if w=$memo[[i, j]]
    return w
  end

  $memo[[i, j]] = [max_candy(i-1, j), max_candy(i, j-1)].max + A[i][j]
end

puts max_candy(1, N-1)


Measured memory_bytes: 1788
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

int main() {
    int n;
    ll t;
    cin >> n;
    vector<ll> input;
    for (int i=0; i<n; ++i) {
        cin >> t;
        input.push_back(t);
    }
    ll prevLcm = input[0];
    for (int i = 0; i < input.size(); ++i) {
        ll currentGcd = gcd(prevLcm, input[i]);
        prevLcm = prevLcm / currentGcd * input[i];
    }
    cout << prevLcm << endl;
}


Measured memory_bytes: 256