akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,C[200007],ANS;

map<ll,ll> M;

int main(){
  ll sum=0;
  ll N,K;
  cin >> N >> K;
  M[0]++;
  if(K-1<=200006){
    C[K-1]=sum;
  }
  rep(i,N){
    cin >> A;
    sum+=A-1;
    sum%=K;
    M[sum]++;
    if(i>=K-1){
      M[C[i]]--;
    }
    if(i+K<=200006){
      C[i+K]=sum;
    }
    ANS+=M[sum]-1;
    //cout << sum  << M[0] << M[3]<< endl;
  }
  cout << ANS << endl;
}


Measured memory_bytes: 16068
n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
for i in range(x + 1, y + 1):
    if max(X) < i and min(Y) >= i:
        print("No War")
        exit()
print("War")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
 

int a,b;
 
cin>>a>>b;
 
      if(a>b)cout<<"a > b"<<endl;
          else
          if(a<b)cout<<"a < b"<<endl;
            else
              cout<<"a == b"<<endl;
 
 
return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n)     for (ll i = 0; i < (n); ++i)
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)  (x).begin(), (x).end()    //昇順
#define rall(x) (x).rbegin(), (x).rend()  //降順
#define yes     out("Yes");
#define no      out("No");

int main() {
    ins(s);
    if (s[s.size() - 1] == 's') {
        out(s + "es");
    } else {
        out(s + "s");
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
vector<pair<int,int>> mp[100010];
ll dist[100010];
bool used[100010] = {};
int n, m;
bool ok = true;

void dfs(int a) {
  if (used[a]) return;
  used[a] = true;
  if (dist[a] == INF) {
    dist[a] = 0;
  }
  for (int i = 0; i < mp[a].size(); i++) {
    int next = mp[a][i].first;
    int d = mp[a][i].second;
    if (!used[next]) {
      dist[next] = dist[a] + d;
      dfs(next);
    } else {
      if (dist[next] != dist[a] + d) {
        ok = false;
        return;
      }
    }
    if (!ok) return;
  }
}

int main(){
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    mp[l].push_back(make_pair(r, d));
    mp[r].push_back(make_pair(l, -d));
  }
  for (int i = 1; i <= n; i++) {
    dist[i] = INF;
  }
  for (int i = 1; i <= n; i++) {
    dfs(i);
    if (!ok) break;
  }
  if (ok) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
using namespace std;
int main(void){
    string s="abcdefghijklmnopqrstuvwxyz";
    int count[26]={0};
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++){
        for(int j=0;j<s.size();j++){
            if(str[i]==s[j]){
                count[j]++;
            }
        }
    }
    for(int i=0;i<26;i++){
        if(count[i]==0){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}


Measured memory_bytes: 512
s = input()
k = int(input())

tmp = 1
count = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        tmp += 1
    else:
        count += tmp // 2
        tmp = 1
count += tmp//2

if len(set(s))==1:
    print(len(s)*k//2)
else:
    if s[0] != s[-1]:
        print(count*k)
    else:
        h = 0
        for i in s:
            if i != s[0]:
                break
            else:
                h += 1
        t = 0
        for i in s[::-1]:
            if i != s[-1]:
                break
            else:
                t += 1
        print(count*k-(h//2+t//2-(h+t)//2)*(k-1))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N+2);
  A[0] = A[N+1] = 0;
  rep(i,N) cin >> A[i+1];
  vector<int> cost(N+1);
  for(int i=0;i<N+1;i++){
    cost[i] = abs(A[i]-A[i+1]);
  }
  ll sumcost = 0;
  rep(i,N+1){
    sumcost += cost[i];
  }

  rep(i,N){
    ll ans = sumcost - cost[i] - cost[i+1];
    ans += abs(A[i]-A[i+2]);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2048
#アライグマはモンスターと戦っています。
# モンスターの体力は H です。
#アライグマは N 種類の必殺技を使うことができ、
#i 番目の必殺技を使うとモンスターの体力を Ai 減らすことができます。
#モンスターの体力を 0 以下にすればアライグマの勝ちです。

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

if H - sum(A) <= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define gos(i, a, n, step) for (ll i = a; i < (ll)n; i += step)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll count(ll s, vector<ll> &dp)
{
    if (!s)
        return 1;
    if (s < 0)
        return 0;
    if (dp[s] != 0)
        return dp[s];
    ll cnt = 0;
    go(i, 3, s + 1) cnt = ((cnt % mod) + (count(s - i, dp) % mod)) % mod;
    return dp[s] = cnt % mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // ll t;
    // cin >> t;
    // while (t--)
    // {
    // }
    ll s;
    cin >> s;
    vector<ll> dp(s + 1, 0);
    show(count(s, dp));
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


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

#define endl '\n'
using namespace std;
using ll = long long;
using Pt = pair<ll,ll>;
#define r first
#define c second

const int N = 3030;
const int M = 200005;
const ll MOD = 1e9+7;

ll h, w, n;
Pt arr[N];
ll dp[N]; // dp[i] - # of valid path to ith invalid pt
ll fac[M], fac_inv[M];

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

ll sub(ll lhs, ll rhs) { return (lhs - rhs + MOD)%MOD; }
ll mul(ll lhs, ll rhs) { return (lhs * rhs % MOD); }
ll fastPw(ll a, ll p)
{
    ll r = 1;
    while(p)
    {
        if(p&1) r = mul(r, a);
        a = mul(a, a);
        p >>= 1;
    }
    return r;
}

ll modInv(ll x) { return fastPw(x, MOD-2); }

ll pathTo(Pt from, Pt to)
{
    ll dr = to.r - from.r;
    ll dc = to.c - from.c;
    return mul(mul(fac[dr+dc],fac_inv[dr]),fac_inv[dc]);
}

void init()
{
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i].r >> arr[i].c;
    sort(arr, arr+n);
    fac[0] = fac[1] = 1;
    fac_inv[0] = fac_inv[1] = modInv(1);
    for(int i = 2; i < M; i++)
    {
        fac[i] = mul(fac[i-1], i);
        fac_inv[i] = modInv(fac[i]);
    }
}

void process()
{
    for(int i = 0; i < n; i++)
    {
        dp[i] = pathTo(make_pair(1,1), arr[i]);
        for(int j = 0; j < i; j++)
        {
            if(arr[j].r <= arr[i].r && arr[j].c <= arr[i].c)
                dp[i] = sub(dp[i], mul(dp[j], pathTo(arr[j], arr[i])));
        }
    }
    ll ans = pathTo(make_pair(1, 1), make_pair(h, w));
    for(int i = 0; i < n; i++)
    {
        ans = sub(ans, mul(dp[i], pathTo(arr[i], make_pair(h, w))));
    }
    cout << ans << endl;
}



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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll x, n;
	cin >> x >> n;

	bool flg[102] = {};
	rep( i, n ) {
		ll p;
		cin >> p;
		flg[p] = true;
	}

	ll m = 101;
	ll idx = -1;

	for ( ll i = 0; i <= 101; i++ ) {
		if ( !flg[i] ) {
			if ( abs(x - i) < m ) {
				m = abs(x - i);
				idx = i;
			}
		}
	}

	cout << idx << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>

using namespace std;

class dset {
public:
	dset(int n) {
		arr = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = -1;
		}
		s = n;
	}
	~dset() {
		// delete[] arr;
	}
	int find(int n) {
		if(arr[n] < 0) {
			return n;
		} else {
			return (arr[n] = find(arr[n]));
		}
	}
	bool join(int a, int b) {
		int c = find(a);
		int d = find(b);

		if(c == d && c >= 0) {
			return false;
		}

		if(c < d) {
			arr[d] = c;
			arr[c]--;
		} else {
			arr[c] = d;
			arr[d]--;
		}

		return true;
	}
	int count() {
		int c = 0;
		for(int i = 0; i < s; i++) {
			if(arr[i] < 0) {
				c++;
			}
		}
		return c;
	}
	void print() {
		for(int i = 0; i < s; i++) {
			cout << arr[i] << " ";
		}
		cout << endl;
	}
private:
	int* arr;
	int s;
	
};

typedef struct edge {
	int a;
	int b;
} edge;

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

	vector<edge> edges;

	for(int i = 0; i < m; i++) {
		edge e;
		cin >> e.a;
		cin >> e.b;
		e.a -= 1;
		e.b -= 1;
		edges.push_back(e);
	}

	int count = 0;
	for(int i = 0; i < m; i++) {
		dset ds(n);
		for(int j = 0; j < m; j++) {
			if(i == j) {
				continue;
			}
			ds.join(edges[j].a, edges[j].b);
		}
		if(ds.count() != 1) {
			count++;
		}
	}

	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
int main()
{
	long long a = 0, b = 0, c = 0, rate[100] = {}, last = 0, k = 0, ansa = 0, ansb = 0, x = 0, y = 0;
	int one = 0, ten = 0, hun = 0, thou = 0, man = 0,kuso,kusoa;
	int onex = 0, tenx = 0, hunx = 0, thoux = 0, manx = 0;
	std::cin >> a;
	bool okada = true;

	for (int i = 1; i <= a-1; i++) {
		b = i;
		c = a - b;
		
		man = b % 100000/10000;
		thou = b % 10000 / 1000;
		hun = b % 1000 / 100;
		ten = b % 100 / 10;
		one = b % 10;
	
		manx = c / 10000;
		thoux = c % 10000 /1000;
		hunx = c % 1000 / 100;
		tenx = c % 100 / 10;
		onex = c % 10;
		ansa = one + ten + hun + thou + man + onex + tenx + hunx + thoux + manx;
		if (i == 1) {
			x = ansa;
		}
		else if (ansa < x) {
			x= ansa;
	
		}

	}
	std::cout << x << std::endl;
}







Measured memory_bytes: 256
H,W = map(int,input().split())
A =[[0]*(W+2)] + [[0] + [0 if s=='.' else 1 for s in input()] + [0]  for _ in range(H)] + [[0]*(W+2)]
pos = [1,1]
A[1][1] = 0
while pos != [W,H]:
  if pos[1]<=H and A[pos[1]+1][pos[0]] == 1:
    A[pos[1]+1][pos[0]] = 0
    pos = [pos[0],pos[1]+1]
  elif pos[0]<=W and A[pos[1]][pos[0]+1] == 1:
    A[pos[1]][pos[0]+1] = 0
    pos = [pos[0]+1,pos[1]]
  else:
    print('Impossible')
    exit()
if sum([sum(row) for row in A]) == 0: print('Possible')
else:print('Impossible')


Measured memory_bytes: 40572
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int n;
    cin>>n;
    if(n<2)cout<<1<<endl;
    else if(n<4)cout<<2<<endl;
    else if(n<8)cout<<4<<endl;
    else if(n<16)cout<<8<<endl;
    else if(n<32)cout<<16<<endl;
    else if(n<64)cout<<32<<endl;
    else cout<<64<<endl;
    return 0;
}



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

double x[100],y[100],z[100],r[100];

double dis(int i,int j){
  return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) + (z[i]-z[j])*(z[i]-z[j]) ); 
}

int main(){
  int n;
  double d[100][100];
  int par[100];
  int tmp;
  int i,j,k,h,w;
  double min,ans;

  while(1){
    cin >> n;
    if(!n)break;

    for(i=0;i<n;i++){
      cin >> x[i] >> y[i] >> z[i] >> r[i];
      for(j=0;j<n;j++)d[i][j] = 0.0;
      par[i] = i;
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	double len = dis(i,j);
	if(len > r[i]+r[j])d[i][j] = len - (r[i]+r[j]);
	else{
	  tmp = par[j];
	  for(k=0;k<n;k++){
	    if(par[k] == tmp)par[k] = par[i];
	  }
	}
      }
    }

    ans = 0.0;
    while(1){
      for(i=1;i<n;i++){
	if(par[i]!=par[0])break;
      }
      if(i==n)break;

      min = 1000001.0;
      for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	  if(d[i][j] > 0.0 && min > d[i][j] && par[i] != par[j]){
	    min = d[i][j];
	    h = i;
	    w = j;
	  }
	}
      }

      ans += min;
      tmp = par[w];
      for(i=0;i<n;i++){
	if(par[i] == tmp)par[i] = par[h];
      }
    }

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

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

int main(){
    string s;
    cin >> s;
    bool flag = true;
    rep(i, s.size()){
        if((i+1) % 2 != 0){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else{
                flag = false;
            }
        }else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else{
                flag = false;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int H, W;
  scanf("%d %d",&H ,&W);

  int i, j;
  while(1)
  {
    if(H == 0 && W == 0){
      break;
    }
    else{
      for(i = 0; i < H; ++i){
        for (j = 0; j < W; ++j) {
          printf("#");
        }
        printf("\n");
      }
    }
    printf("\n");
    scanf("%d %d",&H ,&W);
  }

  return 0;
}

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll n,m;

ll solve() {
	vector<vector<int>> l(n,vector<int>(n,INF));
	vector<vector<int>> s(n,vector<int>(n,INF));
	REP(i,n) l[i][i]=s[i][i]=0;
	REP(i,m) {
		int x,y,t;
		char sl;
		cin>>x>>y>>t>>sl;
		x--; y--;
		if(sl=='L') l[x][y]=l[y][x]=min(t,l[y][x]);
		if(sl=='S') s[x][y]=s[y][x]=min(t,s[y][x]);
	}
	vector<vector<vector<int>>> l_wf(n+1,vector<vector<int>>(n,vector<int>(n,INF)));
	vector<vector<vector<int>>> s_wf(n+1,vector<vector<int>>(n,vector<int>(n,INF)));
	REP(i,n) REP(j,n) l_wf[0][i][j]=l[i][j];
	REP(i,n) REP(j,n) s_wf[0][i][j]=s[i][j];
	FOR(i,1,n+1) REP(j,n) REP(k,n) {
		l_wf[i][j][k]=min(l_wf[i-1][j][k],l_wf[i-1][j][i-1]+l_wf[i-1][i-1][k]);
		s_wf[i][j][k]=min(s_wf[i-1][j][k],s_wf[i-1][j][i-1]+s_wf[i-1][i-1][k]);
	}
	ll r;
	cin>>r;
	vector<ll> z(r);
	REP(i,r) cin>>z[i];
	REP(i,r) z[i]--;
	vector<vector<ll>> dp(2,vector<ll>(n,INF*INF));
	dp[0][z[0]]=0;
	FOR(i,1,r) REP(j,n) {
		dp[i%2][j]=INF*INF;
		dp[i%2][j]=min(dp[i%2][j],dp[!(i%2)][j]+l_wf[n][z[i-1]][z[i]]);
		REP(k,n) {
			dp[i%2][j]=min(dp[i%2][j],dp[!(i%2)][k]+l_wf[n][z[i-1]][k]+s_wf[n][k][j]+l_wf[n][j][z[i]]);
		}
	}
	ll ret=INF*INF;
	REP(j,n) ret=min(ret,dp[!(r%2)][j]);
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		cin>>n>>m;
		if(n==0&&m==0) break;
		cout<<solve()<<endl;
	}
}


Measured memory_bytes: 69444
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

MOD = 10**9 + 7
fact = [1]
fact_inv = [1]
for i in range(10**5 + 10):
    new_fact = fact[-1]*(i+1) % MOD
    fact.append(new_fact)
    fact_inv.append(pow(new_fact, MOD-2, MOD))


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] % mod


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

ans = 0
K1 = K-1
mx = N-K
px = K-1

for i in range(K-1, N):
    cnb = mod_comb_k(i, K1, MOD)
    #print("cnb", cnb, "px", A[px], "mx", A[mx], "ans", ans)
    ans += A[px] * cnb
    ans %= MOD
    ans -= A[mx] * cnb
    ans %= MOD
    px += 1
    mx -= 1

print(ans)

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	string S;
	cin >> S;
	vector<P> seq;
	ll map[100000] = {};
	ll index = 0;
	ll length = 1;
	rep(i,0,S.size()) {
		if (S[i] != S[i+1]) {
			seq.push_back(make_pair(index, length));
			length = 1;
			index = i+1;
		}else{
			length++;
		}
	}
	rep(i,0,seq.size()) {
		if (S[seq[i].first] == 'R') {
			if (seq[i].first + seq[i].second == S.size())
				map[seq[i].first + seq[i].second - 1] += seq[i].second;
			else{
				map[seq[i].first + seq[i].second - 1] += (seq[i].second + 1) / 2;
				map[seq[i].first + seq[i].second] += seq[i].second / 2;
			}
		}else{
			if (seq[i].first - 1 == -1)
				map[seq[i].first] += seq[i].second;
			else{
				map[seq[i].first - 1] += seq[i].second / 2;
				map[seq[i].first] += (seq[i].second + 1) / 2;
			}
		}
	}
	rep(i,0,S.size()-1) {
		cout << map[i] << " ";
	}
	cout << map[S.size()-1] << endl;
	return 0;
}


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

int main() {
    int a, b, x;
    
    cin >> a >> b;
    x = (a+b)/2;
    if((a+b)%2 == 0) {
        cout << x << endl;
    } else {
        cout << x+1 << endl;    
    }
}

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

int main(){
    int K;
    cin >> K;
    int A,B;
    cin >> A >> B;

    bool b = false;
    for(int i = A; i <= B; i++){
        if(i % K == 0){
            b = true;
            break;
        }
    }
    string ans = b ? "OK" :"NG";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
import scala.io.StdIn
import scala.annotation.tailrec
import scala.collection.immutable.{Queue => EmQueue}

case class Process(name: String, time: Int){
  override def toString(): String = s"$name $time"
}

object Main extends App {
  val Array(_, quantum) = StdIn.readLine().split(" ").map(_.toInt)

  val queue = Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foldLeft(Queue.empty) {
    (queue, line) => {
      line.split(" ") match {
        case Array(name: String,time: String) => queue.enqueue(Process(name, time.toInt))
      }
    }
  }

  @tailrec
  def loop(queue: Queue, out: EmQueue[Process] = EmQueue(), curTime: Int = 0): EmQueue[Process] = {
    if(queue.isEmpty) out
    else {
      val(process, nextQueue) = queue.dequeue
      if(process.time > quantum){
        loop(nextQueue.enqueue(process.copy(time = process.time - quantum)), out, curTime + quantum)
      }else{
        loop(
          nextQueue,
          out :+ process.copy(time = curTime + process.time),
          curTime + process.time
        )
      }
    }
  }

  println(loop(queue).mkString("\n"))
}

class Queue private(val in: List[Process], val out: List[Process]){
  def enqueue(elem: Process) = new Queue(elem :: in, out)

  def dequeue: (Process, Queue) = out match {
    case Nil if !in.isEmpty => val rev = in.reverse ; (rev.head, new Queue(Nil, rev.tail))
    case x :: xs            => (x, new Queue(in, xs))
    case _                  => throw new NoSuchElementException("dequeue on empty queue")
  }

  def isEmpty: Boolean = in.isEmpty && out.isEmpty

  override def toString() = in.toString
}

object Queue {
  def empty: Queue = new Queue(Nil, Nil)
  def apply(xs: Process*): Queue = new Queue(Nil, xs.toList)
}

Measured memory_bytes: 149724
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
string s;
cin>>s;
ll sum=0,i;
for(i=0;i<s.size();i++)
{
    int a=s[i]-'0';
    sum+=a;
}
if(sum%9==0)cout<<"Yes";
else
    cout<<"No";
return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <cmath>

using namespace std;

#define ll long long int

int main() {
  ll n, k;
  cin >> n >> k;
  ll x[n];
  for (ll i = 0; i < n; i++) cin >> x[i];
  ll min_d = 2e18;
  for (ll i = 0; i < n - k + 1; i++) {
    ll d = x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1]));
    if (d < min_d) {
      min_d = d;
    }
  }
  cout << min_d;
}


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

