akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int h, w, k;
  std::cin >> h >> w >> k;

  vector<string> field(h);

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

  int ans = 0;
  for(int i=0; i<pow(2, h); i++){
    bitset<6> row_selector(i);
    for(int j=0; j<pow(2, w); j++){

      bitset<6> col_selector(j);
      int count = 0;
      for(int row=0; row<h; row++){
        if(!row_selector[row]) continue;
        for(int col=0; col<w; col++){
          if(!col_selector[col]) continue;
          if(field[row].at(col) == '#'){
            count += 1;
          }
        }
      }

      if(count == k){
        ans += 1;
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(0);cin.tie(NULL);
	int i;
	vector<int> V(3);
	for(i=0; i<3; i++){ cin>>V[i]; }
	sort(V.begin(), V.end());
	if(V[2] == 7 && V[1] == 5 && V[0] == 5)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
a, b, c, x = [int(input()) for _ in range(4)]
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().split())
X = [list(map(int, input().split())) for i in range(M)]
ans =[]
X.sort(reverse = True)

for i in range(N):
  if i == 0:
    ans.append(1)
  
  else:
    ans.append(0)

if M == 0 and N == 1:
  ans = '0'
    
elif M == 1 or (M == 0 and N != 1):
  for j in range(M):
    if X[j][0] == 1:
      if ans[X[j][0]-1] == X[j][1] or ans[X[j][0]-1] == 1:
        ans[X[j][0]-1] = X[j][1]
      
      else:
        ans = '-1'
        break
      
    else:
      if ans[X[j][0]-1] == X[j][1] or ans[X[j][0]-1] == 0:
        ans[X[j][0]-1] = X[j][1]
      
      else:
        ans = '-1'
        break 
    
elif M > 1:
  for k in range(M-1):
    if X[k][0] == X[k+1][0] and X[k][1] != X[k+1][1]:
      ans = '-1'
      break
    
    else:
      for j in range(M):
        if X[j][0] == 1:
          if ans[X[j][0]-1] == X[j][1] or ans[X[j][0]-1] == 1:
            ans[X[j][0]-1] = X[j][1]
      
          else:
            ans = '-1'
            break
      
        else:
          if ans[X[j][0]-1] == X[j][1] or ans[X[j][0]-1] == 0:
            ans[X[j][0]-1] = X[j][1]
      
          else:
            ans = '-1'
            break
    
if N >= 2 and ans[0] == 0:
  print(-1)
  
else:
  ansstr = list(map(str, ans))
  ans = ''.join(ansstr)
  print(int(ans))

Measured memory_bytes: 3192
from itertools import permutations

def calc_d(pos1, pos2):
  return ((pos1[0]-pos2[0])**2 + (pos1[1]-pos2[1])**2)**.5

N = int(input())
XY = [list(map(int,input().split()))+ [i] for i in range(N)]

sumd = 0
cnt = 0
for prm in permutations(XY):
  for i in range(N-1):
    sumd += calc_d(prm[i][:2],prm[i+1][:2])
  cnt += 1
print(sumd/cnt)    

Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
	int a,b;
	scanf ("%d %d",&a,&b);
	if (a <= 0 && 0 <= b) puts("Zero");
	else if (0 < a) puts("Positive");
	else{
		int c = b - a + 1;
		if (c % 2) puts("Negative");
		else puts("Positive");
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,a,b,ct=0,flag;
    string p,q,r;
    cin>>a;
    flag=0;
    while(a--)
    {
        cin>>n;
        if(n%2==0)
        {
           if(n%3==0 || n%5==0) ct++;
           else flag=1;
        }
    }
    if(flag==1) cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int A[N];
    int kai;
    int count[N];
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
    }
    for(int i=0;i<N;i++)
    {
        for(int h=0;h<500000;h++)
        {
         if(A[i]%2==1)
          {
              kai=h;
              break;
          }
         A[i]=A[i]/2;
        }
        count[i]=kai;
    }
    sort(count,count+N);
    cout<<count[0]<<endl;
}




Measured memory_bytes: 256
def solve():
    N = int(input())
    S = input()

    cnt = 0
    for i in range(1000):
        target = str(i).zfill(3)
        idx = 0
        for ch in S:
            if ch == target[idx]:
                idx += 1
                if idx == 3:
                    cnt += 1
                    break
    
    print(cnt)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 40796
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<int> u(m), v(m), w(m, 1'000'000'000), d(n), cr(n, 0);
	vector<vector<int>> to(n);
	for(int i = 0; i < n; i++) cin >> d[i];
	multiset<int> has;
	for(int i = 0; i < n; i++) has.insert(d[i]);
	int good = -1;
	for(int i = 0; i < m; i++){
		cin >> u[i] >> v[i]; u[i]--; v[i]--;
		to[u[i]].push_back(i);
		to[v[i]].push_back(i);
	}
	for(int i = 0; i < n; i++){
		sort(to[i].begin(), to[i].end(), [&](int a, int b){
			int va = u[a] ^ v[a] ^ i;
			int vb = u[b] ^ v[b] ^ i;
			return d[va] < d[vb];
		});
	}
	vector<int> vis(n, 0); int cnt = 0;
	function<void(int)> dfs = [&](int r){
		vis[r] = 1;
		cnt++;
		has.erase(has.find(d[r]));
		for(int eid : to[r]){
			int nxt = u[eid] ^ v[eid] ^ r;
			if(!vis[nxt] && d[nxt] >= d[r]){
				w[eid] = d[nxt];
				cr[nxt] = cr[r] ^ 1;
				dfs(nxt);
			}
		}
	};
	vector<int> ord;
	for(int i = 0; i < m; i++) ord.push_back(i);
	sort(ord.begin(), ord.end(), [&](int a, int b){
		return min(d[u[a]], d[v[a]]) < min(d[u[b]], d[v[b]]);
	});
	for(int i : ord){
		if(has.empty()) continue;
		if(d[u[i]] == *has.begin() && d[v[i]] == *has.begin()){
			if(!vis[u[i]] && !vis[v[i]]){
				dfs(u[i]);
			}
		}
	}
	if(cnt != n){
		cout << -1 << endl;
		return 0;
	}
	for(int i = 0; i < n; i++) cout << (cr[i] ? 'B' : 'W'); cout << endl;
	for(int i = 0; i < m; i++){
		cout << w[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 18292
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int n;
	int num[5] = { 0 };
	long total = 0;
	string s;
	
	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'M') num[0]++;
		if (s[0] == 'A') num[1]++;
		if (s[0] == 'R') num[2]++;
		if (s[0] == 'C') num[3]++;
		if (s[0] == 'H') num[4]++;
	}
	
	/*
		num[0] = 3;
		num[1] = 2;
		num[2] = 1;
		num[3] = 2;
		num[4] = 1;
		*/

	int keta = 0;
	for (i = 0; i < 5; i++) {
		if (num[i] > 0) keta++;
	}

	if (keta < 3) {
		cout << "0" << endl;

		getchar();
		getchar();
		return 0;
	}

	long sum3 = 0;
	int cnt = 0; int sum[9999999] = { 0 };
	for (i = 0; i < 5; i++) {
		if (num[i] == 0) continue;
		total = num[i];
		long total1 = total;
		for (j = i+1; j < 5; j++) {
			if (num[j] == 0) continue;
			//total = total * num[j];
			total = total1 * num[j];
			long total2 = total;
			for (k = j + 1; k < 5; k++) {
				if (num[k] == 0) continue;
				total = total * num[k];
				//sum[cnt] = total;
				//cnt++;

				sum3 = sum3 + (long)total;

				total = total2;
			}

			//total = total1;
		}
	}

	/*
	long sum2 = 0;
	for (i = 0; i < cnt; i++) {
		sum2 = sum2 + (long)sum[i];
	}
	*/
	/*
	int cnt = 0;
	for (i = 0; i < n; i++) {
		if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' || s[i][0] == 'H') {

			for (j = i + 1; j < n; j++) {
				if (s[j][0] == 'M' || s[j][0] == 'A' || s[j][0] == 'R' || s[j][0] == 'C' || s[j][0] == 'H') {
					if (s[j][0] != s[i][0]) {

						for (k = j + 1; k < n; k++) {
							if (s[k][0] == 'M' || s[k][0] == 'A' || s[k][0] == 'R' || s[k][0] == 'C' || s[k][0] == 'H') {
								if (s[k][0] != s[i][0] && s[k][0] != s[j][0]) {
									cnt++;
								}
							}
						}

					}

				}
			}
		}


	}
	*/
		//cout << cnt << endl;

	//cout << sum2 << endl;
	cout << sum3 << endl;







	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
// Many Medians

#define NODEBUG

#include<utility>
#include<type_traits>
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<cassert>

using namespace std;

using X_type = int32_t;

template<typename T, typename Iter>
pair<T,T> sub(Iter first,Iter last, size_t n)
{
        static_assert(is_base_of<random_access_iterator_tag, typename iterator_traits<Iter>::iterator_category>::value,
                        "ランダムアクセス反復子じゃない");

        vector<T> tmp(first,last);
        assert(n==tmp.size());
        assert(n%2==0);

        typename vector<T>::iterator mid;

        mid = tmp.begin()+(n/2)-1;
        nth_element(tmp.begin(), mid, tmp.end());
        T min_cand = *mid;

        mid = tmp.begin()+(n/2);
        nth_element(tmp.begin(), mid, tmp.end());
        T max_cand = *mid;

        return {min_cand,max_cand};
}

int main(){
        size_t N;
        cin >> N;
        assert(N%2==0);

        vector<X_type> X;
        X.reserve(N);
        copy_n(istream_iterator<X_type>{cin}, N, back_inserter(X));

        auto p = sub<X_type>(X.begin(), X.end(), N);
        transform(X.begin(), X.end(), ostream_iterator<X_type>{cout,"\n"},
                        [p](X_type x){ return x<p.second ? p.second : p.first; });

        cout.flush();
        return 0;
}


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int N;
  std::cin >> N;
  int x0=0,x1,y0=0,y1,t0=0,t1;
  for(int i=0;i<N;i++){
    std::cin >> t1 >> x1 >> y1;
    int sum=abs(x0-x1)+abs(y0-y1);
    if(t1-t0<abs(sum)){
      std::cout << "No" <<std::endl;
      return 0;
    }

    if((t1-t0)%2!=abs(sum)%2){
      std::cout << "No" <<std::endl;
      return 0;
    }
    x0=x1;
    y0=y1;
    t0=t1;

  }
  std::cout << "Yes" <<std::endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int c[3][3];
  rep(i, 3) rep(j, 3) {
    cin >> c[i][j];
  }

  int a[3];
  REP(x, -100, 101) REP(y, -100, 101) REP(z, -100, 101) {
    int a[] = {x, y, z};
    int b[] = {c[0][0] - a[0], c[0][1] - a[0], c[0][2] - a[0]};
    rep(i, 3) rep(j, 3) {
      if (c[i][j] != a[i] + b[j]) {
        goto next;
      }
    }
    cout << "Yes\n";
    exit(0);
    next:;
  }
  cout << "No\n";
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  static int MAX = 45;
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int[] array = new int[MAX];
    array[0] = 1;
    array[1] = 1;
    int time = sc.nextInt();

    for (int i = 2; i <= time; i++) {
      array[i] = array[i - 1] + array[i - 2];
    }

    System.out.println(array[time]);
  }
}



