akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    ll ans = INF;
    REP(i, H - 1) {
        ll a = W * (i + 1);
        ll h = H - (i + 1);
        {
            ll w = W / 2;
            ll b = h * w;
            ll c = h * (W - w);
            ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));
        }
        {
            ll hh = h / 2;
            ll b = hh * W;
            ll c = (h - hh) * W;
            ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));
        }
    }
    REP(i, W - 1) {
        ll a = H * (i + 1);
        ll w = W - (i + 1);
        {
            ll h = H / 2;
            ll b = h * w;
            ll c = (H - h) * w;
            ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));
        }
        {
            ll ww = w / 2;
            ll b = ww * H;
            ll c = (w - ww) * H;
            ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if (a == b + c || b == a + c || c == a + b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string a, b;
    cin >> a >> b;

    int n = stoi(a + b);

    if ( sqrt(n) == floor(sqrt(n)) ) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
n,k=map(int, input().split())

sunukes = [0 for i in range(n)]

for i in range(k):
  d = int(input())
  a = list(map(int, input().split()))

  for j in range(d):
    sunukes[a[j]-1] = 1

r=0
for sunuke in sunukes:
  if sunuke == 0:
    r+=1

print(r)

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <bitset>

#define mod 1e9+7
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, a;
    string X, b;
    pair<string, int> c[50];
    cin >> N;
    rep(i, N){
        cin >> b >> a;
        c[i] = mp(b, a);
    }
    cin >> X;
    int ans = 0;
    rep(i, N){
        if(c[i].first == X){
            for(int j = i+1; j < N; j++) ans += c[j].second;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
for i in range(n):
  ans+=b[a[i]-1]
  if i+1<n and a[i]+1==a[i+1]:
    ans+=c[a[i]-1]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 100005

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
#define N 100005
int n, k;
int wv[110][2];
ll dp[110][N];
ll dpf(int i, int w)
{
	if(w < 0)
		return -1e12;
	if(w == 0 || i == n)
		return 0;
	if(dp[i][w] >= 0)
	{
		return dp[i][w];
	}

	return dp[i][w] = max(wv[i][1] + dpf(i + 1, w - wv[i][0]), dpf(i + 1, w));
}

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

	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> wv[i][0] >> wv[i][1];
		
	}
	ll ans = 0;//dpf(0, k);
	int i = 0;
	while(i < wv[0][0])
		dp[0][i++] = 0;
	while(i <= k)
		dp[0][i++] = wv[0][1];
	for(i = 1; i < n; ++i)
	{
		for (int j = 0; j <= k; ++j)
		{
			dp[i][j] = max((j < wv[i][0] ? 0 : wv[i][1] + dp[i - 1][j - wv[i][0]]), dp[i-1][j]);
		}
	}
	cout << dp[n-1][k] << "\n";
	return 0;
}

Measured memory_bytes: 82176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
#include <random>
#include <sstream>
#include <stack>
#include <deque>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

string s;
int K;

int main() {
  cin >> s >> K;
  int n = s.size();
  int r = K;
  rep(i,n) {
    if (i == n-1) {
      s[i] = (s[i] - 'a' + r) % 26 + 'a';
    } else if (s[i] != 'a' && 'z' - s[i] + 1 <= r) {
      r -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

vector<int> parent;
vector<int> L;
vector<int> R;
vector<int> d(10005);
vector<int> h(10005);

int n;

void Depth(int i, int x){
  if(i == -1) return;
  d[i] = x;
  Depth(L[i], x + 1);
  Depth(R[i], x + 1);
}

int Height(int i){
  int h1 = 0;
  int h2 = 0;

  if(L[i] != -1) h1 = Height(L[i]) + 1;
  if(R[i] != -1) h2 = Height(R[i]) + 1;

  return h[i] = max(h1, h2);
  
}

int Sibling(int i){

  if(parent[i] == -1) return -1;
  if(L[parent[i]] != i && L[parent[i]] != -1){
    return L[parent[i]];
  }

  if(R[parent[i]] != i && R[parent[i]] != -1){
    return R[parent[i]];
  }

  return -1;

}

void print(int i){
  cout << "node " << i << ": ";
  cout << "parent = " << parent[i] << ", ";
  cout << "sibling = " << Sibling(i) << ", ";

  int cnt = 0;

  if(L[i] != -1) cnt++;
  if(R[i] != -1) cnt++;
  cout << "degree = " << cnt << ", ";
  cout << "depth = " << d[i] << ", ";
  cout << "height = " << h[i] << ", ";

  if(parent[i] == -1) cout << "root" << endl;
  else if(L[i] == -1 && R[i] == -1) cout << "leaf" << endl;
  else cout << "internal node" << endl;
  
}

int main()
{
  int id, l, r, root = 0;
  cin >> n;

  parent.resize(n);
  R.resize(n);
  L.resize(n);

  for(int i = 0; i < n; i++) parent[i] = -1;

  for(int i = 0; i < n; i++){
    cin >> id >> l >> r;
    L[id] = l;
    R[id] = r;

    if(l != -1) parent[l] = id;
    if(r != -1) parent[r] = id;
  }

  for(int i = 0; i < n; i++) if(parent[i] == -1) root = i;

  Depth(root, 0);
  Height(root);

  for(int i = 0; i < n; i++) print(i);

  return 0;
  
}



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

#define int long long
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define precise cout<<fixed<<setprecision(20)
#define ff first
#define ss second

typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

const int N=100001;
int mod=1000000007;
int mod2=998244353;

int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
int mul(int a,int b){return ((a%mod)*(b%mod))%mod;}
int sub(int a,int b){return (((a-b)%mod)+mod)%mod;}

void solve()
{
	int x,n;
	cin>>x>>n;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	sort(all(a));
	int temp=0;
	int diff=100000;
	int ans=0;
	rep(i,0,102)
	{
		if(binary_search(all(a),i))
		continue;
		else
		{
			temp=abs(i-x);
			if(temp<diff)
			{
				ans=i;
				diff=temp;
			}
		}
	}
	cout<<ans<<endl;
}

signed main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--) 
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#include <set>
#include <stack>
#include <cstdio>

using namespace std;
const int MOD(1000000000 + 7);
typedef long long int LL;

constexpr int Mult(int a, int b)
{
	return (a * 1LL) * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

void exgcd(int a, int b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

int power(int a, int n)
{
	int Ret(1);
	while (n)
	{
		if (n & 1)
			Ret = Mult(Ret, a);
		a = Mult(a, a), n >>= 1;
	}
	return Ret;
}

int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a % b);
}

/*
每个点双的情况是独立的，对每个点双分别计数乘起来就是答案。对于一个点双的答案，分情况讨论：
(1)这个点双是一条边。那么方案数 = K
(2)这个点双是一个环，根据polya定理，设点数是n，方案数 = Sum{K^gcd(n, i)   |   0 <= i <= n - 1} / n
(3)这个点双有多个环。可以对于两个相交的环进行操作，交换任意两条相邻的边，同时不改变其它边的颜色。那么方案是什么只和每种颜色的数量有关，方案数是一个不定方程的解数 
*/

const int Max_N(55);
const int Max_M(105);
const int Max_K(105);

int N, M, K, Head[Max_N], Total, To[Max_M << 1], Next[Max_M << 1], Ans = 1, C[Max_M + Max_K][Max_M + Max_K];

struct edge
{
	edge(const int &_u, const int &_v) : u(_u), v(_v) {}
	int u, v;
};

inline void Add_Edge(int s, int t)
{
	++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total;
}

stack<edge> S;
int dfsclock, Pre[Max_N], bcctot, bccno[Max_N], V[Max_N + Max_M], E[Max_N + Max_M];
int Tarjan(int u, int fa)
{
	int lowu(Pre[u] = ++dfsclock), lowv;
	for (int i = Head[u], v;i;i = Next[i])
	{
		edge e(u, v = To[i]);
		if (!Pre[v])
		{
			S.push(e), lowu = min(lowu, lowv = Tarjan(v, u));
			if (lowv >= Pre[u])
			{
				++bcctot;
				while (true)
				{
					e = S.top(), S.pop();
					if (bccno[e.u] != bcctot)
						++V[bccno[e.u] = bcctot];
					if (bccno[e.v] != bcctot)
						++V[bccno[e.v] = bcctot];
					++E[bcctot];
					if (u == e.u && v == e.v)
						break;
				}
			}
		}
		else
			if (Pre[v] < Pre[u] && v != fa)
				S.push(e), lowu = min(lowu, Pre[v]);
	}
	return lowu;
}

int main()
{
	scanf("%d%d%d", &N, &M, &K);
	C[0][0] = 1;
	for (int i = 1;i <= M + K;++i)
	{
		C[i][0] = C[i][i] = 1;
		for (int j = 1;j < i;++j)
			C[i][j] = Add(C[i - 1][j - 1], C[i - 1][j]);
	}
	for (int u, v;M--;)
		scanf("%d%d", &u, &v), Add_Edge(u, v), Add_Edge(v, u);
	for (int i = 1;i <= N;++i)
		if (!Pre[i])
			Tarjan(i, -1);
	for (int i = 1, Ret;i <= bcctot;++i)
	{
		if (E[i] == 1)
		{
			Ans = Mult(Ans, K);
			continue;
		}
		if (V[i] == E[i])
		{
			Ret = 0;
			for (int j = 0;j <= V[i] - 1;++j)
				Ret = Add(Ret, power(K, gcd(V[i], j)));
			Ans = Mult(Ans, Ret = Mult(Ret, inverse(V[i])));
			continue;
		}
		Ans = Mult(Ans, C[E[i] + K - 1][K - 1]);
	}
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 384
n = int(input())
count = 0
for i in range(n):
    head = str(i + 1)[0]
    tail = str(i + 1)[-1]
    if tail == "0":
        continue
    if head == tail:
        count += 1
    for j in range(len(str(n)) - 2):
        count += (10 ** j)
    min_num = int(tail + "0" * (len(str(n)) - 2) + head)
    max_num = int(tail + "9" * (len(str(n)) - 2) + head)
    if min_num <= n:
        count += min((n - min_num) // 10 + 1, (max_num - min_num) // 10 + 1)
print(count)

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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int lg = 0, lr = 0, lb = 0, rg = 0, rb = 0, rr = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') ++rr;
        if (s[i] == 'G') ++rg;
        if (s[i] == 'B') ++rb;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            --rr;
            ans += lb * rg + lg * rb;
            ++lr;
        }
        if (s[i] == 'G') {
            --rg;
            ans += lb * rr + lr * rb;
            ++lg;
        }
        if (s[i] == 'B') {
            --rb;
            ans += lr * rg + lg * rr;
            ++lb;
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (j + i + i >= n) break;
            if (s[j] != s[j + i] && s[j] != s[j + 2 * i] && s[j + i] != s[j + 2 * i]) --ans;
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<double> vx(n),vy(n);
  REP(i,n) cin >> vx[i] >> vy[i];
  vector<pair<double,int>> atan_ind;
  REP(i,n) atan_ind.emplace_back(atan2(vx[i], vy[i]), i);
  sort(atan_ind.begin(),atan_ind.end());
  vector<int> ind;
  REP(i,n) ind.push_back(atan_ind[i].second);
  REP(i,n) ind.push_back(atan_ind[i].second);
  double answer = 0.0;
  REP(i,n) {
    double x = 0.0;
    double y = 0.0;
    REP(j,n) {
      x += vx[ind[i+j]];
      y += vy[ind[i+j]];
      answer = max(answer, sqrt(x*x+y*y));
    }
  }
  cout << setprecision(20) << answer << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n,t,max=0,min=INT_MAX,ans=0;
    scanf("%d%d",&n,&t);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for (int i=0; i<n; i++){
        if (min>a[i]){
            min=a[i];
        }
        if(max<a[i]-min){
            max=a[i]-min;
        }
    }
    min=INT_MAX;
    for (int i=0; i<n; i++){
        if (min>a[i]){
            min=a[i];
        }
        if(max==a[i]-min){
            ans++;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

void solve()
{
    ll n,k,c;
    cin>>n>>k>>c;
    string x;
    cin>>x;
    vector<ll>l(n), r(n);
    for(int i=0, j=1;i<n && j<=k ;i++)
    {
        if(x[i]=='o')
        {
            l[i]=j++;
            i+=c;
        }
    }

    for(int i=n-1, j=k; i>=0 && j>0 ;i--)
    {
        if(x[i]=='o')
        {
            r[i]=j--;
            i-=c;
        }
    }

    for(int i=0;i<n;i++)
    {
        if(l[i] && l[i]==r[i])
        {
            cout<<i+1<<endl;
        }
    }
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 6036
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      	string a;
      	cin>>a;
      	int ans=0;
      	for(int i=1 ; i<a.length() ; ++i)
        {
          	if(ans==2 || ans==3)
            break;
        	if(a[i-1]==a[i])
        	++ans;
          	else
            ans=0;
        }
      	if(ans>=2)
        cout<<"Yes"<<endl;
    	else
        cout<<"No"<<endl;
    	return 0;
    }

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back

typedef pair<int, int> pii;

const long MAX_N = 100 * 1000 + 24, INF = 1e9 + 24;

int n, m;
int cnt[MAX_N];
bool mark[MAX_N], cyc[MAX_N];
vector<int> G[MAX_N];

void dfs (int v) {
  for (int u : G[v]) {
    if (cnt[u] == 0 or cyc[u] == 0) continue;
    if (mark[u] == 1) {
      cout<<1<<endl;
      exit(0);
    }
    if (mark[u] == 0) {
      mark[u] = 1;
      dfs(u);
      cyc[u] = 0;
      mark[u] = 0;
    }
  }
}

int main() {
  memset(mark, 0, sizeof (mark));
  cin>>n>>m;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin>>u>>v;
    G[u].pb(v);
    cnt[v]++;
    //G[v].pb(mp(u, w));
  }
  for (int i = 0; i < n; i++) cyc[i] = 1;
  for (int i = 0; i < n; i++) {
    if (cnt[i] == 0) continue;
    mark[i] = 1;
    dfs(i);
    mark[i] = 0;
  }
  cout<<0<<endl;
}



Measured memory_bytes: 5616
#include <stdio.h>

#define lli long long int

lli digit_sum(lli b, lli n){
	if(n < b){
		return n;
	}
	else{
		return digit_sum(b, n / b) + n % b;
	}
}

int main(){
	lli n, s, b, p;
	scanf("%lld%lld", &n, &s);
	if(n < s){
		printf("-1\n");
		return 0;
	}
	if(n == s){
		printf("%lld\n", n + 1);
		return 0;
	}
	for(b = 2; b * b <= n; b++){
		if(digit_sum(b, n) == s){
			printf("%lld\n", b);
			return 0;
		}
	}
	for(p = b - 1; p >= 1; p--){
		b = (n - s) / p + 1;
		if(b != 1){
			if(digit_sum(b, n) == s){
				printf("%lld\n", b);
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n, x; cin >> n >> x;
    int t = 1000;
    rep(i, n){
        int m; cin >> m;
        x -= m;
        t = min(t, m);
    }
    int cnt = x / t;
    cout << n + cnt << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
class mod_comb_k():
  def __init__(self, MAX_N = 10**6, mod = 10**9+7):
    self.fact = [1]
    self.fact_inv = [0] * (MAX_N + 4)
    for i in range(MAX_N + 3):self.fact.append(self.fact[-1] * (i + 1) % mod)
    self.fact_inv[-1] = pow(self.fact[-1], mod - 2, mod)
    for i in range(MAX_N + 2, -1, -1):
      self.fact_inv[i] = self.fact_inv[i + 1] * (i + 1) % mod
  def comb(self, n, k, mod = 10**9+7):
    return self.fact[n] * self.fact_inv[k] % mod * self.fact_inv[n - k] % mod
c=mod_comb_k(n)
mod=10**9+7
for i in range(k):
  div=c.comb(k-1,i)
  if n-k+1>=i+1:print(c.comb(n-k+1,i+1)*div%mod)
  else:print(0)

Measured memory_bytes: 74720
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	string S;
	cin >> S;
	int an = 0;
	rep(i, S.size() / 2) {
		if (S.at(i) != S.at(S.size() - i - 1)) {
			an++;
		}
	}
		cout << an << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC043A___キャンディーとN人の子供イージー
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            int childrenNum = int.Parse(input);
            int candiesNum = childrenNum * (childrenNum + 1) / 2;

            string output = candiesNum.ToString();
            Console.WriteLine(output);

        }
    }
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int h,w;
    cin>>h>>w;

    vector<string> pic(h);
    rep(i,h)cin>>pic[i];

    rep(i,h+2){
        if(i==0 || i==h+1){rep(j,w+2)cout<<"#";ln;}
        else cout<< "#"+pic[i-1]+"#"<<endl;
    }

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int box[10];
int l[10],r[10];
void func(int nn);
int flg;
int main(void){
	int n;
	int i,j;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<10;j++){
			cin>>box[j];
			l[i]=r[i]=0;
		}
		flg=0;
		func(0);
		cout<<((flg)?"YES":"NO")<<endl;
	}
	return 0;
}
void func(int nn){
	int i;
	int x;
	int flg1,flg2;
	if(nn>=10){
		flg1=flg2=0;
		x=0;
		for(i=0;i<10;i++){
			if(l[i]==1){
				if(x<box[i])	x=box[i];
				else{
					flg1=1;
					break;
				}
			}
		}
		x=0;
		for(i=0;i<10;i++){
			if(r[i]==1){
				if(x<box[i])	x=box[i];
				else{
					flg2=1;
					break;
				}
			}
		}
		if(flg1==0&&flg2==0)	flg=1;
	}
	else{
		l[nn]=1;
		func(nn+1);
		l[nn]=0;
		r[nn]=1;
		func(nn+1);
		r[nn]=0;
	}
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABK = Io.ReadList<long>();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];

            var a = Math.Max(A - K, 0);
            var b = Math.Max(B - Math.Max(K - A, 0), 0);
            var output = $"{a} {b}";
            Io.Write(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }

        class Io
        {
            public static string Read()
            {
                return Console.ReadLine();
            }

            public static IEnumerable<string> ReadRepeat(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read());
            }

            public static T Read<T>()
            {
                return (T)Convert.ChangeType(Read(), typeof(T));
            }

            public static IEnumerable<T> ReadRepeat<T>(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read<T>());
            }

            public static string[] ReadList(char devide = ' ')
            {
                return Read().Split(devide);
            }

            public static T[] ReadList<T>(char devide = ' ')
            {
                return ReadList(devide)
                    .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                    .ToArray();
            }

            public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
            {
                return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
            }

            public static void Write(string value)
            {
                Console.WriteLine(value);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

ll pow(ll x, ll n)
{
	ll res = 1;
	while (n > 0)
	{
		if (n & 1) res = res * x;
		x = x*x;
		n >>= 1;
	}
	return res;
}

ll n, m, a, b, p, q;

ll calc(ll k)
{
	return p * pow(a, k) + q * pow(b, k);
}

bool check(ld k)
{
	return p * pow(a, k) + q * pow(b, k) <= pow(10, 12);
}

ll use(ll d)
{
	ll loop = min(n + 1, 42ll);
	ll res = n - 1;
	REP(i, loop)
	{
		if (!check(i) || calc(i) > d)
		{
			res = i - 1;
			break;
		}
	}
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n >> m >> a >> b >> p >> q;
	ll ans = LLONG_MAX;
	if (a == 1 && b == 1)
	{
		if (((ld)p + q) * n < (ld)m) ans = m - (p + q) * n;
		else
		{
			ll t = m / (p + q);
			ans = min(m - (p + q) * t, (p + q)*(t + 1) - m);
		}
	}
	else if (a > 1 && b > 1)
	{
		set<int> st;
		ll d = m;
		int cnt = 0, mx = n;
		int loop = min(n + 1, 41ll);
		while (st.size() < loop)
		{
			ll t = use(d);
			if (t + 1 < n && !st.count(t + 1) && d < calc(t + 1))
			{
				chmin(ans, calc(t + 1) - d);
			}
			if (t < 0) break;
			ll tmp = min(n, t);
			while (st.count(tmp) && tmp > 0) tmp--;
			if (tmp == 0 && st.count(0)) break;
			d -= calc(tmp);
			st.insert(tmp);
			chmin(ans, d);
		}
		chmin(ans, d);
	}
	else
	{
		int loop = min(n + 1, 41ll);
		REP(i, loop)
		{
			set<int> st;
			ll d = m;
			int cnt = 0, mx = n;
			while (st.size() < i)
			{
				ll t = use(d);
				if (t < 0) break;
				ll tmp = min(n - 1, t);
				while (st.count(tmp) && tmp > 0) tmp--;
				if (tmp == 0 && st.count(0)) break;
				d -= calc(tmp);
				st.insert(tmp);
			}
			if (st.size() == i - 1)
			{
				if (!st.count(0))
				{
					chmin(ans, calc(0) - d);
				}
				continue;
			}
			else if (st.size() != i) continue;
			chmin(ans, d);
			if (st.size() > 0)
			{
				int last = *st.begin();
				if (last + 1 < n && !st.count(last + 1))
				{
					d = d + calc(last) - calc(last + 1);
					chmin(ans, -d);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

string n;
int k;
ll dp[101][4][2] = {};

void calc(int p){
    for(int i = 0; i < n.size(); i++){
        for(int j = 0; j <= k; j++){
            if(j < k){
                dp[i + 1][j][0] += dp[i][j][0];
                dp[i + 1][j + 1][0] += dp[i][j][0] * 9 + dp[i][j][1] * max(0, n[i] - '0' - 1);
                if(n[i] == '0'){
                    dp[i + 1][j][1] += dp[i][j][1];
                }else{
                    dp[i + 1][j][0] += dp[i][j][1];
                    dp[i + 1][j + 1][1] += dp[i][j][1];
                }
            }else{
                dp[i + 1][j][0] += dp[i][j][0];
                if(n[i] == '0'){
                    dp[i + 1][j][1] += dp[i][j][1];
                }else{
                    dp[i + 1][j][0] += dp[i][j][1];
                }
            }
        }
    }
}

int main(){
    cin >> n >> k;
    dp[0][0][1] = 1;
    calc(0);
    int m = n.size();
    ll ans = dp[m][k][0] + dp[m][k][1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char Map[105][105];
int m,n,ans;
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
void dfs(int x,int y,char ch)
{
    if(Map[x][y]==ch) Map[x][y]='.';
	for(int i=0;i<4;i++)
	{
	    int nx=x+dir[i][0],ny=y+dir[i][1];
		if(nx>=0&&nx<m&&ny>=0&&ny<n&&Map[nx][ny]==ch)
		{
			dfs(nx,ny,ch);
        }
	}
}
int main()
{
	while(scanf("%d%d",&m,&n)!=EOF)
	{
	    if(m==0&&n==0)  break;
		for(int i=0;i<m;i++) 	scanf("%s",Map[i]);
		ans=0;
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(Map[i][j]!='.')
                {
                    ans++;
                    dfs(i,j,Map[i][j]);
                }
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define endl "\n"
typedef long long ll;
using namespace std;

int main()
{
 ll n,sum=0; cin>>n;
 ll a[n];
 ll s=0;
 vector<ll>v;
 for(ll i=0;i<n;i++)
 {
     cin>>a[i];
     s+=a[i];
     v.push_back(s);
 }
 ll k=v[n-1];
 ll ans=0;
 ll x;
 ll mod=1000000007;
 for(ll i=0;i<n;i++)
 {
     x=((a[i]%mod)*((k-v[i])%mod))%mod;
     ans=((ans%mod)+(x))%mod;
}
cout<<ans<<endl;
}

Measured memory_bytes: 6600
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;

int main()
{
	int a,b,t;
	scanf("%d%d%d",&a,&b,&t);
	printf("%d\n",(t/a)*b);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<ll> T(N);
    REP(i, N) cin >> T[i];

    ll ans = T[0];
    REP(i, N-1) {
        ll g = gcd(ans, T[i+1]);

        ans *= T[i+1] / g;
    }

    cout << ans << endl;
}


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



int main() {
	int h, w, s, t;
	cin >> h >> w >> s >> t;
	if (h % 2 == 1 && w % 2 == 1) {
		if ((s - 1) % 2 == 1) {
			if ((t - 1) % 2 == 0) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if ((t - 1) % 2 == 1) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3108
H,N = map(int,input().split())
INF = float('inf')
# dp[i] = 攻撃がh以上となるときに考えられる最小の体力消耗
dp = [INF] * (H+1)

for _ in range(N):
  a,b = map(int,input().split())

  for h in range(1, H+1):
    if h <= a:
      dp[h] = min(dp[h],b)
    else:
      dp[h] = min(dp[h],dp[h-a]+b)

print(dp[-1])

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

using namespace std;

#define F first
#define S second

string world[8] = {"U", "D", "R", "L", "UL", "UR", "DR", "DL"};
const int rx[8] = { -1,  1,  0,  0,  -1,  -1,   1,   1};
const int ry[8] = { 0,  0,  1, -1,  -1,   1,   1,  -1};


int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    bool f = false;
    int l = -1, r = -1;
    for (int i = 1; i < s.length(); i++){
        if (s[i] == s[i - 1]){
            l = i;
            r = i + 1;
        }
    }
    for (int i = 2; i < s.length(); i++){
        if (s[i] == s[i - 2]){
            l = i - 1;
            r = i + 1;
        }
    }
    cout << l << " " << r << endl;
#ifdef TIME
    cerr << "TIME = " << 1. * clock() / CLOCKS_PER_SEC;
#endif
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  ll K;cin >> K;
  vector<ll> v(N);
  vector<ll> w(N);
  rep(i,N)cin >> v[i] >> w[i];

  int M = 30;
  ll ans = 0;
  rep(i,M){
    ll k;
    if(i==0) k = K;
    else if((K>>i)&1) k = (K - (1ll<<i)) | ((1ll<<i) - 1ll);
    else continue;
    ll sum = 0;
    rep(i,N) if(k == (k|v[i])) sum+=w[i];
    ans = max(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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 SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	ll n, h;
	ll atk{ 0 };
	vector<ll> th;
public:
	D()
	{
		cin >> n >> h;

		th.resize(n);

		ll tmp;
		REP(i, n)
		{
			cin >> tmp >> th[i];
			chmax(atk, tmp);
		}

		sort(ALL(th), greater<>());
	}

	void solve()
	{
		ll ans{ 0 };
		ll tmph{ h };

		for (int i{ 0 }; i < n && th[i] >= atk && tmph > 0; i++)
		{
			tmph -= th[i];
			++ans;
		}

		if (tmph > 0)
			ans += (ll)ceil((double)tmph / atk);

		cout << ans << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, p;
	string s;
	cin >> n >> p >> s;

	ll ans = 0;

	if (p == 2 || p == 5) { rep(i, n)if ((s[i] - '0') % p == 0)ans += (ll)i + 1; }
	else {
		int x = 1, k = 0;
		vi cnt(p, 0);cnt[0]++;
		rep(i, n) {
			k += (s[n - 1 - i] - '0') * x;k %= p;
			cnt[k]++;
			x = x * 10 % p;
		}
		rep(i, p) ans += cnt[i] * ((ll)cnt[i] - 1) / 2;
		
	}

	cout << ans << endl;

}

Measured memory_bytes: 640
n, a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]

import itertools
set123 = set([1,2,3])
ans = 10 ** 10
for i in itertools.product([0,1,2,3], repeat=n):
    if len(set(i) & set123) < 3:
        continue
    mp = 0
    ai = 0
    bi = 0
    ci = 0
    for j in range(n):
        if i[j] == 0:
            continue
        if i[j] == 1:
            if ai > 0:
                mp += 10
            ai += l[j]
        if i[j] == 2:
            if bi > 0:
                mp += 10
            bi += l[j]
        if i[j] == 3:
            if ci > 0:
                mp += 10
            ci += l[j]
    mp += abs(ai - a)
    mp += abs(bi - b)
    mp += abs(ci - c)
    ans = min(ans, mp)
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
using namespace std;
int main(void) {
	int a, b, c, d,i;
	scanf("%d%d", &a, &b);
	printf("%d ", a*b);
	c = a * 2; d = b * 2;
	printf("%d\n", c + d);
	//for (i = 0; i < 2;i++)getchar();
	return 0;
}


Measured memory_bytes: 3156
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d",&n);
	printf("%lld",1ll*n*(n-1)/2);
}


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

#define int long long
#define push_back PB
#define pop_back PPB
static const int MAX_N = 10005;

struct UF {
  int par[MAX_N], n;

  void init(int pn) {
    for (int i = 0; i < pn; ++i) {
      par[i] = i;
    }
  }

  int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    par[x] = y;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

UF uf;

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

  int n, q;
  cin >> n >> q;
  uf.init(n);

  for (int i = 0; i < q; ++i) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) cout << uf.same(x, y) << endl;
    else uf.unite(x, y);
  }

  return 0;
}

Measured memory_bytes: 1364
def main():
    N = int(input())
    ans = set()
    if N % 2 == 0:
        for i in range(1,N+1):
            k = N - i + 1
            for j in range(1,N+1):
                if j == k or j == i:
                    continue
                if j > k:
                    ans.add((k,j))
                else:
                    ans.add((j,k))
                if j > i:
                    ans.add((i,j))
                else:
                    ans.add((j,i))
    else:
        for i in range(1,N):
            ans.add((i,N))
        for i in range(1,N):
            k = N - i
            for j in range(1,N+1):
                if j == k or j == i:
                    continue
                if j > k:
                    ans.add((k,j))
                else:
                    ans.add((j,k))
                if j > i:
                    ans.add((i,j))
                else:
                    ans.add((j,i))
    print(len(ans))
    for i, j in ans:
        print(i,j)        

if __name__ == "__main__":
    main()

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

int main(int argc, char const *argv[])
{
	int N ;
	cin>>N ;

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

	int count = 0 ;
	
	for(int i = 0 ; i < N ; i++)
		if(i+1 != vec[i])++count ;

	if(count == 0 || count == 2) cout<<"YES" ;
	else cout<<"NO" ;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int N;
  int length=1;
  cin >> N;
  int A[N+1];
  int L[N+1];
 
  for(int i=1;i<N+1;++i){
     cin >> A[i];
  }
  L[1]=A[1];

   
  for(int i=1;i<N+1;++i){
    if(L[length] < A[i]) L[++length] = A[i];
    if(L[1] > A[i] ) L[1]=A[i];
    else{
      int l=1,r=length,mid;
      while(l<=r){
    mid = (l+r)/2;
    if(A[i] == L[mid] || A[i] == L[mid+1]) break;
    else if(A[i]<L[mid+1] && L[mid]<A[i]){
      L[mid+1] = A[i];
      break;
    }else if(A[i]<L[mid]) r=mid;
    else  if(A[i]>L[mid]) l=mid;
      }
    }
     
  }
   
  cout << length << endl;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

int n, a[55], b[55];
ll MX = (ll(1) << 52);
int mem[55][55], obj;
ll mk;

int dp (int n, int i) {
	if (i == 0)
		return n == obj;

	int &res = mem[n][i];
	if (res != -1)
		return res;

	return res = dp(n, i-1)
			  || ((mk & (ll(1) << i)) && dp(n%i, i-1));
}

bool esPos (ll m) {
	for (int i = 0; i < n; i++) {
		for (int i = 0; i < 55; i++)
			for (int j = 0; j < 55; j++)
				mem[i][j] = -1;
		mk = m;
		obj = b[i];

		if (!dp(a[i], 51))
			return false;
	}

	return true;
}

ll obtRes () {
	if (!esPos(MX-1))
		return -1;

	ll res = 0;
	for (ll i = 50, j = (1LL << 50); i; i--, j /= 2)
		if (!esPos(res | (j-1)))
			res |= j;

	return res;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
 	cin >> n;
 	FOR(i, n) cin >> a[i];
 	FOR(j, n) cin >> b[j];

 	cout << obtRes() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
a+b+2gen(ab)<c
4ab<(c-a-b)^2
*/ 
typedef long long LL;
int main(){
	LL a,b,c;scanf("%lld%lld%lld",&a,&b,&c);
	if(4*a*b<(c-a-b)*(c-a-b)&&a+b<c)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める
    計算量: O(Nlog)
    """
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
MOD = 10**9 + 7
a = list(map(int, input().split()))
lcm_ = multi_lcm(a)
ans = 0
for i in range(n):
    ans += lcm_ * pow(a[i], MOD - 2, MOD)
print(ans % MOD)

Measured memory_bytes: 68696
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    long long int n;
    long long int x=100;
    long long int count=0;
    cin>>n;
    while(x<n){
        x+=0.01*x;
        count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll a, b;
	cin >> a >> b;
	cout << (a + b >= 10 ? "error" : to_string(a + b)) << endl;
}

Measured memory_bytes: 256
a, b, c = gets.chomp.split.map(&:to_i)
k = gets.chomp.to_i

k.times do |i|
  if a >= b
    b = b * 2
    next
  end
  
  if b >= c
    c = c * 2
    next
  end
end
if a < b and b < c
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	@SuppressWarnings("null")
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		int w,n,c=0;
		String str;
		while((w = Integer.parseInt(bf.readLine()))>0){
			n = Integer.parseInt(bf.readLine());
			int[] weight = new int[n+1];
			int[] value = new int[n+1];
			int[][] ans_a = new int[n+1][w+1];
			int[][] ans_b = new int[n+1][w+1];
			weight[0]=0;value[0]=0;
			for(int i=1;i<=n;i++){
				str=bf.readLine();;
				value[i]=Integer.parseInt(str.split(",")[0]);
				weight[i]=Integer.parseInt(str.split(",")[1]);
			}
			for(int j=0;j<=w;j++)ans_a[0][j]=0;
			for(int i=1;i<=n;i++){
				for(int j=0;j<weight[i];j++){
					ans_a[i][j]=ans_a[i-1][j];
					ans_b[i][j]=ans_b[i-1][j];
				}
				for(int j=weight[i];j<=w;j++){
					ans_a[i][j]=Math.max(ans_a[i-1][j],ans_a[i-1][j-weight[i]]+value[i]);
					ans_b[i][j]=(ans_a[i-1][j]>ans_a[i-1][j-weight[i]]+value[i])?(ans_b[i-1][j]):(ans_b[i-1][j-weight[i]]+weight[i]);
				}
			}
			System.out.println("Case "+(++c)+":");
			System.out.println(ans_a[n][w]);
			System.out.println(ans_b[n][w]);
		}
	}
}

Measured memory_bytes: 18000