akhauriyash/Code-Regression huggingface dataset:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, x = inintm()
A = inintl()

A.sort()
ans = 0

for i in range(n-1):
    if x - A[i] >= 0:
        ans += 1
        x -= A[i]

if A[-1] == x:
    ans += 1

print(ans)


Measured memory_bytes: 62104
# Debug Print
isdbg  = False
#isdbg  = True
def dprint(*value,sep=' ',end='\n'):
    if isdbg:
        print(*value,sep=sep,end=end)
    
# 入力を格納
H,W,N = map(int,input().split())

if isdbg:
    XY = [[0 for i in range(W)] for i in range(H)]
BL = {}
for i in range(N):
    x1,y1 = map(int,input().split())
    if isdbg:
        XY[x1-1][y1-1] = 1

    if x1-1 in BL :
        BL[x1-1].append(y1-1)
    else:
        BL[x1-1] = [y1-1]

TL = sorted(BL.items(),key= lambda x: x[0])

# 初期位置
if isdbg:
    for i in range(W):
        for j in range(H):
            dprint(XY[i][j],end='')
        dprint()
#print(TL)

maxr = 1
for i in range(H-1):

    if i+1 in BL:
        l = BL[i+1]
        l.sort()
        #print(l,maxr)
        for ll in l :
            if maxr > ll:
                print(i+1)
                exit(0)
            elif maxr == ll:
                maxr -= 1
                break
            else:
                break
        
    maxr += 1

print(H)


Measured memory_bytes: 62788
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long x, ans;
	cin >> x;
	for (ans = 1; ans * (ans + 1) / 2 < x; ans++);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <vector<ll>> grid(n,vector<ll>(n-1));
    for (int z=0;z<n;z++){
        for (int x=0;x<n-1;x++){
            cin >> grid[z][x];
            grid[z][x]--;
        }
    }
    vector <bool> used(n,false);
    vector <ll> order(n,0);
    vector <ll> next;
    ll count = 1;
    for (int z=0;z<n;z++){
        if (order[z] >= n-1) {
            continue;
        }
        ll a = z;
        ll b = grid[z][order[z]];
        if (used[a] || used[b]) continue;
        if (order[b] >= n-1) continue;
        if (grid[b][order[b]] == a){
            order[b]++;
            order[a]++;
            used[a] = true;
            used[b] = true;
            next.push_back(a);
            next.push_back(b);
        }
    }
    while (true){
        count++;
        bool ok = false;
        vector <bool> used(n,false);
        ll k =0;
        vector <ll> nnext;
        for (int q=0;q<next.size();q++){
            ll z = next[q];
            if (order[z] >= n-1) {
                k++;
                continue;
            }
            ll a = z;
            ll b = grid[z][order[z]];
            if (used[a] || used[b]) continue;
            if (order[b] >= n-1) continue;
            if (grid[b][order[b]] == a){
                order[b]++;
                order[a]++;
                used[a] = true;
                used[b] = true;
                nnext.push_back(a);
                nnext.push_back(b);
                ok = true;
            }
        }
        if (!ok) {
            for (int z=0;z<n;z++){
                if (order[z] < n-1){
                    cout << -1 << endl;
                    return 0;
                }
            }
            cout << count-1 << endl;

            return 0;
        }
        next = move(nnext);
    }
    
}

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

using namespace std;

typedef pair<int, int> pii;

const int MAX_N = 100000;
int n, x, y, z;
int au[MAX_N], ag[MAX_N], cu[MAX_N];
pii dgs[MAX_N];
set<pii, greater<pii> > dgc;
int use[MAX_N];

