akhauriyash/Code-Regression huggingface dataset:
let id x = x

let (n,c,k) = Scanf.scanf "%d %d %d\n" (fun n c k -> (n,c,k))
  
let repeat f =
  let rec loop acc = function
    | 0 -> List.rev acc
    | n -> loop (f () :: acc) (n-1) in
  loop []

let t = repeat (fun () -> Scanf.scanf "%d\n" id) n

let rec partition n a b = function
  [] -> (a, b)
| x::xs -> if x < n then partition n (x::a) b xs
              else partition n a (x::b) xs

let rec quick_sort = function
  [] -> []
| x::xs ->
    let (m, n) = partition x [] [] xs in
    quick_sort m @ (x :: quick_sort n)

let tlist = quick_sort t

let check' tlist c k =
let rec check tlist ans t' d cnt =
  match tlist with
  | [] -> ans
  | hd :: rest -> if hd > t' then check tlist ans hd d cnt else
     match cnt with
     | 0 -> check rest ans t' (hd+k) (cnt+1)
     | _ -> if t' > d || cnt = c then check tlist (ans + 1) t' d 0
             else check rest ans t' d (cnt+1)
in check tlist 1 1 0 0

let ans = check' tlist c k

let () = Printf.printf "%d\n" ans

Measured memory_bytes: 21376
use std::cmp::min;

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

fn main() {
    let s = scan!();

    let mut num0 = 0;
    for (i, c) in s.chars().enumerate() {
        if i % 2 == 0 {
            if c == '1' {
                num0 += 1
            }
        } else {
            if c == '0' {
                num0 += 1
            }
        }
    }

    let mut num1 = 0;

    for (i, c) in s.chars().enumerate() {
        if i % 2 == 0 {
            if c == '0' {
                num1 += 1
            }
        } else {
            if c == '1' {
                num1 += 1
            }
        }
    }

    println!("{}", min(num0, num1));
}


