akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN 100001
#define X first
#define Y second
#define MOD 1000000007
#define fr(a,b,c) for(ll a=b;a<c;++a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll t,n,i,j;
int main()
{
    fastio;
    ll n,w;
    cin>>n>>w;
    vector <ll > v(n+1);
    vector <ll > wt(n+1);
    fr(i,1,n+1)
        cin>>wt[i]>>v[i];
    ll dp[101][MAXN]={0};
    fr(j,1,w+1){
        if(j>=wt[1])
            dp[1][j]=v[1];
    }

    fr(i,2,n+1){
        fr(j,1,w+1){
            if(j>=wt[i]){
                dp[i][j]=max(dp[i-1][j-wt[i]]+v[i],dp[i-1][j]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 79232
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let a: u32 = read();
    let s: String = read();
    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
ma = lambda :map(int,input().split())
n,m = ma()
import collections
que = collections.deque()
ls = [[] for i in range(n)]
for i in range(m):
    a,b = ma()
    ls[a-1].append(b-1)
    ls[b-1].append(a-1)
que.append((0,-1))
vis = [False]*n
ans = [0]*n
while que:
    now,prev = que.popleft()
    if not vis[now]:##同じ床をなんども訪れる予定がある
        vis[now] = True
        ans [now] = prev
        for nex in ls[now]:
            if not vis[nex]:
                que.append((nex,now))
print("Yes")
for i in range(1,n):
    print(ans[i]+1)


Measured memory_bytes: 40416
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int n,t[100003],ans,a,b,m,c;
int main(){
  cin>>n;
  r(i,n){
    cin>>a>>b;
    t[a]++;
    t[b+1]--;
  }
  r(i,100003){
    c+=t[i];
    if(c)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

A,P = map(int,input().split())
ans = (A*3+P)//2
print(ans)


Measured memory_bytes: 7876
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    int           MAX        = 32769;
    boolean       is_prime[] = new boolean[MAX];
    int           prime[]    = new int[MAX];
    List<Integer> primeList  = new ArrayList<Integer>();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Main main = new Main();
        main.calcPrime();
        while (scanner.hasNext()) {
            int ans = 0;
            int input = scanner.nextInt();
            if (input == 0) {
                break;
            }
            for (int i = 2; i < input; i++) {
                if (main.is_prime[i]) {
                    int b = input - i;
                    if (i > b) {
                        break;
                    }
                    if (main.is_prime[b]) {
                        ans++;
                    }
                }
            }
            System.out.println(ans);
        }
    }

    public void calcPrime() {
        int p = 0;
        for (int i = 2; i < MAX; i++)
            is_prime[i] = true;
        for (int i = 2; i < MAX; i++) {
            if (is_prime[i]) {
                prime[p++] = i;
                for (int j = 2 * i; j < MAX; j += i)
                    is_prime[j] = false;
            }
        }
    }
}

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

int main() {
    string s;
    cin >> s;
    set<char> cs;
    rep(i,3) cs.insert(s[i]);
    if(cs.size() == 3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  double L;
  cin >> L;
  double ans = (L/3)*(L/3)*(L/3);

  printf("%.12lf\n",ans);

  return 0;
}

Measured memory_bytes: 256
def main():
    n=int(input())
    p=list(map(int,input().split()))
    x=list(map(int,input().split()))
    g=[[] for _ in [0]*n]
    [g[j-1].append(i+1) for i,j in enumerate(p)]
    dist=[0]*n
    q=[0]
    while q:
        qq=q.pop()
        for i in g[qq]:
            if i!=0:
                dist[i]=dist[p[i-1]-1]+1
                q.append(i)
    dist=sorted([[-j,i] for i,j in enumerate(dist)])
    dist=[j for i,j in dist]
    memo=[[i,0] for i in x]
    for i in dist:
        if len(g[i])==0:
            continue
        dp=[10003]*(x[i]+1)
        dp[0]=0
        for j in g[i]:
            dp2=[10003]*(x[i]+1)
            for k in range(x[i]-memo[j][0],-1,-1):
                if dp[k]!=10003:
                    dp2[k+memo[j][0]]=min(dp2[k+memo[j][0]],dp[k]+memo[j][1],5001)
            for k in range(x[i]-memo[j][1],-1,-1):
                if dp[k]!=10003:
                    dp2[k+memo[j][1]]=min(dp2[k+memo[j][1]],dp[k]+memo[j][0],5001)
            dp=dp2
        memo[i][1]=min(dp)
        if memo[i][1]==10003:
            print("IMPOSSIBLE")
            break
        #print(dp)
    else:
        print("POSSIBLE")
    #print(memo)

if __name__ == '__main__':
    main()

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

int main(){
	int N;
	cin>>N;
	long A[N+1],B[N];
	for(int i=0;i<N+1;++i){
		cin>>A[i];
	}
	for(int i=0;i<N;++i){
		cin>>B[i];
	}
	long ans = 0;
	for(int i=0;i<N;++i){
		if(B[i]<=A[i])ans+=B[i];
		else if(B[i]<=A[i]+A[i+1]){
			ans+=B[i];
			A[i+1] -= B[i] - A[i];
		}
		else{
			ans+=A[i]+A[i+1];
			A[i+1]=0;
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  
  int N, M;
  cin >> N >> M;
  vector<int> bipa(M * 2);
  
  for (int i = 0; i < M * 2; i++) {
    cin >> bipa.at(i);
  }
  
  for (int i = 1; i < N + 1; i++) {
    int sum = 0;
    
    for (int j = 0; j < M * 2; j ++) {
      
	    if (i == bipa.at(j)) {
          sum += 1;      
    	}
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
x = 0
y = 0
for i in a:
    if i %2 != 0:
        x+=1
    elif i%4 == 0:
        y+=1
if y >=x:
    print('Yes')
    exit()
else:
    if x+y == len(a) and y == x-1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 20112
// #include<bits/stdc++.h>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<cmath>
#include<cstdio>
#include<bitset>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

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

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e6+7;


int main(){
        // freopen("../in.txt","r",stdin);
        // freopen("../out.txt","w",stdout);
        ios::sync_with_stdio(0);
        cin.tie(0);
        int a,b;
        cin>>a>>b;
        // cout<<max(max(a+b,a-b),a*b)<<endl;
        for(int i=b-a+1;i<=a+b-1;++i)
                cout<<i<<" ";
        cout<<endl;

        return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;


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

    int n;
    cin >> n;

    int ar[n+1];
    for (int i=0;i<n;i++) cin >> ar[i];
    sort(ar,ar+n);

    if (n&1){
        cout << 0 << el;
        return 0;
    }

    cout << ar[n/2]-ar[n/2-1] << el;

    return 0;
}

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

#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n) {
    rep(i, n) par[i] = i;
  }

  void unite(int a, int b) {
    int ra = root(a);
    int rb= root(b);
    if (ra == rb) return;
    par[ra] = rb;
  }

  int root(int a) {
    if (par[a] == a) return a;
    return par[a] = root(par[a]);
  }

  bool same(int a, int b) {
    int ra = root(a);
    int rb = root(b);

    return ra == rb;
  }
};

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> nums(n);
  UnionFind uf(n);
  rep(i, n) cin >> nums[i];
  rep(i, m) {
    int x, y;

    cin >> x >> y;
    uf.unite(--x, --y);
  }

  int ans = 0;
  for (int i = 0; i < nums.size(); i++) {
    if (uf.same(i, --nums[i])) ++ans;
  }

  cout << ans << endl;

  
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <math.h>
using namespace std;
#define MAXSIZE 100005
#define PI 3.141592653589793
#define MOD_CONST 1000000007
typedef long long int lli;

int n, k, q;

int main(){
  cin >> n >> k >> q;
  vector<int> a(q);
  vector<int> num_correct(n);
  for(int i = 0; i < q; ++i){
    cin >> a[i];
    a[i]--;
    num_correct[a[i]]++;
  }
  
  for(int player = 0; player < n; ++player){
    int points = k - (q - num_correct[player]);
    if(points > 0) puts("Yes");
    else puts("No");
  }
  return 0;
}

Measured memory_bytes: 1408
S = input()
n = len(S) - 1
ans = 0
for i in range(2**n):
    bits = [(i>>j)&1 for j in range(n)]
    bits.append("")
    expr = ""
    for s, b in zip(S, bits):
        expr += s
        if b == 1:
            expr += "+"
    ans += eval(expr)
print(ans)

Measured memory_bytes: 39408
#include<stdio.h>
int main(){
  int c[51];
  int i,n,m,j;
  scanf("%d%d",&n,&m);
  for(i=1;i<=n;i++)c[i]=0;
  for(i=0;i<m*2;i++){scanf("%d",&j);c[j]++;}
  for(i=1;i<=n;i++)printf("%d\n",c[i]);
}


Measured memory_bytes: 128
#include <stdio.h>
typedef int kamei;
typedef long long int kameikameikamei;
kamei main(void) {
    kamei n, a;
    static kamei t[2000000];
    scanf("%d %d", &n, &a);
    for (kamei i = 0; i < n; i++) {
        scanf("%d", &t[i]);
    }
    kameikameikamei sum = 0;
    kamei cnt = 0;
    kamei csum = 0;
    kamei tmp;
    // printf("%d\n", sum);
    for (kamei i = 1; i < n; i++) {
        tmp = t[i] - t[i - 1];
        if (tmp > a) {
            sum += a;
        } else {
            sum += tmp;
        }
    }

    printf("%lld\n", sum + a);
    return 0;
}

Measured memory_bytes: 896
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.ReadInt()
	}

	cnt := 0
	for i, ae := range a {
		if i%2 == 0 && ae%2 == 1 {
			cnt++
		}
	}

	fmt.Println(cnt)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

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

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int x,y;cin>>x>>y;
    if(x+y>=10){
        cout<<"error"<<endl;
    }else{
        cout<<x+y<<endl;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define L(n) (n << 1)
#define R(n) (n << 1 | 1)
using namespace std;

int N, Q;
int A[500005];
int tree[2000005];

void build(int n, int l, int r) {
  if(l == r) {
    tree[n] = A[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(L(n), l, mid);
  build(R(n), mid + 1, r);
  tree[n] = tree[L(n)] | tree[R(n)];
}

void update(int n, int l, int r, int pos) {
  if(l == r) {
    tree[n] = A[pos];
    return;
  }
  int mid = (l + r) >> 1;
  if(pos <= mid) update(L(n), l, mid, pos);
  else update(R(n), mid + 1, r, pos);
  tree[n] = tree[L(n)] | tree[R(n)];
}

int query(int n, int l, int r, int ql, int qr) {
  if(ql <= l && r <= qr) {
    return tree[n];
  }
  int mid = (l + r) >> 1;
  int res = 0;;
  if(ql <= mid) res |= query(L(n), l, mid, ql, qr);
  if(qr > mid) res |= query(R(n), mid + 1, r, ql, qr);
  return res;
}

int main() {
  scanf("%d", &N);
  char ch;
  for(int i = 1; i <= N; i++) {
    cin >> ch;
    A[i] = (1 << (ch - 'a'));
  }
  scanf("%d", &Q);
  build(1, 1, N);
  int ty, l, r;
  while(Q--) {
    scanf("%d", &ty);
    if(ty == 1) {
      scanf("%d", &l);
      cin >> ch;
      A[l] = (1 << (ch - 'a'));
      update(1, 1, N, l);
    }else {
      scanf("%d %d", &l, &r);
//      cout << query(1, 1, N, l, r) << "\n";
      cout << __builtin_popcount(query(1, 1, N, l, r)) << "\n";
    }
  }
}

Measured memory_bytes: 10112
n, m = map(int, input().split())

flag = []
for _ in range(n):
    string = list(input())
    flag.append(string)

ans = 10**9
for white in range(1, n-1):
    for blue in range(1, n-1):
        red = n - white - blue
        if red <= 0:
            continue

        cnt = 0
        for i in range(white):
            for j in range(m):
                if flag[i][j] != "W":
                    cnt += 1

        for i in range(blue):
            for j in range(m):
                if flag[white+i][j] != "B":
                    cnt += 1

        for i in range(red):
            for j in range(m):
                if flag[white+blue+i][j] != "R":
                    cnt += 1

        if ans > cnt:
            ans = cnt

print(ans)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int c[15];
vector<int> v[15];

signed main(){
   IOS;
   int n,m,x;
   cin >> n >> m >> x;
   for(int i = 0; i < n; ++i) {
      cin >> c[i];
      v[i].resize(m);
      for(int j = 0; j < m; ++j) cin >> v[i][j];
   }
   int ans = (int)1e12;
   for(int caso = 1; caso < (1<<n); ++caso) {
      int res = 0;
      vector<int> tmp(m);
      for(int i = 0; i < n; ++i){
         int cur = 1<<i;
         if(cur & caso) {
            res += c[i];
            for(int j = 0;j < m;++j) {
               tmp[j]+=v[i][j];
            }
         }
      }
      bool ok = true;
      for(int i = 0; i < m; ++i){
         if(tmp[i] < x){
            ok = false;
            break;
         }
      }
      if(ok) ans = min(ans,res);
   }
   cout << ((ans == (int)1e12) ? -1 :  ans) << "\n";
}

/*
   2^0
   2^1
   2^2

   11110001

   00010000

*/

Measured memory_bytes: 3660
N = gets.to_i
min = N

1.upto(N-1) do |a|
  b = N-a
  n = (a.to_s+b.to_s).split('').map(&:to_i).inject(:+)
  # puts "a:#{a}, b:#{b}, n:#{n}"
  min = n if n < min
end

puts min

Measured memory_bytes: 1916
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for (auto& e : H) cin >> e;
  vector<int> G;
  H.PB(-1);
  for (int i = 0; i < N; i++) {
    if (H[i] != H[i+1]) G.PB(H[i]);
  }
  for (int i = 0; i < G.size()-1; i++) {
    if (G[i] > G[i+1]) G[i]--;
  }
  for (int i = 0; i < G.size()-1; i++) {
    if (G[i] > G[i+1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
	string a,b,c;
	cin >>a >> b >> c;
  	a[0]+='A'-'a';
  	b[0]+='A'-'a';
    c[0]+='A'-'a';
  cout <<a[0]<<b[0]<<c[0]<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a[1000000],i,ans[1000000];
    scanf("%d",&n);
    for(i=0;i<n-1;i++)
    {
        scanf("%d",&a[i]);
        ans[a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d\n",ans[i]);
    }
    return 0;
}


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

int main() {
    int n; cin >> n;
    int sum = 1;
    int minus = 1;
    rep(i, n) {
        int tmp; cin >> tmp;
        sum *= 3;
        if (tmp % 2 == 0) {
            minus *= 2;
        }
    }
    cout << sum-minus << endl;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(n,k):
	return 1 + floor(log(n,k))
	

N,K = map(int, stdin.readline().rstrip().split())
ans = solve(N,K)
print(ans)


Measured memory_bytes: 5740
<?php
    while($a = fgets(STDIN)){
        $b[] = trim($a);
    }
    foreach ($b as $value) {
        $c[] = explode(" ", $value);
    }
    $i = 0;
    while(($c[$i][0] + $c[$i][1]) != 0){
        if($c[$i][0] <= $c[$i][1]){
            echo $c[$i][0]." ".$c[$i][1].PHP_EOL;
        }else{
            echo $c[$i][1]." ".$c[$i][0].PHP_EOL;
        }
        $i++;
    }    


Measured memory_bytes: 10696
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n; cin >> n;
	if (n == 0) {
		cout << 0 << endl; return 0;
	}
	vector<int>ans;
	for (int i = 1; n; i *= -2) {
		if (n % (i * -2)) {
			ans.push_back(1);
			n -= i;
		}
		else {
			ans.push_back(0);
		}
	}
	reverse(all(ans));
	for (int p : ans)cout << p;
	cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int c[555][555];
int f[555][555];
int g[555][1111];
int main()
{
	//freopen("rabbit.in","r",stdin);
	//freopen("rabbit.out","w",stdout);
	int n=io::F(),M=1000000007;
	for(register int i=0;i<=n;++i)c[i][0]=c[i][i]=1;
	for(register int i=2;i<=n;++i)
		for(register int j=1;j<i;++j)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%M;
	f[1][0]=c[n][1];
	f[1][1]=c[n][1];
	for(register int i=1;i<=n;++i)
	{
		for(register int j=-500;j<=500;++j)
			if(g[i][j+500])
			{
				long long G=g[i][j+500];
				register int y=dmax(j,0);
				if(y+j&1)++y;
				for(;y+i<=n;y+=2)
					f[i+y][abs(j+y)/2]=(f[i+y][abs(j+y)/2]+G*c[n-i][y])%M;
			}
		for(register int j=0;j<=i;++j)
			if(f[i][j])
			{
				long long F=f[i][j];
				for(register int x=1;x+i<=n;++x)
					g[i+x][j-x+500]=(g[i+x][j-x+500]+F*c[n-i][x])%M;
				register int y=1;
				if(y+j&1)++y;
				for(;y+i<=n;y+=2)
				{
					int cnt=y;
					if(cnt<j)continue;
					int ck=j+(cnt-j)/2;
					if(abs(ck)+cnt+i>n)continue; 
					f[i+cnt][ck]=(f[i+cnt][ck]+F*c[n-i][0]%M*c[n-i][y])%M;
				}
			}
	}
	printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
int main(void) {
	int h, a;
	cin >> h >> a;
	if(h % a) cout<<h/a+1<<endl;
	else cout << h / a << endl;
	return 0;
}

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

// typedef long long int ll;
// using namespace std;

// int main()
// {

//     ll H, N;
//     cin >> H >> N;

//     ll inf = 999999999;

//     vector<ll> A(N), B(N);

//     vector<ll> dp(H + 1, inf);

//     for (int i = 0; i < N; i++)
//     {

//         cin >> A[i] >> B[i];
//     }

//     dp[0] = 0;

//     for (int i = 0; i < N; i++)
//     {

//         for (int j = 0; j <= H; j++)
//         {

//             int nj = min(j + A[i], H);
//             dp[nj] = min(dp[nj], dp[j] + B[i]);
//         }
//     }

// cout << dp[H] << endl;
// return 0;
// }

#include <bits/stdc++.h>

typedef long long int ll;
using namespace std;

int main()
{

    int H, N;
    cin >> H >> N;

    int inf = 999999999;

    vector<int> A(N), B(N);

    vector<vector<int>> dp(H + 1, vector<int>(N + 1, inf));

    for (int i = 0; i < N; i++)
    {

        cin >> A[i] >> B[i];
        
    }


    for (int i = 0; i <= N; i++)
    {

        dp[0][i] = 0;
        
    }
   

    for (int j = 0; j  <= min(A[0],H); j++)
    {

        dp[j][1] = B[0];
        
    }
  

    for (int i = 0; i < N; i++)
    {

        for (int j = 0; j <= H; j++)
        {

            if (j > A[i])
            {
                dp[j][i + 1] = min(dp[j][i], dp[j - A[i]][i + 1] + B[i]);
            }
            else{

                dp[j][i+1] = min(dp[j][i],dp[0][i+1] + B[i]);
            }
        }
    }
  

    cout << dp[H][N] << endl;
    return 0;
}

Measured memory_bytes: 39808
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

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

		final int N = sc.nextInt();
		
		for(int tt = 0; tt < N; tt++){
			long[] array = new long[8];
			
			for(int i = 0; i < 8; i++){
				array[i] = sc.nextLong(16);
			}
			
			final long def = sc.nextLong(16);
			
			int[] cal = new int[33];
			int[] det = new int[33];
			
			long ans = 0;
			for(int i = 0; i < 32; i++){
				det[i] += cal[i] % 2;
				for(int t = 0; t < 8; t++){
					det[i] += (((array[t] & ((1L << (i + 1)) - 1))) >> i) % 2;
				}
				det[i] += (((def & ((1L << (i + 1)) - 1))) >> i) % 2;
				
				boolean k = det[i] % 2 == 1;
				if(cal[i] % 2 != 0){
					//k =! k;
				}
				if(k){
					ans |= (1L << i);
				}
				
				int sum = 0;
				sum += cal[i];
				for(int t = 0; t < 8; t++){
					sum += ((k ? 1 : 0) + (((array[t] & ((1L << (i + 1)) - 1))) >> i)) % 2;
				}
				cal[i+1] = sum / 2;
			}
			
			//System.out.println(Arrays.toString(cal));
			//System.out.println(Arrays.toString(det));
			System.out.println(Long.toHexString(ans));
			
		}
	}

}

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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.141592653
#define oo 1000000007
#define loo 10000000000000007

#define prime 998244353 
#define mod 998244353 

ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int v[200100], pai[200100], rk[200100];

int find(int a){
    if(pai[a] == a) return a;
    else return pai[a] = find(pai[a]);
}

void Union(int u, int w){
    int a = find(u);
    int b = find(w);
    if(a == b) return;
    if(rk[a] < rk[b]){
        pai[a] = b;
        rk[b] += rk[a];
    }else{ 
        pai[b] = a;
        rk[a] += rk[b];
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    for (int i = 1; i <= n; ++i){
        pai[i] = i;
        rk[i] = 1;
    }
    for (int i = 0; i < m; ++i){
        int x, y; cin >> x >> y;
        Union(x, y);
    }
    set<int> yo;
    for (int i = 1; i <= n; ++i){
        yo.insert(find(i));
    }
    int ans = 0;
    for(auto l : yo){
        ans = max(ans, rk[l]);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 14376
#include <stdio.h>

struct point {
  float x;
  float y;
};

struct point sub(struct point a, struct point b)
{
  struct point ret;
  ret.x = a.x - b.x;
  ret.y = a.y - b.y;
  return ret;
}

int is_in(struct point a, struct point b, struct point c, struct point p)
{
  struct point ab, bp, bc, cp, ca, ap;
  float c1, c2, c3;

  ab = sub(b, a);
  bp = sub(p, b);

  bc = sub(c, b);
  cp = sub(p, c);

  ca = sub(a, c);
  ap = sub(p, a);

  c1 = ab.x * bp.y - ab.y * bp.x;
  c2 = bc.x * cp.y - bc.y * cp.x;
  c3 = ca.x * ap.y - ca.y * ap.x;

  if ((c1 > 0 && c2 > 0 && c3 > 0) ||
        (c1 < 0 && c2 < 0 && c3 < 0)) {
    return 1;
  } else {
    return 0;
  }
}

int main(void)
{
  float x1, y1, x2, y2, x3, y3, xp, xy;
  struct point p1, p2, p3, p4;

  while (scanf("%f %f %f %f %f %f %f %f",
        &x1, &y1, &x2, &y2, &x3, &y3, &xp, &xy) != EOF) {
    p1.x = x1;
    p1.y = y1;
    p2.x = x2;
    p2.y = y2;
    p3.x = x3;
    p3.y = y3;
    p4.x = xp;
    p4.y = xy;

    if (is_in(p1, p2, p3, p4)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,a=0,b=0;
  cin >> n;
  if(0<n%100&&n%100<=12)a++;
  if(0<n/100&&n/100<=12)b++;
  if(a==1&&b==1)printf("AMBIGUOUS");
  if(a==1&&b!=1)printf("YYMM");
  if(a!=1&&b==1)printf("MMYY");
  if(a!=1&&b!=1)printf("NA");
}

Measured memory_bytes: 256
N = gets.to_i
XY = N.times.map { gets.split.map(&:to_i) }
sum = 0.0
(0...N).to_a.permutation.each do |path|
  sum += path.each_cons(2).reduce(0) do |acc, (u, v)|
    acc + Math.sqrt((XY[u][0] - XY[v][0]) ** 2 + (XY[u][1] - XY[v][1]) ** 2)
  end
end
ans = sum / (1..N).reduce(:*)
puts ans

Measured memory_bytes: 1788
#include<stdio.h>
#define KETA 119
int main(void){

    int a[KETA];
    int b[KETA];
    int i,x,kuri=1,kaisuu;
    
    for(i=0;i<KETA;i++) a[i]=0;
    scanf("%d",&kaisuu);
    for(x=1;x<=kaisuu;x++){
        for(i=KETA-1;i>=0;i--){
            b[i]=(a[i]*x+kuri)%10;
            kuri=(a[i]*x+kuri)/10;
        }
        
        for(i=0;i<KETA;i++) a[i]=b[i];
        for(i=0;i<KETA;i++) b[i]=0;
    }
	    for(i=0;a[i]==0&&i<KETA;i++);
        if(i==12) printf("0");
        for(;i<KETA;i++){
            printf("%d",a[i]);
        }
        printf("\n");
        
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n,i,candies=0;
    scanf("%d",&n);
    if(n>=1 && n<=100)
    {
        for(i=1;i<=n;i++){
            candies=candies + i;
        }
    }
    printf("%d\n",candies);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split())  )
a.sort()
alen = len(a)

if alen %2 == 1:
  s = 2* sum(a[::-1][ :(alen+1)//2 ]) - a[-1] - a[::-1][alen//2]
else:
  s = 2* sum(a[::-1][ :(alen)//2 ]) - a[-1] 
print(s)

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

using namespace std;

int main() {

    int num, cntMax = -1;
    int cnt[101] = {0};

    while(cin >> num) {
       ++cnt[num];
    }

    for(int i = 1; i <= 100; ++i) {
        cntMax = max(cntMax, cnt[i]);
    }

    for(int i = 1; i <= 100; ++i) {
        if(cnt[i] == cntMax) cout << i << endl;
    }

}

Measured memory_bytes: 1160
def main():
    x = int(input())

    if 400 <= x < 600:
        print(8)
    elif 600 <= x < 800:
        print(7)
    elif 800 <= x < 1000:
        print(6)
    elif 1000 <= x < 1200:
        print(5)
    elif 1200 <= x < 1400:
        print(4)
    elif 1400 <= x < 1600:
        print(3)
    elif 1600 <= x < 1800:
        print(2)
    else:
        print(1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61764
#include<stdio.h>
void swap(int* a,int* b){
	int buf = *a;
	*a = *b;
	*b = buf;
}
int main(){
	int cup[3]={1,0,0};
	char str[10];
	int i;
	char a,b;
	while(~scanf("%s",str)){
		sscanf(str,"%c,%c",&a,&b);
		swap(&cup[a-'A'],&cup[b-'A']);
	}
	for(i=0;i<3;i++){
		if(cup[i]==1){
			printf("%c\n",i+'A');
		}
	}
	return 0;
}

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

int main (void)
{
    long i;
    char t[200010];

    scanf("%s", t);

    for (i = 0; t[i] != '\0'; i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }

    printf("%s", t);

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vt vector
#define pb push_back
#define pob pop_back
#define vi vt<int>
#define vvi vt<vi>
#define vii vt<ii>
#define vvii vt<vii>
typedef long long ll;
#define For(i,a,b) for(int i = a; i < b; i++)
#define foR(i,a,b) for(int i = a; i <= b; i++)
#define roF(i,a,b) for(int i = a - 1; i >= b; i--)
#define Rof(i,a,b) for(int i = a; i >= b; i--)

signed main (){
	/*
	freopen(".inp","r",stdin);
	freopen(".out","w",stdout);
	*/
	int n, k;
	cin >> n >> k;
	cout << ((k == 1) ? 0 : (n-k));
}



Measured memory_bytes: 256
A = ['maerd', 'remaerd', 'esare', 'resare']
S = input()[::-1]
cur = 0
N = len(S)
ans = 'YES'
while cur < N:
    if S[cur: cur + 7] in A:
        cur += 7
    elif S[cur: cur + 6] in A:
        cur += 6
    elif S[cur: cur + 5] in A:
        cur += 5
    else:
        ans = 'NO'
        break

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
 int n,l;
 cin>>n>>l;
 string s[n],t;
 for(int i=0;i<n;i++)cin>>s[i];
 set<string> x;
 int ans=0;
 sort(s,s+n);
 for(int i=0;i<s[0].size();i++){
   int k=1;
   while((l-i)%k==0)k<<=1;
   ans^=k;
 }
 for(int i=1;i<n;i++){
  int j0=0;
  while(j0<s[i].size()&&j0<s[i-1].size()&&s[i-1][j0]==s[i][j0])j0++;
  for(int j=j0;j<s[i].size();j++){
    int k=1;
   while((l-j)%k==0)k<<=1;
   ans^=k;
  }
 }
 if(ans)cout<<"Alice"<<endl;
 else cout<<"Bob"<<endl;

 




}


        


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    when {
    	n == 1 || n == 2 || n == 3 || n == 5 || n == 6 || n == 9 || n == 10 || n == 13 || n == 17 -> {
    		println("No")
    	}
		else -> {
		println("Yes")
		}
	}
    
}

Measured memory_bytes: 31956
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int s[3010][3010];
int a[2][1010][1010];
int main(){
	int N,K;
	cin>>N>>K;
	rep(i,N){
		int x,y;
		char c;
		cin>>x>>y>>c;
		if(c=='B') y += K;
		x %= 2*K;
		y %= 2*K;
		s[x][y]++;
		s[x+K][y+K]++;
		s[x][y+K]--;
		s[x+K][y]--;
	}
	rep(i,3*K) rep(j,3*K) s[i][j+1] += s[i][j];
	rep(i,3*K) rep(j,3*K) s[i+1][j] += s[i][j];
	int ans = 0;
	rep(i,K*3) rep(j,K*3){
		int p = (i/K+j/K)%2;
		a[p][i%K][j%K] += s[i][j];
	}
	rep(p,2) rep(i,K) rep(j,K) chmax(ans,a[p][i][j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 43520
N = int(input())
weights = list(map(int, input().split()))
ans = float('inf')

for s in range(1, N-1):
    sum_1 = sum(weights[:s+1])
    sum_2 = sum(weights[s+1:])

    ans = min(ans, abs(sum_1-sum_2))

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int LIMIT = 4000;
const int MAXN = 4005;
const int MOD = 998244353;
int add(int a, int b){
	return (a + b) % MOD;
}
int sub(int a, int b){
	return (a + MOD - b) % MOD;
}
int mul(int a, int b){
	return 1ll * a * b % MOD;
}
int pascal[MAXN][MAXN];
int pow2[MAXN];
void precalculate(){
	pow2[0] = 1;
	for(int i = 1; i <= LIMIT; i++) pow2[i] = mul(2, pow2[i - 1]);
	pascal[0][0] = 1;
	for(int i = 1; i <= LIMIT; i++){
		pascal[i][0] = 1;
		for(int j = 1; j <= i; j++){
			pascal[i][j] = add(pascal[i - 1][j], pascal[i - 1][j - 1]);
		}
	}
}
int get(int cur, int k){
	int ans = 0;
	for(int i = 1; i <= k; i++){
		int r = cur - i;
		if(r > k) continue;
		if(r < i) break;
		ans++;
	}
	return ans;
}
int stars(int n, int k_big, int k_small){
	return pascal[n + k_small - 1][k_big + k_small - 1];
}
int solve(int s, int pairs, int free){
	int total = 0;
	for(int zeros = 0; zeros <= pairs; zeros++){
		int ans = pascal[pairs][zeros];
		ans = mul(ans, pow2[pairs - zeros]);
		ans = mul(ans, stars(s, pairs - zeros, free));
		total = add(total, ans);
	}
	return total;
}
int main(){
	precalculate();
	int n, k;
	cin >> k >> n;
	for(int cur = 2; cur <= 2 * k; cur++){
		int pairs = get(cur, k);
		//printf("cur: %d, parova %d\n", cur, pairs);
		int ans = solve(n, pairs, k - 2 * pairs);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 61440
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}
ll modComb(ll n,ll a){
  ll x=1,y=1;
  rep(i,a){
    x*=n-i;
    x%=MOD;
    y*=i+1;
    y%=MOD;
  }
  y=modPow(y,MOD-2);
  return (x*y)%MOD;
}

int main(){
  ll N,M,K,ans=0,x;
  cin >> N >> M >> K;
  x=modComb(N*M-2,K-2);
  rep(i,N){
    ll k;
    k=i*(N-i);
    k%=MOD;
    k*=M;
    k%=MOD;
    k*=M;
    k%=MOD;
    k*=x;
    k%=MOD;
    ans+=k;
    ans%=MOD;
  }
  rep(i,M){
    ll k;
    k=i*(M-i);
    k%=MOD;
    k*=N;
    k%=MOD;
    k*=N;
    k%=MOD;
    k*=x;
    k%=MOD;
    ans+=k;
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.*;
import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();


	public void run() {
		TCase:while(true){
			int n=sc.nextInt(),q=sc.nextInt();
			if(n==0)return;
			int[][] ds=new int[n][];
			for(int i=0;i<n;i++){
				int k=sc.nextInt();
				ds[i]=new int[k];
				for(int j=0;j<k;j++)
					ds[i][j]=sc.nextInt();
			}

			int max=0,ind=-1;
			for(int d=1;d<=100;d++){
				int num=0;
				for(int j=0;j<n;j++){
					if(Arrays.binarySearch(ds[j],d)>=0)num++;
				}
				if(num>max && num>=q){
					max=num;
					ind=d;
				}
			}

			if(ind>=0)ln(ind);
			else ln(0);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 60736
import bisect
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    ai = bisect.bisect_left(A, b)
    ci = bisect.bisect_right(C, b)
    ans += (N - ci)*ai

print(ans)

Measured memory_bytes: 108684
N = int(input())
lst = list(map(int,input().split()))
anslst = [sum(lst)-2*sum(lst[1::2])]
for i in range(N-1):
    ans = 2*lst[i] - anslst[i]
    anslst.append(ans)
anslst = map(str, anslst)
print(" ".join(anslst))

Measured memory_bytes: 18108
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    double n;
    boolean[] bitsI; // 8テヲツ閉エテヲツ閉ー
    boolean[] bitsD; // 4テ・ツーツ湘ヲツ閉ー
    boolean NA;
    int a;
    double b;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextDouble();
	    if(n<0) break;
	    bitsI = new boolean[8];
	    bitsD = new boolean[4];
	    NA = false;

	    a = (int)n/1;
	    b = n - a;

	    NA = getBitD() || getBitI();


	    if(NA) System.out.println("NA");
	    else show();
	}
    }

    boolean getBitI(){
	if(a>255) return true;
	int c = 128;
	for(int i=0; i<bitsI.length; i++){
	    if(a>=c){
		bitsI[i] = true;
		a -= c;
	    }
	    c /= 2;
	}
	if(a==0) return false;
	return true;
    }

    boolean getBitD(){
	double c = 0.5;
	for(int i=0; i<bitsD.length; i++){
	    if(b>=c){
		bitsD[i] = true;
		b -= c;
	    }
	    c /= 2;
	}
	if(b==0.0) return false;
	return true;
    }
		
    void show(){
	for(int i=0; i<bitsI.length; i++)
	    System.out.print(bitsI[i] ? "1" : "0");
	System.out.print(".");
	for(int i=0; i<bitsD.length; i++)
	    System.out.print(bitsD[i] ? "1" : "0");
	System.out.println();
    }
}

Measured memory_bytes: 26104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <sstream>
using namespace std;

void solve() {
	int n;
	cin >> n;
	long long ans = 0LL;
	for(int i = 1; i < n; i++) {
		long long temp = ((n - i) == 1) ? 1 : 2;
		for(int j = 2; j * j <= (n - i); j++) {
			if((n - i) % j == 0) {
				temp += (((n - i) / j) == j) ? 1 : 2;
			}
		}
		ans += temp;
	}
	cout << ans << endl;
}
 
int main () {
	int t = 1;
	for(int tt = 0; tt < t; tt++) solve();
	return 0;
}

Measured memory_bytes: 3548
// AOJ 1219: Pump up Batteries
// 2017.10.23 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 102
typedef struct { int t, id; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].id < que[i].id)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].id < que[min].id)) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

int deq(void)
{
	if (qsize == 0) return 0;
//	*t = que[0].t, *id = que[0].id;
	que[0] = que[--qsize];
	min_heapify(0);
	return 1;
}

void enq(int t, int id)
{
	int i, min;

	i = qsize++;
	que[i].t = t, que[i].id = id;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		que[min].t == que[i].t && que[min].id > que[i].id)) {
		QUE tt = que[i]; que[i] = que[min]; que[min] = tt;
		i = min;
	}
}

int mque[MAX], top, end, mqsz;
typedef struct { int r, i, n, u[51], c[51]; } T;    // r:remain time
T tbl[MAX], *tp;

int main() 
{
	int n, lim, id, id0, i, t, ans;

	while (scanf("%d%d", &n, &lim) && n > 0) {
		qsize = 0;
		for (tp = tbl, id = 0; id < n; id++, tp++) {
			for (i = 0; scanf("%d", &t) && t > 0; i++) tp->u[i] = t, scanf("%d", &tp->c[i]);
			tp->i = 0, tp->n = i, enq(tp->u[0], id);
		}

		ans = 0, top = end = 0, mqsz = 0;
		for (t = 1; t <= lim; t++) {
			id0 = -1;
			if (mqsz > 0) id0 = mque[top], ans += mqsz - 1;
			while (qsize > 0 && que[0].t == t) {
				id = que[0].id, deq();
				tp = tbl + id, tp->r = tp->c[tp->i];
				mqsz++, mque[end] = id; if (++end == MAX) end = 0;
			}
			if (mqsz == 0) continue;
			if ((id = mque[top]) != id0) continue;
			tp = tbl + id;
			if (--tp->r == 0) {
				if (++tp->i == tp->n) tp->i = 0;
				enq(t + tp->u[tp->i], id);
				mqsz--; if (++top == MAX) top = 0;
			}
		}
		printf("%d\n", ans);
	}
	return 0; 
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<iterator>
#include<list>
#include<math.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<utility>
#include<numeric>
#include<functional> 
#define sz(a) int((a).size()) 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i<v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define MOD 		1000000007
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define pi 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define N 1000006
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef priority_queue<ii,vii,greater<ii> > spq;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%MOD;y/=2;x=(x*x)%MOD;}return ans;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}
int main(){
	int n; cin>>n; string s,t; cin>>s>>t;
	ll ans,ct=0;
	for(int i=0;i<n;i++){
		ct=0; ll dct=0;
		for(int j=i;j<n;j++,dct++){
			if(s[j]==t[dct]) ++ct;
			else {
			ct=0;break;	
			}
		}
		if(ct!=0) break;
	}
	//trace1(ct);
	cout<<(ct+2*(n-ct))<<endl;
}

Measured memory_bytes: 384