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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
vector<int> to[8];
bool exist(vector<int> &vec, int val){
    rep(i, vec.size()){
        if(vec[i] == val) return true;
    }
    return false;
}

int main(){
    int n, m; cin >> n >> m;
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b); to[b].push_back(a);
    }

    vector<int> per; int ans = 0;
    rep(i, n-1) per.push_back(i+1);
    do{
        if(!exist(to[0], per[0])) continue;
        bool ok = true;
        rep(i, n-2){
            if(!exist(to[per[i]], per[i+1])){
                ok = false; break;
            }
        }
        if(ok) ans++;
    }while(next_permutation(per.begin(), per.end()));

    out(ans);
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: u32
    }

    solve(n);
}

fn solve(n: u32) {
    let mut s = 0;
    for i in 1..(n + 1) {
        if i.to_string().len() % 2 == 1 {
            s += 1;
        }
    }
    println!("{}", s);
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  for(int i = 0; i < N-2; i++){
    if(S.at(i) == 'A' && S.at(i + 1) =='B' && S.at(i + 2) == 'C'){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3608
n = int(input())
for i in range(n // 4 + 1):
    for j in range(n // 7 + 1):
        if i * 4 + j * 7 == n:
            print('Yes')
            break
        else:
            continue
    else:
        continue
    break
else:
    print('No')

  

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, K;
    cin >> N >> M >> K;
    ll A[N], B[M];
    REP(i, 0, N) {
        cin >> A[i];
    }
    REP(i, 0, M) {
        cin >> B[i];
    }
    ll ans = 0;
    ll num = 0;
    ll time = 0;
    ll nowa = -4;
    REP(i, 0, N) {
        if (time + A[i] > K) {
            nowa = i - 1;
            break;
        }
        num++;
        time += A[i];
    }
    if (nowa == -4) {
        nowa = N - 1;
    }
    ans = num;
    bool ok = true;
    REP(i, 0, M) {
        while (nowa >= 0) {
            if (time + B[i] <= K) {
                num++;
                time += B[i];
                break;
            } else {
                num--;
                time -= A[nowa];
                nowa--;
            }
        }
        if (nowa < 0) {
            if (time + B[i] <= K) {
                num++;
                time += B[i];
            } else {
                ok = false;
            }
        }
        if (!ok) {
            break;
        }
        ans = max(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
struct unionfind{
  int par[200010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[200010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
int main(){
  int n,m,i;
  cin >> n >> m;
  unionfind tree(n); //treeという名前で宣言
  for(i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    a--,b--;
    tree.unite(a,b); //a,bをつなげる
  }
  int ans=0;
  for(i=0;i<n;i++){
    if(ans<tree.size(i)){
      ans=tree.size(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
#include<iostream>
#include <algorithm>
using namespace std;
int n;
int edge[2010];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>edge[i];
	}
	int sum=0;
	sort(edge,edge+n);
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int sum_1,countor;
			sum_1 = edge[i] + edge[j];
			countor = j+1;
			for(countor;sum_1>edge[countor] && countor<n;countor++){
				sum++;
			}
		}
	}
	cout<<sum;
	return 0;
}

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

int main(){
    int n, k; cin >> n >> k;
    ll ans = 0;
    int tmp;
    for(int i = 1; i <= n - k; i++){
        tmp = n;
        int b = k + i;
        ans += tmp/b*i;
        int cnt = tmp % b;
        if(cnt == 0) continue;
        if(k == 0) ans += (cnt >= k? cnt - k: 0);
        if(k > 0) ans += (cnt >= k? cnt - k + 1: 0);
    }
    cout << ans << endl;

}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n*3);
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v, u--, v--;
        for(int j = 0; j < 3; j++){
            g[u*3 + j].push_back(v*3 + (j+1)%3);
        }
    }
    int s, t;
    cin >> s >> t, s--, t--;

    queue<int> q;
    q.push(s*3);
    vector<int> dist(n*3, -1);
    dist[s*3] = 0;
    while(!q.empty()){
        int a = q.front(); q.pop();
        for(auto& e : g[a]){
            if(dist[e] != -1) continue;
            dist[e] = dist[a] + 1;
            q.push(e);
        }
    }
    cout << (dist[t*3] % 3 == 0 ? dist[t*3] / 3 : -1) << endl;
    return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e8
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

vector<int> alpha(26);

int main() {
    ll n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    ll distance[n][n];
    ll ans[n];
    REP(i, n) ans[i] = 0;

    REP(i, n) REPN(j, i+1, n) {
        distance[i][j] = 0;
    }

    REP(i, n) REPN(j, i+1, n) {
        distance[i][j] = j - i;
    }

    REP(i, n) REPN(j, i+1, n) {
        if(i <= x && y <= j) {
            distance[i][j] = min(distance[i][j], ((x - i) + (j - y) + 1));
        }
        if (i <= x && j <= y) {
            ll tmp = 0;
            tmp += x - i;
            tmp += y - j;
            tmp++;
            distance[i][j] = min(distance[i][j], tmp);
        }
        if (x <= i && y <= j) {
            ll tmp = 0;
            tmp += j - y;
            tmp += i - x;
            tmp++;
            distance[i][j] = min(distance[i][j], tmp);            
        }
        if (x <= i && j <= y) {
            ll tmp = 0;
            tmp += i - x;
            tmp += y - j;
            tmp++;
            distance[i][j] = min(distance[i][j], tmp);                
        }
    }    

    REP(i, n) REPN(j, i+1, n) {
        ans[distance[i][j]]++;
    }

    REPN(i, 1, n) {
        cout << ans[i] << endl;
    }
    

    return 0;
}
 

Measured memory_bytes: 30720
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    int l = s.length();
    int flag = 1;
    for(int i = 0; i < l; i++){
        if(s[i]!=t[i]){
            flag = 0;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include <iomanip>
using namespace std;
double CalDistance(int x1, int y1, int x2, int y2) {
  double dis = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) * 1.0);
  return dis;
}
int main() {
  int n = 0;
  cin >> n;
  vector<int> x(n, 0);
  vector<int> y(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  vector<int> p(n, 0);
  for(int i = 0; i < n; ++i) {
    p[i] = i;
  }
  double sum = 0;
  int kind = 0;
  do {
    kind++;
    for(int i = 0; i < n - 1; ++i) {
      int s = p[i];
      int e = p[i + 1];
      sum += CalDistance(x[s], y[s], x[e], y[e]);
    }
  } while (next_permutation(p.begin(), p.end()));
  cout << setprecision(16);
  double avg = sum / (kind * 1.0);
  cout << avg;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 20
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
int d[N+1][N+1];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int w,h;
char maze[N][N];
int bfs(P start,P goal){
	queue<P> que;
    REP(i,N){
        REP(j,N){
            d[i][j]=INF;
        }
    }
    que.push(start);
    d[start.first][start.second]=0;
    while(SZ(que)){
        P p=que.front();
        que.pop();
        if(p==goal) break;
        REP(i,4){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(nx>=0&&nx<w&&0<=ny&&ny<h&&maze[nx][ny]!='#'&&d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    return d[goal.first][goal.second];
}
int main(){
    cin>>w>>h;
    REP(i,w){
        REP(j,h){
            cin>>maze[i][j];
        }
    }
    int cnt=0;
    REP(i,w){
        REP(j,h){
            if(maze[i][j]=='#') continue;
            REP(s,w){
                REP(t,h){
                    if(s==i&&j==t) continue;
                    if(maze[s][t]=='#') continue;
                    P start={i,j};
                    P goal={s,t};
                    int tmp=bfs(start,goal);
                    cnt=max(cnt,tmp);
                }
            }
        }
    }
    OUT(cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi  3.141592653589793238
const int mod=1000000007;
#define int long long
signed main(){

    
   int n; cin >> n;
   int k; cin >> k;
   vector<int> vv;
   int ss1 = 0;
   int ss2 = 0;
   int cnt1 = 0;
   for(int i = 0; i < k;i++){
    ss1 = (ss1 + cnt1);
    cnt1++;
   }
   int cnt2 = n;
   for(int i =0; i < k;i++) {
      ss2 = (ss2 + cnt2);
      cnt2--;
   }

   int ans  = ss2 - ss1 + 1;
   for(int i = k+1; i <= n+1; i++){
     ss1 = (ss1 + cnt1);
     ss2 = (ss2 + cnt2);
     cnt1++;
     cnt2--;
     ans = (ans + (ss2-ss1 + 1)) % mod;
   }
   cout << ans << endl;


  return 0;
}

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

int main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
 
void solve(){
	cin >> n >> x >> k;
	cout << (n+x-1)/x * k<<endl;	
 
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

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

int main() {
  int n, count = 1;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  if (n > 1) {
    for (int i=1; i<n; i++) {
      if (vec.at(i) < vec.at(i-1)) count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3608
n = int(input())
s = [input() for i in range(n)]
ss = set(s)
m = int(input())
t = [input() for i in range(m)] 
ans = 0

for i in ss:
    if i not in t:
        ans = max(ans, s.count(i))
    else:
        ans = max(ans, s.count(i)-t.count(i))
print(ans)

Measured memory_bytes: 3064
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Measured memory_bytes: 14468
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,n)
#define PER(i,n)  ROF(i,0,n)
#define SIZE(a) int((a).size())

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	string s,t;cin>>s>>t;
	int n = SIZE(s);

	VI s1(26),t1(26);

	REP(i,n){
		s1[s[i]-'a']++;
		t1[t[i]-'a']++;
	}

	SORT_ASC(s1);
	SORT_ASC(t1);
	
	REP(i,26){
		//dump(i)
		//dump(s1[i])
		//dump(t1[i])
		
		if(s1[i] != t1[i]){
			cout << "No" << endl;
			return;
		}
	}

	cout << "Yes" << endl;
	
	return;
}

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

Measured memory_bytes: 916
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

using cnt = map<int, int>; // Counter
using pii = pair<int, int>;

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

int n;
int a[100005];

cnt d0, d1;
vector<pii> l0, l1; 

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

	d0[0] = 0;
	d1[0] = 0;
    for(int i=0;i<n;++i) {
        if(i%2==0)d0[a[i]]++;
        else d1[a[i]]++;
    }

	for(pii v: d0)l0.pb(v);
	for(pii v: d1)l1.pb(v);
	
	sort(l0.begin(), l0.end(), [](const pii& p, const pii& q){ return p.sd > q.sd;});
	sort(l1.begin(), l1.end(), [](const pii& p, const pii& q){ return p.sd > q.sd;});
	
	if(l0[0].ft == l1[0].ft) cout << min(n - l0[0].sd - l1[1].sd, n - l0[1].sd - l1[0].sd) << endl;
    else cout << n - l0[0].sd - l1[0].sd <<endl;

	return 0;
}

Measured memory_bytes: 6524
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
struct Restaurant{
	string city;
	int64_t value;
	ll index;
};
bool operator<(const Restaurant& a,const Restaurant &b){
	if(a.city==b.city){
		return a.value>b.value;
	}else{
		return a.city<b.city;
	}
}
int main(){
	ll n;
	cin>>n;
	vector<Restaurant> lt;
	for(int64_t i1=0;i1<n;i1++){
		string city_temp;
		ll value_temp;
		cin>>city_temp>>value_temp;;
		lt.push_back(Restaurant{city_temp,value_temp,i1+1});
	}
	sort(lt.begin(),lt.end());
	for(auto i1=lt.begin();i1!=lt.end();i1++){
		cout<<i1->index<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    int e = (m + 1) / 2;
    int o = m / 2;
    rep(i, e){
        a[i] = e - 1 - i;
        b[i] = e + i;
    }
    rep(i, o){
        a[e+i] = 2 * e + o - 1 - i;
        b[e+i] = 2 * e + o + 1 + i;
    }
    rep(i, m)cout << a[i]+1 << ' ' << b[i]+1 << endl;
}

Measured memory_bytes: 4004
n=int(input())
i=0
s=[]
s=list(map(int,input().split(" ")))

ans=1
i=1
while i!=n:
    if s[i]>s[i-1]:
        s[i]=s[i]-1
    if s[i]<s[i-1]:
        ans=0
    i+=1
if ans==1:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 14252
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] array = new int[n];
        int dif = 0;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if (i == n - 1) {
                dif = Math.max(dif, (k - array[i]) + array[0]);
            } else {
                dif = Math.max(dif, array[i+1] - array[i]);
            }
        }
        
        System.out.println(k -dif);
    }
}


Measured memory_bytes: 67060
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# A_B = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# edges = [list(map(int,input().split())) for _ in range(M)]
# tree = [[] for _ in range(N + 1)]

# for edge in edges:
#     tree[edge[0]].append([edge[1], edge[2]])
#     tree[edge[1]].append([edge[0], edge[2]])

# depth = [-1] * (N + 1)
# depth[1] = 0

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

# d = deque()
# d.append(1)
# ans = [0] * (N + 1)
# while d:
#  v = d.popleft()
#  for i in tree[v]:
#    if depth[i] != -1:
#      continue
#    depth[i] = depth[v] + 1
#    ans[i] = v
#    d.append(i)

uf = UnionFind(N + 1)

for i in range(M):
    A, B = map(int, input().split())
    uf.union(A, B)

print(-1 * min(uf.parents))


Measured memory_bytes: 14556
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int h, w; cin >> h >> w;
    vector<vector<bool>> maze(h+2, vector<bool>(w+2));
    int num_white=0;
    for(int hi=1; hi<=h; ++hi){
        for(int wi=1; wi<=w; ++wi){
            char c; cin >> c;
            maze[hi][wi]=c=='.';
            num_white+=c=='.';
        }
    }
    vector<vector<bool>> visited(h+2, vector<bool>(w+2));
    queue<pair<int, pair<int, int>>> que;
    que.push(make_pair(0, make_pair(1, 1)));
    int ans=-1;
    int dx[]={1, 0, -1, 0};
    int dy[]={0, 1, 0, -1};
    while(!que.empty()){
        auto e=que.front(); que.pop();
        int len=e.first;
        int hi=e.second.first;
        int wi=e.second.second;
        if(hi==h && wi==w){
            ans=num_white-len-1;
            break;
        }
        if(visited[hi][wi]) continue;
        visited[hi][wi]=true;
        for(int i=0; i<4; ++i){
            int new_hi=hi+dy[i];
            int new_wi=wi+dx[i];
            if(!maze[new_hi][new_wi]) continue;
            que.push(make_pair(len+1, make_pair(new_hi, new_wi)));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c;
    long d=1000000,e=-1000000,f=0;
    scanf("%d",&a);
    for(b=0;b<a;b++){
        scanf("%d",&c);
        if(d>c){
            d=c;
        }
        if(e<c){
            e=c;
        }
        f+=c;
    }
    printf("%ld %ld %ld\n",d,e,f);
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
int main()
{
    long long int occur[100009]={0};
    int n;
    cin>>n;
    int x;
    ll sum=0;
    for(int i=1;i<=n;i++){ cin>>x ; occur[x]++ ; sum+=x ;}
    int q;
    cin>>q;
    ll b,c;
    for(int i=1;i<=q;i++)
    {
        cin>>b>>c;
        sum=sum+occur[b]*(c-b);
        cout<<sum<<"\n";
        occur[c]+=occur[b];
        occur[b]=0;
    }
}



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

int main(){
  int N, M; cin >> N >> M;
  vector<int> table(N);
  for(int i = 0; i < M; i++){
    int L, R; cin >> L >> R;
    table.at(L-1)++;
    if(R <= N-1) table.at(R)--;
  }
  
  for(int i = 0; i < N; i++){
    if(i > 0) table.at(i) += table.at(i-1);
  }
  
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(table.at(i) == M) cnt++;
  }
  
  cout << cnt << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
	int ans = A * X + B * Y;
	repp(i,1,max(X,Y)+1) ans = min(ans , max(0,X-i)*A+max(0,Y-i)*B+2*i*C);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
b = []
for a in 0..m
  b << 0
end
a = []
for x in 1..n
  a = gets.chomp.split.map(&:to_i)
  for y in 1..a[0]
    b[a[y]] = b[a[y]] + 1
  end
end
c = 0
for i in 1..m
  if b[i] == n
    c = c + 1
  end
end
puts c


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

int num[4];
int r[4];
bool used[4];

char op[3] = { '+', '-', '*' };

int perf(char o, int a, int b) {
	if (o == '+') return a+b;
	if (o == '-') return a-b;
	/* if (o == '*') */ return a*b;
}

bool eval(int depth) {
	if (depth == 0) {
		for (int i = 0; i < 3*3*3; i++) {
			int j = i;
			char o1 = op[j%3]; j /= 3;
			char o2 = op[j%3]; j /= 3;
			char o3 = op[j];
			if (10 == perf(o1, r[0], perf(o2, r[1], perf(o3, r[2], r[3])))) {
				printf("(%d%c(%d%c(%d%c%d)))\n", r[0], o1, r[1], o2, r[2], o3, r[3]);
				return true;
			}
			if (10 == perf(o1, r[0], perf(o2, perf(o3, r[1], r[2]), r[3]))) {
				printf("(%d%c((%d%c%d)%c%d))\n", r[0], o1, r[1], o3, r[2], o2, r[3]);
				return true;
			}
			if (10 == perf(o1, perf(o2, r[0], r[1]), perf(o3, r[2], r[3]))) {
				printf("((%d%c%d)%c(%d%c%d))\n", r[0], o2, r[1], o1, r[2], o3, r[3]);
				return true;
			}
			if (10 == perf(o1, perf(o2, r[0], perf(o3, r[1], r[2])), r[3])) {
				printf("((%d%c(%d%c%d))%c%d)\n", r[0], o2, r[1], o3, r[2], o1, r[3]);
				return true;
			}
			if (10 == perf(o1, perf(o2, perf(o3, r[0], r[1]), r[2]), r[3])) {
				printf("(((%d%c%d)%c%d)%c%d)\n", r[0], o3, r[1], o2, r[2], o1, r[3]);
				return true;
			}
		}
		return false;
	}

	for (int i = 0; i < 4; i++) {
		if (used[i]) continue;
		r[depth-1] = num[i], used[i] = true;
		if (eval(depth-1)) return true;
		used[i] = false;
	}

	return false;
}

int main() {
	while (cin >> num[0] >> num[1] >> num[2] >> num[3],
			num[0]||num[1]||num[2]||num[3]) {
		used[0] = used[1] = used[2] = used[3] = false;
		if (!eval(4))
			cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
'use strict';
(function(input){
  const numList=new Array(320).fill(0).map((x,i)=>i);
  numList[0]=numList[1]=Infinity;
  for(let k=0;k<1024;k++){
    let l=2;
    while(numList[k]*l<1024){
      numList[k*l]=Infinity;
      l++;
    }
  }
  const primeList=numList.filter(x => x<2048);
  const isPrime=x=>primeList.some(y=>y===x)||!primeList.reduce((acc,cur)=>x%cur===0||acc,false);
  
  let X=input.trim()-0;
  
  while(!isPrime(X)){
    X++;
  }
  
  console.log(X);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 21192
import heapq
def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

#########################
n,w = map(int,input().split())

edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
for i in range(w):
    x,y,z = map(int,input().split())
    edge[x].append([z,y])
    edge[y].append([z,x])
print(prim_heap())


Measured memory_bytes: 34976
def cal(N,n_str):
    n_list = ["7","5","3"]

    if len(n_str) != 0:
        if int(n_str) <= N:
            if len(n_str) == len(str(N)) and len(set(list(n_str))) == 3:
                return 1
            elif len(n_str) == len(str(N)) and len(set(list(n_str))) < 3:
                return 0
            elif len(n_str) < len(str(N)) and len(set(list(n_str))) == 3:
                return 1 + cal(N,n_str+"7") + cal(N,n_str+"5") + cal(N,n_str+"3")
            elif len(n_str) < len(str(N)) and len(set(list(n_str))) < 3:
                return cal(N,n_str+"7") + cal(N,n_str+"5") + cal(N,n_str+"3")
        else:
            return 0
    else:
        return cal(N,n_str+"7") + cal(N,n_str+"5") + cal(N,n_str+"3")

def main():
    N = int(input())

    print(cal(N,""))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
map<long long,bool> mp;
long long strtoll(string s){
	int id=0;
	long long ret=0;
	for(int i=s.size()-1;i>=0;i--)
	{
		ret+=int(s[i]-'0')*pow(10,id);
		id++;
	}
	return ret;
}
void dfs(string a){
	if(a.size()>9){
		long long temp=strtoll(a);
		if(temp!=0)mp[temp]=1;
		return;
	}
	long long temp=strtoll(a);
	if(temp!=0)mp[temp]=1;
	if(a[0]!='0'&&a[0]!='9'){
		char x=a[0]-1,y=a[0],z=a[0]+1;
		dfs(x+a);dfs(y+a);dfs(z+a);
	}
	else{
		if(a[0]=='0'){
			dfs('0'+a);
			dfs('1'+a);
		}
		else{
			dfs('8'+a);
			dfs('9'+a);
		}
	}
	return;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int K;
	cin>>K;
	for(int i=0;i<10;i++)
	{
		string s;
		s+=char(i+'0');
		dfs(s);
	}
	map<long long,bool>::iterator it=mp.begin();
	int cnt=0;
	long long ans;
	for(it;it!=mp.end();it++){
		cnt++;
		//cout<<it->first<<endl;
		if(cnt==K){
			ans=it->first;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12672
a=input()
if a=='SUN':
    print('7')
elif a=='SAT':
    print('1')
elif a=='FRI':
    print('2')
elif a=='THU':
    print('3')
elif a=='WED':
    print('4')
elif a=='TUE':
    print('5')
else:
    print('6')

Measured memory_bytes: 61580
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 10000;

int par[MAX_N];
int rank[MAX_N];

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

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

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

  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

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

main(){
  int n, q;
  cin >> n >> q;
  init(n);
  for(int i=0;i<q;i++){
    int a, b, c;
    cin >> a >> b >> c;
    if(a) cout << same(b, c) << endl;
    else unite(b, c);
  }
}



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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int k=in(),x=in();
    k--;
    cout << x-k;
    for (int i=x-k+1;i<=k+x;i++) cout << ' ' << i;
    cout << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        S: String,
        T: String
    }
    
    let s_l = S.len();
    let t_l = T.len();
    if (t_l - s_l) == 1 {
        let S_STR: &str = &S[0..s_l];
        let T_STR: &str = &T[0..s_l];
        if S_STR == T_STR {
            println!("Yes");
        } else {
            println!("No");
        }
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 1e4 + 10;
int dp[N];
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			for(int k = 1; k <= 100; k++){
				int val = i * i + j * j + k * k + i * j + j * k + k * i;
				if(val > n) break;
				dp[val] ++;
			}
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%d\n", dp[i]);
	}

}

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

int main() {
	int a, ans;
	string s;
	cin >> s;
	if (s.at(1) == s.at(2) && s.at(0) == s.at(1))cout << "No";
	else cout<<"Yes";

	//cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

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

typedef pair<int,int> pp;

const int maxn = 110, inf = 10100;

int cost[maxn][maxn];
bool used[maxn];
int n,m,a,b;

int main()
{
	while(cin >> n >> m && (n && m))
	{
		memset(used, false, sizeof(used));
		memset(cost,inf, sizeof(cost));
		priority_queue<pp, vector<pp>, greater<pp> > que;
		que.push(pp(0, 0));

		int ans = 0;
		REP(m)
		{
			cin >> a >> b;
			cin >> cost[a][b];
			cost[b][a] = cost[a][b];
		}
		
		while(!que.empty())
		{
			pp p = que.top(); que.pop();
			if(used[p.second]) continue;
			
			ans += p.first;
			used[p.second] = true;
			
			REP(n) que.push(pp(cost[p.second][i], i ));
		}
		cout << ans << endl;
	}

	return 0;
}

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

int h,w,cnt;
int mp[1001][1001];
int dir_x[4] = {0 , 1 , 0 , -1};
int dir_y[4] = {1 , 0 , -1 , 0};

struct object{
    int x;
    int y;
    int depth;
};
queue<object> q;

void dfs(){
    while(!q.empty()){
        object now = q.front();
        q.pop();
        for(int i=0;i<4;i++){
            int nx = dir_x[i] + now.x;
            int ny = dir_y[i] + now.y;
            if(0<=nx&&nx<w&&0<=ny&&ny<h&&mp[ny][nx]!=0){
                if(mp[ny][nx]>now.depth+1){
                    mp[ny][nx] = now.depth+1;
                    object next;
                    next.x = nx;
                    next.y = ny;
                    next.depth = now.depth+1;
                    q.push(next);
                }
            }
        }
    }
}

int main(){
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char ch;
            cin >> ch;
            if(ch=='.') mp[i][j] = 10000;
            else{
                    mp[i][j] = 0;
                    object start = {j,i,0};
                    q.push(start);
            }
        }
    }
    dfs();
    int ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans = max(ans,mp[i][j]);
        }
    }
    cout << ans<<endl;
}

Measured memory_bytes: 16272
#include<iostream>
#include<utility>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
typedef pair<int,int> pii;
long long dp[2010][2010]={0},in[2020],n,o;
queue<pii>q;
int main(){
	cin>>n;rep(i,n)cin>>in[i];
	rep(i,n)dp[i][1]=in[i],q.push(pii(i,1));
	while(!q.empty()){
		pii r=q.front();q.pop();
		int a=r.first,b=r.second,s=a-1,t=(s+1+b)%n;
		if(s==-1)s=n-1;
		rep(i,2){
			if(b%2&&in[s]<in[t])s=a;
			int w=b%2?0:in[(i?t:s)];
			if(dp[s][++b]<dp[a][b-1]+w){
				dp[s][b]=dp[a][b-1]+w;
				if(b!=n)q.push(pii(s,b));
			}
			if(--b%2==0)s=a;
		}
	}
	rep(i,n)o=max(o,dp[i][n]);
	cout<<o<<endl;
}

Measured memory_bytes: 32668
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=a; i<(b); i++)

using namespace std;

const int MOD = 1000000007;
const int MX = 10001;
typedef long long ll;

ll facs[MX];

ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    }
    if(power%2==0) {
        return modExp((base*base)%MOD,power/2);
    }
    return (base*(modExp((base*base)%MOD,(power-1)/2)))%MOD;
}

ll modInv(ll base) {
    return modExp(base, MOD-2);
}

ll mul(ll A, ll B) {
    return (A*B)%MOD;
}

ll add(ll A, ll B) {
    return (A+B)%MOD;
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}

ll choose(ll a, ll b) {
    ll cur = facs[a];
    cur = mul(cur, modInv(facs[b]));
    cur = mul(cur, modInv(facs[a-b]));
    return cur;
}

void initFacs() {
    facs[0] = 1;
    FOR(i, 1, MX) {
        facs[i] = (facs[i-1] * i) % MOD;

    }
}

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

    int N, K; cin >> N >> K;
    initFacs();
    ll ans = 0;


    FOR(i, 1, K+1) {
        int newB = K - i;
        int newR = N - K - i + 1;
        if (newR < 0) {
            cout << 0 << endl; continue;
        }
        ll curAns = choose(K-1, i-1) * choose(N-K+1, i);
        curAns = curAns % MOD;
        cout << curAns << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int F[50];

int fibonacci(int n){
    if ( n == 0 || n == 1 ) 
        F[n] = 1;
    if ( F[n] != NULL ) return F[n];
    return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

int main(){
    int N;
    scanf("%d\n",&N);
    fibonacci(N);
    printf("%d\n",F[N]);
    return 0;
}


Measured memory_bytes: 2104
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().doIt();
	}
	void doIt() {
		abc113c();
	}
	void abc113c() {
		int N = sc.nextInt(), M = sc.nextInt();
		Record [] data = new Record[M+1];
		String [] ans = new String[M];
		data[0] = new Record(-1, -1, -1);
		for(int i = 0; i < M; i++) {
			int p = sc.nextInt(), y = sc.nextInt();
			data[i+1] = new Record(p, y, i);
		}
		Arrays.sort(data);
		int nth = 1;
		for(int i = 1; i <= M; i++) {
			if(data[i-1].preference != data[i].preference) {
				nth = 1;
			} else nth++;
			ans[data[i].id] = String.format("%06d%06d", data[i].preference, nth);
		}
		for(int i = 0; i < M; i++) {
			System.out.println(ans[i]);
		}
	}
	class Record implements Comparable<Record> {
		Record(int p, int y, int id) {
			this.preference = p;
			this.year = y;
			this.id = id;
		}
		int preference, year, id;
		public int compareTo(Record o) {
			if(preference != o.preference) {
				return preference - o.preference;
			} else if (year != o.year) {
				return year - o.year;
			} else {
				return id - o.id;
			}
		}
	}
}


Measured memory_bytes: 151912
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    ll n;
    cin >> n;
    // vector<pair<ll, ll>> a(n);
    vector<ll> a(n);
    vector<ll> b(n);
    ll MAX = 0;
    ll MIN = 1001001001;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        // MIN = min(MIN, a[i].fi);
        // MAX = max(MAX, a[i].se);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    double MID_MIN;
    double MID_MAX;
    // debug_vec(a);
    // debug_vec(b);
    if (n % 2 == 0)
    {
        MID_MIN = (double(a[(n - 1) / 2]) + double(a[(n - 1) / 2 + 1])) / 2.0;
        MID_MAX = (double(b[(n - 1) / 2]) + double(b[(n - 1) / 2 + 1])) / 2.0;
    }
    else
    {
        MID_MIN = double(a[n / 2]);
        MID_MAX = double(b[n / 2]);
    }
    // cout << MID_MIN << endl;

    if (n % 2 == 0)
    {
        cout << ll((MID_MAX - MID_MIN) / 0.5) + 1 << endl;
    }
    else
    {
        cout << ll((MID_MAX - MID_MIN) / 0.5) / 2 + 1 << endl;
        ;
    }
    // cout << ll((MID_MAX - MID_MIN) / 0.5) + 1 << endl;

    return 0;
}


Measured memory_bytes: 6428
import re

N = int(input())

def val(stri):
    a = re.sub(r'\D', '', stri)
    a = int(a)
    return a

def bubble_sort(N, A):
    for i in range(N):
        for j in range(N - 1, i, -1):
            if val(A[j]) < val(A[j - 1]):
                A[j], A[j - 1] = A[j - 1], A[j]
    return A

def selec_sort(N, A):
    for i in range(N):
        minj = i
        for j in range(i + 1, N):
            if val(A[j]) < val(A[minj]):
                minj = j
        A[i], A[minj] = A[minj], A[i]
    return A
    
def isStable(inp, out):
    for i in range(N):
        for j in range(i + 1,N):
            for a in range(N):
                for b in range(a + 1, N):
                    if val(inp[i]) == val(inp[j]) and inp[i] == out[b] and inp[j] == out[a]:
                        return False
    return True



def main():
    A = input().split()

    ST = ''
    for i in A:
        ST += i + ' '
    ST.rstrip(' ')

    bubble_sort(N, A)
    B = ST.split()

    print(*A)
    


    if isStable(A, B):
        print('Stable')
    else:
        print('Not stable')
    A = ST.split()
    selec_sort(N, A)
    B = ST.split()

    print(*A)
    

    if isStable(A, B):
        print('Stable')
    else:
        print('Not stable')

main()




Measured memory_bytes: 6560
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    int sum = 0;
    cin >> N;
    vector<int>Ts(N);
    for(int i=0; i<N; i++)cin >> Ts[i];
    for (int i=0; i<N; i++)sum += Ts[i];
    int M;
    cin >> M;
    for (int i=0; i<M; i++){
        int pi, xi;
        cin >> pi >> xi;
        pi--;
        cout << sum - (Ts[pi]- xi) << endl;

    }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i){return i / 2;}
int left(int i){return 2 * i;}
int right(int i){return 2 * i + 1;}

int main(){
  int i, H, A[MAX+1];

  cin >> H;
  for (i=1; i<=H; i++) cin >> A[i];

  for (i=1; i<=H; i++){
    cout << "node " << i << ": ";
    cout << "key = " << A[i] << ", ";
    if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
    if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>

auto main () -> int {
  int n , a , b;
  std::cin >> n >> a >> b;
  int t [n];
  for (auto && elem : t) {
    std::cin >> elem;
  }
  std::cout << std::count_if(t, t + n, [&](auto && e){
    return e < a || b <= e;
  }) << std::endl;
}


Measured memory_bytes: 256
primelist = Array.new(1000000,true)
primelist[0] = false
primelist[1] = false
for i in 2..999999 do
 if primelist[i]
  t = 2
  k = i * t
  while k <= 999999
   primelist[k] = false
   t += 1
   k = i * t
  end
 end
end
input = gets
until input.nil?
num = input.to_i
cou = 0
for s in 0..num do
 if primelist[s]
  cou += 1
 end
end
puts cou
input = gets
end


Measured memory_bytes: 14664
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int A, B;

    cin >> A >> B;

    if(A==1&&B==2 || A==2&&B==1) {
        cout << 3 << endl;
    } else if(A==2&&B==3 || A==3&&B==2) {
        cout << 1 << endl;
    } else {
        cout << 2 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256