akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int nature(ll a){
  if(a>=0){
    return(a);
  }else{
    return(-1*a);
  }
}
int main(){
  ll a,N,X,Y;
  cin>>N>>X>>Y;
  vector<ll> vec(N-1);
  for(ll i=1;i<N;i++){
    for(ll j=i+1;j<=N;j++){
      a=min(nature(j-i-1),min(nature(i-X)+nature(j-Y),nature(j-X)+nature(i-Y)));
      vec.at(a)++;
    }
  }
  for(ll i=0;i<N-1;i++){
    cout<<vec.at(i)<<endl;
  }
}

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

int n;

void maxHeapify(int *a, int i){
  int l = 2*i, r = 2*i+1, largest;
  if(l <= n && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= n && a[r] > a[largest]) largest = r;
  if(largest != i){
    a[i] += a[largest];
    a[largest] = a[i] - a[largest];
    a[i] -= a[largest];
    maxHeapify(a, largest);
  }
  return;
}

int main(){
  int a[500005], i;

  scanf("%d", &n);
  for(int i=1   ; i<=n ; ++i)   scanf("%d", a + i);
  for(int i=n/2 ; i>0  ; --i)   maxHeapify(a, i);
  for(int i=1   ; i<=n ; ++i)   printf(" %d", *(a + i));
  puts("");
  return 0;
}



Measured memory_bytes: 3652
def cnt(n)
	i = 0
	while n%2 < 1
		n = n / 2
		i += 1
	end
	return i
end
n = gets
nums = gets.chomp.split(" ").map(&:to_i)
sum = 0
nums.each do |num|
	sum+=cnt(num)
end
puts sum

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