Measured memory_bytes: 26204
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
	int N;
	string result;
	cin >> N;
	int f = 1;

	if (N == 0)
		result = "0";
	else{
		while (N){
			if (N % 2){
				N -= 1;
				result += '1';

			}
			else{
				result += '0';
			}
			N /= -2;
			f *= -1;
		}
	}

	reverse(result.begin(), result.end());

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<long long, long long> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
struct edge {
	ll from, to, cost;
};

int n, m;
ll c;
vector<P>es[100005];
ll dis[100005] = { 0 };
int used[100005] = { 0 };
ll sumd = 0;
int main() {
	cin >> n >> m >> c;
	rep(i, m) {
		int a, b;
		ll d;
		cin >> a >> b >> d;
		a--; b--;
		es[a].pb(P(b, d));
		es[b].pb(P(a, d));
		sumd += d;
	}
	rep(i, n) dis[i] = LLINF;
	dis[0] = 0;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, 0));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int V = p.second;
		if (dis[V] < p.first) continue;
		for (int u = 0; u < es[V].size(); u++) {
			int to = es[V][u].first;
			ll cost = es[V][u].second;
			if (dis[to] > dis[V] + cost) {
				dis[to] = dis[V] + cost;
				que.push(P(dis[to], to));
			}
		}
	}
	ll res = sumd;
	//cout << res << endl;
	vector<P>dis2(n);
	for (int i = 0; i < n; i++) {
		dis2[i] = P(dis[i], i);
	}
	sort(all(dis2));
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		int now = dis2[i].second;
		ll nc = dis[now] * c;
		for (int u = 0; u < es[now].size(); u++) {
			int to = es[now][u].first;
			ll cost = es[now][u].second;
			if (used[to]==1) {
				sumd -= cost;
				//cout << cost << endl;
			}
		}
		if (sumd >= 0) res = min(res, nc + sumd);
		//cout <<now<<" "<< nc <<" "<< sumd << endl;
		used[now] = 1;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 19328