int N;
const int SIZE = 100005;
long h [SIZE];
int mem [SIZE];

int dp (int i) {
  if (i == N-1) return 0;
  
  if (mem[i] != -1) return mem[i];

  long ret = LLONG_MAX;

  if (i+1 < N) 
  ret = min (ret,  abs (h[i] - h[i+1])  + dp (i+1));
  if (i+2 < N)
  ret = min (ret,  abs (h[i] - h[i+2])  + dp (i+2)); 

  return  mem[i] = ret;
}

int main (){ 

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

  memset(mem, -1, sizeof mem);

  cout << dp(0);

}

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


void solve(long long A, long long B){
    ll ans=0;
    if(A==1 and B==2)ans=3;
    else if(A==1 and B==3)ans=2;
    else if(A==2 and B==1)ans=3;
    else if(A==2 and B==3)ans=1;
    else if(A==3 and B==1)ans=2;
    else if(A==3 and B==2)ans=1;
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main(){
  int X,N;
  cin >> X >> N;
  
  map<int, int> z;
 
  
  for(int i = 0; i < N; i++){
    int j;
    cin >> j;
    z[j] = j;
  }
  int ans = 10000;
  int i = 0;
  while(ans == 10000){
    if(!(z.count(X-i))){
      ans = X - i;}
    else if (!(z.count(X+i))){
      ans = X + i;
    }
    i++;
  }
  cout << ans << endl;
}
      
    
    

  

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  if(u==NIL || k ==u->key) return u;
  if(k< u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y==NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}
void inorder(Node u){
  if(u !=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");  
    } 
  }
  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	string s;
	while (1){
		cin >> s;
		if (s[0] == '0') break;
		int sum = 0;
		REP(i, (int)s.size()){
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}
}



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

int main () {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  if (s.at(0) == t.at(0)) ans++;
  if (s.at(1) == t.at(1)) ans++;
  if (s.at(2) == t.at(2)) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K ;

  vector<int> vec(N);
  for(int i = 0; i < N; i++){
      cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end()); 

  int sum = 0;
  for(int i = 0; i < K; i++){
      sum += vec.at(i);
  }

  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

int main(void)
{
    //入力
    string S;
    cin>>S;

    //変換
    if(S.size()>2)
    {
        string temp = S;
        S[0] = temp[2];
        S[2] = temp[0];
    }

    //出力
    cout<<S<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int N; cin >> N;
    map<ll,ll> cnt;

    REP(i,N) {
        ll A; cin >> A;
        cnt[A]++;
    }

    vector<ll> koho;
    for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
        while (itr -> second >= 2) {
            itr -> second -= 2;
            koho.push_back(itr -> first);
        }
    }

    if (koho.size() <= 1) {
        cout << 0 << endl;
        return 0;
    }

    sort(koho.begin(), koho.end());
    reverse(koho.begin(), koho.end());

    cout << koho[1] * koho[0] << endl;
    
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0; }
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0; }
#define For(i, l, r) for(register int i = (l); i <= (r); ++ i)
#define Fordown(i, r, l) for(register int i = (r); i >= (l); -- i)
using namespace std;

