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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;
const int N = 1e6 + 5;
int sieve[N];

void init() {
	sieve[1] = 1;
	for (int p = 2; p < N; p++) {
		if (!sieve[p]) {
			sieve[p] = p;
			for (int q = p + p; q < N; q += p)
				sieve[q] = p;
		}
	}
}

ll powmod(ll a, int b) {
	ll r = 1;
	while (b > 0) {
		if (b & 1) r = (r * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return r;
}

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

	int n; scanf("%d", &n);
	vi a(n);
	map<int,int> lc;
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		a[i] = x;
		for (int p = sieve[x]; p > 1; p = sieve[x]) {
			int t = 0;
			while (x % p == 0) {
				x /= p;
				++t;
			}
			lc[p] = max(lc[p], t);
		}
	}

	ll lm = 1;
	for (auto x : lc)
		lm = (lm * powmod(x.first, x.second)) % MOD;
	ll ans = 0;
	for (int x : a) {
		ans += (lm * powmod(x, MOD - 2)) % MOD;
		ans %= MOD;
	}

	printf("%lld\n", ans);
}


Measured memory_bytes: 4608
import sys
from itertools import product

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    S = input().rstrip()

    N = len(S)
    ans = 0
    for comb in product(["+", ""], repeat=N - 1):
        eq = S[0]
        for s, c in zip(S[1:], comb):
            eq = "".join([eq, c])
            eq = "".join([eq, s])
        ans += eval(eq)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9040
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <utility>
#include <numeric>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i=0;(i)<(n);(i)++)
#define repi(i, n) for (int i=0;(i)<=(n);(i)++)
#define repr(i, n) for (int i=n;(i)>=0;(i)--)
#define print(x) (cout<<x<<endl)
#define MAX 100002
int main() {
    int n; cin>>n;
    vi a(MAX);
    rep(i, n) {
        int t; cin>>t;
        a[t]++;
        a[t+1]++;
        a[t+2]++;
    }
    int t = 0;
    int ans;
    rep(i, MAX) {
        if (a[i]>t) {
            ans=i;
            t=a[i];
        }
    }
    print(a[ans]);
}

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

int main() {
  string s, t;
  cin >> s >> t;

  string ans;

  for (int i = 0; i < s.size() + t.size(); i++) {
    if (i % 2 == 0)
      cout << s[i / 2];
    else
      cout << t[i / 2];
  }

  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define NIL (-1)
#define m 1046527
char T[m][14];
int h1(int key) {return key%m;}
int h2(int key) {return key%(m-1);}
 
 
int getChar(char ch){
    if (ch=='A') return 1;
    else if (ch=='C') return 2;
    else if (ch=='G') return 3;
    else if (ch=='T') return 4;
    else return 0;
}
 
long long getKey(char moji[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(moji);i++){
        sum+=p*(getChar(moji[i]));
        p*=5;
    }
    return sum;
}
 
 
int search(char moji[]){
    long long key,i,h;
    key=getKey(moji);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%m;
        if(strcmp(T[h],moji)==0) return 1;
        else if(strlen(T[h])==0) return 0;
    }
    return 0;
}
 