int main()
{
  cin >> x >> y >> z;
  n = x + y + z;
  for (int i = 0; i < n; i++) {
    cin >> au[i] >> ag[i] >> cu[i];
    dgs[i] = make_pair(au[i] - ag[i], i);
    dgc.insert(make_pair(au[i] - cu[i], i));
  }

  sort(dgs, dgs+n);

  int64_t l = 0, r = 0;
  int c = x;
  while (c--) {
    int i = dgc.begin()->second;
    r += au[i];
    use[i] = 0;
    dgc.erase(dgc.begin());
  }
  for (auto p : dgc) {
    r += cu[p.second];
    use[p.second] = 2;
  }

  set<pii> sc;
  int64_t m = 0;
  for (int k = 1; k <= n; k++) {
    int i = dgs[k-1].second;
    if (use[i] == 0) {
      r -= au[i];
      if (!dgc.empty()) {
        int j = dgc.begin()->second;
        r += au[j] - cu[j];
        use[j] = 0;
        dgc.erase(dgc.begin());
      }
    } else {
      r -= cu[i];
      auto it = dgc.find(make_pair(au[i] - cu[i], i));
      dgc.erase(it);
    }

    if (sc.size() < y) {
      sc.insert(make_pair(ag[i] - cu[i], i));
      l += ag[i];
    } else {
      auto it = sc.begin();
      if (it->first < ag[i] - cu[i]) {
        l += ag[i] - ag[it->second] + cu[it->second];
        sc.erase(it);
        sc.insert(make_pair(ag[i] - cu[i], i));
      } else {
        l += cu[i];
      }
    }

    if (k < y || n - k < x) continue;
    m = max(m, l + r);
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long total=0,n,k;
  priority_queue<long long>pq;
  cin>>n>>k;
  while(n--)
  {
    long long temp;
    cin>>temp;
    pq.push(temp);
  }
  while(!pq.empty())
  {
    if(k==0)
    {
     total+=pq.top(); 
    }
    else
    {
      k--;
    }
   	pq.pop();    
  }
  cout<<total<<endl;
}

Measured memory_bytes: 2420
n = gets.to_i
n.times{
  a,b = gets.split.map(&:to_i).sort
  if a==b
    p a+b-2
  else
    ok = 0
    ng = 10**9
    40.times{
      mid = (ok+ng)/2
      if mid**2<a*b
        ok = mid
      else
        ng = mid
      end
    }
    p (ok*(ok+1)<a*b)? ok*2-1 : ok*2-2
  end
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
//using namespace __gnu_pbds;
//using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
int N;
int f[10000010];
void MAIN() {
	cin>>N;
	rng(i,1,N) {
		for(int j=i;j<=N;j+=i)f[j]++;
	}
	ll ans=0;
	rng(i,1,N)ans+=(ll)i*f[i];
	cout<<ans;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<pair<int, int>, int> MA;
  for (int i = 1; i <= N; i++) {
    int f = i;
    int b = f % 10;
    while (f >= 10) f /= 10;
    MA[{f, b}]++;
  }
  long ans = 0;
  for (int i = 1; i <= N; i++) {
    int f = i;
    int b = f % 10;
    while (f >= 10) f /= 10;
    ans += MA[{b, f}];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, X, T = map(int, input().split())
print(((N + X - 1) // X) * T)

Measured memory_bytes: 9320
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ull n, a, b, c, d;
map<ull, ull> memo;

ull dfs(ull i) {
  if (memo.find(i) != end(memo)) {
    return memo[i];
  }
  if (i == 1) {
    return memo[i] = d;
  }
  ull ans = i * d;
  if (i >= 2) {
    if (i % 2 == 0) {
      ans = min(ans, dfs(i / 2) + a);
    } else {
      ans = min(ans, dfs((i + 1) / 2) + a + d);
      ans = min(ans, dfs((i - 1) / 2) + a + d);
    }
  }
  if (i >= 3) {
    if (i % 3 == 0) {
      ans = min(ans, dfs(i / 3) + b);
    } else if (i % 3 == 1) {
      ans = min(ans, dfs((i - 1) / 3) + b + d);
      ans = min(ans, dfs((i + 2) / 3) + b + 2 * d);
    } else {
      ans = min(ans, dfs((i - 2) / 3) + b + 2 * d);
      ans = min(ans, dfs((i + 1) / 3) + b + d);
    }
  }
  if (i >= 5) {
    if (i % 5 == 0) {
      ans = min(ans, dfs(i / 5) + c);
    } else if (i % 5 == 1) {
      ans = min(ans, dfs((i - 1) / 5) + c + d);
      ans = min(ans, dfs((i + 4) / 5) + c + 4 * d);
    } else if (i % 5 == 2) {
      ans = min(ans, dfs((i - 2) / 5) + c + 2 * d);
      ans = min(ans, dfs((i + 3) / 5) + c + 3 * d);
    } else if (i % 5 == 3) {
      ans = min(ans, dfs((i - 3) / 5) + c + 3 * d);
      ans = min(ans, dfs((i + 2) / 5) + c + 2 * d);
    } else {
      ans = min(ans, dfs((i - 4) / 5) + c + 4 * d);
      ans = min(ans, dfs((i + 1) / 5) + c + d);
    }
  }
  return memo[i] = ans;
}

void solve() {
  cin >> n >> a >> b >> c >> d;
  memo.clear();
  cout << dfs(n) << endl;
}

int main() {
  int T;
  cin >> T;
  REP(i, T) { solve(); }
  return 0;
}


Measured memory_bytes: 4284
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [(int(p), int(x)) for (p, x) in [input().split() for _ in range(m)]]
for p, x in px:
    t_cp = t.copy()
    t_cp[p-1] = x
    print(sum(t_cp))
    

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long 
 
using namespace std;
 
main(){
    int n,m=0,c=0;
    cin>>n;
    double ans;
    for(int i=1;i<=n;i++){
        if(i%2==0) m++;
        else c++;
    }
    cout<<c*1.0/n;
    return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  if (N % 2 == 1) {
    cout << "No" << BR;
    return 0;
  }
  int n = N / 2;
  bool ok = true;
  rep0(i, n) {
    if (S[i] != S[n + i]) ok = false;
  }

  if (ok) cout << "Yes" << BR;
  else cout << "No" << BR;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n; cin>>n;
	int x = n/100;
	int y = n%100;
	if(x>=1 && x<=12){
		if(y>=1 && y<=12){
			cout<<"AMBIGUOUS"<<endl;
		}else{
			cout<<"MMYY"<<endl;
		}
	}else{
		if(y>=1 && y<=12){
			cout<<"YYMM"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
}


Measured memory_bytes: 3612
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

vector <int> g[2005];
map <int,int> cnt;
bool vis[2005];

signed main()
{
    int n,x,y; 
    cin>>n>>x>>y;
    for (int i=1;i<n;i++) {
        g[i].pb(i+1);
        g[i+1].pb(i);
    }
    g[x].pb(y);
    g[y].pb(x);
    for (int i=1;i<=n;i++){
        memset(vis,false,sizeof(vis));
        queue<int> q;
        q.push(i);
        vi dis(n+1,0);
        vis[i]=true;
        while (q.size()){
            int x=q.front();
            //cout << x << " = "<<dis[x]<<'\n';
            q.pop();
            for (auto &it: g[x]){
                if (!vis[it]) {
                    q.push(it); 
                    vis[it]=true;
                    dis[it]=dis[x]+1;
                    cnt[dis[it]]++;
                }
            }
        }
    }
    for (int i=1;i<n;i++) cout << cnt[i]/2 << endl; 
    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x;
    cin >> x;
    int q1 = 0, n = 100;
    while (n < x){
        n += n/100, q1++;
    }
    cout << q1 << endl;
    return 0;
}


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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int MOD = 100000;
constexpr int X = 100;

std::vector<std::vector<int>> dp;

int dfs(int i, int j) {
    auto& ret = dp[i][j];
    if (ret != -1) return ret;

    if (i == 0 && j == 0) {
        return ret = 1;
    }

    ret = 0;
    if (i == 1 && j == 0) (++ret) %= MOD;
    for (int d = 2; d <= i; ++d) {
        (ret += dfs(j, i - d)) %= MOD;
    }
    return ret;
}

bool solve() {
    int w, h;
    std::cin >> w >> h;
    if (w == 0) return false;
    --w, --h;

    int ans = 0;
    for (int d = 1; d <= w; ++d) {
        (ans += dfs(h, w - d)) %= MOD;
    }
    for (int d = 1; d <= h; ++d) {
        (ans += dfs(w, h - d)) %= MOD;
    }

    std::cout << ans << "\n";
    return true;
}

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

    dp = vec(X, vec(X, -1));
    for (int i = 0; i < X; ++i) {
        for (int j = 0; j < X; ++j) {
            dfs(i, j);
        }
    }

    while (solve()) {}

    return 0;
}



Measured memory_bytes: 3220
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define MOD  1000000007

int n;
string s;
int E[300010],W[300010];
int main(int argc, char const *argv[]) {
  
  std::cin >> n >> s;
  memset(E,0,sizeof(E));
  memset(W,0,sizeof(W));
  if(s[0]=='W') W[0]=1;
  else E[0]=1;
  for(int i=1; i<n; i++){
    if(s[i]=='W'){
      W[i]=W[i-1]+1;
      E[i]=E[i-1];
    }
    else{
      E[i]=E[i-1]+1;
      W[i]=W[i-1];
    }
  }
  int mini=9999999;
  for(int i=1; i<n; i++){
    mini=min(W[i-1]+E[n-1]-E[i],mini);
    if(i==1)mini--;
    
  }
  std::cout << mini << '\n';
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++)
        cin >> A[i];
    int ans = 0, count = 0;
    for(int i = 1; i < N; i++)
    {
        if(A[i] <= A[i-1])
        {
            count++;
            ans = max(ans, count);
        }
        else count = 0;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){int n,i,t;for(long int ans;cin>>n,n;cout<<ans<<endl){vector<int> m;for(ans=i=0;i++<n;m.push_back(t))cin>>t;sort(m.begin(),m.end());for(i=1;i<n;i++)ans+=m[i-1]*(n-i);}}

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

int main()
{
  int n, i, bit, sum_1, j;
  vector<int> a(4);
  string op, ans;
  cin >> n;
  for(i=0; i<4; i++)
  {
    a[i] = n % 10;
    n = n / 10;
  }
  reverse(a.begin(),a.end());
  for(bit = 0;  bit < (1<<4);  bit++)
  {

    sum_1   = a[0];
    j = 0;
    for(i=1; i<4; i++)
    {
      if(bit & (1<<i))
      {
         sum_1 += a.at(i);
         op[j] = '+';
      }
      else
      {
        sum_1 -= a.at(i);
        op[j] = '-';
      }
      j++;   
    }
    if(sum_1 == 7) break;
  }
  cout << a[0] << op[0]<< a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   ll n, k;
   cin >> n >> k;
   ll ans = n % k;
   ans = min(ans, abs((ans - k) % k));
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a



nu=int(input())
total=0
for p in range(1,nu):
    s=collections.Counter(prime_factorize(p))
    sama=1
    for j in s.values():
        sama=sama*(j+1)
    total+=sama
print(total)

Measured memory_bytes: 69816
(* O(n^2) *)
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let _ =
  for x = 0 to n do
    for y = 0 to n do
      let z = n - x - y in
      if z >= 0 && 10000 * x + 5000 * y + 1000 * z = m then (Printf.printf "%d %d %d \n" x y z; exit 0) done done;
  print_endline "-1 -1 -1"

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

using namespace std;

int N, C[100];
int dp[100][101][10];

int rec(int left, int right, int value)
{
  if(~dp[left][right][value]) return (dp[left][right][value]);
  if(left + 1 == right) return (C[left] == value);
  auto &ret = dp[left][right][value];
  if(value == 0) {
    for(int mid = left + 1; mid < right; mid++) {
      for(int j = 0; j < 10; j++) {
        if(rec(left, mid, j) && rec(mid, right, j)) return (ret = true);
      }
    }
  } else {
    for(int mid = left + 1; mid < right; mid++) {
      if(rec(left, mid, 0) && rec(mid, right, value)) return (ret = true);
      if(rec(left, mid, value) && rec(mid, right, 0)) return (ret = true);
      if(rec(left, mid, value) && rec(mid, right, value)) return (ret = true);
    }
  }
  return (ret = false);
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> C[i];
  }
  memset(dp, -1, sizeof(dp));
  if(rec(0, N, 0)) cout << "yes" << endl;
  else cout << "no" << endl;
}

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

int main(){
    int r, c, sum, t_sum = 0;
    cin >> r >> c;
    int table[101][101] = {{}};
    
    for(int i = 0; i < r; i++){
        sum = 0;
        for(int j = 0; j < c; j++){
            cin >> table[i][j];
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        t_sum += sum;
    }
    table[r][c] = t_sum;
    
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            cout << table[i][j] << " ";
        }
        cout << table[i][c] << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
N, A, B, C = [int(_) for _ in input().split()]
S = [input() for _ in range(N)] + ['X']


def no():
    print('No')
    exit()


ans = []
for sa, sb in zip(S, S[1:]):
    if sa == 'AB':
        if A == B == 0:
            no()
        elif B == 0:
            ans += ['B']
            B += 1
            A -= 1
        elif A == 0:
            ans += ['A']
            A += 1
            B -= 1
        elif A == 1 and C == 0 and sb == 'AC' or B > A:
            ans += ['A']
            A += 1
            B -= 1
        else:
            ans += ['B']
            B += 1
            A -= 1
    elif sa == 'BC':
        if B == C == 0:
            no()
        elif B == 0:
            ans += ['B']
            B += 1
            C -= 1
        elif C == 0:
            ans += ['C']
            C += 1
            B -= 1
        elif B == 1 and A == 0 and sb == 'AB' or C > B:
            ans += ['B']
            B += 1
            C -= 1
        else:
            ans += ['C']
            C += 1
            B -= 1
    elif sa == 'AC':
        if C == A == 0:
            no()
        elif C == 0:
            ans += ['C']
            C += 1
            A -= 1
        elif A == 0:
            ans += ['A']
            A += 1
            C -= 1
        elif A == 1 and B == 0 and sb == 'AB' or C > A:
            ans += ['A']
            A += 1
            C -= 1
        else:
            ans += ['C']
            C += 1
            A -= 1
print('Yes')
print('\n'.join(ans))


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

int main()
{
	string s;
	getline(cin ,s);
	string ans(s);
    transform( s.begin(), s.end(), ans.begin(), ::toupper );

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ans[i])
		{
			ans[i] = tolower(ans[i]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

using pint = pair<int,int>;
string S;
int main() {
    while (cin >> S) {
        if (S[0] == '0') {
            cout << -1 << endl;
            continue;
        }
        else if (S.back() == '1') {
            cout << -1 << endl;
            continue;
        }
        
        int N = (int)S.size();
        bool ok = true;
        for (int i = 1; i < N; ++i) {
            int j = N - i;
            if (S[i-1] != S[j-1]) ok = false;
        }
        if (!ok) {
            cout << -1 << endl;
            continue;
        }
        
        vector<pint> res;
        int prev = 1;
        int i = 2;
        for (i = 2; i <= N; ++i) {
            if (S[i-1] == '1') {
                for (; prev < i; ++prev) res.push_back(pint(i, prev));
            }
        }
        res.push_back(pint(N, N-1));
        //if (N & 1) res.push_back(pint(N/2, N/2+1));
        //for (; prev < i; ++prev) res.push_back(pint(i, prev));
        

        
        
        /*
        int m = (int)res.size();
        for (int i = 0; i < m; ++i) {
            res.push_back(pint(N+1-res[i].first, N+1-res[i].second));
        }

        
        
        if (N % 2 == 0) {
            res.push_back(pint(N/2, N/2+1));
        }
        */
        
        
        for (auto p : res) {
            cout << p.first << " " << p.second << endl;
        }
    }
}





























Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
int main() {
    int A, B;
    while(cin >> A >> B) {
        cout << A + B << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]

graph = [[0] * n for _ in range(n)]
for a, b, c in abc:
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c

dist = floyd_warshall(csr_matrix(graph))

ans = 0
for a, b, c in abc:
    a -= 1
    b -= 1

    if dist[a][b] != c:
        ans += 1

print(ans)


Measured memory_bytes: 17428
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double a[] = new double[n];
        
        for(int  i = 0 ; i<n ; i++){
            
              a[i] = sc.nextDouble();
        }
          Arrays.sort(a);
        
         for (int j =0 ; j<n-1 ; j++){
             
                a[j+1]= (a[j] + a[j+1])/2 ;
         }
            
        System.out.println(a[n-1]);
    }
}


Measured memory_bytes: 23252
N = int(input())
A = list(map(int,input().split()))

n = 62
D = [0]*n

for i in range(N):
    s = list(bin(A[i])[2:])[::-1]
    s = [i for i in range(len(s)) if s[i]=='1']
    for j in s:
        D[j] += 1
ans = 0
for i in range(n):
    ans += D[i]*(N-D[i])*2**i
    ans %= 10**9+7
print(ans)


Measured memory_bytes: 122936
n, m = list(map(int, input().split()))
s = input()
t = input()

def gcd(a, b):
  if a<b:
    a, b = b, a
  if b==0:
    return a
  return gcd(b, a%b)

g = gcd(n, m)
l = n*m//g
nn = n//g
mm = m//g

for i in range(g):
  if s[i*nn] != t[i*mm]:
    print(-1)
    exit()
print(l)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 10000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    double t,x;
    cin >> t >> x;
    double ans = t/x;
    printf("%.8f"  , ans);
    cout << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static int n;
        static int a;
        static int b;
        static int[] problems;

        static void Main(string[] args)
        {
            //[summary]B - Contests
            n = int.Parse(Console.ReadLine());

            var line = ReadLine();
            a = line[0];
            b = line[1];

            problems = ReadLine().OrderBy(x => x).ToArray();
            var count = new int[3];

            count[0] = CountFirstQuestion();
            count[1] = CountSecondQuestion();
            count[2]  = CountThirdQuestion();

            int min = int.MaxValue;

            foreach(var c in count)
            {
                if (c < min)
                {
                    min = c;
                }
            }

            Console.WriteLine(min);
        }

        static int CountFirstQuestion()
        {
            int count = 0;

            foreach(var p in problems)
            {
                if (p <= a)
                {
                    count++;
                }
            }

            return count;
        }

        static int CountSecondQuestion()
        {
            int count = 0;

            foreach (var p in problems)
            {
                if (p > a && p <= b)
                {
                    count++;
                }
            }

            return count;
        }

        static int CountThirdQuestion()
        {
            int count = 0;

            foreach (var p in problems)
            {
                if (p > b)
                {
                    count++;
                }
            }

            return count;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13524
def solve():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    a = [list(map(int, input().split())) for _ in range(n)]
    count = 0
    for data in a:
        num = sum([ai * bi for ai, bi in zip(data, b)]) + c
        if num > 0:
            count += 1
    return count


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3060
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define testcases() int t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
 //----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	ll maxx=-INF;
	ll sec_maxx=INF;
	ll cnt=0;
	for(auto it: v)
	{
		if(it>=maxx)
		{
			if(it==maxx)
				cnt++;
			else
			{
				cnt=1;
				sec_maxx=maxx;
				maxx=it;
			}
		}
		else if(it>sec_maxx)
		{
			sec_maxx=it;
		}
	}
	int ans;
	for(auto it: v)
	{
		ans=maxx;
		if(it==maxx)
		{
			if(cnt==1)
				ans=sec_maxx;
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3200
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    h,w=map(int,input().split())
    ans=0
    if h==1 or w==1:
        ans=1
    elif h%2==0 or w%2==0:
        ans=h*w//2
    else:
        ans=h*w//2+1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll s = 0, t = 0;
    vector<ll> a(n);
    vector<int> ss, tt;
    rep(i, 0, n) {
        cin >> a[i];
        if (i % 2 == 0 && a[i] > 0) {
            s += a[i];
            ss.emplace_back(i + 1);
        }
        if (i % 2 == 1 && a[i] > 0) {
            t += a[i];
            tt.emplace_back(i + 1);
        }
    }
    if (s == 0 && t == 0) {
        ll mx = -1e18, pos = 0;
        rep(i, 0, n) {
            if (mx < a[i]) {
                mx = a[i];
                pos = i;
            }
        }
        cout << mx << endl;
        cout << n - 1 << endl;
        for (int i = n; i > pos + 1; i--) cout << i << endl;
        rep(i, 0, pos) cout << 1 << endl;
        return 0;
    }
    debug(s, t);
    vector<int> res;
    if (s < t) {
        swap(s, t);
        swap(ss, tt);
    }
    set<int> st;
    for (int se : ss) st.insert(se);
    for (int i = n; i > ss.back(); i--) res.emplace_back(i);
    for (int i = ss.back(); i > *ss.begin(); i -= 2) {
        if (st.find(i) == st.end()) res.emplace_back(i);
    }
    rep(i, 1, *ss.begin()) res.emplace_back(1);
    rep(i, 1, ss.size()) res.emplace_back(2);
    cout << s << endl;
    cout << res.size() << endl;
    for (int e : res) cout << e << endl;
    return 0;
}


Measured memory_bytes: 256
n = list(input())

# print(n[-1])

if int(n[-1]) == 2 or int(n[-1]) == 4 or int(n[-1]) == 5 or int(n[-1]) == 7 or int(n[-1]) == 9:
  print('hon')

elif int(n[-1]) == 0 or int(n[-1]) == 1 or int(n[-1]) == 6 or int(n[-1]) == 8:
  print('pon')

else:
  print('bon')




Measured memory_bytes: 61672
#include<stdio.h>


int main(void){
	int A,B;
	int pul,minus,mul;

	scanf("%d %d",&A, &B);

	pul = A+B;
	minus = A-B;
	mul = A*B;

	if(pul>minus && pul>mul){
		printf("%d", pul);
		return 0;
	}else if(mul>minus && mul >pul){
		printf("%d", mul);
		return 0;
	}else{
		printf("%d", minus);
		return 0;
	}
	return 0;

}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    var ans = 0
    (0..Math.min(a, x / 500)).forEach {
        val y = x - 500 * it
        (0..Math.min(b, y / 100)).forEach {
            val z = y - 100 * it
            if (z / 50 <= c) ans++
        }
    }
    println(ans)
}


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

int main(){
  int a,b,c,d,g[101][101];
  cin>>a;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      g[i][j]=0;
    }
  }
  for(int i=0;i<a;i++){
    cin>>b>>c;
    for(int j=0;j<c;j++){
      cin>>d;
      g[b][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout<<g[i][j];
      if(a-j>=1)cout<<" ";
    }
    cout<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
main()
{
    int A,B,C,D,e,f,c=0,c1=0;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    while(1)
    {
        e=A-D;
        c++;
        A=e;
        if(e<=0)
            break;
    }
    while(1)
    {
        f=C-B;
        c1++;
        C=f;
        if(f<=0)
            break;
    }
    if(c<c1)
        printf("No\n");
    else
        printf("Yes\n");
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    map<int,int> m;
    long long int n;
    cin>>n;
    for(int i=2;i<=sqrt(n);i++)
    {
        while(n%i==0)
        {
            m[i]++;
            n=n/i;
        }
    }
    if(n>1)
    m[n]++;
    int ans=0;
    for(auto it:m)
    {
        int p=it.second;
        int curr=1;
        while(p>=curr)
        {
            ans++;
            p-=curr;
            curr++;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n, k;
    cin >> n >> k;

    vl rui(n+1);
    rep(i, n) {
        ll a;
        cin >> a;
        a--;
        rui[i+1] = (rui[i] + a)%k;
    }

    map<ll, ll> mp;
    queue<ll> Q;
    ll ans = 0;
    rep(i, n+1) {
        ans += mp[rui[i]];
        mp[rui[i]]++;
        Q.push(rui[i]);
        if(Q.size() == k) {
            mp[Q.front()]--;
            Q.pop();
        }
    }

    out(ans);
    re0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int bells[3];
    rep(0, 3) cin >> bells[i];

    sort(bells, bells + 3);

    cout << (bells[0] + bells[1]) << endl;

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  100005

ll n,k,fa[N];

ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}

ll comb(ll n,ll r)
{
	ll ans=fa[n];
	ans=(ans*expo(fa[n-r],hell-2,hell))%hell;
	ans=(ans*expo(fa[r],hell-2,hell))%hell;
	return ans;
}

ll solve(vector<ll> v)
{
	ll cc[N];
	for(ll i=0;i<k-2;i++)
	{
		cc[i]=0;
	}
	for(ll i=k-2;i<=n;i++)
	{
		cc[i]=comb(i,k-2);
	}
	for(ll i=1;i<=n;i++)
		cc[i]=(cc[i-1]+cc[i])%hell;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x=0;
		if(i-1<k-2)continue;
		x=(cc[i-1]*v[i])%hell;
		x+=hell;
		x%=hell;
		ans=(ans+x)%hell;
	}
	return ans;
}

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,l,m;
    	cin>>n>>k;
    	fa[0]=1;
    	for(i=1;i<N;i++)
    		fa[i]=(fa[i-1]*i)%hell;
    	vi v;
    	for(i=0;i<n;i++)
    	{
    		cin>>l;
    		v.pb(l);
    	}
    	if(k==1)
    	{
    		cout<<0;
    		return 0;
    	}
    	sort(all(v));
    	ll ans=solve(v);
    	for(i=0;i<n;i++)
    		v[i]=-v[i];
    	sort(all(v));
    	for(i=0;i<n;i++)
    		v[i]=-v[i];
    	ans=ans-solve(v);
    	ans+=hell;
    	ans=ans%hell;
    	cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3572
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, x, t = i_map()

    print(ceil(n/x) * t)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77032
#Insertion Sort
def insertion_sort(arr, n):
    for i_ in range(n-1):
        i = i_+1
        a = arr[i]
        j = i_ #initial value
        while j>=0 and arr[j]>a:
            #print(arr)
            arr[j+1]=arr[j]
            j -= 1
        arr[j+1] = a
    return arr


arr = list( map(int, input().split()) )
n = len(arr)
b = insertion_sort(arr,n)
print( str(b[0]) + " " + str(b[1]) + " " + str(b[2]) )


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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        st: String,
    }
    let mut min = 10000;
    let s = &st[..];
    for i in 0..s.len() - 2 {
        let ss = &s[i..i+3];
        let m = ss.parse::<i64>().unwrap();
        let b = i64::abs(753-m);
        if min >= b {
            min = b;
        }
    }
    println!("{}", min);
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int nums [n];
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        nums[i] = h;
    }
    int dp [n];
    dp[0] = 0;
    dp[1] = abs(nums[1] - nums[0]);
    for(int i=2;i<n;i++){
        int x = dp[i-1] + abs(nums[i-1]-nums[i]);
        int y = dp[i-2] + abs(nums[i-2]-nums[i]);
        dp[i] = min(x,y);
    }
    cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 4372
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdio>
using namespace std;

int main(){

        double r, l, c;

        cin >> r;

        l = r * r * M_PI;
        c = 2 * r * M_PI;

        printf("%.7lf %.7lf\n", l, c);

}



Measured memory_bytes: 3156
def main():
    n = int(input())
    p = [int(x) - 1 for x in input().split()]
    ans = 0
    for i in range(n):
        if p[i] == i:
            if i < n - 1:
                p[i], p[i + 1] = p[i + 1], p[i]
                ans += 1
            else:
                p[i], p[i - 1] = p[i - 1], p[i]
                ans += 1
    print(ans)


main()
# print(*data, sep='\n')


Measured memory_bytes: 52332
n, m = gets.split.map(&:to_i)

cities = []
m.times do |i|
  q, y = gets.split.map(&:to_i)
  cities << [y, q, i]
end

cities.sort_by! {|elm| elm[0] }

prefs = Array.new(n+1, 0)

cities.map {|c|
  city_code = (prefs[c[1]] += 1)
  [c[2], sprintf("%06d%06d", c[1], city_code)]
}.sort_by! {|elm| elm[0]}.each do |c|
  puts c[1]
end


Measured memory_bytes: 23232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

i64 n;
i64 m;

vector<int> edges[100010];

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

	bool nib = true;

	vector<int> color(n + 1,-1);
	{
		queue<P> que;
		que.push({1,0});
		color[1] = 0;
		while(!que.empty())
		{
			int v = que.front().first;
			int c = que.front().second;
			que.pop();

			for(int to : edges[v])
			{
				if(color[to] == -1)
				{
					color[to] = 1-c;
					que.push({to,color[to]});
				}
				else
				{
					if(color[to] != 1-c)
					{
						nib = false;
					}
				}
			}
			if(!nib) break;
		}

	}

	if(!nib)
	{
		cout << n * (n - 1) / 2 - m;
		return 0;
	}

	i64 one = 0;

	for(int i = 1;i <= n;i++)
	{
		if(color[1] != color[i]) one++;
	}

	i64 result = 0;
	for(int i = 1;i <= n;i++)
	{
		if(color[1] == color[i])
		{
			result += one - edges[i].size();
		}
	}

	cout << result << endl;
}



Measured memory_bytes: 7040