akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double abs() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
int iSP(Pt a, Pt b, Pt c) {
	int s = sig((b - a).det(c - a));
	if (s) return s;
	if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b
	if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c
	return 0;
}
bool iSS(Pt a, Pt b, Pt c, Pt d) {
	return (iSP(a, b, c) * iSP(a, b, d) <= 0 && iSP(c, d, a) * iSP(c, d, b) <= 0);
}
int ax[1100];int ay[1100];int bx[1100];int by[1100];
double ijk[1100];
int v[1100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",ax+i,ay+i);
	}
	for(int i=0;i<b;i++)scanf("%d%d",bx+i,by+i);
	for(int i=0;i<a;i++)ijk[i]=999999999;
	ijk[0]=0;
	for(int i=0;i<a;i++){
		int at=0;
		double val=999999999;
		for(int j=0;j<a;j++)if(!v[j]&&val>ijk[j]){
			at=j;val=ijk[j];
		}
		v[at]=1;
		for(int j=0;j<a;j++){
			if(iSS(Pt(bx[0],by[0]),Pt(bx[1],by[1]),Pt(ax[at],ay[at]),Pt(ax[j],ay[j])))continue;
			ijk[j]=min(ijk[j],ijk[at]+sqrt((ax[at]-ax[j])*(ax[at]-ax[j])+(ay[at]-ay[j])*(ay[at]-ay[j])));
		}
	}
	double ret=ijk[1]+sqrt((bx[0]-bx[1])*(bx[0]-bx[1])+(by[0]-by[1])*(by[0]-by[1]));
	for(int i=0;i<b;i++)ijk[i]=999999999;
	ijk[0]=0;
	for(int i=0;i<b;i++)v[i]=0;
	for(int i=0;i<b;i++){
		int at=0;
		double val=999999999;
		for(int j=0;j<b;j++)if(!v[j]&&val>ijk[j]){
			at=j;val=ijk[j];
		}
		v[at]=1;
		for(int j=0;j<b;j++){
			if(iSS(Pt(ax[0],ay[0]),Pt(ax[1],ay[1]),Pt(bx[at],by[at]),Pt(bx[j],by[j])))continue;
			ijk[j]=min(ijk[j],ijk[at]+sqrt((bx[at]-bx[j])*(bx[at]-bx[j])+(by[at]-by[j])*(by[at]-by[j])));
		}
	}
	ret=min(ret,ijk[1]+sqrt((ax[0]-ax[1])*(ax[0]-ax[1])+(ay[0]-ay[1])*(ay[0]-ay[1])));
	if(ret>909090909)printf("-1\n");
	else printf("%.12f\n",ret);
	
}

Measured memory_bytes: 1096
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

d = defaultdict(int)
v = 0
ans = []

for a in A:
    d[a] += 1
    v += a

for i in range(Q):
    B, C = map(int, input().split())
    v += d[B] * (C - B)
    d[C] += d[B]
    d[B] = 0
    ans.append(v)

for a in ans:
    print(a)


Measured memory_bytes: 26948
#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int d[2][1000005],len;
int main(){
    scanf("%s",s);
    len=strlen(s);
    d[0][0]=(int)(s[0]-'0'),d[1][0]=11-(int)(s[0]-'0');
    for(int i=1;i<len;i++){
        int x=(int)(s[i]-'0');
        d[0][i]=min(d[0][i-1],d[1][i-1])+x;
        d[1][i]=10-x+min(d[1][i-1]-1,d[0][i-1]+1);
    }
    printf("%d",min(d[0][len-1],d[1][len-1]));
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
#define yes        cout<<"YES"<<"\n"
#define no         cout<<"NO"<<"\n"
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int n;cin>>n;
 vector <int> a(n),b(n),c(n);
 f(i,n)
 {cin>>a[i]>>b[i]>>c[i];}
 vector <int> A(n),B(n),C(n);
 A[0]=a[0],B[0]=b[0],C[0]=c[0];
 for(int i=1;i<n;i++)
 {
   A[i]=a[i]+max(B[i-1],C[i-1]);
   B[i]=b[i]+max(C[i-1],A[i-1]);
   C[i]=c[i]+max(A[i-1],B[i-1]);
 }
 cout<<MX(A[n-1],B[n-1],C[n-1]);
}
   

Measured memory_bytes: 5536
s = gets.chomp
acgt = {
  'A' => true,
  'C' => true,
  'G' => true,
  'T' => true
}