/*
ID: Aman Raj
LANG: C++
TASK: preface
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
  //# define mod 1e9+7

int main()
{   ll n,k;cin>>n>>k;
     vector<ll> v(n);
       for(ll i=0;i<n;i++)cin>>v[i];
       //dp[i][j] will represent ways yo distribure j among i
         vector<vector<ll> > dp(n+1,vector<ll>(k+1,0));
          //for(ll j=1;j<=v[0];j++)dp[0][j]=1;
       dp[0][0]=1;
       sort(all(v));
    for(ll i=1;i<=n;i++)
    {  dp[i][0]=1;
        for(ll j=1;j<=k;j++)
        {
              dp[i][j]=dp[i-1][j];
               dp[i][j]+=dp[i][j-1];
              // if(dp[i][j]>=mod)dp[i][j]%=mod;

        }ll s=0;
        for(ll j=1;j<=k;j++)
        {if(j>v[i-1]){s+=dp[i-1][j-v[i-1]-1];s%=mod;dp[i][j]-=s;}if(dp[i][j]>=mod)dp[i][j]%=mod;
        }
    }
    /*for(ll i=0;i<=n;i++)
    {
        for(auto x:dp[i])cout<<x<<" ";
        cout<<endl;
    }*/

  cout<<dp[n][k];
	return 0;

}


Measured memory_bytes: 80256
#include<stdio.h>
#include<math.h>