Measured memory_bytes: 4352
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	// n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	strA := sc.Text()
	strAList := strings.Split(strA, " ")
	aList := []float64{}
	for _, v := range strAList {
		intV, _ := strconv.Atoi(v)
		aList = append(aList, float64(intV))
	}
	sum := float64(0.0)
	for _, v := range aList {
		sum += 1 / v
	}
	fmt.Println(1 / sum)
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll a[52];
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    while(true){
        int l = 0;
        for(int i = 1; i < n; i++){
            if(a[i] > a[l]) l = i;
        }
        if(a[l] < n) break;
        ll c = a[l] / n;
        for(int i = 0; i < n; i++){
            if(i == l) a[i] %= n;
            else a[i] += c;
        }
        ans += c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
  string a,b;
  int s = 0;
  cin >> a;
  cin >> b;
  for(int i=0;i<a.size();i++){
  if(a.at(i)!=b.at(i)){
  break;

  }
        s++;
  }
  if(s == a.size()){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
sd = input()
t = input()

found = False
for i in range(len(sd) - len(t), -1, -1):
    for j in range(len(t)):
        if sd[i+j] != "?" and sd[i+j] != t[j]:
            break
    else:
        ans = sd[:i] + t + sd[i+len(t):]
        ans = ans.replace("?", "a")
        break
else:
    ans = "UNRESTORABLE"

print(ans)


Measured memory_bytes: 3060
a = gets.chomp
if a == "SUN"
  puts 7
elsif a == "MON"
  puts 6
  elsif a == "TUE"
  puts 5
  elsif a == "WED"
  puts 4
  elsif a == "THU"
  puts 3
  elsif a == "FRI"
  puts 2
elsif a == "SAT"
  puts 1
end 

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

signed main(void){
    int n; cin>>n;
    string s; cin>>s;
  
    rep(i,n){
        string s1="", s2 = ""; 
        rep(j,i){
            s1 += s[j]; 
        }
        for(int j = i; j<n;j++){
            s2 += s[j];
        }
        
        if(s1 == s2){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

w_list = [(i+1, n) for i, n in enumerate(a_list)]
w_list = sorted(w_list, key=lambda x: x[1])
w_list = [str(w[0]) for w in w_list]
ans = ' '.join(w_list)
print(ans)


Measured memory_bytes: 25132
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int):
    i = 1
    ret = float('inf')
    while i * i <= N:
        if N % i == 0:
            tmp = N // i
            ret = min(ret, max(len(str(i)), len(str(tmp))))
        i += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;


int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	LL n,m;
	cin>>n>>m;
	LL res = min(n, m/2);
	n -= res;
	m -= res * 2;

	if (n == 0)
	{
		res += m / 4;
	}

	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    int A, B, M;
    cin >> A >> B >> M;
    int a[A], b[B], x[M], y[M], c[M];
    rep(i,A) cin >> a[i];
    rep(i,B) cin >> b[i];
    rep(i,M) cin >> x[i] >> y[i] >> c[i];

    int amin = INF;
    rep(i,A) amin = min(amin, a[i]);
    int bmin = INF;
    rep(i,B) bmin = min(bmin, b[i]);

    int sum = INF;
    rep(i,M) sum = min(sum, a[x[i]-1] + b[y[i]-1] - c[i]);

    cout << min(sum, amin + bmin) << endl;

}




//              g++ -std=c++1z






Measured memory_bytes: 2176
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 22


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
ll n;
vvi a(N,vi(N)),dp(N,vi(1<<N,-1));
ll count(ll i,ll mask)
{
	if(i==n)
		return 1;
	if(dp[i][mask]!=-1)
		return dp[i][mask];
	dp[i][mask]=0;
	for(ll j=0;j<n;++j)
	{
		if(!(mask&(1<<j)) && a[i][j])
		{
			dp[i][mask]=(dp[i][mask]+count(i+1,mask|(1<<j)))%mod;
		}
	}
	return dp[i][mask];
}
void solve()
{
	cin>>n;
	for(ll i=0;i<n;++i)
	{
		for(ll j=0;j<n;++j)
		{
			cin>>a[i][j];
		}
	}
	dp[0][0]=count(0,0);
	cout<<dp[0][0]<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 754048
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

const int MAX_V = 100;
vector<int> G[MAX_V];

int V, E;
bool seen[MAX_V];

int dfs(int s) {
    int see_c = 0;
    rep(i, V) if (seen[i]) see_c++;
    if (see_c == V) return 1;

    int ret = 0;
    rep(i, G[s].size()) {
        if (!seen[G[s][i]]) {
            seen[G[s][i]] = true;
            ret += dfs(G[s][i]);
            seen[G[s][i]] = false;
        }
    }
    return ret;
}

void solve() {
    seen[0] = true;
    cout << dfs(0) << endl;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        scanf("%d %d", &V, &E);
        for (int i = 0; i < E; ++i) {
            int s, t;
            scanf("%d %d", &s, &t);
            s--, t--;
            G[s].push_back(t);
            G[t].push_back(s);
        }

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
X = int(input())

dp = [0 for _ in range(X+1)]
dp[0] = 1

for i in range(X):
    if dp[i] == 1:
        for v in range(100, 105 + 1):
            if i+v <= X:
                dp[i+v] = 1
print(dp[X])

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

char field[8][12];
int n, a, b;

void fire(int x, int y){
    field[x][y] = '0';
    for(int i = -3; i <= 3; i++){
        if( x+i >= 0 && x+i < 8 && field[x+i][y] == '1' ) fire(x+i, y);
        if( y+i >= 0 && y+i < 8 && field[x][y+i] == '1' ) fire(x, y+i);
    }
}

int main(){
    string dummy;
    cin >> n;
    for(int m = 1; m <= n; m++){
        getline(cin, dummy);
        for(int i = 0; i < 8; i++){
            cin >> field[i];
        }
        cin >> a >> b;
        fire(b-1, a-1);
        cout << "Data " << m << ":" << endl;
        for(int i = 0; i < 8; i++){
            cout << field[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1176
//A
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&a!=c) {
		printf("Yes");
		return 0;
	}
	if(a==c&&a!=b) {
		printf("Yes");
		return 0;
	}
	if(c==b&&a!=c) {
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int x = nextInt();

		int[] a = nextInts();
		Arrays.sort(a);
		int ans=0;
		for(int i=0;i<N;i++){
			x-=a[i];
			if(x<0){
				break;
			}
			ans++;
		}
		if(x>0){
			ans--;
		}
		System.out.println(ans);
	}

	public static boolean isExpN(long a,int base){
		int x=1;
		while((int)Math.pow(x, 2) <= a){
			if((int)Math.pow(x, 2) == a){
				return true;
			}
			x*=base;
		}
		return false;
	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22612
n = int(input())
a = [int(x) for x in input().split()]

count = 0
set = [a[0]]

for i in range(n-1):
    if a[i] >= a[i+1]:
        count += 1
if count == n-1:
    print(1000)
    exit()

for i in range(1,n):
    if a[i-1] != a[i]:
        set += [a[i]]

#print(set)
num = len(set)
seifu = 0

set2 = [set[0],set[1]]

if set[0] > set[1]:
    seifu = -1
else:
    seifu = 1

i_now = 1

for i in range(2,num):
    if set[i-1] < set[i] and seifu < 0:
        set2 += [set[i]]
        seifu = 1
        i_now += 1
    elif set[i-1] < set[i] and seifu > 0:
        set2[i_now] = set[i]
    elif set[i-1] > set[i] and seifu > 0:
        set2+= [set[i]]
        i_now += 1
        seifu = -1
    elif set[i-1] > set[i] and seifu < 0:
        set2[i_now] = set[i]


if set2[0] > set2[1]:
    set2 = set2[1:]

if len(set2)%2 != 0:
    set2 = set2[:len(set2)-1]



buy = 0
coin = 1000
num2 = 0

for i in range(len(set2)-1):
    if set2[i] < set2[i+1] and buy == 0:
        num2 = coin//set2[i]
        coin = coin - set2[i] * num2
        buy = 1

    elif set2[i] > set2[i+1] and buy == 1:
        coin = coin + num2 * set2[i]
        buy = 0


coin += num2*set2[len(set2)-1]

print(coin)


Measured memory_bytes: 9340
#include<stdio.h>
int main(void){
int a,b;
scanf("%d %d",&a,&b);
if(a<b){
	printf("a < b\n");
}
else if(a>b){
	printf("a > b\n");
}
else{
	printf("a == b\n");
}
return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define mm(a,b) a>b? a:b
int main()
{
  int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++)cin>>s[i];
  
  sort(s.begin(),s.end());
  set<string>set_s;
  int max=0;
  vector<int>c;
  int count=1;
  set_s.insert(s[0]);
  for(int i=1;i<n;i++)
  {
    set_s.insert(s[i]);
    if(s[i]==s[i-1])
    {
      count++; 
    }
    else
    {
      max=mm(max,count);
      c.push_back(count);
      count=1;
    }
   
     if(i==n-1){
      max=mm(max,count);
      c.push_back(count);
     }
  }
  int p=0;
  for(auto u:set_s)
  { 
    if(c[p]==max)cout<<u<<endl;
    p++;
  }
 return 0;
}
  

Measured memory_bytes: 24436
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
 
int main ()
{
    ll X,K,D;
    cin >> X >> K >> D;

    X = abs(X);
    ll t = X / D;

    if (t > K) {
        cout << abs(X) - abs(K * D) << endl;
        return 0;
    }

    K -= t;
    X = abs(X) - abs(t * D);

    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << abs(X - abs(D)) << endl;
    }

    return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

vvi adj;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  int m;
  cin >> m;

  int e;
  cin >> e;
  adj = Mat(n + 2, 0, 0);

  vector<int> f(m + 2);
  multiset<int> freq;

  while (e--) {
    int u, v;
    cin >> u >> v;
    adj[u].eb(v);
    ++f[v];
  }

  for (int i = 1; i <= m; ++i) {
    freq.emplace(f[i]);
  }

  int ans = 0;
  for (int u = 1; u <= n; ++u) {
    for (int v : adj[u]) {
      freq.erase(freq.find(f[v]));
      --f[v];
      freq.emplace(f[v]);
    }

    ans = max(ans, (int)adj[u].size() + *freq.rbegin());

    for (int v : adj[u]) {
      freq.erase(freq.find(f[v]));
      ++f[v];
      freq.emplace(f[v]);
    }
  }

  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    int n;
    cin >> n;

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

    vector<pii> s(n);
    for (int i = 0; i < n; ++i) {
        s[i] = mp(a[i], i);
    }
    sort(all(s));
    int ans = 0;

    for (int i = 0; i < n; ++i) {
        if (i % 2 != s[i].second % 2) {
            ++ans;
        }
    }
    cout << (ans + 1) / 2 << "\n";

}


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

int h[20],c[20];
int main()

{	
	int n,b=0,max;
	cin >> n;
	for (int i=0;i<n;i++)
		cin >>h[i];
		
	max=h[0];
	
	for (int i=0;i<n;i++)
	{
		if (h[i]>=max)
		{ b++;
		  max=h[i];	}
	}
	cout << b;
}


Measured memory_bytes: 256
s = int(input())
array = [s]
 
m = 2
while m < 100000:
  if (s % 2 == 0):
    s = s / 2
  else:
    s = 3 * s + 1
  
  if s in array:
    print(m)
    break
  else:
    array.append(s)
    m += 1

Measured memory_bytes: 2940
// ABC_170_B

#include <iostream>
using namespace std;

int main()
{
  int x, y;
  cin >> x >> y;

  bool flag = false;

  for (int i = 0; i <= x; ++i) {
    int ans = 4 * i + 2 * (x - i);

    if(ans == y) {
      flag = true;
      break;
    }
    else continue;
   }

  if(flag) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
  
using namespace std;
  
#define EPS 1e-8
#define equal(a,b) (fabs(a-b) < EPS)
#define lt(a,b) (a-b < -EPS)
#define le(a,b) (lt(a,b) || equal(a,b))
#define MAX_N 86401
#define MAX_L 1000000
#define END 86400
  
struct P{
    double s,t,u;
    P(){}
    P(double s,double t,double u) : s(s),t(t),u(u) {}
    bool operator < (const P &p)const{
	return s < p.s;
    }
};
 
int main(){
    int N;
    double L;
    P p[MAX_N];
    while(cin >> N >> L,N){
	for(int i = 0 ; i < N ; i++){
	    cin >> p[i].s >> p[i].t >> p[i].u;
	}
	sort(p,p+N);
	double l = 0, r = MAX_L;
	for(int i = 0 ; i < 150 ; i++){
	    double mid = (l + r) / 2.0;
	    bool ok = true;
	    double rem[2]; rem[0] = L;
	    for(int j = 0 ; j < 2 ; j++){
		double prev = 0;
		for(int k = 0 ; k < N ; k++){
		    rem[j] = min(L,rem[j]+mid*(p[k].s-prev));
		    double d = p[k].t-p[k].s;
		    rem[j] = min(L,rem[j]+d*(mid-p[k].u));
		    if(le(rem[j],0)){ ok = false; break; }
		    prev = p[k].t;
		}
		rem[j] = min(L,rem[j]+mid*(END-prev));
		if(j == 0){ rem[1] = rem[0]; }
		else if(lt(rem[1],rem[0])){
		    ok = false;
		}
		if(!ok){ break; }
	    }
	    if(ok){ r = mid; }else{ l = mid; }
	}
	printf("%.8f\n",r);
    }
    return 0;
}

Measured memory_bytes: 5184
a, b = map(int, input().split())

for i in range(1, 999):
    west_tower = 0
    for n in range(1, i + 1):
        west_tower += n
    east_tower = west_tower + (i + 1)
    if west_tower - a == east_tower - b:
        print(west_tower - a)
        break
    else:
        pass


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

int main(){
    int W,a,b;
    cin >> W>> a >>b;
    if(max(a,b)-min(a,b)-W>0)cout << max(a,b)-min(a,b)-W << endl;
    else cout << 0 << endl;
    return 0;
}


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


int main()
{
  string S,T;
  cin >> S; cin >> T;
  cout << T << S << endl;
}

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

int main(){
    int n, x, i, tmp, ans=0;
    vector<int>v;
    
    cin >> n>> x;
    for (i=0; i<n; i++) {
        cin>>tmp;
        v.push_back(tmp);
        ans++;
        x -= tmp;
    }
    
    sort(v.begin(), v.end());
    while (x-v[0]>=0) {
        ans++;
        x -=v[0];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int num, a, tmp, cnt;

  cnt = INT_MAX;
  cin >> num;

  for(int i=0; i<num; i++) {
    cin >> a;
    tmp = 0;
    while(a % 2 == 0) {
      a /= 2;
      tmp++;
    }
    if (tmp < cnt) {
      cnt = tmp;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &k, &s)

	for i, v := range s {
		if i+1 == k {
			fmt.Print(string(v + 32))
		} else {
			fmt.Print(string(v))
		}
	}
}


Measured memory_bytes: 512
import Data.List
import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as B

import Control.Monad

solve :: [[Int]] -> [String]
solve l = removeIdx $ sortOn (\(x,_)-> x) $ iter 1 1 (sortOn (\(_, [x,y]) -> x*10^9+y) (addIdx l)) where
    iter _ _ [] = []
    iter cp i ((idx,[p,_]):cs)
        | cp == p   = (idx, (toString p ++ toString i)) : iter p (i+1) cs
        | otherwise = (idx, (toString p ++ toString 1)) : iter p 2 cs

    toString n = iter stn (6 - length stn) where
        iter ac 0 = ac
        iter ac i = iter ('0':ac) (i-1)
        stn = show n

    addIdx = iter 0 where
        iter _ [] = []
        iter i (x:xs) = (i, x):iter (i+1) xs  
    removeIdx = iter where
        iter [] = []
        iter ((_,x):xs) = x:iter xs  
    
readLine:: B.ByteString -> [Int]
readLine s = map (fst . fromJust . B.readInt) (B.words s)

readLines :: [B.ByteString] -> [[Int]]
readLines [] = []
readLines (s:ss) = readLine s : readLines ss

main :: IO() 
main = do
    contents <- B.getContents
    let lines = B.lines contents
        [n,m] = readLine (head lines)
        l = readLines (tail lines)
    let ans = solve l
    mapM_ putStrLn ans


Measured memory_bytes: 57980
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int n, m, q, ans;
vint a(q), b(q), c(q),d(q);

void dfs(int i, int r, int *x) {
	if (r == n) {
		int res = 0;
		rep(j, q) {
			if (x[b[j]-1] - x[a[j]-1] == c[j]) {
				res += d[j];
			}
		}
		ans = max(ans, res);
		return;
	}
	if (i == m+1) {
		return;
	}
	x[r] = i;
	dfs(i, r + 1, x);
	
	dfs(i + 1, r, x);


	return ;

}

int main(void) {
	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	int x[10];
	ans = 0;
	dfs(1, 0, x);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '9') {
      s[i] = '1';
    } else if (s[i] == '1') {
      s[i] = '9';
    }
  }
  
  cout << s << '\n';
}

Measured memory_bytes: 3628
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	int n;
  	cin>>n;
  	vector<pair<int,int> > v;
  	for(int i=0;i<n;i++){
      int temp;	
      cin>>temp;
      v.push_back({temp,i+1});
    }
  	sort(all(v));
  	for(int i=0;i<v.size();i++)cout<<v[i].second<<" ";
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    // 二分探索
    ll l = 0; // NG側
    ll r = 1e9; // OK側

    while (r - l > 1) {
        ll m = (l + r) / 2;
        auto f = [&](ll x) {
            // 全丸太をx以下にするために切る回数
            ll count = 0;
            // 一本ずつ考えていけば良い
            for (ll i = 0; i < n; ++i) {
                count += (a[i] - 1) / x; // ここは具体例を考えて立式する
            }

            return count <= k;
        };

        if (f(m)) {
            r = m;
        } else {
            l = m;
        }
    }

    cout << r << endl;
}

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

char upper(char c) {
	if (c >= 'a' && c <= 'z')
		return c + ('A' - 'a');
	return c;
}

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << upper(a[0]) << upper(b[0]) << upper(c[0]) << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)

def khan(a):
    k = 0
    for i in range(len(a)//2):
        if a[i] == a[-i-1]:
            k += 1
    if k == len(a)//2:
        return True
    else:
        return False

khan(s)

sz = []
sk = []

for i in range(n//2):
    sz.append(s[i])
    sk.append(s[-i-1])

khan(sz)
khan(sk)

if khan(s) and khan(sz) and khan(sk):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
ll a[200100];
ll sum = 0; 
int main() {
	int n;
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,n) {
		sum += a[i];
		sum %= MOD;
	}
	ll ans = 0;
	rep(i,n) {
		sum -= a[i];
		if (sum < 0) sum += MOD;
		ans += a[i] * sum % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5144
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
a = stdin.readline().rstrip()
b = stdin.readline().rstrip()
c = stdin.readline().rstrip()

point = 0
for i in range(n):
    if a[i] != b[i] and b[i] == c[i]:
        point += 1
    elif a[i] == b[i] and b[i] != c[i]:
        point += 1
    elif a[i] == c[i] and b[i] != a[i]:
        point += 1
    elif a[i] != c[i] and b[i] != a[i]:
        point += 2

print(point)

Measured memory_bytes: 5048
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(ll i = z; i < n; i++)
//const int INF = 1<<29;
//const ll MOD = 1000000007;
using namespace std;

ll powmod(ll x, ll n, ll mod){
    //pow(x, n) % MOD
    int ret = 1;
    while(n > 0){
        if(n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}

int main(){
    ll K, mod;
    cin >> K;
    int ans = -1;
    if(K % 7 != 0){
        mod = K * 9;
    }
    else{
        mod = K * 9 / 7;
    }
    rep(i, 1, K + 1){
        ll A = powmod(10, i, mod);
        A--;
        if (A == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
import math
import fractions

N, Y = map(int, input().split())
possible = 0
for x in range(N + 1):
    flag = 0
    for y in range(N - x + 1):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            possible = 1
            flag = 1
            print(x, y, N - x - y)
            break
    if flag:
        break
if not possible:
    print(-1, -1, -1)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

//aのb乗
int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

int main(){
	
	int N;
	cin>>N;
	
	vector<int> x(N);
	
	for(int i=0;i<N;i++){
		cin>>x[i];
	}
	
	vector<int> a(N+1,0);
	int sum = 0;
	for(int i=1;i<=N;i++){
		a[i] = mod(sum + i);
		a[i] = mod(a[i] * gyakugen(i));
		sum = mod(sum + a[i]);
	}
	
	int ans = 0;
	
	int S = 0;
	/*
	k = 1;
	for(int i=1;i<=N-1;i++){
		k = mod(k*i);
	}*/
	
	for(int i=0;i<N-1;i++){
		int sum = (a[i+1]);
		sum = mod(sum * (x[i+1]-x[i]));
		ans = mod(ans + sum);
	}
	
	for(int i=1;i<=N-1;i++){
		ans = mod(ans * i);
	}
	
	cout<<ans<<endl;
	
    return 0;
}


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

int main(){
int n,k;
cin >> n>>k;
int h[111111];
int ans =0;
for (int i=0; i<n; ++i) cin >> h[i];

for (int i=0;i<n; ++i){
    if (h[i]>=k)
    { ans +=1;}
}
cout << ans << endl;
   }

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
const int64 INF = 1LL << 60;
 
int main()
{
  int64 N, X[200000], Y[200000];
 
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    if(X[i] > Y[i]) swap(X[i], Y[i]);
  }
 
  int64 ret = INF;
 
  int64 latte = INF, malta = -INF;
  for(int i = 0; i < N; i++) {
    latte = min(latte, X[i]);
    malta = max(malta, Y[i]);
  }
 
  int64 beet = latte, ukuku = malta;
  for(int i = 0; i < N; i++) {
    beet = max(beet, X[i]);
    ukuku = min(ukuku, Y[i]);
  }
 
  ret = min(ret, (beet - latte) * (malta - ukuku));
 
  vector< pair< int64, int64 > > vs;
  for(int i = 0; i < N; i++) {
    vs.emplace_back(X[i], Y[i]);
  }
  sort(begin(vs), end(vs));
 
  int64 len = max(beet, malta) - min(ukuku, latte);
  latte = max(beet, malta), malta = vs.back().first;
  for(int i = 0; i < N; i++) {
    ret = min(ret, len * (malta - min(latte, i == N ? INF : vs[i].first)));
    latte = min(latte, vs[i].second);
    malta = max(malta, vs[i].second);
  }
  cout << ret << endl;
}

Measured memory_bytes: 9584
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        while(true){
 
            int H = sc.nextInt();
            int W = sc.nextInt();
 
            if(H == 0 && W == 0){
                break;
            }
 
            else{
                int i, j;
 
                for(i=1;i<=H;i++){
                    for(j=1;j<=W;j++){
                        if(i % 2 == j % 2){
                            System.out.print("#");
                        }
                        else{
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }      
        }
 
        sc.close();
 
    }
 
}

    

    


Measured memory_bytes: 33828
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    string s, t;
    cin >> s >> t;
    lli x = 0;
    for (lli i = 0; i < s.length();i++)
    {
        if(s[i]!=t[i])
            x++;
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 3776
#include <iostream>
using namespace std;
int main(){
  int i=0 ,n ,ticket;
  while( i < 4 ){
    cin >> n >> ticket;
    if( n == 1 ){
      cout << 6000 * ticket << endl;
    }

    else if( n == 2 ){
      cout << 4000 * ticket << endl;
    }

    else if( n == 3 ){
      cout << 3000 * ticket << endl;
    }

    else if( n == 4 ){
      cout << 2000 * ticket << endl;
    }
    i++;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d",&n)
#define sc(s) scanf("%s",s)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N, K;
int main(void){
    cin >> N >> K;
    for (int i = 1;i <= K;i++){
        cout << C(N-K+1,i) * C(K-1,i-1) << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 998244353;

struct UnionFind {
	vector<int> par, rank;

	UnionFind(int n) : par(n, -1), rank(n, 0) { }
	void init(int n) { par.assign(n, -1), rank.assign(n, 0); }

	int root(int x) {
		if (par[x] == -1) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y);
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		return true;
	}
};


int main() {
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	UnionFind uf(n - k + 1);
	
	// もともと昇順な範囲を尺取りで連結
	int r = 1, sorted = -1;
	for (int l = 0; l + k-1 < n;) {
		while (r < n && a[r] > a[r - 1]) {
			++r;
			if (r - l >= k) {
				if(sorted!=-1) uf.merge(sorted, r - k);
				else sorted = l;
			}
		}
		l = r;
		++r;
	}

	// Setでi, i+1がequivalentか判定
	set<ll> se;
	for (int i = 0; i < k; ++i)	se.insert(a[i]);

	for (int l = 0; l + k < n; ++l) {
		ll kl = a[l]; // iの範囲の左端
		ll kr = a[l + k]; // i+1の範囲の右端
		se.erase(kl);
		ll m = *se.begin(); // 共通部分の最小値
		ll M = *se.rbegin(); // 共通部分の最大値
		if (kl < m && M < kr) uf.merge(l, l + 1);
		se.insert(kr);
	}

	// 連結成分を数える
	ll ans = 0;
	for (int i = 0; i < n - k + 1; ++i) {
		if (uf.par[i] == -1) ++ans;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, k, r, s, p, c = 0;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    for(int i = 0; i < n; i++) {
        if(i >= k && t[i] == t[i - k]) {
            t[i] = ' ';
            continue;
        }
        if(t[i] == 'r')
            c += p;
        if(t[i] == 's')
            c += r;
        if(t[i] == 'p')
            c += s;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul

mod = 10 ** 9 + 7
sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        self.group_num -= 1

n = I()
P = LI()

fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod


inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod


def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod


ret = 0
for p in P:
    if p == -1:
        ret += 1

U = UnionFind(n)
for i in range(n):
    if P[i] != -1:
        U.union(P[i] - 1, i)

L = []
for j in range(n):
    if P[j] == -1:
        L += [U.size[j]]

dp = [0] * (len(L) + 1)
dp[0] = 1
for l in range(1, len(L) + 1):
    for m in range(l, 0, -1):
        dp[m] += dp[m - 1] * L[l - 1]

if L:
    dp[1] = sum(L) - len(L)
cycle_cnt = 0
for i in range(1, len(L) + 1):
    cycle_cnt = (cycle_cnt + fac[i - 1] * dp[i] * pow(n - 1, len(L) - i, mod)) % mod

ans = (n - (U.group_num - ret)) * pow(n - 1, ret, mod) % mod
print((ans - cycle_cnt) % mod)


Measured memory_bytes: 236900
N = int(input())
A = list(map(int, input().split()))

M = [0]*10001
for a in A:
    M[a] += 1

first = True
for i, m in enumerate(M):
    if m > 0:
        if first:
            print(*([i]*m), end='')
            first = False
        else:
            print(' ', end='')
            print(*([i]*m), end='')
print()



Measured memory_bytes: 224508