int insert(char moji[]){
    long long key,i,h;
    key=getKey(moji);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%m;
        if(strcmp(T[h],moji)==0) return 1;
        else if(strlen(T[h])==0){
            strcpy(T[h],moji);
            return 0;
        }
    }
    return 0;
}
 
 
int main(void){
    int i,n;
    char order[9],moji[14];
     for ( i = 0; i < m; i++ ) T[i][0] = '\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s%s",order,moji);
        if(order[0]=='i') insert(moji);
        else if(search(moji)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 16960
#include <stdio.h>
int main(void){
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(a < c){
        if(b < d){
            if(b > c){
                printf("%d", b - c);
            }else{
                printf("0");
            }
        }else{
            printf("%d", d - c);
        }
    }else if(b < d){
        printf("%d", b - a);
    }else if(a >= d){
        printf("0");
    }else{
        printf("%d", d - a);
    }
}


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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int N;
    cin >> N;
    lint A[200001];
    for(int i=0;i<N;i++) cin >> A[i];
    if(A[0]!=0){
        cout << "-1" << endl;
        return 0;
    }
    lint cnt=0;
    for(int i=1;i<N;i++){
        if(A[i]>i || A[i]-A[i-1]>1){
            cout << "-1" << endl;
            return 0;
        }
        if(A[i]!=A[i-1]+1) cnt+=A[i-1];
    }
    cnt+=A[N-1];

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1920
program main
character*3 :: n
character*1 :: m
integer :: l
read(*,*)n
l = len_trim(n)
m = n(l:l)

if(m == '3') then
write(*,*)'bon'
else if (m == '0' .or. m == '1' .or. m == '6' .or. m =='8') then
write(*,*)'pon'
else
write(*,*)'hon'
end if
end program

Measured memory_bytes: 2876
#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 all(v) (v).begin(), (v).end()
#define mod 1000000007  
const int N = 100001; 



void solve(){
	int n;cin>>n;
	int ans=1;
	int rem=7;
	rem=rem%n;
	while(rem>0){
		rem=(rem*10)+7;
		rem=rem%n;
		ans++;
		if(ans>1e6){ans=-1;break;}	
	}
	cout<<ans;

    return;
}
         
signed main(){
        IOS;    

        int t=1;
        // cin>>t;
        // fac[0] = 1; 
        // for (int i=1 ; i<=2000001; i++) fac[i] = fac[i-1]*i%mod; 
        rep(i,0,t){
            solve();
            cout<<"\n";
        //   cout<<" * "<<t<<"\n";
        }
    //    return 0;
}

Measured memory_bytes: 3568
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

int a[arr];

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int n;
    cin>>n;
    int ans=0;
    for (int i=1;i<=n;i++){
        cin>>a[i];
    }
    for (int i=1;i<=n;i++){
        ans+=a[i]/2;
        a[i]%=2;
        if (a[i]&&a[i+1]){
            a[i]--;
            a[i+1]--;
            ans++;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 1024
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	int N, M;
	cin >> N >> M;
	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll a[MAX * 2];
int main(void) {
  cin >> n;

  FOR(i, 0, n) {
	cin >> tmp;
	if (a[tmp - 1] != 0) {
	  a[tmp] += a[tmp - 1] + 1;
	}
	else {
	  a[tmp]++;
	}
	//cout << a[tmp] << endl;
  }

  FOR(i, 1, n + 1) ans = max(ans, a[i]);
  
  cout << n - ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
#ifdef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
  boost::for_each(vc, [&os](T value) {
#else
  std::for_each(vc.begin(), vc.end(), [&os](T value) {
#endif
    os << value << '\n';
    });
  return os;
    }

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  //ui N{}; cin >> N;
  int A{}, B{};
  cin >> A >> B;

  vector<int> vc;

  vc.push_back(A + B);
  vc.push_back(A - B);
  vc.push_back(A * B);

  auto ans = *boost::max_element(vc);

  using std::cout;
  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


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

int main() {
	int M, D;
	cin >> M >> D;
	int cnt = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 22; j <= D; j++) {
			int d1, d10;
			d1 = (j % 10);
			d10 = ((j / 10) % 10);
			if (d1 < 2 || d10 < 2) continue;
			if (d1 * d10 == i) cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
H_list = list(map(int,input().split()))
ans = 0
a = 0
for i in range(N-1):
    if H_list[i] >= H_list[i+1]:
        a += 1
    else:
        ans = max(ans,a)
        a = 0
print(max(ans,a))

Measured memory_bytes: 14252
package main

import (
	"fmt"
)

var nums = []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

func solution(n int, nums []int) int {
	return nums[n-1]
}

func main() {
	var k int
	fmt.Scan(&k)
	fmt.Println(solution(k, nums))
}


Measured memory_bytes: 512
use proconio::input;
use std::cmp::Reverse;

fn main() {
    input! {
        n: usize,
        mut a: [i32; n],
    }

    let mut a1 = a.clone();
    a1.sort_by_key(|&k| Reverse(k));

    let larget_element = a1[0];
    let second_largest_element = a1[1];

    for a in a {
        let ans = if a == larget_element {
            second_largest_element
        } else {
            larget_element
        };

        println!("{}", ans);
    }
}


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

ll i,j,k,l;

int main(){
    ll x;cin>>x;
    ll a,b;
    for(b=-1000;b<=999;b++){
        for(a=b+1;a<=1000;a++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3604
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
    if(a[i]+1==a[i+1]):
        ans+=c[a[i]-1]
print(ans)

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

sum_score, set_score = 0, set()
for n in range(1, N + 1):
	sum_score += n
	set_score |= {n}
	if N <= sum_score:
		set_score -= {sum_score - N}
		break
for score in sorted(set_score):
	print(score)


Measured memory_bytes: 3700
n = int(input())
s = []
t = []
for i in range(n):

    a = input().split(' ')
    _s = a[0]
    _t = int(a[1])

    s.append(_s)
    t.append(_t)

x = input()

idx_last = s.index(x)

playedsongs = sum(t[idx_last + 1:])

print(playedsongs)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

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


int main() {
	int x, y;
	cin >> x >> y;
	cout << x + y - gcd(x, y) + 1 << endl;
	return 0;
}



Measured memory_bytes: 3116
#ABC107C
n,k=list(map(int,input().split()))
x = list(map(int,input().split()))
m = 10**9
for i in range(n-k+1):
    r = i+k-1
    if x[r]<0:
        m = min(m,abs(x[i]))
    elif x[i]>0:
        m = min(m,x[r])
    else:
        m = min(m,abs(x[i])*2+x[r],abs(x[i])+x[r]*2)
print(m)

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


#define ll long long
#define pll pair <ll,ll>
#define fi first
#define se second
#define endl "\n"
#define sqr(b) (b)*(b)


using namespace std;

ll a[111111][3];
ll dp[111111][3];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    ll n;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) if (k != j) {
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i + 1][k]);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++) ans = max(ans, dp[n][i]);
    cout << ans << endl;

    return 0;
}


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

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    
    const long long sz = (long long)1e5;
    const long long mx = (long long)2e5+5;
    const long long inf = (long long)1e18;
    const long long mod = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    long long pw(long long x,unsigned long long y) { 
        if (y==0) return 1; 
        else if (y%2==0)  return pw(x,y/2)*pw(x,y/2); 
        else return x*pw(x,y/2)*pw(x,y/2);
    }
    ll comp(pair<string, ll> &a, pair<string, ll> &b) {
        if(a.ff == b.ff) {
            if(a.ss < b.ss) return 1;
            else return 0;
        }
        if(a.ff < b.ff)return 1;
        else return 0;
    }
    int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        string s;
        cin >> s;
        map<char, ll> mp;
        f(i, 3) mp[s[i]]++;
        if(mp['A'] == 0 or mp['B'] == 0) cout << "No";
        else cout << "Yes";
        return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
int Mod = 1000000007, D[110][4000];
int n, K;
int main(){
    int i, j, k;
    scanf("%d%d",&n,&K);
    if(n==K)D[n][0] = K, D[n][1] = 1;
    else D[n][0] = K+1;
    for(i=n-1;i>=1;i--){
        for(j=0;j<=35*(n-i);j++){
            for(k=0;k<=K;k++){
                if(i<k){
                    D[i][j] = (D[i][j] + D[i+1][j])%Mod;
                    continue;
                }
                D[i][j + (k+j)/i] = (D[i][j + (k+j)/i] + D[i+1][j])%Mod;
            }
        }
    }
    int sum = K*(K+1)/2*n;
    for(i=1;i<n;i++)sum=1ll*sum*(K+1)%Mod;
    for(i=0;i<=35*n;i++){
        sum=(sum-1ll*i*D[1][i]%Mod+Mod)%Mod;
    }
    printf("%d\n",sum);
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> x(m);
  rep(i,m) cin >> x[i];
  ll ans = 0;
  if (n >= m) {
    cout << ans << endl;
    return 0;
  } else {
    sort(x.begin(), x.end());
    vector<ll> dis(m-1);
    rep(i,m-1) {
      dis[i] = x[i+1] - x[i];
    }
    sort(dis.begin(), dis.end());

    rep(i,m-n) {
      ans += dis[i];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4616
e = false
w = false
n = false
s = false
gets.strip.each_char do |c|
	e = true if c == "E"
	w = true if c == "W"
	n = true if c == "N"
	s = true if c == "S"
end
if e ^ w || n ^ s
	puts "No"
else
	puts "Yes"
end


Measured memory_bytes: 1788
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int s;
	cin >> s;
	map<int, int> geko;
	geko[s] = 1;
	for (int i = 2; i >= 0; ++i) {
		if (s % 2 == 0) {
			s /= 2;
		}
		else {
			s = 3 * s + 1;
		}
		if (geko[s] == 0) {
			geko[s] = 1;
		}
		else {
			cout << i << endl;
			return 0;
		}
	}
}

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

int main() {
  int N;
  int x = 0;
  cin >> N ;
  for(int i = 0;i < N; i++){
    int l, r;
    cin >> l >> r;
    x = x + r - l + 1;
  }
  cout << x << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)

int main() {
	int n;
	cin >> n;
	vint a(n, 0);
	rep(i, n)cin >> a[i];
	int ans = 0;
	int cnt = 1;
	rep(i, n) {
		if (a[i] == cnt)cnt++;
		else ans++;
	}
	if (ans == n)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min, __gcd, substring, erase, push_back,stoll、stoi

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
string str;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	cin>>str;
	puts(str[2]==str[3]&&str[4]==str[5]?"Yes":"No");
}

Measured memory_bytes: 256
#!/usr/bin/env python3

# from numba import njit
from collections import Counter

# input = stdin.readline

# @njit
def solve(n,l):
  l_dash = ["".join(sorted(s)) for s in l]
  d = Counter(l_dash)
  return sum(v*(v-1)//2 for v in d.values())


def main():
  N = int(input())
  l = [input() for _ in range(N)]
  print(solve(N,l))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 31224
H,W = map(int,input().split())
S = list(list(input()) for _ in range(H))

vector = [[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,-1],[1,-1],[-1,1]]

for y in range(H):
    tmp = ""
    for x in range(W):
        ##print(y,x)
        if S[y][x] == "#":
            tmp += "#"
        else:
            cnt = 0
            for s,t in vector:
                dx = x + s
                dy = y + t
                if 0 <= dx <= W-1 and 0 <= dy <= H-1:
                    if S[dy][dx] == "#":
                        cnt += 1
            tmp += str(cnt)
    print(tmp)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var AList = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var max = 0;
            var min = 1000000001;
            foreach (var A in AList)
            {
                if (max < A)
                {
                    max = A;
                }

                if (min > A)
                {
                    min = A;
                }
            }

            var output = max - min;
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 13396
n = int(input())
a = list(map(int, input().split()))

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


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


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


print(multi_gcd(a))

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

using namespace std;

int main(){
    int x,y;
    cin>>x>>y;
    if(y>=2*x && y<=4*x && y%2==0){
    	cout<<"Yes"<<endl;
    }
  	else{
    	cout<<"No"<<endl;
    }
    
    return 0;
}


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

#define INF 2000000000
#define MAXN 100100

int dp[MAXN], h[MAXN];

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    fill(dp, dp+n+1, INF);
    dp[1] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 2; j++){
            if(i-j < 1) continue;
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin>>n>>m;
  int sum=0;
  REP(i,m) {
    int a;
    cin>>a;
    sum += a;
  }
  if (sum > n) {
    cout<<-1<<endl;
  } else {
    cout<<(n-sum)<<endl;
  }
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    bool flag = false;
    for (int i=0; i<s.size(); i++) {
        if (s[i] == 'h' && !flag) {
            flag = true;
        }
        else if (s[i] == 'i' && flag) {
            flag = false;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }

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

    return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let yymm = (s[2] == '0' && s[3] != '0' ) || (s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2'));
    let mmyy = (s[0] == '0' && s[1] != '0' ) || (s[0] == '1' && (s[1] == '0' || s[1] == '1' || s[1] == '2'));

    println!("{}", if yymm && mmyy { "AMBIGUOUS" } else if yymm { "YYMM" } else if mmyy { "MMYY" } else { "NA" });
}


Measured memory_bytes: 2196
#include<stdio.h>
int main(){
	int str[3]={1,2,3},i;
	int n,m;
	scanf("%d %d",&n,&m);
	for(i=0;i<3;i++){
		if(i!=n-1&&i!=m-1)
		printf("%d",str[i]);
	}
	
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 N, K; cin >> N >> K;
  map<i64, i64> ma;
  rep(i, N) {
    i64 a, b; cin >> a >> b;
    ma[a] += b;
  }
  each(m, ma) {
    if (m.second >= K) {
      cout << m.first << '\n';
      return;
    }
    K -= m.second;
  }
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	int a = N % 10; N /= 10;
	int b = N % 10; N /= 10;
	int c = N;
	if(a == 7 || b == 7 || c == 7) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#define N 1000

int main(){
  int i,j,n,k=0,sum=0,tlen,plen,v[N];
  char T[N],P[N];

  scanf("%s%s",T,P);
  tlen=strlen(T);
  plen=strlen(P);
  //printf("%d %d\n",tlen,plen);
  for(i=0;i<tlen;i++){
    if(T[i]==P[0]){
      j=i+1;
      n=1;
      while(n<plen){
        if(T[j]!=P[n])
          break;
        j++;
	n++;
      }
      if(n==plen){
        v[k]=i;
        sum++;
	k++;
      }
    }
  }
  for(k=0;k<sum;k++){
    printf("%d\n",v[k]);
  }
  //printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 544
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int maxn = 1e5+5;
int ans[maxn], vis[maxn];

void run_case() {
    int n, m, cnt = 0;
    cin >> n >> m;
    LL pa = 0;
    for(int i = 0; i < m; ++i) {
        int num; string s;
        cin >> num >> s;
        if(vis[num]) continue;
        if(s[0] == 'W') ans[num]++;
        else vis[num] = 1, cnt++, pa += ans[num];
    }
    cout << cnt << " " << pa;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 1024
#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);

	int k, a, b;

	cin >> k >> a >> b;

	b -= b % k;
	if (b >= a) cout << "OK\n";
	else cout << "NG\n";
		

	return 0;
}




Measured memory_bytes: 3636
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int M = in.i();

        boolean[] possible = new boolean[N];
        possible[0] = true;

        int[] cnt = new int[N];
        Arrays.fill(cnt, 1);

        int ans = 1;
        for (int i = 0; i < M; i++) {
            int x = in.i() - 1;
            int y = in.i() - 1;

            if (possible[x]) {
                if (!possible[y] && cnt[x] != 1) {
                    ans++;
                } else if (possible[y] && cnt[x] == 1) {
                    ans--;
                }
            }

            possible[y] |= possible[x];
            possible[x] &= cnt[x] != 1;

            cnt[y]++;
            cnt[x]--;
        }

        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 35132
from collections import deque
s = str(input())
q = int(input())
s = deque(s)
query = []
w = True
for i in range(q):
    query = list(map(str,input().split()))
    if(query[0] == "1"):
        w = not(w)
    else:
        mem = query[2]
        if(query[1] == "1"):
            if(w):
                s.appendleft(mem)
            else:
                s.append(mem)
        else:
            if(w):
                s.append(mem)
            else:
                s.appendleft(mem)
if(w):
    print("".join(s))
else:
    s.reverse()
    print("".join(s))

Measured memory_bytes: 8692
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    double x, sum=100.0;
    long year=0;
    cin >> x;

    while(true){
        sum += floor(sum * 0.01);
        year += 1;
        if(sum >= x){
            break;
        }
    }
    cout << year;
}


Measured memory_bytes: 3720
#include <iostream>
 
using namespace std;
 
int main(){
    for(int i = 1 ; i <= 9 ; i++){
	for(int j = 1 ; j <= 9 ; j++){
	    cout << i << "x" << j << "=" << i*j << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i =0 ; i<n;i++)
    cin>>a[i];
  int l =1;
  int count=0;
  if(n==1)
  {
    if(a[0]==1)
      cout<<"0";
    else
      cout<<"-1";
  }
  else
  {
  for(int i =0;i<n;i++)
  {
    if(count!=n-1)
    {
      if(a[i]==l)
      {
        l++;
        continue;
      }
      else if(a[i]!=l)
      {
        count++;
        continue;
      }
    }
    else if(count==n-1)
      break;
  }
      if(l==1)
    cout<<"-1";
  else if(l>1)
    cout<<count;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

const int INF = 1e9;

//?????¶???????????°???????????¨(RSQ & RAQ)??????????????¨?????????
struct SegTree {
    int N;
    vector<int> dat, lazy;
    SegTree() {}
    SegTree(int n) {
        N = 1;
        while(N < n) N *= 2;
        dat.resize(2 * N, 0);
        lazy.resize(2 * N, 0);
    }
    //?????¶??????
    void lazy_evaluate(int k, int l, int r){
        if(lazy[k] != 0){//?????¶????????????
            dat[k] += lazy[k] * (r - l);
            if(k < N - 1){//k????????§???????????????????????¬
                lazy[k * 2 + 1] += lazy[k];
                lazy[k * 2 + 2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }
    int marge(int x, int y){
        return x + y;
    }
    //add x [a, b)
    void update(int a, int b, int x){ update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, int x){
        lazy_evaluate(k, l, r);        
        if(r <= a || b <= l) return;
        if(a <= l && r <= b){
            lazy[k] += x;
            lazy_evaluate(k, l, r);
        }else{
            int m = (l + r) / 2;
            update(a, b, k * 2 + 1, l, m, x);
            update(a, b, k * 2 + 2, m, r, x);
            dat[k] = marge(dat[k * 2 + 1], dat[k * 2 + 2]);
            // dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    // min [a, b)
    int query(int a, int b){ return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        lazy_evaluate(k, l, r);
        if(r <= a or b <= l) return 0;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        int x = query(a, b, k * 2 + 1, l, m);
        int y = query(a, b, k * 2 + 2, m, r);
        return marge(x, y);
        // return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};


signed main(){
    int n, q;
    cin >> n >> q;
    SegTree sg(n);
    rep(i, 0, q){
        int k, s, t, x;
        cin >> k;
        if(k == 0){
            cin >> s >> t >> x;
            sg.update(s - 1, t, x);
        }else{
            cin >> s;
            cout << sg.query(s - 1, s) << endl;
            // cout << sg.dat[s + sg.N - 2] << endl;
            //  rep(j, 0, n){
            //     cout << sg.dat[n + j] << " ";
            // }
            // cout << endl;
        }
    }
}

Measured memory_bytes: 7012
#AGC007 A
'''
問題
縦H行で横W列の盤面がある
コマははじめ左上隅のマスに置かれており，右下隅に移動した
駒は1マスずつ上下左右に動ける
駒が通ったことのあるマスが提示されるので，駒が常に右または下にしか動いていなかったどうか判定せよ
ただし通ったことのあるマスは'#',一度も通らなかったマスは'.'で与えられる

考察
各行0,1,...,i,...,H-1に対して'#'のマスが存在する範囲を[ai,bi]とする。ただし0<=ai<=bi<=W-1
このとき各0,1,...,j,...,H-2について b_j == a_(j+1) であればよい
'''

import re

H,W = map(int,input().split(' '))
A = []

ans = ''
answers = ('Possible','Impossible')

r = re.compile(r'\.*#+\.*')

for i in range(H):
	s = input()
	if len(r.findall(s)) == 1:
		A.append(s)
	else:
		#'#'が2箇所以上にわかれていたらその時点でアウト
		ans = answers[1]
		break

if ans == '':
	for i in range(H-1):
		if A[i].rfind('#') == A[i+1].find('#'):
			continue
		else:
			ans = answers[1]
			break

if ans == '':
	ans = answers[0]

print(ans)

Measured memory_bytes: 3188
N,P = map(int,input().split())

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d
fac = factorize(P)

ans = 1
for k,v in fac.items():
    x = v//N
    ans *= k**x

print(ans)

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

int main(){
  int n;
  cin >> n;
  if(n<=9) cout <<  n;
  else if(n>9 && n<99) cout <<  9;
  else if(n<=999 && n>=99) cout <<  n-90;
  else if(n>999 && n<=9999) cout <<  909;
  else if(n>9999 && n<100000) cout <<  n-9090;
  else if(n=100000) cout <<  90909;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

ll N, K;
char D[10];

bool OK(ll n){
   //nがOKかどうかを判定
   string s = to_string(n);
   ll d = s.size(); //nはd桁の整数//
//   cout << s << ' ' << d << endl;
   REP(i, d){
      REP(k, K){
         if(s[i] == D[k]) return false;
      }
   }
   return true;
}
int main(){
   cin >> N >> K;
   REP(i, K) cin >> D[i];
   ll ans = N;
   while(true){
      if(OK(ans)) break;
      ans++;
   }
   cout << ans << endl;


   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
ll mod = 998244353ll;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};


int main() {
    int n;
    cin >> n;
    map <int,int> mp;
    vector <ll> vec(n);

    for(int i = 0; i < n; i++){
        cin >> vec[i];
        mp[vec[i]]++;
    }
    if(vec[0] != 0){
        cout << 0;
            return 0;
    }
    int cnt = 0;
    ll ans = 1LL, prev = 1LL;
    for(auto x:mp){
        //cout << x.first << " " << x.second << endl;
        if(x.first > cnt || (x.first == 0 && x.second > 1)){
            cout << 0;
            return 0;
        }
        ans = (ans*expo(prev, x.second))%mod;
        prev = x.second;
        cnt++;
    }

    cout << ans;
    
}
 


Measured memory_bytes: 5760
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};




int main (){
      int N;
      cin>>N;
      int a[N],b[N];
      rep0(i,N) cin>>a[i];
      rep0(i,N) cin>>b[i];
      int ans=0;
      for(int k=28;k>=0;k--){
            int hoge = 1ll<<(k+1);
            rep0(i,N) a[i]%=hoge;
            rep0(i,N) b[i]%=hoge;
            sort(b,b+N);
            int T = 1ll<<k;
            int piyo=0;
            rep0(i,N){
                  int huga =lower_bound(b,b+N,2*T-a[i])-lower_bound(b,b+N,T-a[i]);
                  int mochi =lower_bound(b,b+N,4*T-a[i])-lower_bound(b,b+N, 3*T-a[i]);
                  huga= (huga<0)? 0 : huga;
                  mochi=(mochi<0)? 0 : mochi;
                  piyo=(piyo+huga+mochi)%2;
                  //if(k==29)cout<<huga<<" "<<mochi<<" "<<piyo<<endl;
            }
            ans=2*ans+piyo;
      }
      cout<<ans<<endl;

      return 0;
}


Measured memory_bytes: 1792
from math import sqrt


def solve(string):
    q, *ab = map(int, string.split())
    ans = []
    for a, b in zip(ab[::2], ab[1::2]):
        c = a * b
        d = int(sqrt(c))
        answer = 2 * d - 2
        if d * d == c:
            answer -= 1
        if d * (d + 1) < c:
            answer += 1
        if a == b:
            answer += 1
        ans.append(str(answer))
    return "\n".join(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {
    int n;
    cin >> n;

    vector<double> x( n ), y( n );
    rep( i, n ) cin >> x.at( i );
    rep( i, n ) cin >> y.at( i );

    // p:1
    double dis1 = 0;
    rep( i, n ) dis1 += abs( x.at( i ) - y.at( i ) );
    printf( "%.6lf\n", dis1 );

    // p:2
    double dis2 = 0;
    rep( i, n ) dis2 += pow( x.at( i ) - y.at( i ), 2 );
    dis2 = sqrt( dis2 );
    printf( "%.6lf\n", dis2 );

    // p:3
    double dis3 = 0;
    rep( i, n ) dis3 += pow( abs(x.at( i ) - y.at( i )), 3 );
    dis3 = pow( dis3, 1.0/ 3.0 );
    printf( "%.6lf\n", dis3 );

    // p:∞
    double dis8      = 0;
    rep( i, n ) dis8 = max( abs( x.at( i ) - y.at( i ) ), dis8 );
    printf( "%.6lf\n", dis8 );

    return 0;
}



Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, D;
    cin >> N >> D;
    ll x, y; 
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        cin >> x >> y;
        if(x*x + y*y <= D*D){
            ans++;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3760