int main(){

    int a, b, n, total;

    int precount[20] = {};
    for (a=0; a<=9; a++){
        for (b=0; b<=9; b++){
            ++precount[a+b];
        }
    }

    while ( (fscanf(stdin, "%d", &n)) != EOF){
        total = 0;
        for (a=0; a<=9; a++){
            for (b=0; b<=9; b++){
                int v = n - a - b;
                if ( 0 <= v && v <= 18){
                    total += precount[v];
                }
            }
        }
        printf("%d\n", total);
    }

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
    ll a = min(x, y), b = max(x, y);
    if (b%a == 0) 
        return a;
    else 
        return gcd(a, b%a);
}

int main() {
    ll n, sx;    cin >> n >> sx;
    ll *x = new ll[n];
    for (ll i = 0; i < n; i++) {
        ll y;   cin >> y;
        x[i] = abs(y-sx);
    }

    ll ans = x[0];
    for (int i = 1; i < n; i++)
        ans = gcd(x[i], ans);

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

Measured memory_bytes: 1024
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sp=sn=0
P=[]
a=0
for i in range(n):
  d=A[i]-B[i]
  if d<0:
    sn+=d
    a+=1
  else:
    sp+=d
    P.append(d)
if sp<-sn:
  print(-1)
  exit()
for p in sorted(P)[::-1]:
  if sn>=0:
    break
  else:
    sn+=p
    a+=1
print(a)

Measured memory_bytes: 24044
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<long long> vec(n);
    ll flag = 0;
    map<ll, ll> tmp;
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
        if(vec[i] == 1){
            flag++;
        }
        tmp[vec[i]]++;
    }

    if(flag == 1){
        cout << 1 << endl;
        return 0;
    }
    if(flag > 2){
        cout << 0 << endl;
        return 0;
    }

    sort(all(vec));
    ll ans = 0;


    map<ll, ll> mp;
    rep(i, n){
        if(mp.count(vec[i]) == 0){
            if(tmp[vec[i]] == 1){
                mp[vec[i]]++;
                ans++;
            }
            for(ll j = vec[i]; j <= 1000000 ; j += vec[i]){
                mp[j]++;
            }
        }
    }
    cout << ans << endl;


    /*
    vector<ll> res;
    ll roop = 0;
    for(ll i = 0; i < n; i++){
        bool flag = true;
        for(ll j = 0; j < res.size(); j++){
            if(vec[i]%vec[j] == 0){
                flag = false;
            }
            roop++; 
        }
        if(flag){
            ans++;
            res.push_back(vec[i]);
        }
    }

    cout << ans << endl;
    cout << roop << endl;
    */

    


}

Measured memory_bytes: 71368
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
using namespace std;


int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(a*b %2){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}


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


int main() {
    int N;
  cin >> N;
  vector<int> d(N);
  
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  
  }
  
  long long Ans = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      Ans += d.at(i)*d.at(j);
    
    }
  
  }
  
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string N;
  cin >> N;
  if ((N[0] == N[1] && N[0] == N[2]) || (N[1] == N[2] && N[1] == N[3]))
    cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int N,count = 0;
  cin >> N;// N=2
  vector<int> d(N);//要素数N=4
  vector<int> allzero(N,0);
  
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  
  rep(i,N-1){
    if(d.at(i) > d.at(i+1) ){
      count++;
    }
      
  }

 
  cout << count+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 405;

ll dp[MX][MX];

int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin>>a;
  vl s(n+1);
  rep(i,n) s[i+1] = a[i]+s[i];
  rep(i,n)rep(j,n) dp[i][j] = LINF;
  drep(l,n)srep(r,l,n) {
    if (l == r) dp[l][r] = 0;
    else {
      srep(k,l,r) {
        mins(dp[l][r], dp[l][k]+dp[k+1][r]+(s[r+1]-s[l]));
      }
    }
  }
  cout<<dp[0][n-1]<<endl;
  return 0;
}






