const int N = 100100;
long long a[N];
int n;

int main() {
	cin >> n;
	For (i, 1, n)
		scanf ("%lld", &a[i]);
	if (a[n] != 2) return printf ("-1"), 0;
	
	long long min_ans = 2, max_ans = 2;
	Fordown (i, n, 2) {
		long long res;
		if (min_ans % a[i - 1]) {
			res = a[i - 1] - min_ans % a[i - 1] - a[i];
			if (res >= 0) min_ans += res / (a[i] % a[i - 1]) * a[i];
			if (min_ans % a[i - 1]) min_ans += (a[i - 1] - min_ans % a[i - 1]);
		}
		
		max_ans += a[i] - 1;
		res = max_ans % a[i - 1] - a[i];
		if (res >= 0) max_ans -= res / (a[i] % a[i - 1]) * a[i];
		max_ans -= max_ans % a[i - 1];
		
		if (min_ans > max_ans) return printf("-1"), 0;
	}
	cout << min_ans << ' ' << max_ans + (long long)(a[1] - 1) << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	im := make(IntMap, 1)
	sum := 0
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		if im.get(a) > 0 {
			sum++
		}
		im.increment(a)
	}

	ans := n - sum - sum%2

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}
func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}


Measured memory_bytes: 7424
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	alpha = [chr(i) for i in range(97, 123)]
	cnt = 0
	var = None
	for i in range(1, 100):
		if N <= 26 ** i:
			var = i
			break
		N -= 26 ** i

	N -= 1
	# print(N)
	# print(var)
	ans = ""
	for i in range(var):
		ans += alpha[N % 26]
		N = int(N // 26)

	print(ans[::-1])





if __name__ == '__main__':
	main()

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

int main(){
    ll n;
    string s;   cin >> n >> s;
    ll rc=0, gc=0, bc=0;
    for(auto c: s){
        if(c=='R')  rc += 1;
        else if(c=='G') gc += 1;
        else bc += 1;
    }

    ll cnt = rc*gc*bc;
    for(ll i=0; i<n-2; i++){
        for(ll j=i+1; j<n-1; j++){
            if(s[i]==s[j])  continue;
            int k = 2*j-i;
            if(n<=k || s[k]==s[i] || s[j]==s[k])    continue;
            cnt -= 1;
        }
            
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    int N, H, W;
    scanf("%d %d %d", &N, &H, &W);
    
    // 2. 縦 H, 横 W の板が得られるか？
    int ans = 0;
    rep(i, N){
        int a, b;
        scanf("%d %d", &a, &b);
        if(a >= H && b >= W) ans++;
    }
    
    // 3. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
vector<set<int>> graph;
vector<int> memo;

void rec(int x, int num) {
  if (memo.at(x) != -1) return;
  memo.at(x) = num;
  for (auto v: graph.at(x)) {
    rec(v, num);
  }
}

int main()
{
  int n, m;
  cin >> n >> m;
  graph.resize(n, set<int>());
  memo.resize(n, -1);

  rep(i,m) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    graph.at(x).insert(y);
    graph.at(y).insert(x);
  }
  int gcnt = 0;
  rep(i, n) {
    if (memo.at(i) != -1) continue;
    rec(i, gcnt);
    gcnt++;
  }
  vector<int> cnt(n, 0);
  rep(i, n) {
    if (memo.at(i) == -1) continue;
    cnt.at(memo.at(i))++;
  }
  int v = 1;
  rep(i, n) {
    v = max(cnt.at(i), v);
  }
  cout << v << endl;
  
  return 0;
}

Measured memory_bytes: 38968
#include <iostream>
#include <set>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int, int> pii;
typedef multiset<int> si;

int main() {
    int n, q;
    cin >> n >> q;
    pii st[2*n];
    for (int i = 0; i < n; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        st[i*2] = pii(s - x, x);
        st[i*2+1] = pii(t - x, -x);
    }
    sort(st, st+2*n);
    
    int ls = -1e9-1;
    si s;
    s.insert(1e9+1);
    pii sm[2*n+1];
    sm[0] = pii(-1e9-1, 1e9+1);
    int cst = 1;
    for (int i = 0; i < 2 * n; i++) {
        if (st[i].second > 0) {
            s.insert(st[i].second);
        } else {
            s.erase(s.find(-st[i].second));
        }

        ls = st[i].first;

        if (i == 2 * n - 1 || st[i+1].first != ls) {
            sm[cst++] = pii(st[i].first, *s.begin());
        }
    }

    for (int i = 0; i < q; i++) {
        int d;
        cin >> d;
        int t = prev(lower_bound(sm, sm+cst, pii(d, 1e9+2)))->second;
        cout << (t == 1e9+1 ? -1 : t) << endl;
    }

    return 0;
}


Measured memory_bytes: 16896
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int f[510000];
int c[510000];
void add(int x,int y)
{
	for (;x <= 500010;x+=x&(-x))
		c[x] += y;
}
int find(int x)
{
	int res = 0;
	for (;x;x-=x&(-x))
		res += c[x];
	return res;
}
int n;
int judge(int x)
{
	if (f[x]) {f[x]--; add(x,-1);return 1;}
	if (find(x-1) == 0) return 0;
	
	int i;
	for (i = x-1;i >= 0;i--)
		if (f[i])
			break;
//	cout << i << endl;
	f[i]--; add(i,-1);
	for (i=i+1;i <= x;i++)
		f[i]++,add(i,1);
	return 1;
}
int main()
{
	cin >> n;
	add(1,2);
	f[1] = 2;
	for (int i = 1;i <= n;i++)
	{
		int x;scanf("%d",&x);
		x = min(x,500005);
		if (judge(x))
			printf("Yes\n");
		else 
			printf("No\n");
	}
}

Measured memory_bytes: 7076
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

constexpr int MOD = 1e9 + 7;

struct modint {
	int n;
	modint(int n = 0) : n(n) {}
};

modint operator+(modint a, modint b) { return modint((a.n += b.n) >= MOD ? a.n - MOD : a.n); }
modint operator-(modint a, modint b) { return modint((a.n -= b.n) < 0 ? a.n + MOD : a.n); }
modint operator*(modint a, modint b) { return modint(1LL * a.n * b.n % MOD); }
modint &operator+=(modint &a, modint b) { return a = a + b; }
modint &operator-=(modint &a, modint b) { return a = a - b; }
modint &operator*=(modint &a, modint b) { return a = a * b; }

class Combination {
public:
	Combination() {
		inv.push_back(0);
		inv.push_back(1);
		f.push_back(1);
		f.push_back(1);
		invf.push_back(1);
		invf.push_back(1);
	}

	modint F(int n) {
		check(n);
		return f[n];
	}

	modint IF(int n) {
		check(n);
		return invf[n];
	}

	modint inverse(int n) {
		check(n);
		return inv[n];
	}

	modint P(int n, int r) {
		if (n < 0 || r < 0 || n < r) {
			return 0;
		}
		check(n);
		return f[n] * invf[n - r];
	}

	modint C(int n, int r) {
		if (n < 0 || r < 0 || n < r) {
			return 0;
		}
		check(n);
		return f[n] * invf[r] * invf[n - r];
	}

	modint H(int n, int r) {
		if (n == 0 && r == 0) {
			return 1;
		}
		return C(n + r - 1, r);
	}

private:
	std::vector<modint> inv;
	std::vector<modint> f;
	std::vector<modint> invf;

	void check(int k) {
		if (k < inv.size()) {
			return;
		}
		int p = inv.size() - 1;
		inv.resize(k + 1);
		f.resize(k + 1);
		invf.resize(k + 1);
		for (int i = p + 1; i <= k; i++) {
			inv[i] = inv[MOD % i] * (MOD - MOD / i);
			f[i] = i * f[i - 1];
			invf[i] = inv[i] * invf[i - 1];
		}
	}
};

int main() {
	int n;
	std::cin >> n;

	int x = 0;
	for (int i = 1; i <= n; i++) {
		x ^= i;
	}

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

	int fst = std::find(a.begin(), a.end(), x) - a.begin();
	int snd = std::find(a.begin() + fst + 1, a.end(), x) - a.begin();

	// 0 1 2 3 4 5 6 7 8
	//     x       x
	int A = fst;
	int C = n - 1 - snd;
	int B = n - A - C - 2;

	Combination comb;

	for (int i = 1; i <= n; i++) {
		modint ans = comb.C(n, i) - comb.C(A + C, i - 1);
		std::cout << ans.n << std::endl;
	}
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


/**
 * @brief Union-Find
 * @docs docs/union-find.md
 */
struct UnionFind {
  vector< int > data;

  UnionFind() = default;

  explicit UnionFind(size_t sz) : data(sz, -1) {}

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return data[k] = find(data[k]);
  }

  int size(int k) {
    return -data[find(k)];
  }

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


int main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    uf.unite(a, b);
  }
  int ret = 1;
  for(int i = 0; i < N; i++) {
    chmax(ret, uf.size(i));
  }
  cout << ret << "\n";
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int Sub(int a,int b){
	int low=0,high=a;
	while(high-low>1){
		int mid=(low+high)/2;
		int y=b+mid,x=mid,z=y+1;
		int mx=max(y,(z-x)*x);
		if(z/2<=x)
			chmax(mx,(z-z/2)*(z/2));
		if(mx<a*b)low=mid;
		else high=mid;
	}
	return low;
}

void Solve(){
	int a=read(),b=read();
	int x=Sub(a,b),y=Sub(b,a);
	cerr<<x<<" "<<y<<endl;
	cout<<x+y+min(a-1-x,b-1-y)<<endl;
}

signed main(){
	int q=read();
	REP(_,q)
		Solve();
}


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

int K;

int main()
{
    cin >> K;
    long long res = 0;

    for(int i = 1; i <= K; i++)
    for(int j = 1; j <= K; j++)
    for(int k = 1; k <= K; k++)
    res += gcd(gcd(i, j), k);

    cout << res << endl;
}

Measured memory_bytes: 3636
/*
  B - ∵∴∵
  Contest 058
  Rakesh Kumar --> 23/08/2020
 */

#include <bits/stdc++.h>

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

    std::string o;
    std::getline(std::cin, o);
    std::string e;
    std::getline(std::cin, e);
    int i = 0, j = 0;
    int c = 0;
    while (i < o.size() && j < e.size()) {
        if (c & 1)
            std::cout << e[i++];
        else
            std::cout << o[j++];
        ++c;
    }

    while (i < e.size())
        std::cout << e[i++];
    while (j < o.size())
        std::cout << o[j++];
    std::cout << std::endl;

    return 0;
}


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

int main() {
    int K,N;
    string S;
    cin >> N >> S >> K;
    char x = S.at(K-1);
    for(int i = 0;i<N;i++){
        if(S.at(i)!=x){
            S.at(i)='*';
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
 
int main(void)
{
    int n, t[100001], x[100001], y[100001];
    int i, dt, dist;
    bool flag = false;
    scanf("%d", &n);
    t[0] = x[0] = y[0] = 0;
    for (i=1; i<n+1; i++)
    {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
 
    for (i=1; i<n+1; i++)
    {
        dt =  t[i] - t[i-1];
        dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if (dt < dist) {
            flag = true;
            break;
        }
        if (dt%2 != dist%2) {
            flag = true;
            break;
        }
    }
 
    if (flag == true) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1280
// A - A+...+B Problem

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;

	if (A > B || (N == 1 && A != B)) {
		cout << 0 << endl;
		return 0;
	}

	ll min_s = A + (N-2) * A + B;
	ll max_s = A + (N-2) * B + B;

	ll ans = max_s - min_s + 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main (){

  int A,B;

  cin>>A>>B;


  if(A==1)A=14;
  if(B==1)B=14;
  if(A>B)cout<<"Alice"<<endl;
  else if(A<B)cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <iomanip>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cout<<setprecision(10);
  int n;
  cin>>n;
  double res=0;
  for(int i=0;i<n;i++)
  {
    double tmp1;
    string tmp2;
    cin>>tmp1>>tmp2;
    if(tmp2=="JPY")
    {
      res+=tmp1;
    }
    else
    {
      res+=tmp1*380000.0;
    }

  }
  cout<<res<<endl;

  return 0;

}


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

int H, W, K, dp[110][110];
const int M=1e9+7;

int main()
{
    cin>>H>>W>>K;
    dp[0][0]=1;
    for(int i=0; i<H; ++i) {
        for(int k=0; k<1<<(W-1); ++k) {
            if (k&k/2) continue;
            for(int j=0; j<W; ++j) {
                if (j+1<W && (k>>j&1)) {
                    (dp[i+1][j]+=dp[i][j+1])%=M;
                }
                else if (j && (k>>(j-1)&1)) {
                    (dp[i+1][j]+=dp[i][j-1])%=M;
                }
                else {
                    (dp[i+1][j]+=dp[i][j])%=M;
                }
            }
        }
    }
    cout<<dp[H][K-1]<<endl;
}


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

for testCase in range(N):
    A = list(map(int,input().split()))
    ok = False
    for i in range(2 ** 10):
        x = []
        y = []
        for j in range(10):
            if i & (1 << j):
                x.append(A [j])
            else:
                y.append(A [j])
        if x == sorted(x) and y == sorted(y):
            ok = True
    if ok:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7688