//2で割れる回数を返す
int func(int i){
	int ret = 0;
	while(i % 2 == 0){
		i /= 2;
		ret++;		
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	int maximum = 0;
	int ans = 1;
	for(int i = 1; i <= N; i++){
		if(func(i) > maximum){
			maximum = func(i);
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
i8 = np.int64
i4 = np.int32

def main():
    stdin = open('/dev/stdin')
    N, K= map(int, stdin.readline().split())
    h = np.fromstring(stdin.readline(), i8, sep=' ')
    ans = np.count_nonzero(h >= K)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21536
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.System;
import java.lang.reflect.Array;
import java.util.Arrays;

class Main {
    public static void main(String[] a) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

        int[] mountains = new int[10];
        for(int i = 0; i < 10; i++) {
            int tmp = Integer.parseInt(r.readLine());
            mountains[i] = tmp;
        }

        Arrays.sort(mountains);
        for(int i = 9; i > 6; i--) {
            System.out.println(mountains[i]);
        }
    }
}

Measured memory_bytes: 16936
s = [*input()]
if len(s) == 1:
    print(1)
    exit()
hugo = ["<", ">"]
a = [0]
b = []
base = -1
for i in range(len(s) - 1):
    if base == -1: #一番最初
        base = hugo.index(s[i])
        b = [0,1]
    elif base != hugo.index(s[i]): #符号が切り替わった時
        #前グループの処理
        if base == 1:
            b.reverse()
        max_ = max(a[-1],b[0])
        a.pop(-1)
        b[0] = max_
        a.extend(b)
        #新しい処理
        b = [0,1]
        base = hugo.index(s[i])
    else: #同じ符号が続いてる時
        b.append(b[-1] + 1) 
if hugo.index(s[-1]) == base: #一番ラストの符号
    b.append(b[-1] + 1)
    if base == 1:
        b.reverse()
    max_ = max(a[-1],b[0])
    b[0] = max_
    a.pop(-1)
    a.extend(b)    
else:
    #前グループの処理
    if base == 1:
        b.reverse()
    max_ = max(a[-1],b[0])
    b[0] = max_
    a.pop(-1)
    a.extend(b)
    
    #今回の処理
    if hugo.index(s[-1]) == 1:
        b = [1,0]
    else:
        b = [0,1]
    max_ = max(a[-1],b[0])
    b[0] = max_
    a.pop(-1)
    a.extend(b)
    
print(sum(a))
    

Measured memory_bytes: 37104
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#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};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; 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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    int p=-1;
    REP(i,n) {
        int x;
        cin>>x;
        if(i!=0) ans+=min(a*(x-p),b);
        p=x;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};

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

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

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

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

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

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

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

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

fn main() {
    input! {
        l: i64,
        r: i64,
    };
    let mut ans = 2019 as i64;
    for i in l..r+1 {
        let mut set = HashSet::new();
        for j in l..i {
            let tmp = i * j % 2019;
            if set.contains(&tmp) {
                break;
            }
            set.insert(tmp);
            ans = min(ans, tmp);
        }
        if ans == 0 {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
type Node struct {
	x, y int
}

type Queue struct {
	arr []Node
}

func (q *Queue) push(v Node) {
	q.arr = append(q.arr, v)
}

func (q *Queue) pop() Node {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *Queue) isEmpty() bool {
	return len(q.arr) == 0
}

const mod = int(1e+9) + 7

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	H, W := sc.nextInt(), sc.nextInt()
	G := make([][]rune, H)
	for i := 0; i < H; i++ {
		G[i] = sc.nextRuneSlice()
	}
	dp := make([][]int, H)
	for i := 0; i < H; i++ {
		dp[i] = make([]int, W)
	}
	dx := []int{1, 0}
	dy := []int{0, 1}
	var q Queue
	search := func(node Node) {
		x, y := node.x, node.y
		for i := 0; i < 2; i++ {
			nx, ny := x+dx[i], y+dy[i]
			if nx >= W || ny >= H {
				continue
			}
			if G[ny][nx] == '.' {
				if dp[ny][nx] == 0 {
					dp[ny][nx] += dp[y][x]
					dp[ny][nx] %= mod
					q.push(Node{nx, ny})
				} else {
					dp[ny][nx] += dp[y][x]
					dp[ny][nx] %= mod
				}
			}
		}
	}
	dp[0][0] = 1
	q.push(Node{0, 0})
	for !q.isEmpty() {
		search(q.pop())
	}

	fmt.Fprintln(wtr, dp[H-1][W-1])
	wtr.Flush()
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m, 0);
    for(int i=0;i<m;++i) cin >> b[i];

    int a, z, x=0;
    for(int i=0;i<n;++i) {
        z=c;
        for(int j=0;j<m;++j) {
            cin >> a;
            z += a*b[j];
        }
        if(z>0) ++x;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()

    print('yes' if len(set(s)) == len(s) else 'no')

if __name__ == '__main__':
    main()


Measured memory_bytes: 77156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

struct edge {
  int to;
  ll cost;
  edge(int t, ll c): to(t), cost(c) {};
};

vector<pair<ll, ll>> d;
ll l;
void dijkstra(int s, int N, vector<vector<edge>>& G) {
  priority_queue<pair<pair<ll, ll>, int>,
                 vector<pair<pair<ll, ll>, int>>,
                 greater<pair<pair<ll, ll>, int>>> que;
  d = vector<pair<ll, ll>>(N, {longinf, longinf});
  d[s] = {0, 0};
  que.push(make_pair(make_pair(0, 0), s));

  while(!que.empty()) {
    auto p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;

    for(int i=0; i<(int)G[v].size(); i++) {
      edge e = G[v][i];
      if(d[v].second + e.cost > l) {
        if(e.cost > l) continue;
        if(d[e.to] > make_pair(d[v].first+1, e.cost)) {
          d[e.to] = make_pair(d[v].first+1, e.cost);
          que.push(make_pair(d[e.to], e.to));
        }
      } else {
        if(d[e.to] > make_pair(d[v].first, d[v].second+e.cost)) {
          d[e.to] = make_pair(d[v].first, d[v].second+e.cost);
          que.push(make_pair(d[e.to], e.to));
        }
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  cin >> l;
  vector<vector<edge>> G(n);
  rep(i, m) {
    int a, b; cin >> a >> b;
    ll c; cin >> c;
    a--; b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  vector<vector<ll>> ans(n, vector<ll>(n, longinf));
  rep(i, n) {
    dijkstra(i, n, G);
    rep(j, n) ans[i][j] = d[j].first;
  }
  int q; cin >> q;
  rep(_, q) {
    int s, t; cin >> s >> t;
    s--; t--;
    cout << (ans[s][t]==longinf ? -1 : ans[s][t]) << endk;
  }
  return 0;
}


Measured memory_bytes: 7888
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+500;
int fa[N],dep[N],siz[N],stack[N],dfs_cnt,top,nid[N],tag[N<<1],a[N<<1],dfn[N],K,kfa[N],n;
int fst[N],nxt[N],to[N],mm;
void ade(int u,int v){to[++mm]=v,nxt[mm]=fst[u],fst[u]=mm;}
void dfs(int u)
{
    dep[u]=dep[fa[u]]+1;dfn[u]=++dfs_cnt;nid[dfs_cnt]=u;
    siz[u]=1;
    stack[++top]=u;
    if(dep[u]>=K)kfa[u]=stack[dep[u]-K+1];
    for(int i=fst[u];i;i=nxt[i])
    {
        int v=to[i];dfs(v);
        siz[u]+=siz[v];
    }
    --top;
}
void upd(int rot){a[rot]=0,tag[rot]=1;}
void build(int rot,int lt,int rt)
{
    if(lt==rt){a[rot]=nid[lt];return;}
    int mid=(lt+rt)>>1;
    build(rot<<1,lt,mid),build(rot<<1|1,mid+1,rt);
    a[rot]=dep[a[rot<<1]]>dep[a[rot<<1|1]]?a[rot<<1]:a[rot<<1|1];
}
void pushdown(int rot)
{
    if(tag[rot]){upd(rot<<1),upd(rot<<1|1),tag[rot]=0;}
}
void update(int rot,int lt,int rt,int lq,int rq)
{
    if(lt>=lq&&rt<=rq){upd(rot);return;}
    int mid=(lt+rt)>>1;pushdown(rot);
    if(lq<=mid)update(rot<<1,lt,mid,lq,rq);
    if(rq>mid)update(rot<<1|1,mid+1,rt,lq,rq);
    a[rot]=dep[a[rot<<1]]>dep[a[rot<<1|1]]?a[rot<<1]:a[rot<<1|1];   
}
int main()
{
    scanf("%d%d",&n,&K);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",fa+i);
        if(i!=1)ade(fa[i],i);
    }
    if(K==1)
    {
        int ans=0;
        for(int i=1;i<=n;i++)if(fa[i]!=1)++ans;
        cout<<ans<<endl;
        return 0;
    }
    int ans=0;if(fa[1]!=1)++ans;
    dfs(1);
    build(1,1,n);
    while(dep[a[1]]>K+1)
    {
        ++ans;int u=kfa[a[1]];
        update(1,1,n,dfn[u],dfn[u]+siz[u]-1);
    }
    cout<<ans<<endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var A = input[0];
            var B = input[1];

            Console.WriteLine(B % A == 0 ? A + B : B - A);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int G=5,mod=924844033;
const int maxn=530005;
int len,lim,wm[maxn],rev[maxn];
inline int powmod(int a,int b){
	int res=1;for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}return res;
}
inline void init(int n,int m){
	len=1;lim=0;
	while(len<=n+m)len<<=1,lim++;
	int w=powmod(G,(mod-1)/len);
	wm[0]=1;
	rep(i,1,len)wm[i]=1ll*wm[i-1]*w%mod;
	rep(i,0,len-1)rev[i]=(rev[i>>1]>>1)|((i&1)<<(lim-1));
}
int n;
inline void NTT(int a[],int on){
	rep(i,0,len-1)if(i<rev[i])swap(a[i],a[rev[i]]);
	for(int h=2;h<=len;h<<=1){
		int wn=wm[len/h];
		for(int k=0;k<len;k+=h){
			int w=1;
			rep(j,0,h/2-1){
				int u=a[j+k],t=1ll*a[j+k+h/2]*w%mod;
				a[j+k]=(u+t)%mod;
				a[j+k+h/2]=(u-t+mod)%mod;
				w=1ll*w*wn%mod;
			}
		}
	}
	if(on==-1){
		int inv=powmod(len,mod-2);
		rep(i,0,len-1)a[i]=1ll*a[i]*inv%mod;
	}
}
namespace tree{
	int num,size[maxn],head[maxn],t[maxn<<1],ne[maxn<<1];
	inline void addedge(int x,int y){
		ne[++num]=head[x];head[x]=num;t[num]=y;
		ne[++num]=head[y];head[y]=num;t[num]=x;
	}
	inline void dfs(int x,int f){
		size[x]=1;
		forE(i,x)if(t[i]!=f){
			dfs(t[i],x);
			size[x]+=size[t[i]];
		}
	}
	inline void solve(){
		rep(i,1,n)head[i]=-1;
		rep(i,1,n-1){
			int x,y;read(x);read(y);
			addedge(x,y);
		}
		dfs(1,-1);
	}
}
int A[maxn],B[maxn],fac[maxn],facinv[maxn];
inline void prprpr(){
	fac[0]=1;
	rep(i,1,400000)fac[i]=1ll*fac[i-1]*i%mod;
	facinv[400000]=powmod(fac[400000],mod-2);
	per(i,399999,0)facinv[i]=1ll*facinv[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
	if(n<0||m<0||m>n)return 0;
	return 1ll*fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
int main(){
    prprpr();
    read(n);
    tree::solve();
    rep(i,2,n)A[tree::size[i]]++,A[n-tree::size[i]]++;
    rep(i,0,n)A[i]=1ll*A[i]*fac[i]%mod;
    rep(i,0,n)B[i]=facinv[n-i];
    init(n,n);
    NTT(A,1);NTT(B,1);
    reverse(wm+1,wm+len);
    rep(i,0,len-1)A[i]=1ll*A[i]*B[i]%mod;
    NTT(A,-1);
    rep(K,1,n){
    	int nowans=1ll*(n-1)*C(n,K)%mod;
    	nowans=(nowans-1ll*A[K+n]*facinv[K]%mod+mod)%mod;
    	nowans=(nowans+C(n,K))%mod;
    	printf("%d\n",nowans);
    }
    return 0;
}


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

ll solve() {
    int N, M, u, v;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    
    vector<int> col(N, -1);
    function<bool(int,int,int)> dfs = [&](int v, int p, int c) {
        if ( col[v] != -1 ) {
            if ( col[v] != c ) return false;
            else return true;
        }
        col[v] = c;
        bool bi = true;
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            bool b = dfs(u, v, 1-c);
            bi = bi && b;
        }
        return bi;
    };

    ll iso = 0, con = 0, nb = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( col[i] != -1 ) continue;
        if ( G[i].size() == 0 ) iso++;
        else {
            con++;
            if ( !dfs(i,-1,0) ) nb++;
        }
    }
    
    ll n = N;
    ll ans = (n*n-(n-iso)*(n-iso)) + con*con + (con-nb)*(con-nb);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12800
class RollingHash(object):
    """
    construct: O(N)
    query:
        hash: O(1)
        lcp: O(logN)
        search: O(N)
    """
    __base1=1007; __mod1=10**9
    __base2=1009; __mod2=10**7
 
    def __init__(self,s):
        """
        s: str
        """
        n=len(s)
        self.__s=s
        self.__n=n
        b1=self.__base1; m1=self.__mod1
        b2=self.__base2; m2=self.__mod2
        H1,H2=[0]*(n+1),[0]*(n+1)
        P1,P2=[1]*(n+1),[1]*(n+1)
        for i in range(n):
            H1[i+1]=(H1[i]*b1+ord(s[i]))%m1
            H2[i+1]=(H2[i]*b2+ord(s[i]))%m2
            P1[i+1]=P1[i]*b1%m1
            P2[i+1]=P2[i]*b2%m2
        self.__H1=H1; self.__H2=H2
        self.__P1=P1; self.__P2=P2
 
    @property
    def str(self):
        return self.__s
 
    @property
    def len(self):
        return self.__n
 
    def hash(self,l,r=None):
        """
        l,r: int (0<=l<=r<=n)
        return (hash1,hash2) of S[l:r]
        """
        m1=self.__mod1; m2=self.__mod2
        if r is None: r=self.__n
        assert 0<=l<=r<=self.__n
        return ((self.__H1[r]-self.__P1[r-l]*self.__H1[l]%m1)%m1,
                (self.__H2[r]-self.__P2[r-l]*self.__H2[l]%m2)%m2)
 
    @classmethod
    def lcp(cls,rh1,rh2,l1,l2,r1=None,r2=None):
        """
        rh1,rh2: RollingHash object
        l1,l2,r1,r2: int 0<=l1<=r1<=r1.len,0<=l2<=r2<=rh2.len
        return lcp length between rh1[l1:r1] and rh2[l2:r2]
        """
        if r1 is None: r1=rh1.__n
        if r2 is None: r2=rh2.__n
        assert 0<=l1<=r1<=rh1.__n and 0<=l2<=r2<=rh2.__n
        L=0
        R=min(r1-l1,r2-l2)
        if rh1.hash(l1,l1+R)==rh2.hash(l2,l2+R): return R
        while(R-L>1):
            H=(L+R)//2
            if rh1.hash(l1,l1+H)==rh2.hash(l2,l2+H): L=H
            else: R=H
        return L
 
    @classmethod
    def search(cls,pattern,text):
        """
        pattern,text: RollingHash object
        return list of index i's satisfying text[i:] starts with pattern
        """
        n=text.__n; m=pattern.__n
        res=[]
        for i in range(n-m+1):
            if text.hash(i,i+m)==pattern.hash(0,m):
                res.append(i)
        return res
    
#------------
from collections import defaultdict

N = int(input())
S =input()

rh = RollingHash(S)

#長さlenが上位園を満たすか二分探索
#条件を満たすためには，S[i:i+len]のhash値を計算．S[i:i+len]==S[j:j+len] and j-i>=lenならok
#ここで，i,jでループを回すのではなく，iで回してその時の{ハッシュ値:i}を辞書に持っておく．

#長さlが条件を満たすか？
def test(len):
    dd = defaultdict(int)
    for i in range(N-len+1):
        h=rh.hash(i,i+len)
        if dd[h]!=0:
            if i-dd[h]+1>=len:#+1の理由は下記のコメントを参照
                return True
        else:
            dd[h]=i+1#本当はiにしたいけど，i=0でやばい
    return False
        

ok=-1
ng=N
while abs(ng-ok)>1:
    med = (ng+ok)//2
    if test(med):
        ok=med
    else:
        ng=med

print(ok)

Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a + b){
        cout << min(k, a) << endl;
    }else{
        cout << a - (k - a - b) << endl;
    }
    return 0;

}


Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

typedef uint32_t  uint;



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

  uint n;
  cin>>n;
  uint result=0;
  uint limit=std::pow(2,n);
  std::vector<std::pair<int,bool>> data[15];
  for(uint i=0;i<n;i++){
    int a;
    cin>>a;
    for(int j=0;j<a;j++){
      int x;
      bool y;
      cin>>x>>y;
      data[i].push_back(std::make_pair(x-1,y));
    }
  }

  for(uint i=0;i<limit;i++){
    std::bitset<15> bs(i);

    bool is_ok=true;

    for(int p=0;p<n;p++){
      if(bs[p]==true){
        //pは正直
        for(auto d:data[p]){
          if(bs[d.first]==d.second){
            continue;
          }else{
            is_ok=false;
            break;
          }
        }

      }else{
        // for(auto d:data[p]){
        //   if(bs[d.first]!=d.second){
        //     continue;
        //   }else{
        //     is_ok=false;
        //     break;
        //   }
        // }
      }

      if(!is_ok){
        break;
      }
    }

    if(is_ok){
      result=std::max(result,(uint)bs.count());
    }
  }

  cout<<result<<endl;





  return 0;
}


Measured memory_bytes: 1016
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define inf (1LL<<61)
#define int long long
typedef long long ll;
#define ld long double
#define N 301 


int32_t main()
{
    IOS;
   

    int n;
    cin >> n;
    string s;
    cin >> s;
    int dp[2][n+1];
    for(int i = 1;i <= n;i++){

        dp[0][i] = 1;
        dp[1][i] = 0;
        
    }
    dp[0][0] = 0;
    dp[1][0] = 0;
    for(int i = 1;i < n;i++)
    {
        int cur = i & 1;
        int prev = cur ^ 1;
        for(int j = 0;j <= n;j++)
            dp[cur][j] = 0;
        for(int j = 1;j <= i+1;j++)
        {

            if(s[i - 1] == '<')
            {
                dp[cur][j] = dp[prev][j - 1];

            }
            else
            {
                dp[cur][j] = (dp[prev][n] - dp[prev][j - 1] + mod)%mod;
            }
           
        }

        int c = 0;
        
        for(int j = 1;j <= n;j++)
        {
            c += dp[cur][j];
            c %= mod;
            dp[cur][j] = c;
        }
        if(i == n-1)
            cout << c;
    }
}

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

void Main() {
  int N, T;
  cin >> N >> T;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int l = 2000000000, max_benefit = 0;
  map<int, int> cost;
  for (int i = 1; i < N; i++) {
    l = min(l, A[i - 1]);
    int benefit = A[i] - l;
    cost[benefit]++;
    max_benefit = max(max_benefit, benefit);
  }

  cout << cost[max_benefit] << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

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

const string al = "abcdefghijklmnopqrstuvwxyz";

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

  string res = "";
  while(n > 0) {
    --n;
    res += al[n % 26];
    n /= 26;
  }

  string ans = "";
  for(ll i = (ll)res.size()-1; i >= 0; --i) {
    ans += res[i];
  }
  cout << ans << endl;
}

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


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

using namespace std;

int main () {
    long long int x;
    cin >> x;
    //x = 180 - x;
    for(long long int i = 3 ; ; i ++ ) {
        long double n = i;
        if((i * x) % 360 == 0) return cout << i ,0;
    }
}


Measured memory_bytes: 3632
package main

import "fmt"

// 2018-07-29T20:49:12+0800
func main() {
	var N, t int
	fmt.Scanf("%d", &N)
	m := make(map[int]bool)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &t)
		m[t] = true
	}
	fmt.Println(len(m))
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

// 素数判定 2からfor分で回して行く limitはどこまでやるか エラトステネスの篩
bool isPrime[100101];
void computePrimes(int limit = 100100) {              // #include <cassert>
    fill(isPrime, isPrime + limit + 1, true);  //最初全部trueにしておく
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i <= limit; i++)
        if (isPrime[i])
            for (int j = 2 * i; j <= limit; j += i) isPrime[j] = false;
}

int main() {
    int n;
    cin >> n;
    computePrimes();
    for (int i=n; ; i++) {
        if (isPrime[i]) {
            cout << i << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] input = br.readLine().split(" ");
			for(String str : input){
				System.out.print(str.toUpperCase().charAt(0));
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN

    ll n,q;cin>>n>>q;
    string s;cin>>s;
    vll v(n,0);

    ll cnt=0;
    REP(i,n){
        if(i>0 && s[i]=='C' && s[i-1]=='A'){
            cnt++;
            
        }
        v[i]=cnt;
    }
    // REP(i,n) cout<<v[i]<<endl;
    REP(i,q){
        ll l,r; cin>>l>>r; l--; r--;
        cout<<v[r]-v[l]<<endl;

    }
    // cout<<v[1]<<endl;
    return 0;
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using bint = boost::multiprecision::cpp_int;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    bool ok = true;
    bint ans = 1;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    sort(a.begin(),a.end());
    rep(i,n) {
        ans *= a[i];
        if (ans > 1000000000000000000) {
            ok = false;
            break;
        }
    }
    if (ok) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4028
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	string ans;
	cin >> ans;
	cout << ans.substr(0, ans.size()-8) << endl;
	return 0;
}
/*
死のマウス
.　　あり許せん！
　　　∧＿＿∧
　|| （＃｀Д´ ） ||
　|| ( |　 　| | |||
　从| |　 　| |从从
￣) ⊂ノ￣￣!_つ￣て
　フヘ(　　　　ヽヘ(＼

*/

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let rec loop i tt xx yy =
        if i = n then "Yes" else
            let t, x, y =  Scanf.scanf " %d %d %d" (fun t x y -> t, x, y) in
            let t0 = t - tt in
            let x0 = abs (xx - x) in
            let y0 = abs (yy - y) in
            if x0 + y0 <= t0 && (t0 - x0 - y0) mod 2 = 0 then loop (i + 1) t x y else "No"
    in
    loop 0 0 0 0 |> print_endline
)

Measured memory_bytes: 5820
#include<queue>
#include <functional>
#include<stdio.h>
#include<assert.h>
#include <deque>
#include<stack>
#include<sstream>
#include <cstdlib>
#include<map>
#include<algorithm>
#include<iostream>
#include<set>
#include<utility>
#include<memory.h>
#include<string>
#include<vector>
#include <iostream>
#include <cstdio>
#include<list>
#include<iomanip>
#include<cmath>
#include<numeric>
using namespace std;
typedef vector<int> vi;
const int maxn = 705;
int n, m;
int adj[maxn][maxn];
int col[maxn];
int has[maxn][4];
int dp[maxn][maxn];
int ok = 1;
int comps = 0;

void dfs(int u) {
	++has[comps][col[u]];
	for (int v = 0 ; v < n ; ++v) {
		if (adj[u][v]) continue;
		if (u == v) continue;
		if (col[v] == -1) {
			col[v] = 1 ^ col[u];
			dfs(v);
		} else {
			if (col[u] != (1 ^ col[v])) {
				ok = 0;
			}

		}
	}

}

int gg(int x) {
	return (x) * (x - 1) / 2;
}

int solve(int ind,int b,int r) {

	if (ind == comps) {
		return gg(b) + gg(r);
	}

	int &ret = dp[ind][b];
	if (ret != -1) {
		return ret;
	}
	ret = 1 << 27;


	ret = min(ret,solve(ind + 1,b + has[ind][0], r + has[ind][1]));

	// make 1 b
	//cont = (has[ind][1] * b) / 2 + (has[ind][0] * r) / 2;

	ret = min(ret,solve(ind + 1,b + has[ind][1],r + has[ind][0]));
	//ret += gg(has[ind][0]) + gg(has[ind][1]);
	return ret;
}

int main() {
	cin >> n >> m;
	int u, v;
	for (int i = 0; i < m; ++i) {
		cin >> u >> v;
		--u, --v;
		adj[u][v] = adj[v][u] = 1;
	}

	memset(col,-1,sizeof(col));
	memset(dp,-1,sizeof(dp));
	for (int i = 0 ; i < n ; ++i) {
		ok = 1;
		if (col[i] == -1) {
			col[i] = 0;
			dfs(i);
			++comps;
			if (!ok) {
				cout << "-1\n";
				return 0;
			}
		}
	}

	//cerr << comps << endl;
	cout << solve(0,0,0);

}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F_(i,a,b) for(int i=(a);i>=(b);--i)
#define G(i,u) for(int i=Head[a];i;i=Next[i])

typedef long long ll;
typedef double db;
typedef long double ld;

template<typename T> inline T max(T& a, T b) { return a>b?a:a=b; }
template<typename T> inline T min(T& a, T b) { return a<b?a:a=b; }

const int N = 100005;

int to[N], fa[N]; int find(int x) {return x == fa[x]? x : fa[x]=find(fa[x]);}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	F(i,1,n) scanf("%d", &to[i]), fa[i] = i;
	F(i,1,m) {
		int a, b;
		scanf("%d%d", &a, &b);
		fa[find(a)] = find(b);
	}
	int ans = 0;
	F(i,1,n) {
		if( i == to[i] || find(i) == find(to[i]) ) ans ++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 200005;

vector<pair<ll,int> > X;

template<typename T>
struct LazySegmentTree {
 
 private:
     int n;
     T init_v;
     vector<T> node;
     vector<T> lazy;
 
 public:
     LazySegmentTree(vector<T> a, T _init_v) {
 
         n = 1;
         init_v = _init_v;
 
         int sz = a.size();
         while (n < sz) n *= 2;
 
         node.resize(2 * n, init_v);
         lazy.resize(2 * n, init_v);
 
         for (int i = 0; i < sz; i++) node[i + n - 1] = a[i];
         for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2];
     }
 
     void eval(int k, int l, int r) {
         if (lazy[k] != 0) {
             node[k] += lazy[k];
             if (r - l > 1) {
                 lazy[k * 2 + 1] += lazy[k] / 2;
                 lazy[k * 2 + 2] += lazy[k] / 2;
             }
             lazy[k] = 0;
         }
     }
 
     void add(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
         if (r < 0) r = n;
         eval(k, l, r);
         if (r <= a || b <= l) return;
         if (a <= l && r <= b) {
             lazy[k] += (r - l) * x;
             eval(k, l, r);
         } else {
             add(a, b, x, k * 2 + 1, l, (l + r) / 2);
             add(a, b, x, k * 2 + 2, (l + r) / 2, r);
             node[k] = node[k * 2 + 1] + node[k * 2 + 2];
         }
     }
 
     T getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
         if (r < 0) r = n;
         eval(k, l, r);
         if (r <= a || b <= l) return 0;
         if (a <= l && r <= b) return node[k];
         T lv = getsum(a, b, k * 2 + 1, l, (l + r) / 2);
         T rv = getsum(a, b, k * 2 + 2, (l + r) / 2, r);
         return lv + rv;
    }
 
};

int main(){
    int N, D;
    ll A;
    cin >> N >> D >> A;
    LazySegmentTree<ll> T(vector<ll>(N,0), 0);

    rep(i,N){
        int x, h;
        cin >> x >> h;
        X.push_back(make_pair(x,h));
    }
    sort(X.begin(), X.end());

    ll ans = 0;
    rep(i,N){
        X[i].second -= T.getsum(i,i+1) * A;
        if(X[i].second <= 0)continue;
        ll j = upper_bound(X.begin(), X.end(), make_pair(X[i].first + 2*D, 1<<30)) - X.begin();
        ll k = (X[i].second+A-1) / A;
        T.add(i, j, k);
        ans += k;
    }
    

    std::cout << ans << endl;

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = (int)(s.back() - '0');
    if(n == 2 || n == 4 || n == 5 || n == 7|| n == 9) cout << "hon" << '\n';
    else if(n == 3) cout << "bon" << '\n';
    else cout << "pon" << '\n';
    
    return 0;
}


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



int main(){
    string s;
    cin>>s;
    int ans=0;
    if(s.at(0)=='1')ans++;
    if(s.at(1)=='1')ans++;
    if(s.at(2)=='1')ans++;
cout<<ans<<endl;    
}


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

int FindSumOfDigits(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; ++i){
        int sum = FindSumOfDigits(i);
        if (A <= sum && sum <= B){
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	int a[3][111];
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	a[1][0]+=a[0][0];
	for(int i=1;i<n;i++){
		a[0][i]+=a[0][i-1];
	}
	for(int i=1;i<n;i++){
		a[1][i]+=max(a[0][i],a[1][i-1]);
	}
	cout<<a[1][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
loop do
  judge_num = gets.chomp.to_i
  if judge_num == 0
    break
  end
  max_val = 0
  min_val = 1001
  sum = 0
  judge_num.times do |i|
    value = gets.chomp.to_i
    if value > max_val
      max_val = value
    end
    if value < min_val
      min_val = value
    end
    sum += value
  end
  sum -= (min_val + max_val)
  puts (sum / (judge_num - 2)).floor
end


Measured memory_bytes: 6848
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
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("");
}
ll n, t; int ans;
int main() {
	read(n);
	while (10 * t + 9 <= n) {
		t = 10 * t + 9;
		ans += 9;
	}
	n -= t;
	while (n >= t + 1) n -= t + 1, ans++;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
L=len(a)
for i in range(L):
    a[i]-=(i+1)
a=sorted(a)
c=0
d=0
ans=0
ans_c=0
ans_d=0
if len(a)%2==1:
    c=int(len(a)/2)+1
    for i in a:
        ans+=abs(i-a[c-1])
    print(ans)
else:
    c=int(len(a)/2)
    d=int(len(a)/2)+1
    for i in a:
        ans_c+=abs(i-a[c-1])
        ans_d+=abs(i-a[d-1])
    print(min(ans_c,ans_d))


Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> p(n), q(n), o(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	for(int i = 0; i < n; i++) cin >> q[i];
	iota(o.begin(), o.end(), 1);
	int ord = 1;
	int pp = -1, qq = -1;
	do{
		if(o == p) pp = ord;
		if(o == q) qq = ord;
		ord++;
	}while(next_permutation(o.begin(), o.end()));
	cout << abs(pp - qq) << endl;
	return 0;
}


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

const double eps=1e-6;
const int MAX=1010;
int n,m;
char ans[MAX];

int main()
{
    int i,j,k,t;
    while(~scanf("%d",&n))
    {
        char a[MAX],b[MAX];
        scanf("%s%s",a,b);
        if(strcmp(a,b)==0)
        {
            printf("%d\n",n);
            continue;
        }
        for(i=0;i<n;i++)
        {
            k=i;
            for(j=0;j<n;j++)
            {
                if(a[k]==b[j])
                    k++;
                else
                    break;
            }
            if(k==n)
            {
                printf("%d\n",2*n-j);
                break;
            }
        }
        if(i==n)
            printf("%d\n",2*n);
    }
    return 0;
}
/*
1234567899
111199991
*/


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a, b;
    ll sum=0;
    bool flag=true;
    rep(i, n){
        ll x;
        cin >> x;
        sum += x;
        if(flag){
            if(sum<=k){
                a.push_back(sum);
            }else{
                flag=false;
            }
        }
    }
    if (a.empty()) {
      a.push_back(1e10);
    }
    sum=0;
    flag = true;
    rep(i, m) {
      ll x;
      cin >> x;
      sum += x;
      if (flag) {
        if (sum <= k) {
            b.push_back(sum);
        } else {
            flag = false;
        }
      }
    }
    if(b.empty()){
        b.push_back(1e10);
    }
    int len = a.size(), maxim=0;
    for(int i=len-1;i>=0;i--){
        ll rem = k - a[i];
        int x = 1;
        if(rem<0){
            rem = k;
            x = 0;
        }
        int l = 0, r = b.size(), mid;
        while(l<r){
            mid = (l + r) / 2;
            if(b[mid]>rem){
                r = mid;
            }else{
                if(b[mid]<rem){
                  l = mid + 1;
                }else{
                    break;
                }
            }
        }
        // cout << mid << endl;
        if(b[mid]>rem){
            mid--;
            // mid = max(mid, 0);
        }
        maxim = max(maxim, i + mid + x + 1);
        // cout << maxim << endl;
    }
    // a, 1個も取らない場合
    ll rem = k;
    int l = 0, r = b.size(), mid;
    while (l < r) {
      mid = (l + r) / 2;
      if (b[mid] > rem) {
        r = mid;
      } else {
        if (b[mid] < rem) {
          l = mid + 1;
        } else {
          break;
        }
      }
    }
    // cout << mid << endl;
    if (b[mid] > rem) {
      mid--;
      // mid = max(mid, 0);
    }
    maxim = max(maxim, mid + 1);
    cout << maxim << endl;
    return 0;
}

Measured memory_bytes: 7996
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
#include<cmath>
#include<algorithm>
#include<vector>
void swap(int *x,int *y){
    int tmp;
    tmp=*x;
    *x=*y;  
    *y=tmp;
}

int gcd(int a,int b){
    if(a<b) swap(&a,&b);
    if(b<1) return -1;

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


int main(){
    int N;
    std::cin>>N;
    std::vector<int> vec(N);

    int flag=0;

    for(int i=0;i<N;i++) std::cin>>vec[i];
    
    std::vector<int> left(N);
    std::vector<int> right(N);

    for(int i=0;i<N;i++){
        if(i==0) left[i]=vec[i];
        else left[i]=gcd(left[i-1],vec[i]);
    }
    //left[0]=0;

    for(int i=N-1;0<=i;i--){
        if(i==N-1) right[i]=vec[i];
        else right[i]=gcd(right[i+1],vec[i]);
    }
    //right[N-1]=0;

    /*
    for(int i=0;i<N;i++) std::cout<<left[i]<<" ";
    std::cout<<std::endl;
    for(int i=0;i<N;i++) std::cout<<right[i]<<" ";
    std::cout<<std::endl;
    */

    int max=0;
    int SUM=0;
    for(int i=0;i<N;i++){
        if(i==0) SUM=right[i+1];
        else if(i==N-1) SUM=left[i-1];
        else SUM=gcd(left[i-1],right[i+1]);
        if(max<SUM) max=SUM;
        //std::cout<<SUM<<std::endl;
    }

    std::cout<<max<<std::endl;


    return 0;
}



Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++){ cin >> d[i];}
    int ans{0};
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

long long h[2001][2001], w[2001][2001];

int main(){	
	long long H;
	long long W;
	scanf("%lld",&H);
	vector<string> S(H-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> S[i];
	}
	
	rep(i,H) {
		long long start=-1;
		rep(j,W+1) {
			if (j < W && S[i][j] == '.') {
				if (start == -1) start = j;
				// cout << "a " << i << " " << j << endl;
			} else {
				if (start != -1) {
					for (long long k = start; k < j; k++) {
						w[i][k] = j - start - 1;
					}
				}
				// cout << "b " << i << " " << j << " " << start << endl;
				w[i][j] = 0;
				start = -1;
			}
		}
	}

	rep(i,W) {
		long long start=-1;
		rep(j,H+1) {
			if (j < H && S[j][i] == '.') {
				if (start == -1) start = j;
			} else {
				if (start != -1) {
					for (long long k = start; k < j; k++) {
						h[k][i] = j - start - 1;
					}
				}
				h[j][i] = 0;
				start = -1;
			}
		}
	}

	long long res = 0;
	rep(i,H+1) {
		rep(j,W+1) {
			res = max(res, h[i][j]+w[i][j]+1);
			// cout << i << " " << j << "  " << h[i][j] << " " << w[i][j] << " " << h[i][j]+w[i][j]+1 << endl;
		}
	}
	cout << res << endl;

	return 0;
}



Measured memory_bytes: 66944
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		if(N < 2 * K - 1) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
        int div = 536870912; //div = 2**29
        for(int j = 29; j >= 1; --j){
            if(a.at(i) % div == 0){
                ans += j;
                break;
            }
            else div /= 2; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624