Measured memory_bytes: 1536
#include <stdio.h>
#include <iostream>
#include <map>
#include <string>
#include <string.h>
using namespace std;
map<int,int> m;
char c[500];
int main(){
	int n;
	cin>>n;
	getchar();
    gets(c);
    int len=strlen(c);
   for(int i=0;i<len;i++){
   	m[c[i]-'A'+1]=1;
   }
	if(m.size()-1==3) printf("Three\n");
	else printf("Four\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool check(int k, int *d, int x) {
    while (x) {
        int tmp = x % 10;
        for (int i = 0; i < k; i++)
            if (tmp == d[i])
                return false;
        x /= 10;
    }
    return true;
}

int main() {
    int n, k;   cin >> n >> k;
    int *d = new int[k];
    for (int i = 0; i < k; i++)
        cin >> d[i];

    int ans = n;
    while (1) {
        if (check(k, d, ans)) {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353 
const int N = 100001; 



void solve(){
    int n;cin>>n;
    vi a(n);
    vi m(100000);
    int sum=0;
    rep(i,0,n)cin>>a[i],sum=sum+a[i],m[a[i]]++;
    int k;cin>>k;
    rep(i,0,k){
    	int b,c;cin>>b>>c;
    	sum=sum+(c-b)*(m[b]);
    	m[c]=m[c]+m[b];
    	m[b]=0;
    	cout<<sum<<endl;
    }

    return ;
}
     
signed main(){
    IOS;
 
    int t=1;
    // cin>>t;
    rep(i,0,t){
        solve();
        cout<<"\n";
    //   cout<<" * "<<t<<"\n";
    }
//    return 0;
}

Measured memory_bytes: 4756
#include "bits/stdc++.h" 
using namespace std; 
int main(){
   int N; cin >> N; 
   vector<int> V(N); 
   vector<int> C(N);
   vector<int> X(N); 
   
   for (int i=0; i<N; i++) {
         cin >> V.at(i);
   }
   for (int i=0; i < N; i++){
         cin >> C.at(i);
   }
   for(int i=0; i < N; i++){
      int res;
      res = V.at(i)-C.at(i); 
      if (res<0) X.at(i)=0; 
     else X.at(i)=res;
   }
   int S;
   for(int i=0;i<N;i++){
         S=S+X.at(i);
   }
   cout << S<<endl;
}

Measured memory_bytes: 256
// 400

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
    ll K,A,B;
    cin >> K >> A >> B;
    if(B<=A){
        cout << K+1 << endl;
    }else{
        if(K<=A) cout << (K+1) << endl;
        else{
            if(B-A<=2) cout << (K+1) << endl;
            else cout << B + (K-A-1)/2*(B-A) + (K-A-1)%2 << endl;
        }
    }    
    return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

struct UnionFind {
  vector<int> par;

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

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

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

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

  int64 size(int x) {return -par[root(x)];}
};

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

  int64 n, m; cin >> n >> m;
  UnionFind u(n);

  int64 a[m], b[m];

  rep(i, m){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }

  int64 ans = n * (n - 1) / 2;

  vector<int64> v;

  for (int i = m - 1; i >= 0; --i){
    v.push_back(ans);
    if (u.issame(a[i], b[i])) ;
    else {
      ans -= (int64) u.size(a[i]) * u.size(b[i]);
      u.unite(a[i], b[i]);
    }
  }

  reverse(all(v));

  for (auto x : v) print(x);

  return 0;
}

Measured memory_bytes: 4212
#include<vector>
// 補助関数
template<typename T> T modpow(T x, T p, T M) {
  if(!p) return 1;
  if(p & 1) return (x * modpow(x, p - 1, M)) % M;
  return modpow((x * x) % M, p >> 1, M);
}
// 剰余類
template<typename T, T M = T(1e9 + 7)>
struct ModInt {
  T number;
  ModInt(T n = 0) : number(n % M) {while(number < 0) number += M;}
  // 代入演算
  ModInt& operator+=(const ModInt& m) {return *this = *this + m;}
  ModInt& operator-=(const ModInt& m) {return *this = *this - m;}
  ModInt& operator*=(const ModInt& m) {return *this = *this * m;}
  ModInt& operator/=(const ModInt& m) {return *this = *this / m;}
  ModInt& operator%=(const ModInt& m) {return *this = *this % m;}
  // 二項演算
  friend const ModInt operator+(const ModInt& lhs, const ModInt& rhs) {return lhs.number + rhs.number;}
  friend const ModInt operator-(const ModInt& lhs, const ModInt& rhs) {return lhs.number - rhs.number;}
  friend const ModInt operator*(const ModInt& lhs, const ModInt& rhs) {return lhs.number * rhs.number;}
  friend const ModInt operator/(const ModInt& lhs, const ModInt& rhs) {return lhs.number * modpow(rhs.number, M - 2, M);}
  friend const ModInt operator%(const ModInt& lhs, const ModInt& rhs) {return lhs.number % rhs.number;}
  // 関係演算
  friend bool operator==(const ModInt& lhs, const ModInt& rhs) {return lhs.number == rhs.number;}
  friend bool operator!=(const ModInt& lhs, const ModInt& rhs) {return lhs.number != rhs.number;}
  friend bool operator<=(const ModInt& lhs, const ModInt& rhs) {return lhs.number <= rhs.number;}
  friend bool operator>=(const ModInt& lhs, const ModInt& rhs) {return lhs.number >= rhs.number;}
  friend bool operator<(const ModInt& lhs, const ModInt& rhs) {return lhs.number < rhs.number;}
  friend bool operator>(const ModInt& lhs, const ModInt& rhs) {return lhs.number > rhs.number;}
  // 組み合わせ
  friend ModInt combination(const ModInt& n, const ModInt& r) {
    if(n < r) return 0;
    if(n < 0 || r < 0) return 0;
    static std::vector<T> fact{1, 1}, inv{1, 1}, finv{1, 1};
    for(T i = fact.size(); i <= n; ++i) {
      fact.emplace_back(fact.back() * i % M);
      inv.emplace_back(inv.at(M % i) * (M - M / i) % M);
      finv.emplace_back(finv.back() * inv.back() % M);
    }
    return (fact.at(n.number) * finv.at((n - r).number) % M) * finv.at(r.number) % M;
  }
};
// 入出力ストリーム
#include<iostream>
template<typename T, T M> inline std::istream& operator>>(std::istream& is, ModInt<T, M>& m) {return is >> m.number;}
template<typename T, T M> inline std::ostream& operator<<(std::ostream& os, const ModInt<T, M>& m) {return os << m.number;}

#include<bits/stdc++.h>
using namespace std;

using MI = ModInt<long long, 998244353>;

int main() {
  MI K, N;
  cin >> K >> N;
  for(MI x = 2; x <= 2*K; x += 1) {
    MI p = (K<x ? 2*K+2-x : x).number / 2;
    MI sum;
    for(MI i = 0; i <= p; i += 1) sum += combination(p, i) * combination(K-p+N-i-1, N-i);
    cout << sum << endl;
  }
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
   for(int i = 0; i < 9; i++){
       for(int j = 0; j < 9; j++){
           printf("%dx%d=%d\n",i + 1, j + 1, (i + 1) * (j + 1));
       }
   }

   return 0;

}

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

int main() {
	// your code goes here
	int k,t;
	vector<int> a;
	cin >>k>>t;
	int max_a = 0;
	for (int i = 0; i < t; i++) {
		int in;
		cin >> in;
		a.push_back(in);
		if (max_a < in) {
			max_a = in;
		}
	}
	if (max_a * 2 <= k + 1) {
		cout << 0 << endl;
	}
	else {
		cout << (max_a - (k - max_a)) -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        Integer[] num = new Integer[] { 2, 4, 8, 16, 32, 64 };
        Arrays.sort(num, Collections.reverseOrder());
        int result = 1;
        for (int i = 0; i < num.length; i++) {
            if (num[i] <= n) {
                result = num[i];
                break;
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e3 + 10, inf = 3 * N;

int solve(vector<string> s);
bool bad(char a, char b);

int main() {
	fast_cin();
	vector<string> s(3);
	for (auto& i : s) {
		cin >> i;
	}
	sort(s.begin(), s.end());
	int ans = inf;
	do {
		ans = min(ans, solve(s));
	} while (next_permutation(s.begin(), s.end()));
	cout << ans << endl;
}

int solve(vector<string> s) {
	vector<int> len(3);
	for (int i = 0; i < 3; ++i) {
		len[i] = s[i].length();
	}
	int mx = accumulate(len.begin(), len.end(), 0);
	vector<vector<bool>> f(3, vector<bool>(mx + 1, true));
	for (int i = 1; i <= 2; ++i) {
		for (int p = 0; p < len[0]; ++p) {
			for (int p0 = p, pi = 0; p0 < len[0] and pi < len[i]; ++p0, ++pi) {
				if (bad(s[0][p0], s[i][pi])) {
					f[i][p] = false;
					break;
				}
			}
		}
	}
	for (int p = 0; p < len[1]; ++p) {
		for (int p1 = p, p2 = 0; p1 < len[1] and p2 < len[2]; ++p1, ++p2) {
			if (bad(s[1][p1], s[2][p2])) {
				f[0][p] = false;
				break;
			}
		}
	}
	int ans = inf;
	for (int p1 = 0; p1 <= len[0]; ++p1) {
		for (int p2 = p1; p2 <= max(p1 + len[1], len[0]); ++p2) {
			if (f[1][p1] and f[2][p2] and f[0][p2 - p1]) {
				ans = min(ans, max({len[0], p1 + len[1], p2 + len[2]}));
			}
		}
	}
	return ans;
}

bool bad(char a, char b) {
	return (a != '?' and b != '?' and a != b);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

import numpy as np


def main():
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)

    a.sort()
    f.sort()
    f = f[::-1]

    l = -1
    r = 10 ** 13

    def test(x):
        cnt = np.maximum(0, a - x // f).sum()
        return cnt <= k

    while l + 1 < r:
        m = (l + r) // 2
        if test(m):
            r = m
        else:
            l = m

    ans = r
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	ll sum=0;
	while(1){
		sum += a;
		if(sum%b == c){
			cout << "YES" << endl;
			return 0;
		}
		if(sum%b == 0){
			cout << "NO" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
def resolve():
    a11,a12,a13=map(int, input().split())
    a21,a22,a23=map(int, input().split())
    a31,a32,a33=map(int, input().split())
    n=int(input())
    lyo1=[a11,a12,a13]
    lyo2=[a21,a22,a23]
    lyo3=[a31,a32,a33]
    lta1=[a11,a21,a31]
    lta2=[a12,a22,a32]
    lta3=[a13,a23,a33]
    lna1=[a11,a22,a33]
    lna2=[a13,a22,a31]
    yo1=0
    yo2=0
    yo3=0
    ta1=0
    ta2=0
    ta3=0
    na1=0
    na2=0
    b=[int(input()) for i in range(n)]
    for x in range(n):
        if b[x] in lyo1:
            yo1+=1
        if b[x] in lyo2:
            yo2+=1
        if b[x] in lyo3:
            yo3+=1
        if b [x] in lta1:
            ta1+=1
        if b[x] in lta2:
            ta2+=1
        if b[x] in lta3:
            ta3+=1
        if b[x] in lna1:
            na1+=1
        if b[x] in lna2:
            na2+=1

    if yo1==3 or yo2==3 or yo3==3 or ta1==3 or ta2==3 or ta3==3 or na1==3 or na2==3:
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<deque>
using namespace std;
typedef pair<int, int>pii;
bool flag[1000000];
int main()
{
	int num;
	scanf("%d", &num);
	fill(flag, flag + num, false);
	deque<pii>deq;
	deq.push_back(make_pair(1, 1));
	for (;;)
	{
		pii z = deq.front();
		deq.pop_front();
		if (flag[z.second])continue;
		flag[z.second] = true;
		if (z.second == 0)
		{
			printf("%d\n", z.first);
			break;
		}
		deq.push_back(make_pair(z.first + 1, z.second + 1));
		deq.push_front(make_pair(z.first, z.second * 10 % num));
	}
}

Measured memory_bytes: 1152
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse = True)
b = list(map(int,input().split()))
b = sorted(b,reverse = True)
c = list(map(int,input().split()))
c = sorted(c,reverse = True)

ls1= []
for i in range(min(x,k)):
    for j in range(min(y,k)):
        ls1.append(a[i]+b[j])

ls1 = sorted(ls1,reverse=True)

ls1 = ls1[:k]
ls2 = []
for i in range(min(z,k)):
    for j in range(len(ls1)):
        ls2.append(c[i]+ls1[j])

ls2 = sorted(ls2,reverse=True)

for i in range(k):
    print(ls2[i])


Measured memory_bytes: 140484
def solve():
    from itertools import combinations
    from sys import stdin
    file_input = stdin
    
    while True:
        W, H = map(int, file_input.readline().split())
        if W == 0:
            break
        
        carpets = []
        state = 0
        
        # Largest Square algorithm
        prev = [0] * (W + 1)
        for i in range(1, H + 1):
            f_line = file_input.readline().split()
            cur = [0] * (W + 1)
            for j, tpl in enumerate(zip(f_line, prev, prev[1:]), start=1):
                p, p1, p2 = tpl
                if p == '1':
                    side = min(p1, p2, cur[j - 1]) + 1
                    cur[j] = side
                    
                    # making carpet bit sequence
                    line_bit = (1 << side) - 1
                    line_bit <<= (j - side)
                    c_b = line_bit
                    for k in range(side - 1):
                        c_b <<= W
                        c_b += line_bit
                    c_b <<= (W * (i - side))
                    carpets.append(c_b)
                else:
                    b = 1 << (j - 1)
                    b <<= (W * (i - 1))
                    state += b
            prev = cur
        
        flag = -1
        ans = 0
        while flag != state:
            flag = state
            
            c_check = dict(zip(carpets, [False] * len(carpets)))
            for c1, c2 in combinations(carpets, 2):
                if c_check[c1] or c_check[c2]:
                    continue
                overlap = c1 & c2
                if overlap == c2:
                    c_check[c2] = True
                elif overlap == c1:
                    c_check[c1] = True
            carpets = []
            for k, v in c_check.items():
                if not v:
                    carpets.append(k)
            
            for i in range(W * H):
                b = 1 << i
                if b & state:
                    continue
                t_carpets = []
                for c in carpets:
                    if b & c:
                        t_carpets.append(c)
                if len(t_carpets) == 1:
                    c = t_carpets[0]
                    state |= c
                    ans += 1
                    carpets.remove(c)
            
            carpets = list(set(c^(c & state) for c in carpets))
            
        goal = (1 << (W*H)) - 1
        if state == goal:
            print(ans)
            continue
        
        for i in range(1, len(carpets) + 1):
            for t_carpets in combinations(carpets, i):
                t_state = state
                for c in t_carpets:
                    t_state |= c
                if t_state == goal:
                    print(ans + i)
                    break
                else:
                    continue
                break
            else:
                continue
            break

solve()


Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	map<int,int> cnt;
	for (int n = 2; n <= N; ++ n) {
		int i = n;
		for (int j = 2; j <= N; ++ j) if (i % j == 0) {
			int c = 0;
			while (i % j == 0) { i /= j; ++ c; }
			cnt[j] += c;
		}
	}
	long long r = 1;
	for (auto p : cnt) (r *= p.second + 1) %= 1000000007;
	cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
*/ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
/*ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  { facto();
    int n,k;
    cin>>n>>k;
    int ans=0;
    vector<int> v(n);
    for (int i = 0; i <n; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=n;i>=k;i--)
     {   ans=(ans+(ncrm(i-1,k-1)*v[i-1])%mod)%mod;

     }
    for(int i=1;i<=n-k+1;i++)
        ans=(mod+ans-(ncrm(n-i,k-1)*v[i-1])%mod)%mod;
    cout<<ans<<endl;
   }
  //time("");
  return 0;
}

Measured memory_bytes: 8832
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
 
int main(void){
    string S;
    cin >> S;
    int sum=0;
    rep(i,S.length()) sum+=S[i]-'0';
    if(sum%9) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <algorithm>

using namespace std;

int a[100], n, x;

int main() {
	scanf("%d %d",&n,&x);
	int res=0;
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		res++; x-=a[i];
	}
	sort(a,a+n);
	printf("%d\n",res+x/a[0]);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

vector<int>primes;

const int adx[] = { 1,1,1,0,-1,-1,-1,0 };
const int ady[] = { 1,0,-1,-1,-1,0,1,1 };

int add(const int base, const int plus) {
	if (plus) {
		return base + 1;
	}
	else {
		return 0;
	}
}
vector<vector<vector<int>>>get_cumulative_sum(const vector<vector<int>>&field) {
	const int H = field.size();
	const int W = field[0].size();
	//0 :?????????1:??????2:?????????3:??? 4:?????????5:??? 6:?????? 7:???
	vector<vector<vector<int>>>sums(H, vector<vector<int>>(W, vector<int>(8)));
	for (int ny = 0; ny <H; ++ny) {
		for (int nx = 0; nx <W; ++nx) {
			for (int k = 0; k < 2; ++k) {
				int py = ny - ady[k];
				int px = nx - adx[k];
				if (!(px >= 0 && px <W && py >= 0 && py <H))continue;

				sums[ny][nx][k] = add(sums[py][px][k], field[ny][nx]);

			}
		}
	}
	for (int ny = H-1; ny >= 0; --ny) {
		for (int nx = 0; nx <W; ++nx) {
			for (int k = 2; k < 4; ++k) {
				int py = ny - ady[k];
				int px = nx - adx[k];
				if (!(px >= 0 && px <W && py >= 0 && py <H))continue;

				sums[ny][nx][k] = add(sums[py][px][k], field[ny][nx]);

			}
		}
	}
	for (int ny = H-1; ny >= 0; --ny) {
		for (int nx =W-1; nx >= 0; --nx) {
			for (int k = 4; k < 6; ++k) {
				int py = ny - ady[k];
				int px = nx - adx[k];
				if (!(px >= 0 && px <W && py >= 0 && py <H))continue;

				sums[ny][nx][k] = add(sums[py][px][k], field[ny][nx]);

			}
		}
	}
	for (int ny = 0; ny <H; ++ny) {
		for (int nx = W-1; nx >= 0; --nx) {
			for (int k = 6; k < 8; ++k) {
				int py = ny - ady[k];
				int px = nx - adx[k];
				if (!(px >= 0 && px <W && py >= 0 && py <H))continue;

				sums[ny][nx][k] = add(sums[py][px][k], field[ny][nx]);

			}
		}
	}
	return sums;
}

int main() {
	while (1) {

		int N; cin >> N;
		if (!N)break;
		vector<vector<int>>field(N+2, vector<int>(N+2));
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			for (int j = 0;  j < N; ++j) {
				field[i+1][j+1] = st[j] - '0';
			}
		}
		auto vs(get_cumulative_sum(field));
		int ans = 0;
		for (auto aa : vs) {
			for (auto a : aa) {
				for (auto g : a) {
					ans = max(ans, g);
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 7884
#include<stdio.h>
#define array_length 400000

int main(){
    int a[array_length] = {0};
    int request_num;
    int num;
    int front = 0;
    int rear = 0;
    int i;
    int q;
    int d;

    scanf("%d", &request_num);
    
    for(i=0;i<request_num;i++){
        scanf("%d", &q);
        switch(q){
            case 0: scanf("%d%d", &d, &num);
                    if(d){
                        a[rear++] = num;
                    }else{
                        if(front<0)a[-(front++)] = num;
                        else a[array_length-1-(front++)] = num;
                    }
                    break;

            case 1: scanf("%d", &num);
                    if(num-front<0)printf("%d\n", a[array_length-front+num]);
                    else printf("%d\n", a[num-front]);
                    break;

            case 2: scanf("%d", &d);
                    if(d)rear--;
                    else front--;
                    break;

            default: break;
        }
    }
    return 0;
}


Measured memory_bytes: 3372
# ABC092
# 参加者
N = int(input())
# D日間の合宿でX個のチョコが残った
D, X = map(int, input().split())
# 参加者iは,1,Ai+1,2Ai+1..目にチョコを一つ食べる
A = [int(input()) for _ in range(N)]

eaten = 0
for i in range(N):
    day = 0
    cnt = 0
    while True:
        day = A[i]*cnt + 1
        if day <= D:
            eaten += 1
            cnt += 1
        else:
            break
print(eaten+X)


Measured memory_bytes: 9144