max = 0
0.upto(s.size - 1) do |i|
  len = 0
  i.upto(s.size - 1) do |j|
    break unless acgt[s[j]]
    len += 1
  end
  max = [max, len].max
end

puts max


Measured memory_bytes: 1916
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
	int n; cin >> n;
	vector<int> h(n); for (int i = 0;i < n;i++) { cin >> h[i]; }
	int ans = 1;
	int big = h[0];
	auto iter = h.begin() + 1;
	while (iter != h.end())
	{
		if (big <= *(iter))
		{
			ans++;
			big = *(iter);
		}
		iter++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
N = int(input())
C = [int(input()) for i in range(N)]
MOD = 10**9+7

A = []
for c in C:
    if A and A[-1]==c: continue
    A.append(c)

last = [-1] * 200001
B = [-1] * len(A)
for i,a in enumerate(A):
    B[i] = last[a]
    last[a] = i

dp = [0] * (len(A))
dp[0] = 1
for i in range(1,len(A)):
    bk = 0 if B[i] < 0 else dp[B[i]]
    dp[i] = (dp[i-1] + bk) % MOD
print(dp[-1])

Measured memory_bytes: 29876
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    vector<ll> t(N+2,0),a(N+2,0);
    for (int i = 1; i <= N; ++i) {
        cin>>t[i];
    }

    for (int i = 1; i <= N; ++i) {
        cin>>a[i];
    }

    ll ans=1ll;

    for (int i = 1; i <= N; ++i) {
        if(t[i]>t[i-1]){
            if(a[i]<t[i]){
                cout<<0<<endl;
                return 0;
            }
        }else if(a[i]>a[i+1]){
            if(t[i]<a[i]){
                cout<<0<<endl;
                return 0;
            }
        }else{
            (ans*=min(a[i],t[i]))%=MOD;
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int64_t gcd(int64_t m,int64_t n){
  if(n==0){
    return m;
  }else{
    return gcd(n,m%n);
  }
}

int64_t lcm(int64_t a,int64_t b){
  return a/gcd(a,b)*b;
}

int main(){
  int N;
  cin >> N;
  int64_t ans;
  cin >> ans;
  for(int i=1;i<N;i++){
    int64_t T;
    cin >> T;
    ans=lcm(ans,T);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int N,M,C;
  	cin >> N >> M >> C;
  
  	vector<vector<int>> a(N, vector<int>(M));
  	vector<int> b(M);
  
  	for(int i = 0; i < M; i++) {
    	cin >> b.at(i);
    } 
  
  	int ans = 0;
  
  	for(int i = 0; i < N; i++) {
      	int sum = C;
    	for(int j = 0; j < M; j++) {
        cin >> a.at(i).at(j);
        sum += b.at(j) * a.at(i).at(j);
        }
      if(sum > 0) ans++;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll mod = 998244353;



ll N,A,B,ans;
ll h[100001];

bool f(ll m) {
	ll cnt = 0;
	FOR(i, 0, N) {
		ll tmp = h[i] - B * m;
		if (tmp >= 0)cnt += (tmp + A - B - 1) / (A - B);
	}
	return (cnt <= m);

}

int main() {
	cin >>N>> A >> B;
	
	FOR(i, 0, N) {
		cin >> h[i];
	}
	ll ng = 0, ok = 1e9;

	while (ok - ng > 1) {
		ll mid = (ok + ng) / 2;
		if (f(mid))ok = mid;
		else ng = mid;
	}
	cout << ok << endl;

	return 0;
}

Measured memory_bytes: 1024
X,Y=map(int,input().split())
mod=pow(10,9)+7
m=(2*X-Y)//3
n=(2*Y-X)//3
if  m!=(2*X-Y)/3 or n!=(2*Y-X)/3 or m<0 or n<0:
    print(0)

else:
    bunsi = 1
    bunbo = 1
    for i in range(0, n):
        bunsi = (bunsi * (m + 1 + i)) % mod
        bunbo = (bunbo * (1 + i)) % mod
    print((bunsi * pow(bunbo, mod - 2, mod)) % mod)

Measured memory_bytes: 3064
// Problem: 
// 			A - Air Conditioner
// 			Editorial
// 		
// Contest: AtCoder - AtCoder Beginner Contest 174
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int a;
	cin>>a;
	cout<<((a >= 30)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <bitset>

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

void solve()
{
	int W, H;
	while(cin >> H >> W, W, H)
	{
		bool Flag[128][128];
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				Flag[i][j] = false;
			}
		}
		vector< vector<char> > Field(H);
		for(int i = 0; i < H; ++i)
		{
			Field[i].resize(W);
		}
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cin >> Field[i][j];
			}
		}
		P Pos(0, 0);
		bool LoopFlag = false;
		while(true)
		{
			if(Flag[Pos.second][Pos.first] == true)
			{
				LoopFlag = true;
				break;
			}
			Flag[Pos.second][Pos.first] = true;
			if(Field[Pos.second][Pos.first] == '>')
			{
				++Pos.first;
			}
			else if(Field[Pos.second][Pos.first] == '<')
			{
				--Pos.first;
			}
			else if(Field[Pos.second][Pos.first] == '^')
			{
				--Pos.second;
			}
			else if(Field[Pos.second][Pos.first] == 'v')
			{
				++Pos.second;
			}
			else if(Field[Pos.second][Pos.first] == '.')
			{
				break;
			}
		}
		if(!LoopFlag)
		{
			cout << Pos.first << " " << Pos.second << endl;
		}
		else
		{
			cout << "LOOP" << endl;
		}
	}
}

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

Measured memory_bytes: 0
import copy

n=int(input())
ps=list(map(int,input().split()))

sortedps = copy.deepcopy(ps)
sortedps.sort()

count = 0
for i in range(0,n):
    if count > 2:
        print('NO')
        exit()
    if ps[i] != sortedps[i]:
        count = count +1
if count > 2:
    print('NO')
    exit()

print('YES')
    


Measured memory_bytes: 3444
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;
#define int ll 
signed main() {
	int N, M, X; cin >> N >> M >> X;
	vi C(N);
	vvi A(N, vi(M));

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

		rep(j, M) cin >> A[i][j];
	}

	int min = int_INF;
	for (int i = 0; i < (1 << N) ; i++) {
		vi Compreh(M);
		bitset<12> bs = i;
		int cost = 0;
		for (int k = 0; k < bs.size(); k++) { // 指定参考本
			if (bs[k] == true) {
				//K番目の参考書使う
				for (int j = 0; j < M; j++) {
					Compreh[j] += A[k][j];
					
				}
				cost += C[k];
			}
		}

		//本全部読んだ->Xチェック&コスト計算
		sort(ALL(Compreh));

		if (Compreh[0] < X) {
			continue;
		}
		else {
			cost < min ? min = cost : 1;
		}

	}
	
	if (min == int_INF) {
		cout << -1 << endl;
	}
	else {
		cout << min << endl;
	}
	
}

Measured memory_bytes: 3640
import Data.List
import Text.Printf

f (a,b) (c,d) = if a /= b
                then compare a c
                else compare b d
cnv x = sortBy f $ map (\[a,b] -> (a,b) ) x

srch _ [] = (0,0)
srch t@((tx,ty):tgt) ((sx,sy):str) =
  let dx = sx-tx
      dy = sy-ty
      rr = map (\e -> elem e str) $ map (\(x,y)->(x+dx,y+dy)) tgt
  in
    if foldr (&&) True rr
    then (dx,dy)
    else srch t str

ans ([0]:_) = []
ans ([n]:xs) =
  let tgt = cnv $ take n xs
      m   = head $ head $ drop n xs
      str = cnv $ take m $ drop (n+1) xs
      a   = srch tgt str
      res = drop (n+1+m) xs
  in
    a:ans res

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ (\(a,b) -> printf "%d %d\n" a b) o
  

Measured memory_bytes: 5540
import java.util.Scanner;

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

		long k = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ans = 1;

		if (b - a <= 2) {
			ans = k + 1;
		} else {
			if (k <= a) {
				ans = k + 1;
			} else {
				long n = k - (a - 1);
				if (n % 2 == 0) {
					ans = (b - a) * (n / 2) + a;
				} else {
					ans = (b - a) * (n / 2) + a + 1;
				}
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 23508
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

void solve(){
  int a[3]; cin >> a[0] >> a[1] >> a[2];
  int maxi = 0;
  for(int i = 1; i < 3; i++){
    if(a[i] > a[maxi]) maxi = i;
  }
  int ans = 10 * a[maxi];
  for(int i = 0; i < 3; i++){
    if(i == maxi) continue;
    ans += a[i];
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=0;
	     int arr[]=new int[a+2];
		 for(int i=1;i<=b;i++){
			 int m=sc.nextInt();
			 int n=sc.nextInt();
			 arr[m]=arr[m]+1;
			 arr[n+1]=arr[n+1]-1;
		 }
		 for(int i=2;i<=a+1;i++)
			 arr[i]=arr[i-1]+arr[i];
		 for(int i=1;i<=a;i++){
			  if(arr[i]>=b)
				 c++;
		 }
		 System.out.println(c);
	}
}

Measured memory_bytes: 66780
N=int(input())
A=list(map(int,input().split()))
L=10**18
ans=A[0]
if 0 in A:
    ans=0
else:
    for i in range(1,N):
        if ans<=L:
            ans*=A[i]
        else:
            print(-1)
            exit()
    
print(ans if ans<=L else -1)
    

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int r,d,x;
  cin>>r>>d>>x;
  for(int i=0;i<10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
double a;
long double dp[3005][3005];
int main(){
dp[0][0]=1.0;
cin>>n;
for(int i=1;n>=i;i++)
{
	cin>>a;
	for(int j=0;n>=j;j++)
	{
		dp[i][j]=dp[i-1][j]*(1-a);
		if(j)
			dp[i][j]+=dp[i-1][j-1]*a;
	}
}
long double out=0;
int s=n/2+1;
for(int i=s;i<=n;i++)
	out+=dp[n][i];
cout<<fixed<<setprecision(11)<<out;
return 0;
}


Measured memory_bytes: 141056
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long X, long long K, long long D){
    X = abs(X);
    ll K1 = X/D;
    if(K1 >= K) {
        X -= K*D;
        cout<<X<<endl; return;
    }
    X -= K1*D;
    K -= K1;
    if(K % 2 == 0) {cout<<X<<endl; return;}
    else {X = abs(X-D); cout<<X<<endl; return;}
}
int main(){
    long long X;
    scanf("%lld",&X);
    long long K;
    scanf("%lld",&K);
    long long D;
    scanf("%lld",&D);
    solve(X, K, D);
    return 0;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  int n,K; cin >> n >> K;
  vector<pii> v(n);
  rep(i,n) cin >> v[i].fst >> v[i].snd;

  int ans = inf;
  rep(i,n) rep(j,n) rep(k,n) rep(l,n){
    int xl = min(min(v[i].fst, v[j].fst), min(v[k].fst, v[l].fst));
    int xr = max(max(v[i].fst, v[j].fst), max(v[k].fst, v[l].fst));
    int yl = min(min(v[i].snd, v[j].snd), min(v[k].snd, v[l].snd));
    int yr = max(max(v[i].snd, v[j].snd), max(v[k].snd, v[l].snd));
    int c = 0;
    if(xl == xr or yl == yr) continue;
    rep(m,n) if(xl <= v[m].fst and v[m].fst <= xr and yl <= v[m].snd and v[m].snd <= yr) c++;
    if(K <= c){
      ans = min(ans, (xr - xl) * (yr - yl));
      dump(c);
    }
  }
  cout << ans << endl;    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define MAX_N 1000010

const ll INF = ll(1e18)+1;
vector<ll> a(200020);
ll n, k;

bool is_ok(ll x){
    // 積が x 未満となるペアの数を数えて、k個未満なら true
    ll num_pair = 0;
    for(ll i=0; i<n; i++){
        ll fix = a[i];
        ll l = -1, r = n;
        if(fix >= 0){
            while(r - l > 1){
                ll mid = (l + r) / 2;
                if(fix * a[mid] < x){
                    l = mid;
                }
                else{
                    r = mid;
                }
            }
            num_pair += r;
        }
        else{
            while(r - l > 1){
                ll mid = (l + r) / 2;
                if(fix * a[mid] < x){
                    r = mid;
                }
                else{
                    l = mid;
                }
            }
            num_pair += (n-r);
        }
        if(a[i] * a[i] < x) num_pair--;
    }
    num_pair /= 2;
    return num_pair < k;
}

int main(void){
    cin >> n >> k;
    a.resize(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll l = -INF, r = INF;
    while(r - l > 1){
        ll middle = (l + r) / 2;
        if(is_ok(middle)){
            l = middle;
        }
        else{
            r = middle;
        }
    }
    cout << l << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std ;
int main ()
{
	int a=0 , b=0 , c=0 , d=0 ;
	cin >> a >> b >> c ;
	for(; a<=b ; a++)
	{
		if(c%a==0)
		{
			d++ ;
		}
	}
	cout << d << endl ;
	return 0 ;
}



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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  REP(i,n) {
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  cout << a[a.size()-1] - a[0] << endl;
  
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	long long b[87];
	for(int i=0;i<a+1;i++){
		if(i==0){
			b[i]=2;
		}
		else if(i==1){
			b[i]=1;
		}
		else{
		b[i]=b[i-1]+b[i-2];
	}
		if(i==a){
			cout<<b[i]<<endl;
			return 0;
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
// template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n;cin>>n;
  bool s[n][n];CLR(s,true);
  ll score[n][n];
  rep(i,0,n){
    rep(j,0,n){
      score[i][j]=min({i,j,n-1-i,n-1-j});
    }
  }
  ll dy[4]={-1,0,0,1},dx[4]={0,-1,1,0};
  ll ans=0;
  rep(i,0,n*n){
    ll p;cin>>p;
    p--;
    ll y=p/n,x=p%n;
    ans+=score[y][x];
    s[y][x]=false;

    queue<array<ll,3>>aq;
    rep(j,0,4){
      ll nx=x+dx[j],ny=y+dy[j];
      if(IN(0,n,nx)&&IN(0,n,ny)){
        rep(k,0,4){
          if(chmin(score[ny][nx],score[y][x])){
            aq.push({nx,ny,score[y][x]});
          }
        }
      }
    }

    while(!aq.empty()){
      ll x=aq.front()[0],y=aq.front()[1],sc=aq.front()[2];
      aq.pop();
      rep(j,0,4){
        ll nx=x+dx[j],ny=y+dy[j];
        if(IN(0,n,nx)&&IN(0,n,ny)){
          if(s[y][x] && chmin(score[ny][nx],sc+1)){
            aq.push({nx,ny,sc+1});
          }
          if(!s[y][x] && chmin(score[ny][nx],sc)){
            aq.push({nx,ny,sc});
          }
        }
      }
    }
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 5792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  mat dp(n+1,vec(n+1));
  for(ll i=0;i<n;i++) dp[0][i]=1;
  for(ll i=0;i<n-1;i++) {
    vec sum(3010);
    for(ll j=0;j<n-i;j++) {
      sum[j+1]=(sum[j]+dp[i][j])%mod;
    }
    for(ll j=0;j<n-i;j++) {
      if(s[i]=='>') {
        dp[i+1][j]=sum[j+1];
      }
      else {
        dp[i+1][j]=(sum[n-i]-sum[j+1]+mod)%mod;
      }
    }
  }
  cout << dp[n-1][0] << endl;
}

Measured memory_bytes: 70784
#include<stdio.h>

int main(void) {
   int i,j,k,n,b,f,r,v;
   static int count[4][3][10];

   scanf("%d", &n);
   
   for(i=0;i<n;i++){
     scanf("%d %d %d %d", &b,&f,&r,&v);
     count[b-1][f-1][r-1] += v;
   }

   for(i=0;i<4;i++){
     for(j=0;j<3;j++){
       for(k=0;k<10;k++){
         printf(" %d", count[i][j][k]);
       }
       printf("\n");
     }
     if(i<3) printf("####################\n");
   }

   return 0;
}



Measured memory_bytes: 2072
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define vin(v,n) rep(i,n)cin>>v[i];
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define sz size()
#define fi first
#define se second
#define pb push_back
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n,k, v[100010],ans,p,l,r;
int main() {
	cin >> n>>k;
	rep(i, n) { cin >> v[i]; if (v[i] == 1)p = i; }
	l = p,r=n-p-1;
	ans += l / (k - 1);
	l %= (k - 1);
	ans += r / (k - 1);
	r %= (k - 1);
	l += r;
	ans += (l / (k - 1) + (l % (k - 1) == 0 ? 0 : 1));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
a0 = int(input())
a = [a0]

#print(a)
i = 0

while True:
    if a[i] % 2 == 0:
        a.append(a[i]//2)
    else:
        a.append(a[i]*3+1)
    #print(a)

    if a[i+1] in a[:i+1]:
        break
    i += 1

print(i+2)

Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;

    int m = n / 2 * 2;
    vector<P> p;
    for(int i = 1; i <= m / 2; i++){
        p.emplace_back(i, m + 1 - i);
    }

    vector<P> ans;
    rep(i, SZ(p)){
        for(int j = i + 1; j < SZ(p); j++){
            ans.emplace_back(p[i].first, p[j].first);
            ans.emplace_back(p[i].first, p[j].second);
            ans.emplace_back(p[i].second, p[j].first);
            ans.emplace_back(p[i].second, p[j].second);
        }
    }

    if(n % 2){
        rep(i, SZ(p)){
            ans.emplace_back(n, p[i].first);
            ans.emplace_back(n, p[i].second);
        }
    }

    cout << SZ(ans) << endl;
    rep(i, SZ(ans)){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 512
/*
30
40
50
6000
*/
fn main() {
    let a = read();
    let b = read();
    let c = read();
    let x = read();

    let mut cnt = 0;
    for na in 0..a + 1 {
        for nb in 0..b + 1 {
            for nc in 0..c + 1 {
                let sum = na * 500 + nb * 100 + nc * 50;
                if sum == x {
                    cnt += 1;
                }
            }
        }
    }

    println!("{}", cnt);
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    
    ll n;cin>>n;
    cout<<n*(n-1)/2<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n+2);
  rep(i,n)cin>>a[i+1];
  a[0]=a[n+1]=0;
  n+=2;

  vi x(n,0),y(n,0);
  //x[i] := 最初の座標0から観光スポットi-1までの値段
  //y[i] := 観光スポットi+1から最後の座標0までの値段

  rep(i,n-1) 
    x[i+1]=x[i]+abs(a[i+1]-a[i]);
  for(i=n-1;i>0;i--)
    y[i-1]=y[i]+abs(a[i-1]-a[i]);

  loop(i,1,n-1){
    cout<<x[i-1]+abs(a[i-1]-a[i+1])+y[i+1]<<endl;
  }

}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <set>
#include <utility>
using namespace std;

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

    set<pair<int, int>> R, C;
    R.insert({N-1, N-1});
    C.insert({N-1, N-1});

    long long ans = (long long)(N-2)*(N-2);
    for (int q=0; q<Q; q++)
    {
        int rc;
        cin>>rc;
        set<pair<int, int>> &S1 = rc==1 ? R : C;
        set<pair<int, int>> &S2 = rc==1 ? C : R;
        int x;
        cin>>x;
        x--;

        pair<int, int> s = *S2.lower_bound(make_pair(x, -1));
        ans -= s.second-1;
        S1.insert({s.second, x});
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12532
#include <iostream>

using namespace std;

static int card[100];

static int pattern[] ={
	0x07,
	0x111,
	0x38,
	0x1a0,
	0x54,
	0x1c0,
	0x49,
	0x92,
	0x124,
};

int main(){
	int val;
	int flg = 0;
	int shiftval = 0;
	
	for(int i=0;i<9;++i){
		cin >> val;
		card[val] = 1 << shiftval;
		++shiftval;
	}

	int n;
	cin >> n;
	for(int i=0;i<n;++i){
		int input;
		cin >> input;
		flg |= card[input];
	}

	for(auto &i : pattern){
		if((flg & i) == i){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;
	while(ch<'-')ch=gt;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return k;
}
const int YL=1e9+7;
inline int MO(const int &a){return a>=YL?a-YL:a;}
inline int ksm(int a,int k){int r=1;while(k){if(k&1)r=1ll*r*a%YL;a=1ll*a*a%YL;k>>=1;}return r;}
int dp[2005][2005],fac[4000005],fnv[4000005];
inline int C(int x,int y){if(x<y||y<0)return 0;return 1ll*fac[x]*fnv[y]%YL*fnv[x-y]%YL;}
int main()
{
	int n=in(),k=in();fac[0]=fnv[0]=1;if(k==1)return puts("1"),0;
	for(int i=1;i<=n*k;++i)fac[i]=1ll*fac[i-1]*i%YL;
	fnv[n*k]=ksm(fac[n*k],YL-2);
	for(int i=n*k-1;i ;--i)fnv[i]=1ll*fnv[i+1]*(i+1)%YL;
	for(int i=1;i<=n&&(dp[i][0]=1);++i)
		for(int j=1;j<=i;++j)
		{
			dp[i][j]=MO(dp[i-1][j]+1ll*C(n-i-1+(n-j+1)*(k-1),k-2)*dp[i][j-1]%YL*(n-j+1)%YL);
		}
	printf("%d\n",dp[n][n]);
	return 0;
}


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

using namespace std;

int main(){
	std:ios_base::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	if(c >=65 && c <=90)
		cout<<"A\n";
	else
		cout<<"a\n";
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

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

ll lcm(ll a, ll b) {
	if (a == 0 || b == 0) return 0;
	ll g = gcd(a, b);
	return (a / g) * b;
}

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

	ll A, B;
	cin >> A >> B;
	puts(lcm(A, B));

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if (S == "SUN"){
    cout << 7 << endl;
  }
  else if (S == "MON"){
    cout << 6 << endl;
  }
    else if (S == "TUE"){
    cout << 5 << endl;
  }
    else if (S == "WED"){
    cout << 4 << endl;
  }
    else if (S == "THU"){
    cout << 3 << endl;
  }
    else if (S == "FRI"){
    cout << 2 << endl;
  }
    else if (S == "SAT"){
    cout << 1 << endl;
  }
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	ll x;
	 cin>>x;

	ll temp=100ll;
	ll ans=0;
	while(temp<x)
	{
		ll y= (ll)(temp*0.01);	
		temp+=y;
		ans++;
	}
	cout<<ans<<"\n";

	
	return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s[m];
  rep(i, m) {
    int k;
    cin >> k;
    s[i].resize(k);
    rep(j, k) {
      cin >> s[i][j];
      --s[i][j];
    }
  }
  int p[m];
  rep(i, m) cin >> p[i];

  int ans = 0;
  rep(sn, 1 << n) {
    int on[n];
    rep(i, n) on[i] = sn >> i & 1;

    bool ok = true;
    rep(i, m) {
      int sum = 0;
      for (auto id : s[i]) sum += on[id];
      if (sum % 2 != p[i]) ok = false;
    }
    if (ok) ++ans;
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
	int A[13] = { 0,1,0,2,0,2,0,0,2,0,2,0 };
	int x, y; cin >> x >> y; x--; y--;

	cout << (A[x] == A[y] ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
long long a[90],n;

int main(){
	cin>>n;
	a[0]=2;a[1]=1;
	for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
	printf("%lld\n",a[n]);
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10 ** 9 + 7

f = [1 for _ in range(N + 1)]
inv = [1 for _ in range(N + 1)]
finv = [1 for _ in range(N + 1)]

for i in range(2, N + 1):
    f[i] = f[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def comb(n, r):
    return f[n] * (finv[r] * finv[n - r] % mod) % mod


for i in range(1, K + 1):
    print((comb(N - K + 1, i) * comb(K - 1, i - 1)) % mod) if i <= N - K + 1 else print(0)


Measured memory_bytes: 3572
using System;
using System.Linq;

class PG{
    public static void Main(string[] args){
        Console.ReadLine();
        BubbleSort(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
    }
    
    
    public static void BubbleSort(int[] a){
        bool flag=true;
        int count=0;
        while(flag){
            flag=false;
            for(int j=a.Length-1;j>=1;j--){
                if(a[j]<a[j-1]){
                    int temp=a[j];
                    a[j]=a[j-1];
                    a[j-1]=temp;
                    flag=true;
                    count++;
                }
            }
        }
        Console.WriteLine(String.Join(" ",a));
        Console.WriteLine(count);
    }
}



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

#define REP(i,a,b) for(int i=a; i<b; i++)
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    FAST_IO

    int n;
    cin >> n;
    int h[n];
    REP(i, 0, n)
        cin >> h[i];
    if(n == 2)
        cout << abs(h[1] - h[0]) << "\n";
    else
    {
        int dp[n];
        dp[0] = 0;
        dp[1] = abs(h[1] - h[0]);
        REP(i,2,n)
            dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);
        cout << dp[n-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
const int MaxN = 1e5;

int num[105];

int main()
{
	int n, x, flag = MaxN + 5, sum = 0;
	cin >> n >> x;
	for(int i = 1;i <= n;i++){
		cin >> num[i];
		flag = min(flag, num[i]);
		sum += num[i];
	}
	int re = x - sum;
	int ans = n;
	ans += re/flag;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var m = cin.ReadInt;
            var n = cin.ReadInt;

            Console.WriteLine((n % m == 0) ? n + m : n - m);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 11220
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M, ans;
std::map<LL, LL>cou;

int main()
{
	in >> N >> M;
	std::vector<LL>A(N);
	rep(i, N)
	{
		in >> A[i];
		A[i] %= M;
		if (i > 0)
		{
			A[i] += A[i - 1];
			A[i] %= M;
		}
		++cou[A[i]];
	}
	for (auto& i : cou)
	{
		if (i.first == 0) ans += i.second;
		ans += i.second * (i.second - 1) / 2;
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define UNIQUE(v)       sort(all(v));v.erase(unique(all(v)),v.end());s
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef online_judge
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int &i : arr)
        cin >> i;
    sort(all(arr));
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            for(int k = j + 1; k < n; ++k) {
                if(arr[i] + arr[j] > arr[k]
                   && arr[i] + arr[k] > arr[j]
                   && arr[k] + arr[j] > arr[i]
                   && (arr[i] != arr[j] && arr[j] != arr[k]))
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;

  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
def array_integer(a)
	0.upto(a.count) {|x|
		a[x] = a[x].to_i
	}
	return a
end

eof = false

until eof do
	m,f,r = array_integer(STDIN.gets.split(" "))
	add = m + f
	
	if m == -1 && f == -1 && r == -1 then
		eof = true
		break
	elsif m == -1 || f == -1 then
		print "F\n"
	elsif add >= 80 then
		print "A\n"
	elsif add >= 65 then
		print "B\n"
	elsif add >= 50 then
		print "C\n"
	elsif add >= 30 then
		if r >= 50 then
			print "C\n"
		else
			print "D\n"
		end
	else
		print "F\n"
	end
end



Measured memory_bytes: 6876
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,ans;
bool fix(pair<int,int> a,pair<int,int> b){
	return a.first<b.first;
}
int main(){
	cin >> n >> m;
	pair<int,int> a[m];
	bool c[m];
	memset(c,true,sizeof(c));
	for(int i=0;i<m;i++)
		cin >> a[i].first >> a[i].second;
	sort(a,a+m);
	for(int i=0;i<m;i++){
		if(c[i]==false)continue;
		int lo=a[i].first,hi=a[i].second;
		ans++;
		for(int j=i+1;j<m;j++){
			if(lo<hi){
				lo=max(lo,a[j].first);
				hi=min(hi,a[j].second);
				if(lo<hi)c[j]=false;
			}
                        else break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1152
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
 
typedef long long        ll;
typedef pair<int,int>    PII;
 
#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
 
const int N = 5e5+7;
const int rn = 750;

/** Template Ends **/
int n, q;
int c[N];
int cnt[N];
int dis;
int ans[N];
int l, r;

struct query {
	int l, r, idx;
	bool operator<(const query& oth) const {
		int s1 = l / rn, s2 = oth.l / rn;
		if (s1 == s2) return r < oth.r;
		return s1 < s2;
	}
};
int solve(int L, int R) {
	while (l < L) {
		cnt[c[l]]--;
		if (cnt[c[l]] == 0)	dis--;
		l++;
	}
	while (l > L) {
		l--;
		cnt[c[l]]++;
		if (cnt[c[l]] == 1)	dis++;
	}
	while (r < R) {
		r++;
		cnt[c[r]]++;
		if (cnt[c[r]] == 1)	dis++;
	}
	while (r > R) {
		cnt[c[r]]--;
		if (cnt[c[r]] == 0)	dis--;
		r--;
	}
	return dis;
}
signed main() {
 
    IOS;
    cin >> n >> q;   
    FOR(i,1,n) cin >> c[i];
    vector<query> queries(q);
    LP(i,q) {
    	cin >> queries[i].l >> queries[i].r;
    	queries[i].idx = i;
    }
    sort(all(queries));
    l = 0, r = -1;
    for (auto query : queries) {
    	ans[query.idx] = solve(query.l, query.r);
    }
    LP(i,q) cout << ans[i] << endl;
 
    return 0;
}

Measured memory_bytes: 15468
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <unordered_map>

#include <cassert>
using namespace std;


long long f_hs(long long a,long long b){
    return a*1000000000+b;
}
pair<long long,long long> i_hs(long long k){
    return pair<long long,long long>(k/1000000000,k%1000000000);
}
 
std::unordered_map<long long,bool> blacks, well_known;
std::vector<long long> result;

int main(void){

	int n;
	cin >> n;
	vector<int> a(n);
	unordered_map<int,int> m;
	for(int i=0;i<n;++i){
		cin >> a[i];
		if(m.count(a[i])==0){
			m[a[i]]=1;
		}else{
			m[a[i]]+=1;
		}
	}

	int cnt=0;
	for(auto k=m.begin();k!=m.end();++k){
		if(k->first > k->second){
			cnt+=k->second;
		}else{
			cnt+=k->second - k->first;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a,v,b,w,t;
signed main(){
	cin>>a>>v>>b>>w>>t;
	int x=t*(v-w);
	if(x<0)puts("NO");
	else{
		if(abs(a-b)>x)puts("NO");
		else puts("YES");
	}
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main (void)
{
    char s[100055] ={0};
    int count = 0;
    int len = 0;
    int i;
    scanf("%s",s);
    while(s[len]){
        len++;
}
    
    for(i=0;i<len -1;i++){
        if(s[i] != s[i+1]){
            count++;
        }
    }
    printf("%d",count);

    return 0;
}

Measured memory_bytes: 256